Commit 4443b581 authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Add pop() to buffer_obs_file_binary

parent 8ff9040b
......@@ -20,6 +20,7 @@
// C headers
#include <time.h>
#include <typeinfo>
#include <stdint.h>
// Custom C++ Headers
#include <buffer_obs_file_binary.hpp> // Buffer using File I/O
......@@ -92,13 +93,58 @@ int buffer_obs_file_binary::put(data_obs* data) {
/********************************************************************************
* *
* Read data from the buffer. This is done by reading from Standard Input and *
* parsing the string. *
* Read data from the buffer. *
* *
********************************************************************************/
int buffer_obs_file_binary::pop(data_obs* data) {
return(-1);
struct timespec time;
std::vector<double> values_orig;
std::vector<float> values;
int N;
int32_t tmp_32;
// Write data info to stderr
if (!info_written){
info(data);
}
// Open new file if necessary
check(data);
if ( !file.is_open() ) {
std::cerr << "No file opened for reading." << std::endl;
return(-1);
}
// Read time
read((char*) &tmp_32, sizeof(tmp_32));
if (!file.eof()) {
time.tv_sec = (time_t) tmp_32;
read((char*) &tmp_32, sizeof(tmp_32));
time.tv_nsec = (long) tmp_32;
data->set_time(&time);
// Read data
//TODO Add option for reading supplementary data
N = data->get_Ndata();
values.resize(N, data->get_MD());
read((char*) values.data(), sizeof(values[0]) * N);
values_orig.assign(values.begin(), values.end());
if ((data->set_data(values_orig)) < 0) {
std::cerr << "COULD NOT ASSIGN DATA" << std::endl;
}
return (0);
} else {
std::cerr << "END OF FILE REACHED" << std::endl;
data->set_values_MD();
return(-1);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment