controls scripts of eiger and debug msgs

This commit is contained in:
lhdamiani
2021-03-05 16:47:18 +01:00
parent edb9b94fa5
commit 22f73b0273
11 changed files with 268 additions and 34 deletions
+2 -2
View File
@@ -24,8 +24,8 @@ struct det_packet {
uint64_t timestamp;
uint16_t moduleID;
uint16_t row;
uint16_t column;
uint16_t xCoord;
uint16_t yCoord;
uint16_t reserved;
uint32_t debug;
+3 -5
View File
@@ -157,15 +157,13 @@ BufferUtils::DetectorConfig BufferUtils::read_json_config(
rapidjson::Document config_parameters;
config_parameters.ParseStream(isw);
BufferUtils::DetectorConfig det_config = {
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(),
"",
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(),
+23 -15
View File
@@ -44,19 +44,6 @@ 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()
@@ -124,9 +111,22 @@ void RamBuffer::assemble_image(
auto is_pulse_init = false;
auto is_good_image = true;
// for each module it collects the metadata from each frame
for (int i_module=0; i_module < n_modules_; i_module++) {
ModuleFrame *frame_meta = src_meta + i_module;
#ifdef DEBUG_OUTPUT
using namespace date;
cout << " [" << std::chrono::system_clock::now();
cout << "] [RamBuffer::assemble_image] :";
cout << "module_id: " << i_module;
cout << " || frame index: " << frame_meta->frame_index;
cout << " || row: " << frame_meta->row;
cout << " || column: " << frame_meta->column;
cout << " || n_recv_packets: " << frame_meta->n_recv_packets;
cout << endl;
#endif
auto is_good_frame =
frame_meta->n_recv_packets == N_PACKETS_PER_FRAME;
@@ -142,6 +142,7 @@ void RamBuffer::assemble_image(
#endif
continue;
}
// in the first module will enter here and define image metadata
if (!is_pulse_init) {
if (frame_meta->frame_index != pulse_id) {
stringstream err_msg;
@@ -160,11 +161,18 @@ void RamBuffer::assemble_image(
throw runtime_error(err_msg.str());
}
image_meta.pulse_id = frame_meta->pulse_id;
image_meta.frame_index = frame_meta->frame_index;
image_meta.daq_rec = frame_meta->daq_rec;
#ifdef DEBUG_OUTPUT
using namespace date;
cout << " [" << std::chrono::system_clock::now();
cout << "] [RamBuffer::assemble_image] :";
cout << " Defining image_meta";
cout << " || image_meta.frame_index " << image_meta.frame_index;
cout << endl;
#endif
is_pulse_init = 1;
}
+5 -2
View File
@@ -3,7 +3,10 @@
"streamvis_rate": 10,
"live_stream": "tcp://0.0.0.0:9106",
"live_rate": 10,
"pedestal_file": "",
"gain_file": "",
"detector_name": "eiger",
"n_modules": 1,
"start_udp_port": 50200
"n_modules": 2,
"start_udp_port": 50200,
"buffer_folder": ""
}
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
UDP=0
STREAM=0
ASSEMBLER=0
HELP_FLAG=0
while getopts h:u:s:a: flag
do
case "${flag}" in
h ) HELP_FLAG=${OPTARG};;
u ) UDP=${OPTARG};;
s ) STREAM=${OPTARG};;
a ) ASSEMBLER=${OPTARG};;
esac
done
if (( ${UDP} == 0 )) && (( ${STREAM} == 0 )) && (( ${ASSEMBLER} == 0 )); then
echo "Nothing to do..."
exit
fi
# prints help and exits
if (( ${HELP_FLAG} == 1 )); then
echo "Usage : $0 -u <udp_recvs> -s <stream> -a <assembler> -h <help_flag>"
echo " udp : kill udp receivers."
echo " stream : kill stream."
echo " assembler : kill assembler."
echo " help_flag : show this help and exits."
exit
fi
if (( ${UDP} == 1 )); then
echo "Killing upd recvs..."
ps aux | grep eiger_udp_recv | awk 'NR > 1 { print prev } { prev = $2 }' | xargs -I{} kill {}
fi
if (( ${STREAM} == 1 )); then
echo "Killing stream..."
ps aux | grep eiger_stream | awk 'NR > 1 { print prev } { prev = $2 }' | xargs -I{} kill {}
fi
if (( ${ASSEMBLER} == 1 )); then
echo "Killing stream..."
ps aux | grep eiger_assembler | awk 'NR > 1 { print prev } { prev = $2 }' | xargs -I{} kill {}
fi
+46
View File
@@ -0,0 +1,46 @@
#!/bin/bash
MAKE_FLAG=0
ASSEMBLER='/home/hax_l/software/sf_daq_buffer/build/eiger_assembler'
CONFIG_FILE='/home/hax_l/software/sf_daq_buffer/eiger/config/eiger.json'
BUILD_PATH='/home/hax_l/software/sf_daq_buffer/build'
NAME='eiger_assembler'
HELP_FLAG=0
while getopts m:h:c: flag
do
case "${flag}" in
m ) MAKE_FLAG=${OPTARG};;
h ) HELP_FLAG=${OPTARG};;
c ) CONFIG_FILE=${OPTARG};;
esac
done
# prints help and exits
if (( ${HELP_FLAG} == 1 )); then
echo "Usage : $0 -c <config_file> -m <make_flag> -h <help_flag>"
echo " config_file : detector configuration file."
echo " make_flag : compile code before running."
echo " help_flag : show this help and exits."
exit
fi
# compiles the sf_buffer_daq
if (( ${MAKE_FLAG} == 1 )); then
echo "Compile flag detected..."
set -e
cd ${BUILD_PATH} && make
fi
# proceeds to start the receivers
echo "Starting the ${NAME} (config file: ${CONFIG_FILE})"
if [ -f "${ASSEMBLER}" ]; then
if [ -f "${CONFIG_FILE}" ]; then
${ASSEMBLER} ${CONFIG_FILE} &
else
echo "Something went wrong with the config file..."
exit
fi
else
echo "Something went wrong with the assembler executable..."
exit
fi
+48
View File
@@ -0,0 +1,48 @@
#!/bin/bash
MAKE_FLAG=0
STREAM='/home/hax_l/software/sf_daq_buffer/build/eiger_stream'
CONFIG_FILE='/home/hax_l/software/sf_daq_buffer/eiger/config/eiger.json'
BUILD_PATH='/home/hax_l/software/sf_daq_buffer/build'
STREAM_NAME='eiger'
HELP_FLAG=0
while getopts m:h:n:c: flag
do
case "${flag}" in
m ) MAKE_FLAG=${OPTARG};;
h ) HELP_FLAG=${OPTARG};;
n ) STREAM_NAME=${OPTARG};;
c ) CONFIG_FILE=${OPTARG};;
esac
done
# prints help and exits
if (( ${HELP_FLAG} == 1 )); then
echo "Usage : $0 -c <config_file> -n <stream_name> -m <make_flag> -h <help_flag>"
echo " config_file : detector configuration file."
echo " stream_name : stream name."
echo " make_flag : compile code before running."
echo " help_flag : show this help and exits."
exit
fi
# compiles the sf_buffer_daq
if (( ${MAKE_FLAG} == 1 )); then
echo "Compile flag detected..."
set -e
cd ${BUILD_PATH} && make
fi
# proceeds to start the receivers
echo "Starting stream name ${STREAM_NAME} (config file: ${CONFIG_FILE})"
if [ -f "${STREAM}" ]; then
if [ -f "${CONFIG_FILE}" ]; then
${STREAM} ${CONFIG_FILE} ${STREAM_NAME} &
else
echo "Something went wrong with the config file..."
exit
fi
else
echo "Something went wrong with the stream executable..."
exit
fi
+55
View File
@@ -0,0 +1,55 @@
#!/bin/bash
N_UDP_RECVS=4
MAKE_FLAG=0
UDP_RECV='/home/hax_l/software/sf_daq_buffer/build/eiger_udp_recv'
CONFIG_FILE='/home/hax_l/software/sf_daq_buffer/eiger/config/eiger.json'
BUILD_PATH='/home/hax_l/software/sf_daq_buffer/build'
HELP_FLAG=0
while getopts p:n:m:h:u:c: flag
do
case "${flag}" in
p ) PORT=${OPTARG};;
n ) N_UDP_RECVS=${OPTARG};;
m ) MAKE_FLAG=${OPTARG};;
h ) HELP_FLAG=${OPTARG};;
u ) UDP_RECV=${OPTARG};;
c ) CONFIG_FILE=${OPTARG};;
esac
done
# prints help and exits
if (( ${HELP_FLAG} == 1 )); then
echo "Usage : $0 -n <n_udp_recvs> -c <compile_flag> -h <help_flag> -u <udp_executable> -c <config_file>"
echo " n_udp_recvs : number of receivers."
echo " compile_flag : compile code before running."
echo " help_flag : show this help and exits."
echo " udp_executable : executable for the udp receivers."
echo " config_file : detector configuration file."
exit
fi
# compiles the sf_buffer_daq
if (( ${MAKE_FLAG} == 1 )); then
echo "Compile flag detected..."
set -e
cd ${BUILD_PATH} && make
fi
# proceeds to start the receivers
echo "Starting ${N_UDP_RECVS} udp receivers..."
COUNTER=0
if [ -f "${UDP_RECV}" ]; then
if [ -f "${CONFIG_FILE}" ]; then
while [ $COUNTER -lt 4 ]; do
${UDP_RECV} ${CONFIG_FILE} ${COUNTER} &
let COUNTER=COUNTER+1
sleep 0.5
done
else
echo "Something went wrong with the udp recv executable..."
exit
fi
else
echo "Something went wrong with the udp recv executable..."
exit
fi
+27 -9
View File
@@ -1,21 +1,39 @@
#!/bin/bash
# usage ./start_eiger_detector.sh Eiger 1
if [ $# -lt 1 ]
# default port 2050 and 2052
if [ $# -eq 0 ]
then
PORT=2050
PORT_SLAVE=2052
elif [ $# -eq 1 ]
then
PORT=$1
PORT_SLAVE=$(( $1 + 2 ))
else
echo "Usage : $0 <port>"
echo " tcp port : optional, default 2000"
echo " tcp port : optional, default 2050"
exit
fi
SLS_DET_PACKAGE_PATH='/home/hax_l/software/sf_daq_buffer/slsDetectorPackage/build/bin/'
PORT=2050
if [ $# == 2 ]
then
PORT=$1
echo "Starting the master eiger virtual detector at port ${PORT}..."
if [ -f "${SLS_DET_PACKAGE_PATH}eigerDetectorServerMaster_virtual" ]; then
${SLS_DET_PACKAGE_PATH}eigerDetectorServerMaster_virtual -p ${PORT} &
else
echo "Eiger master was not found at ${SLS_DET_PACKAGE_PATH}."
exit
fi
echo "Starting the server..."
echo "Starting the slave bottom eiger virtual detector at port ${PORT_SLAVE}..."
echo ${SLS_DET_PACKAGE_PATH}eigerDetectorServerMaster_virtual -p ${PORT}
if [ -f "${SLS_DET_PACKAGE_PATH}eigerDetectorServerSlaveBottom_virtual" ]; then
${SLS_DET_PACKAGE_PATH}eigerDetectorServerSlaveBottom_virtual -p ${PORT} &
else
echo "Eiger slave bottom was not found at ${SLS_DET_PACKAGE_PATH}."
exit
fi
+1 -1
View File
@@ -57,7 +57,7 @@ PulseAndSync ZmqPulseSyncReceiver::get_next_pulse_id() const
using namespace date;
cout << " [" << std::chrono::system_clock::now();
cout << "] [ZmqPulseSyncReceiver::get_next_pulse_id] modules_in_sync true";
cout << "] returning pulses[0]";
cout << "] returning pulses[0] (frame index):" << pulses[0];
cout << endl;
#endif
return {pulses[0], 0};
+12
View File
@@ -5,6 +5,8 @@
#include <BufferUtils.hpp>
#include <AssemblerStats.hpp>
#include "date.h"
#include <chrono>
#include "assembler_config.hpp"
#include "ZmqPulseSyncReceiver.hpp"
@@ -40,6 +42,16 @@ int main (int argc, char *argv[])
AssemblerStats stats(config.detector_name, ASSEMBLER_STATS_MODULO);
ImageMetadata meta;
#ifdef DEBUG_OUTPUT
using namespace date;
cout << " [" << std::chrono::system_clock::now();
cout << "] [Assembler] :";
cout << " Details of Assembler:";
cout << "detector_name: " << config.detector_name;
cout << "n_modules: " << config.n_modules;
#endif
while (true) {
auto pulse_and_sync = receiver.get_next_pulse_id();
ram_buffer.assemble_image(pulse_and_sync.pulse_id, meta);