diff --git a/core-buffer/include/jungfrau.hpp b/core-buffer/include/jungfrau.hpp index 99156e6..4ff93a8 100644 --- a/core-buffer/include/jungfrau.hpp +++ b/core-buffer/include/jungfrau.hpp @@ -17,7 +17,7 @@ struct jungfrau_packet { uint32_t exptime; uint32_t packetnum; - double bunchid; + uint64_t bunchid; uint64_t timestamp; uint16_t moduleID; diff --git a/jfj-combined/test/SimulatedDetector.cpp b/jfj-combined/test/SimulatedDetector.cpp new file mode 100644 index 0000000..74fc70c --- /dev/null +++ b/jfj-combined/test/SimulatedDetector.cpp @@ -0,0 +1,74 @@ +#include +#include +#include +#include +#include +#include +#include "../../core-buffer/include/jungfrau.hpp" + + +void MockDetector(uint16_t udp_port, int32_t moduleId, int32_t sleep_ms){ + auto send_socket_fd = socket(AF_INET,SOCK_DGRAM,0); + if(send_socket_fd < 0){std::cout << "Failed to create socket" << std::endl; exit(-1); }; + + struct sockaddr_in server_address, client_address; + memset(&server_address, 0, sizeof(server_address)); + memset(&client_address, 0, sizeof(client_address)); + + // Filling server information + server_address.sin_family = AF_INET; // IPv4 + server_address.sin_addr.s_addr = INADDR_ANY; + server_address.sin_port = htons(udp_port); + + // Send loop + jungfrau_packet send_udp_buffer; + memset(&send_udp_buffer, 0, sizeof(send_udp_buffer)); + + for(int64_t ff=0; ff<10000; ff++){ + send_udp_buffer.framenum = ff; + send_udp_buffer.bunchid = ff; + send_udp_buffer.moduleID = moduleId; + send_udp_buffer.debug = 0; + + for(int64_t pp=0; pp<128; pp++){ + send_udp_buffer.packetnum = pp; + ::sendto(send_socket_fd, &send_udp_buffer, sizeof(send_udp_buffer), 0, (sockaddr*) &server_address, sizeof(server_address)); + } + + std::this_thread::sleep_for(std::chrono::milliseconds(sleep_ms)); + if(ff%1000==0){ + std::cout << "Sent " << ff << " frames" << std::endl; + } + } + + //close(send_socket_fd); +} + + +int main (int argc, char *argv[]) { + if (argc != 4) { + std::cout << "\nERROR\nUsage: jf_buffer_writer [num_modules] [start_port] [sleep_ms]\n"; + exit(-1); + } + + int num_modules = atoi(argv[1]); + int start_port = atoi(argv[2]); + int sleep_ms = atoi(argv[3]); + sleep_ms = (sleep_ms>=1) ? sleep_ms : 1; + + + std::cout << "Starting worker threads..." << std::endl; + std::vector vThreads; + + for(int mm=0; mm