diff --git a/core-buffer/include/BufferUtils.hpp b/core-buffer/include/BufferUtils.hpp index bb09dea..835e602 100644 --- a/core-buffer/include/BufferUtils.hpp +++ b/core-buffer/include/BufferUtils.hpp @@ -3,6 +3,7 @@ #include #include +#include namespace BufferUtils { @@ -19,6 +20,20 @@ namespace BufferUtils const int n_modules; const int start_udp_port; const std::string buffer_folder; + + friend std::ostream& operator <<(std::ostream& os, DetectorConfig const& det_config) + { + return os << det_config.streamvis_address << ' ' + << det_config.reduction_factor_streamvis << ' ' + << det_config.live_analysis_address << ' ' + << det_config.reduction_factor_live_analysis << ' ' + << det_config.PEDE_FILENAME << ' ' + << det_config.GAIN_FILENAME << ' ' + << det_config.detector_name << ' ' + << det_config.n_modules << ' ' + << det_config.start_udp_port << ' ' + << det_config.buffer_folder << ' '; + } }; diff --git a/core-buffer/include/eiger.hpp b/core-buffer/include/eiger.hpp index b256e28..0746fd9 100644 --- a/core-buffer/include/eiger.hpp +++ b/core-buffer/include/eiger.hpp @@ -6,8 +6,12 @@ #define N_MODULES 1 #define BYTES_PER_PACKET 1072 #define DATA_BYTES_PER_PACKET 1024 -#define N_PACKETS_PER_FRAME 128 -#define DATA_BYTES_PER_FRAME 131072 +// DR 16 +#define N_PACKETS_PER_FRAME 256 +#define DATA_BYTES_PER_FRAME 262144 +// DR 32 +// #define N_PACKETS_PER_FRAME 512 +// #define DATA_BYTES_PER_FRAME 524288 #pragma pack(push) #pragma pack(2) diff --git a/core-buffer/include/formats.hpp b/core-buffer/include/formats.hpp index fe29600..a5aec2a 100644 --- a/core-buffer/include/formats.hpp +++ b/core-buffer/include/formats.hpp @@ -10,7 +10,7 @@ #endif #ifdef DEBUG_OUTPUT -#define EIGER_DATA_BYTES_PER_PACKET_VALIDATION 131072 +#define EIGER_DATA_BYTES_PER_PACKET_VALIDATION 262144 #define JUNGFRAU_DATA_BYTES_PER_PACKET_VALIDATION 1048576 #endif diff --git a/core-buffer/src/BufferUtils.cpp b/core-buffer/src/BufferUtils.cpp index 3d12259..a59682c 100644 --- a/core-buffer/src/BufferUtils.cpp +++ b/core-buffer/src/BufferUtils.cpp @@ -4,7 +4,10 @@ #include #include #include +#include #include +#include +#include "date.h" #include #include #include @@ -136,16 +139,32 @@ BufferUtils::DetectorConfig BufferUtils::read_json_config( rapidjson::Document config_parameters; config_parameters.ParseStream(isw); - return { - config_parameters["streamvis_stream"].GetString(), - config_parameters["streamvis_rate"].GetInt(), - config_parameters["live_stream"].GetString(), - config_parameters["live_rate"].GetInt(), - config_parameters["pedestal_file"].GetString(), - config_parameters["gain_file"].GetString(), + BufferUtils::DetectorConfig det_config = { + // config_parameters["streamvis_stream"].GetString(), + "", + // config_parameters["streamvis_rate"].GetInt(), + -1, + // config_parameters["live_stream"].GetString(), + "", + // config_parameters["live_rate"].GetInt(), + -1, + // config_parameters["pedestal_file"].GetString(), + "", + // config_parameters["gain_file"].GetString(), + "", config_parameters["detector_name"].GetString(), config_parameters["n_modules"].GetInt(), config_parameters["start_udp_port"].GetInt(), - config_parameters["buffer_folder"].GetString() - }; + // config_parameters["buffer_folder"].GetString() + "" + }; + + #ifdef DEBUG_OUTPUT + using namespace date; + cout << " [" << std::chrono::system_clock::now(); + cout << "] [BufferUtils::read_json_config] Config:"; + cout << det_config; + cout << endl; + #endif + return det_config; } diff --git a/core-buffer/src/RamBuffer.cpp b/core-buffer/src/RamBuffer.cpp index 3b04783..626d655 100644 --- a/core-buffer/src/RamBuffer.cpp +++ b/core-buffer/src/RamBuffer.cpp @@ -5,6 +5,9 @@ #include #include "RamBuffer.hpp" #include "buffer_config.hpp" +#include "date.h" +#include +#include using namespace std; @@ -40,6 +43,19 @@ RamBuffer::RamBuffer( meta_buffer_ = (ModuleFrame *) buffer_; // Image buffer start right after metadata buffer. image_buffer_ = (char*)buffer_ + (meta_bytes_ * n_slots_); + + #ifdef DEBUG_OUTPUT + using namespace date; + cout << " [" << std::chrono::system_clock::now(); + cout << "] [RamBuffer::RamBuffer] :"; + cout << " Details of rambuffer:"; + cout << "n_modules: " << n_modules_; + cout << " || meta_bytes: " << meta_bytes_; + cout << " || image_bytes: " << image_bytes_; + cout << " || buffer_bytes: " << buffer_bytes_; + cout << " || n_slots: " << n_slots_; + cout << endl; + #endif } RamBuffer::~RamBuffer() @@ -53,7 +69,8 @@ void RamBuffer::write_frame( const ModuleFrame& src_meta, const char *src_data) const { - const int slot_n = src_meta.pulse_id % n_slots_; + + const int slot_n = src_meta.frame_index % n_slots_; ModuleFrame *dst_meta = meta_buffer_ + (n_modules_ * slot_n) + @@ -63,6 +80,18 @@ void RamBuffer::write_frame( (image_bytes_ * slot_n) + (MODULE_N_BYTES * src_meta.module_id); + #ifdef DEBUG_OUTPUT + using namespace date; + cout << " [" << std::chrono::system_clock::now(); + cout << "] [RamBuffer::write_frame] :"; + cout << " || src_meta.frame_index " << src_meta.frame_index; + cout << " || src_meta.n_recv_packets " << src_meta.n_recv_packets; + cout << " || src_meta.daq_rec " << src_meta.daq_rec; + cout << " || src_meta.module_id " << src_meta.module_id; + cout << " || dst_data " << dst_data; + cout << endl; + #endif + memcpy(dst_meta, &src_meta, sizeof(ModuleFrame)); memcpy(dst_data, src_data, MODULE_N_BYTES); } diff --git a/eiger/config_udp_recv.json b/eiger/config/eiger.json similarity index 63% rename from eiger/config_udp_recv.json rename to eiger/config/eiger.json index 01c3813..c2bf6d8 100644 --- a/eiger/config_udp_recv.json +++ b/eiger/config/eiger.json @@ -1,5 +1,5 @@ { "detector_name": "Eiger", "n_modules": 1, - "start_udp_port": 50100 -} \ No newline at end of file + "start_udp_port": 50200 +} diff --git a/eiger/start_eiger_acquisition.sh b/eiger/start_eiger_acquisition.sh index a2c231f..6f55a10 100755 --- a/eiger/start_eiger_acquisition.sh +++ b/eiger/start_eiger_acquisition.sh @@ -1,30 +1,10 @@ #!/bin/bash -# usage ./start_eiger_detector.sh Eiger 1 -if [ $# -lt 1 ] -then - echo "Usage : $0 DETECTOR_NAME " - echo " DETECTOR_NAME: Eiger..." - echo " number_of_cycles : optional, default 100" - exit -fi - -SLS_DET_PACKAGE_PATH='/home/hax_l/software/sf_daq_buffer/slsDetectorPackage/build/bin/' - -DETECTOR=$1 - -n_cycles=10 -if [ $# == 2 ] -then - n_cycles=$2 -fi - +${SLS_DET_PACKAGE_PATH}sls_detector_put triggers 1 ${SLS_DET_PACKAGE_PATH}sls_detector_put timing trigger -${SLS_DET_PACKAGE_PATH}sls_detector_put triggers ${n_cycles} ${SLS_DET_PACKAGE_PATH}sls_detector_put exptime 0.000005 ${SLS_DET_PACKAGE_PATH}sls_detector_put frames 1 ${SLS_DET_PACKAGE_PATH}sls_detector_put dr 16 -#sls_detector_put ${D}-clearbit to 0x5d 0 # normal mode, not highG0 ${SLS_DET_PACKAGE_PATH}sls_detector_put start -echo "Now start trigger" +echo "Acquisition started..." diff --git a/jf-udp-recv/src/FrameUdpReceiver.cpp b/jf-udp-recv/src/FrameUdpReceiver.cpp index 003e945..d522f00 100644 --- a/jf-udp-recv/src/FrameUdpReceiver.cpp +++ b/jf-udp-recv/src/FrameUdpReceiver.cpp @@ -13,6 +13,16 @@ FrameUdpReceiver::FrameUdpReceiver( const int module_id) : module_id_(module_id) { + #ifdef DEBUG_OUTPUT + using namespace date; + cout << " [" << std::chrono::system_clock::now(); + cout << "] [FrameUdpReceiver::FrameUdpReceiver] :"; + cout << " Details of FrameUdpReceiver:"; + cout << "module_id: " << module_id_; + cout << " || port: " << port; + cout << " BUFFER_UDP_N_RECV_MSG: " << BUFFER_UDP_N_RECV_MSG << endl; + cout << endl; + #endif udp_receiver_.bind(port); for (int i = 0; i < BUFFER_UDP_N_RECV_MSG; i++) { @@ -37,6 +47,14 @@ 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 << "i_packet" << i_packet << endl; + // cout << endl; + // #endif } inline void FrameUdpReceiver::copy_packet_to_buffers( @@ -50,6 +68,13 @@ 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( @@ -62,7 +87,7 @@ inline uint64_t FrameUdpReceiver::process_packets( i_packet++) { // First packet for this frame. - if (metadata.pulse_id == 0) { + if (i_packet == 0) { init_frame(metadata, i_packet); // Happens if the last packet from the previous frame gets lost. @@ -85,7 +110,8 @@ inline uint64_t FrameUdpReceiver::process_packets( using namespace date; cout << " [" << std::chrono::system_clock::now(); cout << "] [FrameUdpReceiver::process_packets] :"; - cout << " Total packets of frame finished. "; + cout << " Frame " << metadata.frame_index << " || "; + cout << packet_buffer_[i_packet].packetnum << " packets received."; cout << endl; #endif // Buffer is loaded only if this is not the last message. @@ -100,7 +126,7 @@ inline uint64_t FrameUdpReceiver::process_packets( packet_buffer_offset_ = 0; } - return metadata.pulse_id; + return metadata.frame_index; } } // We emptied the buffer. diff --git a/jf-udp-recv/src/main.cpp b/jf-udp-recv/src/main.cpp index 49668a1..75ea403 100644 --- a/jf-udp-recv/src/main.cpp +++ b/jf-udp-recv/src/main.cpp @@ -18,7 +18,7 @@ int main (int argc, char *argv[]) { if (argc != 3) { cout << endl; - cout << "Usage: jf_udp_recv [detector_json_filename] [module_id]"; + cout << "Usage: XXX_udp_recv [detector_json_filename] [module_id]"; cout << endl; cout << "\tdetector_json_filename: detector config file path." << endl; cout << "\tmodule_id: id of the module for this process." << endl;