mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 14:24:13 +02:00
Adjust the main for the jf-live-writer to ImageWriter
This commit is contained in:
@@ -11,11 +11,8 @@ add_executable(jf-live-writer src/main.cpp)
|
||||
set_target_properties(jf-live-writer PROPERTIES OUTPUT_NAME jf_live_writer)
|
||||
target_link_libraries(jf-live-writer
|
||||
jf-live-writer-lib
|
||||
sf-writer-lib
|
||||
hdf5
|
||||
hdf5_hl
|
||||
hdf5_cpp
|
||||
pthread
|
||||
zmq
|
||||
rt
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
#include <zmq.h>
|
||||
#include <RamBuffer.hpp>
|
||||
#include <BufferUtils.hpp>
|
||||
#include <ImageBinaryWriter.hpp>
|
||||
#include "live_writer_config.hpp"
|
||||
#include "../../jf-buffer-writer/include/BufferStats.hpp"
|
||||
#include "WriterStats.hpp"
|
||||
|
||||
|
||||
using namespace std;
|
||||
@@ -16,15 +17,16 @@ int main (int argc, char *argv[])
|
||||
if (argc != 3) {
|
||||
cout << endl;
|
||||
cout << "Usage: jf_live_writer [detector_json_filename]"
|
||||
" [stream_name]" << endl;
|
||||
" [writer_id]" << endl;
|
||||
cout << "\tdetector_json_filename: detector config file path." << endl;
|
||||
cout << "\twriter_id: Index of this writer instance." << endl;
|
||||
cout << endl;
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
const auto stream_name = string(argv[2]);
|
||||
auto config = BufferUtils::read_json_config(string(argv[1]));
|
||||
const int writer_id = atoi(argv[2]);
|
||||
|
||||
auto ctx = zmq_ctx_new();
|
||||
zmq_ctx_set(ctx, ZMQ_IO_THREADS, LIVE_ZMQ_IO_THREADS);
|
||||
@@ -32,15 +34,21 @@ int main (int argc, char *argv[])
|
||||
ctx, config.detector_name, "assembler");
|
||||
|
||||
RamBuffer ram_buffer(config.detector_name, config.n_modules);
|
||||
BufferStats stats(config.detector_name, stream_name, STATS_MODULO);
|
||||
|
||||
ImageMetadata meta;
|
||||
const uint64_t image_n_bytes = config.n_modules * MODULE_N_BYTES;
|
||||
ImageBinaryWriter writer(config.detector_name, image_n_bytes);
|
||||
|
||||
WriterStats stats(config.detector_name, STATS_MODULO, image_n_bytes);
|
||||
|
||||
ImageMetadata meta = {};
|
||||
while (true) {
|
||||
zmq_recv(receiver, &meta, sizeof(meta), 0);
|
||||
char* data = ram_buffer.read_image(meta.pulse_id);
|
||||
|
||||
sender.send(meta, data);
|
||||
stats.start_image_write();
|
||||
|
||||
stats.record_stats(meta);
|
||||
writer.write(meta, data);
|
||||
|
||||
stats.end_image_write();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
#include <BinaryReader.hpp>
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
TEST(BinaryReader, basic_interaction) {
|
||||
// TODO: Write some real tests.
|
||||
auto detector_folder = "test_device";
|
||||
auto module_name = "M1";
|
||||
BinaryReader reader(detector_folder, module_name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user