53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#ifndef JUNGFRAUJOCH_ZMQIMAGEPULLER_H
|
|
#define JUNGFRAUJOCH_ZMQIMAGEPULLER_H
|
|
|
|
#include <future>
|
|
|
|
#include "../common/ZMQWrappers.h"
|
|
#include "../common/Logger.h"
|
|
#include "../common/SpotToSave.h"
|
|
#include "../frame_serialize/JFJochFrameDeserializer.h"
|
|
|
|
struct ZMQImagePullerStatistics {
|
|
uint64_t processed_images;
|
|
float performance_MBs;
|
|
float performance_Hz;
|
|
};
|
|
|
|
class ZMQImagePuller {
|
|
std::vector<uint8_t> zmq_recv_buffer;
|
|
|
|
JFJochFrameDeserializer deserializer;
|
|
|
|
constexpr const static uint32_t ReceiverWaterMark = 100;
|
|
// ZeroMQ receive timeout allows to check for abort value from time to time
|
|
constexpr const static auto ReceiveTimeout = std::chrono::milliseconds(100);
|
|
size_t processed_size = 0;
|
|
size_t processed_images = 0;
|
|
std::chrono::time_point<std::chrono::system_clock> start_time;
|
|
std::chrono::time_point<std::chrono::system_clock> end_time;
|
|
ZMQSocket socket;
|
|
std::string addr;
|
|
volatile int abort = 0;
|
|
|
|
std::unique_ptr<StartMessage> start_message;
|
|
std::unique_ptr<EndMessage> end_message;
|
|
std::unique_ptr<DataMessage> deserialized_image_message;
|
|
public:
|
|
ZMQImagePuller(ZMQContext &context);
|
|
void Connect(const std::string &in_address);
|
|
void Disconnect();
|
|
void Abort();
|
|
|
|
void WaitForImage();
|
|
const DataMessage &GetDataMessage() const;
|
|
[[nodiscard]] JFJochFrameDeserializer::Type GetFrameType() const;
|
|
[[nodiscard]] ZMQImagePullerStatistics GetStatistics();
|
|
[[nodiscard]] StartMessage GetStartMessage() const;
|
|
[[nodiscard]] EndMessage GetEndMessage() const;
|
|
};
|
|
|
|
#endif //JUNGFRAUJOCH_ZMQIMAGEPULLER_H
|