ModuleFrame struct with row and column

This commit is contained in:
lhdamiani
2021-03-03 17:48:57 +01:00
parent 0ede084a7b
commit 9eb81caabd
6 changed files with 84 additions and 24 deletions
+3 -3
View File
@@ -24,9 +24,9 @@ struct det_packet {
uint64_t timestamp;
uint16_t moduleID;
uint16_t xCoord;
uint16_t yCoord;
uint16_t zCoord;
uint16_t row;
uint16_t column;
uint16_t reserved;
uint32_t debug;
uint16_t roundRobin;
+2
View File
@@ -22,6 +22,8 @@ struct ModuleFrame {
uint64_t daq_rec;
uint64_t n_recv_packets;
uint64_t module_id;
uint16_t row;
uint16_t column;
};
#pragma pack(pop)
+1 -1
View File
@@ -3,7 +3,7 @@
"streamvis_rate": 10,
"live_stream": "tcp://0.0.0.0:9106",
"live_rate": 10,
"detector_name": "Eiger",
"detector_name": "eiger",
"n_modules": 1,
"start_udp_port": 50200
}
+12 -6
View File
@@ -1,8 +1,14 @@
hostname localhost:2050+
detsize 1024 512
hostname localhost:2050+localhost:2052+
udp_dstmac 90:1b:0e:19:1c:ae
udp_srcmac 90:1b:0e:19:1c:ae
udp_srcip 129.129.130.177
udp_dstip 129.129.130.177
0:udp_dstport 50200
0:udp_dstport2 50201
0:udp_dstip 127.0.0.1
0:udp_dstmac 90:1b:0e:19:1c:ae
0:udp_srcip 129.129.130.177
0:udp_srcmac 90:1b:0e:19:1c:ae
1:udp_dstport 50202
1:udp_dstport2 50203
+33
View File
@@ -0,0 +1,33 @@
import socket
import numpy as np
frame_header_dt = np.dtype(
[
("Frame Number", "u8"),
("SubFrame Number/ExpLength", "u4"),
("Packet Number", "u4"),
("Bunch ID", "u8"),
("Timestamp", "u8"),
("Module Id", "u2"),
("Row", "u2"),
("Column", "u2"),
("Reserved", "u2"),
("Debug", "u4"),
("Round Robin Number", "u2"),
("Detector Type", "u1"),
("Header Version", "u1"),
]
)
ip = "127.0.0.1"
ports = list(range(50200, 50205, 1))
sockets = [socket.socket(socket.AF_INET, socket.SOCK_DGRAM) for i in range(len(ports))]
for s, p in zip(sockets, ports):
s.bind((ip, p))
while True:
for s in sockets:
data, address = s.recvfrom(4096)
h = np.frombuffer(data, count=1, dtype=frame_header_dt)[0]
print(f'pkt:{h["Packet Number"]}, frame: {h["Frame Number"]}, row: {h["Row"]}, column: {h["Column"]}, mod_id: {h["Module Id"]}, timestamp: {h["Timestamp"]}')
+33 -14
View File
@@ -47,13 +47,18 @@ inline void FrameUdpReceiver::init_frame(
frame_metadata.frame_index = packet_buffer_[i_packet].framenum;
frame_metadata.daq_rec = (uint64_t) packet_buffer_[i_packet].debug;
frame_metadata.module_id = (int64_t) module_id_;
// #ifdef DEBUG_OUTPUT
// using namespace date;
// cout << " [" << std::chrono::system_clock::now();
// cout << "] [FrameUdpReceiver::init_frame] :";
// cout << " Frame number: " << frame_metadata.frame_index << endl;
// cout << endl;
// #endif
frame_metadata.row = (int16_t) packet_buffer_[i_packet].row;
frame_metadata.column = (int16_t) packet_buffer_[i_packet].column;
#ifdef DEBUG_OUTPUT
using namespace date;
cout << " [" << std::chrono::system_clock::now();
cout << "] [FrameUdpReceiver::init_frame] :";
cout << "module_id: " << module_id_;
cout << " || row: " << frame_metadata.row;
cout << " || column: " << frame_metadata.column;
cout << endl;
#endif
}
inline void FrameUdpReceiver::copy_packet_to_buffers(
@@ -67,13 +72,6 @@ inline void FrameUdpReceiver::copy_packet_to_buffers(
DATA_BYTES_PER_PACKET);
metadata.n_recv_packets++;
// #ifdef DEBUG_OUTPUT
// using namespace date;
// cout << " [" << std::chrono::system_clock::now();
// cout << "] [FrameUdpReceiver::copy_packet_to_buffers] :";
// cout << "buffer: n_recv_packets" << metadata.n_recv_packets;
// cout << endl;
// #endif
}
inline uint64_t FrameUdpReceiver::process_packets(
@@ -100,6 +98,27 @@ inline uint64_t FrameUdpReceiver::process_packets(
}
copy_packet_to_buffers(metadata, frame_buffer, i_packet);
#ifdef DEBUG_OUTPUT
using namespace date;
if (i_packet == 120){
cout << "Packet: " << i_packet;
cout << " || framenum " << packet_buffer_[i_packet].framenum;
cout << " || exptime " << packet_buffer_[i_packet].exptime;
cout << " || packetnum " << packet_buffer_[i_packet].packetnum;
cout << " || bunchid " << packet_buffer_[i_packet].bunchid ;
cout << " || timestamp " << packet_buffer_[i_packet].timestamp ;
cout << " || moduleID " << packet_buffer_[i_packet].moduleID ;
cout << " || x coord " << packet_buffer_[i_packet].row ;
cout << " || y coord " << packet_buffer_[i_packet].column ;
cout << " || reserved " << packet_buffer_[i_packet].reserved ;
cout << " || debug " << packet_buffer_[i_packet].debug ;
cout << " || roundRobin " << packet_buffer_[i_packet].roundRobin ;
cout << " || detectortype " << packet_buffer_[i_packet].detectortype ;
cout << " || headerVersion " << packet_buffer_[i_packet].headerVersion ;
cout << endl;
}
#endif
// Last frame packet received. Frame finished.
if (packet_buffer_[i_packet].packetnum ==