mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 01:22:23 +02:00
Change logic of writer to make it more simple
This commit is contained in:
+13
-18
@@ -153,26 +153,19 @@ int main (int argc, char *argv[])
|
||||
size_t total_ms = 0;
|
||||
size_t max_ms = 0;
|
||||
|
||||
for (
|
||||
size_t current_pulse_id=start_pulse_id;
|
||||
current_pulse_id <= stop_pulse_id;
|
||||
current_pulse_id++)
|
||||
{
|
||||
auto start_time = chrono::steady_clock::now();
|
||||
|
||||
pair<shared_ptr<DetectorFrame>, char *> received_data;
|
||||
|
||||
while (true)
|
||||
{
|
||||
received_data = ring_buffer.read();
|
||||
auto start_time = chrono::steady_clock::now();
|
||||
|
||||
// .first is nullptr if ringbuffer is empty.
|
||||
if(received_data.first == nullptr) {
|
||||
this_thread::sleep_for(chrono::milliseconds(
|
||||
config::ring_buffer_read_retry_interval));
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
auto current_pulse_id = start_pulse_id;
|
||||
while (current_pulse_id <= stop_pulse_id) {
|
||||
|
||||
auto received_data = ring_buffer.read();
|
||||
|
||||
if(received_data.first == nullptr) {
|
||||
this_thread::sleep_for(chrono::milliseconds(
|
||||
config::ring_buffer_read_retry_interval));
|
||||
continue;
|
||||
}
|
||||
|
||||
auto metadata = received_data.first;
|
||||
@@ -194,8 +187,8 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
writer.write(metadata, data);
|
||||
|
||||
ring_buffer.release(metadata->buffer_slot_index);
|
||||
current_pulse_id++;
|
||||
|
||||
i_write++;
|
||||
|
||||
@@ -216,6 +209,8 @@ int main (int argc, char *argv[])
|
||||
total_ms = 0;
|
||||
max_ms = 0;
|
||||
}
|
||||
|
||||
start_time = chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
writer.close_file();
|
||||
|
||||
Reference in New Issue
Block a user