v1.0.0-rc.36
This commit is contained in:
+22
-22
@@ -3,21 +3,18 @@
|
||||
|
||||
#include "../common/JFJochException.h"
|
||||
#include "StreamWriter.h"
|
||||
#include "HDF5Writer.h"
|
||||
|
||||
#include <utility>
|
||||
#include "FileWriter.h"
|
||||
|
||||
StreamWriter::StreamWriter(Logger &in_logger,
|
||||
const std::string &zmq_addr,
|
||||
const std::string &repub_address,
|
||||
const std::string &in_file_done_address,
|
||||
const std::optional<int32_t> &rcv_watermark,
|
||||
const std::optional<int32_t> &repub_watermark)
|
||||
: image_puller(repub_address, rcv_watermark, repub_watermark),
|
||||
ImagePuller &in_image_puller,
|
||||
std::string in_file_done_address)
|
||||
: image_puller(in_image_puller),
|
||||
logger(in_logger),
|
||||
file_done_address(in_file_done_address),
|
||||
file_done_address(std::move(in_file_done_address)),
|
||||
socket_number(0),
|
||||
run_number(0) {
|
||||
image_puller.Connect(zmq_addr);
|
||||
logger.Info("Connected via ZMQ to {}", zmq_addr);
|
||||
}
|
||||
|
||||
void StreamWriter::CollectImages(std::vector<HDF5DataFileStatistics> &v) {
|
||||
@@ -45,7 +42,7 @@ void StreamWriter::CollectImages(std::vector<HDF5DataFileStatistics> &v) {
|
||||
run_number = image_puller_output.cbor->start_message->run_number;
|
||||
run_name = image_puller_output.cbor->start_message->run_name;
|
||||
|
||||
HDF5Writer writer(*image_puller_output.cbor->start_message);
|
||||
FileWriter writer(*image_puller_output.cbor->start_message);
|
||||
|
||||
if (!file_done_address.empty())
|
||||
writer.SetupFinalizedFileSocket(file_done_address);
|
||||
@@ -59,7 +56,7 @@ void StreamWriter::CollectImages(std::vector<HDF5DataFileStatistics> &v) {
|
||||
run = WaitForImage();
|
||||
while (run && image_puller_output.cbor->calibration) {
|
||||
try {
|
||||
writer.Write(*image_puller_output.cbor->calibration);
|
||||
writer.WriteHDF5(*image_puller_output.cbor->calibration);
|
||||
} catch (const JFJochException &e) {
|
||||
logger.ErrorException(e);
|
||||
}
|
||||
@@ -73,7 +70,7 @@ void StreamWriter::CollectImages(std::vector<HDF5DataFileStatistics> &v) {
|
||||
first_image = false;
|
||||
}
|
||||
|
||||
writer.Write(*image_puller_output.cbor->data_message);
|
||||
writer.WriteHDF5(*image_puller_output.cbor->data_message);
|
||||
if (max_image_number < image_puller_output.cbor->data_message->number + 1)
|
||||
max_image_number = image_puller_output.cbor->data_message->number + 1;
|
||||
|
||||
@@ -90,7 +87,7 @@ void StreamWriter::CollectImages(std::vector<HDF5DataFileStatistics> &v) {
|
||||
if ((image_puller_output.cbor->end_message->max_image_number == 0) && (max_image_number > 0))
|
||||
image_puller_output.cbor->end_message->max_image_number = max_image_number;
|
||||
|
||||
writer.Write(*image_puller_output.cbor->end_message);
|
||||
writer.WriteHDF5(*image_puller_output.cbor->end_message);
|
||||
|
||||
data_collection_seq_ok = true;
|
||||
}
|
||||
@@ -103,7 +100,7 @@ void StreamWriter::CollectImages(std::vector<HDF5DataFileStatistics> &v) {
|
||||
|
||||
void StreamWriter::Cancel() {
|
||||
logger.Info("Cancel requested");
|
||||
image_puller.Abort();
|
||||
abort = true;
|
||||
}
|
||||
|
||||
StreamWriterOutput StreamWriter::Run() {
|
||||
@@ -117,18 +114,21 @@ StreamWriterOutput StreamWriter::Run() {
|
||||
}
|
||||
|
||||
ret.stats = GetStatistics();
|
||||
logger.Info("Write task done. Images = {} Throughput = {:.0f} MB/s Frame rate = {:.0f} Hz max occupation of queues (C/O/R) {}/{}/{}",
|
||||
logger.Info("Write task done. Images = {} Throughput = {:.0f} MB/s Frame rate = {:.0f} Hz max occupation of FIFO {}",
|
||||
ret.stats.processed_images, ret.stats.performance_MBs, ret.stats.performance_Hz,
|
||||
ret.stats.puller_stats.cbor_fifo_max_util,
|
||||
ret.stats.puller_stats.outside_fifo_max_util,
|
||||
ret.stats.puller_stats.repub_fifo_max_util);
|
||||
ret.stats.max_puller_fifo_utilization);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool StreamWriter::WaitForImage() {
|
||||
try {
|
||||
image_puller_output = image_puller.WaitForImage();
|
||||
return (image_puller_output.cbor != nullptr);
|
||||
std::optional<ImagePullerOutput> ret;
|
||||
while (!ret && !abort)
|
||||
ret = image_puller.PollImage();
|
||||
|
||||
if (ret.has_value())
|
||||
image_puller_output = ret.value();
|
||||
return ret.has_value();
|
||||
} catch (const JFJochException &e) {
|
||||
logger.ErrorException(e);
|
||||
return false;
|
||||
@@ -159,7 +159,7 @@ StreamWriterStatistics StreamWriter::GetStatistics() const {
|
||||
.run_number = run_number,
|
||||
.socket_number = socket_number,
|
||||
.state = state,
|
||||
.puller_stats = image_puller.GetStatistics()
|
||||
.max_puller_fifo_utilization = image_puller.GetMaxFifoUtilization()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user