mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-26 04:20:44 +02:00
Add counter for frames to save instead of just flag
This commit is contained in:
@@ -12,7 +12,7 @@ class ZmqRecvModule
|
|||||||
RingBuffer& ring_buffer_;
|
RingBuffer& ring_buffer_;
|
||||||
const header_map& header_values_;
|
const header_map& header_values_;
|
||||||
std::atomic_bool is_receiving_;
|
std::atomic_bool is_receiving_;
|
||||||
std::atomic_bool is_saving_;
|
std::atomic_int n_frames_to_save_;
|
||||||
std::vector<std::thread> receiving_threads_;
|
std::vector<std::thread> receiving_threads_;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -24,12 +24,14 @@ public:
|
|||||||
RingBuffer& ring_buffer,
|
RingBuffer& ring_buffer,
|
||||||
const header_map& header_values);
|
const header_map& header_values);
|
||||||
|
|
||||||
void start_recv(const std::string& connect_address,
|
void start_recv(
|
||||||
const uint8_t n_receiving_threads);
|
const std::string& connect_address,
|
||||||
|
const uint8_t n_receiving_threads);
|
||||||
void stop_recv();
|
void stop_recv();
|
||||||
|
|
||||||
void start_saving();
|
void start_saving(const int n_frames = -1);
|
||||||
void stop_saving();
|
void stop_saving();
|
||||||
|
bool is_saving();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -84,17 +84,18 @@ void ZmqRecvModule::stop_recv()
|
|||||||
receiving_threads_.clear();
|
receiving_threads_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZmqRecvModule::start_saving()
|
void ZmqRecvModule::start_saving(const int n_frames_to_save)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_OUTPUT
|
#ifdef DEBUG_OUTPUT
|
||||||
using namespace date;
|
using namespace date;
|
||||||
using namespace chrono;
|
using namespace chrono;
|
||||||
cout << "[" << system_clock::now() << "]";
|
cout << "[" << system_clock::now() << "]";
|
||||||
cout << "[ZmqRecvModule::start_saving]";
|
cout << "[ZmqRecvModule::start_saving]";
|
||||||
cout << " Enable saving." << endl;
|
cout << " n_frames_to_save " << n_frames_to_save;
|
||||||
|
cout << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
is_saving_ = true;
|
n_frames_to_save_ = n_frames_to_save;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZmqRecvModule::stop_saving()
|
void ZmqRecvModule::stop_saving()
|
||||||
@@ -107,7 +108,12 @@ void ZmqRecvModule::stop_saving()
|
|||||||
cout << " Disable saving." << endl;
|
cout << " Disable saving." << endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
is_saving_ = false;
|
n_frames_to_save_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ZmqRecvModule::is_saving()
|
||||||
|
{
|
||||||
|
return n_frames_to_save_ != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZmqRecvModule::receive_thread(const string& connect_address)
|
void ZmqRecvModule::receive_thread(const string& connect_address)
|
||||||
@@ -128,10 +134,12 @@ void ZmqRecvModule::receive_thread(const string& connect_address)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_saving_.load(memory_order_relaxed)) {
|
if (!is_saving()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
n_frames_to_save_--;
|
||||||
|
|
||||||
auto frame_metadata = frame.first;
|
auto frame_metadata = frame.first;
|
||||||
auto frame_data = frame.second;
|
auto frame_data = frame.second;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user