Dynamically assign dataset type

This commit is contained in:
2018-01-17 14:31:12 +01:00
parent 25ac006658
commit 8c79e76d71
3 changed files with 17 additions and 5 deletions
+4 -1
View File
@@ -5,6 +5,7 @@
#include <vector>
#include <map>
#include <mutex>
#include <string>
struct FrameMetadata
@@ -14,8 +15,10 @@ struct FrameMetadata
size_t frame_bytes_size = 0;
// Part of the message header.
size_t frame_index = 0;
uint64_t frame_index = 0;
size_t frame_shape[2];
std::string endianness = "little";
std::string type;
};
class RingBuffer
+1 -2
View File
@@ -5,7 +5,6 @@
#include <string>
#include <atomic>
#include <boost/any.hpp>
#include "config.hpp"
#include "h5_utils.hpp"
class WriterManager
@@ -19,7 +18,7 @@ class WriterManager
std::atomic_int n_written_frames;
public:
WriterManager(uint64_t n_images=0, std::string dataset_name=config::dataset_name);
WriterManager(uint64_t n_images=0, std::string dataset_name="data");
void stop();
std::string get_status();
std::map<std::string, uint64_t> get_statistics();
+12 -2
View File
@@ -33,7 +33,9 @@ void write_h5(WriterManager *manager, RingBuffer *ring_buffer, string output_fil
writer.write_data(received_data.first.frame_index,
received_data.first.frame_shape,
received_data.first.frame_bytes_size,
received_data.second);
received_data.second,
received_data.first.type,
received_data.first.endianness);
ring_buffer->release(received_data.first.buffer_slot_index);
@@ -71,12 +73,20 @@ void receive_zmq(WriterManager *manager, RingBuffer *ring_buffer, string connect
char* header = static_cast<char*>(message_data.data());
header_parser.Parse(header);
// Extract frame_index and frame_shape from the message header.
// Extract data from message header.
frame_metadata.frame_index = header_parser["frame"].GetUint64();
auto header_shape = header_parser["shape"].GetArray();
frame_metadata.frame_shape[0] = header_shape[0].GetUint64();
frame_metadata.frame_shape[1] = header_shape[1].GetUint64();
if (header_parser.HasMember("endianness")) {
if (string("big") == header_parser["endianness"].GetString()) {
frame_metadata.endianness = "big";
}
}
frame_metadata.type = header_parser["type"].GetString();
// Get the message data.
receiver.recv(&message_data);