more debug info. bunch/pulseid adjusts.

This commit is contained in:
2021-02-12 16:58:02 +01:00
parent 64a92eb3cd
commit 1de8f66bdc
9 changed files with 114 additions and 41 deletions
+15
View File
@@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <ostream>
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 << ' ';
}
};
+6 -2
View File
@@ -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)
+1 -1
View File
@@ -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
+28 -9
View File
@@ -4,7 +4,10 @@
#include <buffer_config.hpp>
#include <zmq.h>
#include <fstream>
#include <iostream>
#include <stdexcept>
#include <chrono>
#include "date.h"
#include <rapidjson/istreamwrapper.h>
#include <rapidjson/document.h>
#include <rapidjson/stringbuffer.h>
@@ -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;
}
+30 -1
View File
@@ -5,6 +5,9 @@
#include <unistd.h>
#include "RamBuffer.hpp"
#include "buffer_config.hpp"
#include "date.h"
#include <chrono>
#include <iostream>
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);
}
@@ -1,5 +1,5 @@
{
"detector_name": "Eiger",
"n_modules": 1,
"start_udp_port": 50100
}
"start_udp_port": 50200
}
+2 -22
View File
@@ -1,30 +1,10 @@
#!/bin/bash
# usage ./start_eiger_detector.sh Eiger 1
if [ $# -lt 1 ]
then
echo "Usage : $0 DETECTOR_NAME <number_of_cycles>"
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..."
+29 -3
View File
@@ -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.
+1 -1
View File
@@ -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;