print statistics from udp writer every N seconds (not N frames)

check that frame packets sending is finished (new frame) by new trigger number, not pulse_id
check if pulse_id of the frame is more or less correct (in case not - do not store that frame in the ram buffer)
This commit is contained in:
Dmitry Ozerov
2021-02-16 16:25:28 +01:00
committed by Data Backend account
parent 94749585d8
commit aba739ce87
5 changed files with 49 additions and 16 deletions
+24 -4
View File
@@ -33,7 +33,7 @@ int main (int argc, char *argv[]) {
const auto udp_port = config.start_udp_port + module_id;
FrameUdpReceiver receiver(udp_port, module_id);
RamBuffer buffer(config.detector_name, config.n_modules);
FrameStats stats(config.detector_name, module_id, STATS_MODULO);
FrameStats stats(config.detector_name, module_id, STATS_TIME);
auto ctx = zmq_ctx_new();
auto socket = bind_socket(ctx, config.detector_name, to_string(module_id));
@@ -41,14 +41,34 @@ int main (int argc, char *argv[]) {
ModuleFrame meta;
char* data = new char[MODULE_N_BYTES];
uint64_t pulse_id_previous = 0;
uint64_t frame_index_previous = 0;
while (true) {
auto pulse_id = receiver.get_frame_from_udp(meta, data);
buffer.write_frame(meta, data);
bool bad_pulse_id = false;
zmq_send(socket, &pulse_id, sizeof(pulse_id), 0);
if ( ( meta.frame_index != (frame_index_previous+1) ) ||
( (pulse_id-pulse_id_previous) < 0 ) ||
( (pulse_id-pulse_id_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;
stats.record_stats(meta);
}
delete[] data;