mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-06-07 03:48:41 +02:00
Stuff
This commit is contained in:
@@ -20,7 +20,7 @@ JfjFrameWorker::~JfjFrameWorker() {
|
||||
|
||||
|
||||
inline uint64_t JfjFrameWorker::process_packets(BufferBinaryFormat& buffer){
|
||||
// std::cout << " Called process_packets()" << std::endl;
|
||||
//std::cout << " Called process_packets()" << std::endl;
|
||||
|
||||
while(!m_buffer.is_empty()){
|
||||
// Happens if the last packet from the previous frame gets lost.
|
||||
@@ -36,6 +36,8 @@ inline uint64_t JfjFrameWorker::process_packets(BufferBinaryFormat& buffer){
|
||||
jfjoch_packet_t& c_packet = m_buffer.pop_front();
|
||||
m_frame_index = c_packet.framenum;
|
||||
this->in_progress = true;
|
||||
//std::cout << " ff: " << c_packet.framenum << std::endl;
|
||||
//std::cout << " ex: " << c_packet.exptime << std::endl;
|
||||
//std::cout << " pp: " << c_packet.packetnum << std::endl;
|
||||
|
||||
// Always copy metadata (otherwise problem when 0th packet gets lost)
|
||||
@@ -62,12 +64,14 @@ inline uint64_t JfjFrameWorker::process_packets(BufferBinaryFormat& buffer){
|
||||
}
|
||||
|
||||
uint64_t JfjFrameWorker::get_frame(BufferBinaryFormat& buffer){
|
||||
//std::cout << "Called get_frame()" << std::endl;
|
||||
// std::cout << "Called get_frame()" << std::endl;
|
||||
// Reset the metadata and frame buffer for the next frame. (really needed?)
|
||||
memset(&buffer, 0, sizeof(buffer));
|
||||
|
||||
// Process leftover packages in the buffer
|
||||
if (!m_buffer.is_empty()) {
|
||||
//std::cout << "Leftovers" << std::endl;
|
||||
auto pulse_id = process_packets(buffer);
|
||||
if (pulse_id != 0) { return pulse_id; }
|
||||
}
|
||||
@@ -75,8 +79,10 @@ uint64_t JfjFrameWorker::get_frame(BufferBinaryFormat& buffer){
|
||||
|
||||
while (true) {
|
||||
// Receive new packages (pass if none)...
|
||||
//std::cout << "New packages" << std::endl;
|
||||
m_buffer.fill_from(m_udp_receiver);
|
||||
if (m_buffer.is_empty()) { continue; }
|
||||
std::cout << "\tGot " << m_buffer.size() << std::endl;
|
||||
|
||||
// ... and process them
|
||||
auto pulse_id = process_packets(buffer);
|
||||
|
||||
@@ -22,8 +22,8 @@ int main (int argc, char *argv[]) {
|
||||
|
||||
std::cout << "Creating workers..." << std::endl;
|
||||
JfjFrameWorker W0(5005, 0, push_cb);
|
||||
JfjFrameWorker W1(5006, 1, push_cb);
|
||||
JfjFrameWorker W2(5007, 2, push_cb);
|
||||
//JfjFrameWorker W1(5006, 1, push_cb);
|
||||
// JfjFrameWorker W2(5007, 2, push_cb);
|
||||
|
||||
std::thread T0(&JfjFrameWorker::run, &W0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user