Modifications in preparation to MAX IV experiment
This commit is contained in:
+19
-3
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user