Modifications in preparation to MAX IV experiment

This commit is contained in:
2024-01-27 21:23:56 +01:00
parent 2446643489
commit f5f86d9ab6
250 changed files with 9363 additions and 3022 deletions
+19 -3
View File
@@ -6,8 +6,8 @@
#include "HDF5NXmx.h"
#include "MakeDirectory.h"
StreamWriter::StreamWriter(ZMQContext &context, Logger &in_logger, const std::string &zmq_addr)
: image_puller(context), logger(in_logger) {
StreamWriter::StreamWriter(ZMQContext &context, Logger &in_logger, const std::string &zmq_addr, const std::string& repub_address)
: image_puller(context, repub_address), logger(in_logger), running(false) {
image_puller.Connect(zmq_addr);
logger.Info("Connected via ZMQ to {}", zmq_addr);
}
@@ -47,11 +47,18 @@ void StreamWriter::EndDataCollection() {
}
void StreamWriter::Abort() {
void StreamWriter::Cancel() {
image_puller.Abort();
}
StreamWriterStatistics StreamWriter::Run() {
{
std::unique_lock<std::mutex> ul(m);
if (running)
throw JFJochException(JFJochExceptionCategory::WrongDAQState, "Writer is busy");
running = true;
}
StreamWriterStatistics ret;
start_message = StartMessage();
StartDataCollection();
@@ -67,9 +74,18 @@ StreamWriterStatistics StreamWriter::Run() {
ret.image_puller_stats = image_puller.GetStatistics();
logger.Info("Write task done. Images = {} Throughput = {:.0f} MB/s Frame rate = {:.0f} Hz",
ret.image_puller_stats.processed_images, ret.image_puller_stats.performance_MBs, ret.image_puller_stats.performance_Hz);
{
std::unique_lock<std::mutex> ul(m);
running = false;
}
return ret;
}
std::future<StreamWriterStatistics> StreamWriter::RunFuture() {
std::unique_lock<std::mutex> ul(m);
if (running)
throw JFJochException(JFJochExceptionCategory::WrongDAQState, "Writer is busy");
return std::async(std::launch::async, &StreamWriter::Run, this);
}