48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#ifndef JUNGFRAUJOCH_STREAMWRITER_H
|
|
#define JUNGFRAUJOCH_STREAMWRITER_H
|
|
|
|
#include <future>
|
|
|
|
#include "ZMQImagePuller.h"
|
|
#include "HDF5DataFile.h"
|
|
|
|
enum class StreamWriterState {Idle, Started, Receiving};
|
|
|
|
struct StreamWriterStatistics {
|
|
uint64_t processed_images;
|
|
float performance_MBs;
|
|
float performance_Hz;
|
|
std::string file_prefix;
|
|
StreamWriterState state;
|
|
};
|
|
|
|
struct StreamWriterOutput {
|
|
StreamWriterStatistics image_puller_stats;
|
|
std::vector<HDF5DataFileStatistics> data_file_stats;
|
|
};
|
|
|
|
class StreamWriter {
|
|
StreamWriterState state = StreamWriterState::Idle;
|
|
|
|
std::atomic<uint64_t> processed_images;
|
|
std::atomic<uint64_t> processed_image_size;
|
|
std::chrono::time_point<std::chrono::system_clock> start_time;
|
|
std::chrono::time_point<std::chrono::system_clock> end_time;
|
|
std::string file_prefix;
|
|
|
|
ZMQImagePuller image_puller;
|
|
Logger &logger;
|
|
void CollectImages(std::vector<HDF5DataFileStatistics> &v);
|
|
bool WaitForImage();
|
|
public:
|
|
StreamWriter(ZMQContext& context, Logger &logger, const std::string& zmq_addr, const std::string& repub_address = "");
|
|
StreamWriterOutput Run();
|
|
void Cancel();
|
|
StreamWriterStatistics GetStatistics() const;
|
|
};
|
|
|
|
|
|
#endif //JUNGFRAUJOCH_STREAMWRITER_H
|