From 8c2cabebd2cb7e5ec80e6aadd803429f59648669 Mon Sep 17 00:00:00 2001 From: lhdamiani Date: Tue, 6 Jul 2021 14:44:43 +0200 Subject: [PATCH] clean-up of jf-udp-recv --- jf-udp-recv/src/main.cpp | 80 ---------------------------------------- 1 file changed, 80 deletions(-) delete mode 100644 jf-udp-recv/src/main.cpp diff --git a/jf-udp-recv/src/main.cpp b/jf-udp-recv/src/main.cpp deleted file mode 100644 index 598c16c..0000000 --- a/jf-udp-recv/src/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -#include -#include -#include - -#include "formats.hpp" -#include "buffer_config.hpp" -#include "FrameUdpReceiver.hpp" -#include "BufferUtils.hpp" -#include "FrameStats.hpp" - -using namespace std; -using namespace chrono; -using namespace buffer_config; -using namespace BufferUtils; - - - -int main (int argc, char *argv[]) { - - if (argc != 4) { - cout << endl; - #ifndef USE_EIGER - cout << "Usage: jf_udp_recv [detector_json_filename] [module_id] [bit_depth]"; - #else - cout << "Usage: eiger_udp_recv [detector_json_filename] [module_id] [bit_depth]"; - #endif - cout << endl; - cout << "\tdetector_json_filename: detector config file path." << endl; - cout << "\tmodule_id: id of the module for this process." << endl; - cout << "\tbit_depth: bit depth of the incoming udp packets." << endl; - cout << endl; - exit(-1); - } - - const auto config = read_json_config(string(argv[1])); - const int module_id = atoi(argv[2]); - const int bit_depth = atoi(argv[3]); - const int n_receivers = config.n_modules * config.n_submodules; - const auto udp_port = config.start_udp_port + module_id; - - FrameUdpReceiver receiver(module_id, udp_port, n_receivers, config.n_submodules, bit_depth); - RamBuffer buffer(config.detector_name, sizeof(ModuleFrame), N_BYTES_PER_MODULE_FRAME(bit_depth), n_receivers, - buffer_config::RAM_BUFFER_N_SLOTS); - FrameStats stats(config.detector_name, n_receivers, module_id, bit_depth, STATS_TIME); - - auto ctx = zmq_ctx_new(); - auto socket = bind_socket(ctx, config.detector_name, to_string(module_id)); - - ModuleFrame meta; - char* data = new char[MODULE_N_PIXELS * bit_depth / 8]; - - uint64_t pulse_id_previous = 0; - uint64_t frame_index_previous = 0; - - while (true) { - - auto pulse_id = receiver.get_frame_from_udp(meta, data); - - bool bad_pulse_id = false; - if ( ( meta.frame_index != (frame_index_previous+1) ) || - ( (meta.frame_index-frame_index_previous) <= 0 ) || - ( (meta.frame_index-frame_index_previous) > 1000 ) ){ - bad_pulse_id = true; - } else { - buffer.write_frame(meta, data); - - zmq_send(socket, &pulse_id, sizeof(pulse_id), 0); - - } - - stats.record_stats(meta, bad_pulse_id); - - pulse_id_previous = pulse_id; - frame_index_previous = meta.frame_index; - - } - - delete[] data; -}