mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 02:52:22 +02:00
bit_depth defined via config file
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ add_subdirectory(
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
add_subdirectory("core-buffer")
|
||||
#add_subdirectory("std-stream-send")
|
||||
add_subdirectory("std-stream-send")
|
||||
add_subdirectory("std-udp-recv")
|
||||
add_subdirectory("std-udp-sync")
|
||||
#add_subdirectory("jf-buffer-writer")
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace BufferUtils
|
||||
const int image_height;
|
||||
const int image_width;
|
||||
const int start_udp_port;
|
||||
const int bit_depth;
|
||||
|
||||
|
||||
friend std::ostream& operator <<(std::ostream& os, DetectorConfig const& det_config)
|
||||
@@ -23,6 +24,7 @@ namespace BufferUtils
|
||||
<< det_config.detector_type << ' '
|
||||
<< det_config.n_modules << ' '
|
||||
<< det_config.start_udp_port << ' '
|
||||
<< det_config.bit_depth << ' '
|
||||
<< det_config.image_height << ' '
|
||||
<< det_config.image_width << ' ';
|
||||
}
|
||||
|
||||
@@ -164,6 +164,7 @@ BufferUtils::DetectorConfig BufferUtils::read_json_config(
|
||||
config_parameters["n_modules"].GetInt(),
|
||||
config_parameters["image_height"].GetInt(),
|
||||
config_parameters["image_width"].GetInt(),
|
||||
config_parameters["bit_depth"].GetInt(),
|
||||
config_parameters["start_udp_port"].GetInt(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@
|
||||
"n_modules": 4,
|
||||
"image_height": 514,
|
||||
"image_width": 1030,
|
||||
"bit_depth": 16,
|
||||
"start_udp_port": 50200
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ CONFIG_FILE='/home/hax_l/sf_daq_buffer/eiger/sf-daq-4/config/eiger.json'
|
||||
HELP_FLAG=0
|
||||
|
||||
# CONFIGURATION
|
||||
BIT_DEPTH=16
|
||||
N_MPI_EXEC=3
|
||||
STREAM_NAME='streamvis'
|
||||
while getopts h:c:b:m: flag
|
||||
@@ -29,7 +28,6 @@ do
|
||||
case "${flag}" in
|
||||
h ) HELP_FLAG=${OPTARG};;
|
||||
c ) CONFIG_FILE=${OPTARG};;
|
||||
b ) BIT_DEPTH=${OPTARG};;
|
||||
m ) N_MPIT_EXEC=${OPTARG};;
|
||||
s ) STREAMVIS=${OPTARG};;
|
||||
esac
|
||||
@@ -37,10 +35,9 @@ done
|
||||
|
||||
# prints help and exits
|
||||
if (( ${HELP_FLAG} == 1 )); then
|
||||
echo "Usage : $0 -h <help_flag> -c <config_file> -b <bit_depth> -s <stream_name>"
|
||||
echo "Usage : $0 -h <help_flag> -c <config_file> -s <stream_name>"
|
||||
echo " help_flag : show this help and exits."
|
||||
echo " config_file : detector configuration file."
|
||||
echo " bit_depth : detector bit depth."
|
||||
echo " stream name : live stream name."
|
||||
exit
|
||||
fi
|
||||
@@ -74,16 +71,11 @@ echo "Starting ${N_UDP_RECVS} udp receivers..."
|
||||
COUNTER=0
|
||||
if [ -f "${BUILD_PATH}${UDP_RECV}" ]; then
|
||||
if [ -f "${CONFIG_FILE}" ]; then
|
||||
if [ ${BIT_DEPTH} -ne 0 ]; then
|
||||
while [ $COUNTER -lt ${N_UDP_RECVS} ]; do
|
||||
${BUILD_PATH}${UDP_RECV} ${CONFIG_FILE} ${COUNTER} ${BIT_DEPTH} &
|
||||
let COUNTER=COUNTER+1
|
||||
sleep 0.5
|
||||
done
|
||||
else
|
||||
echo "Error: ${BIT_DEPTH} can't be zero..."
|
||||
exit
|
||||
fi
|
||||
while [ $COUNTER -lt ${N_UDP_RECVS} ]; do
|
||||
${BUILD_PATH}${UDP_RECV} ${CONFIG_FILE} ${COUNTER}&
|
||||
let COUNTER=COUNTER+1
|
||||
sleep 0.5
|
||||
done
|
||||
else
|
||||
echo "Something went wrong while starting the ${UDP_RECV}..."
|
||||
exit
|
||||
@@ -115,13 +107,8 @@ fi
|
||||
echo "Starting the ${EIGER_ASSEMBLER}..."
|
||||
if [ -f "${BUILD_PATH}${EIGER_ASSEMBLER}" ]; then
|
||||
if [ -f "${CONFIG_FILE}" ]; then
|
||||
if [ ${BIT_DEPTH} -ne 0 ]; then
|
||||
${BUILD_PATH}${EIGER_ASSEMBLER} ${CONFIG_FILE} ${BIT_DEPTH} &
|
||||
sleep 0.5
|
||||
else
|
||||
echo "Error: ${BIT_DEPTH} can't be zero..."
|
||||
exit
|
||||
fi
|
||||
${BUILD_PATH}${EIGER_ASSEMBLER} ${CONFIG_FILE} &
|
||||
sleep 0.5
|
||||
else
|
||||
echo "Something went wrong while starting the ${EIGER_ASSEMBLER}..."
|
||||
exit
|
||||
@@ -135,12 +122,7 @@ fi
|
||||
echo "Starting the ${STD_STREAM_SEND}..."
|
||||
if [ -f "${BUILD_PATH}${STD_STREAM_SEND}" ]; then
|
||||
if [ -f "${CONFIG_FILE}" ]; then
|
||||
if [ ${BIT_DEPTH} -ne 0 ]; then
|
||||
${BUILD_PATH}${STD_STREAM_SEND} ${CONFIG_FILE} ${BIT_DEPTH} ${STREAM_NAME} &
|
||||
else
|
||||
echo "Error: ${BIT_DEPTH} can't be zero..."
|
||||
exit
|
||||
fi
|
||||
${BUILD_PATH}${STD_STREAM_SEND} ${CONFIG_FILE} ${STREAM_NAME} &
|
||||
else
|
||||
echo "Something went wrong while starting the ${STD_STREAM_SEND}..."
|
||||
exit
|
||||
@@ -157,7 +139,7 @@ export LD_LIBRARY_PATH="/usr/lib64/mpich-3.2/lib:${LD_LIBRARY_PATH}";
|
||||
|
||||
if [ -f "${BUILD_PATH}${STD_DET_WRITER}" ]; then
|
||||
if [ -f "${CONFIG_FILE}" ]; then
|
||||
mpiexec -n ${N_MPI_EXEC} ${BUILD_PATH}${STD_DET_WRITER} ${CONFIG_FILE} ${BIT_DEPTH} &
|
||||
mpiexec -n ${N_MPI_EXEC} ${BUILD_PATH}${STD_DET_WRITER} ${CONFIG_FILE} &
|
||||
sleep 0.5
|
||||
else
|
||||
echo "Something went wrong while starting the ${STD_DET_WRITER}..."
|
||||
|
||||
@@ -24,28 +24,25 @@ using namespace assembler_config;
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
if (argc != 2) {
|
||||
cout << endl;
|
||||
#ifndef USE_EIGER
|
||||
cout << "Usage: jf_assembler [detector_json_filename] "
|
||||
" [bit_depth]" << endl;
|
||||
<< endl;
|
||||
#else
|
||||
cout << "Usage: eiger_assembler [detector_json_filename] "
|
||||
" [bit_depth]" << endl;
|
||||
<< endl;
|
||||
#endif
|
||||
cout << "\tdetector_json_filename: detector config file path.";
|
||||
cout << endl;
|
||||
cout << "\tbit_depth: bit depth of the image.";
|
||||
cout << endl;
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
auto config = BufferUtils::read_json_config(string(argv[1]));
|
||||
const int bit_depth = atoi(argv[2]);
|
||||
auto const stream_name = "assembler";
|
||||
|
||||
const size_t IMAGE_N_BYTES = config.image_height * config.image_width * bit_depth / 8;
|
||||
const size_t IMAGE_N_BYTES = config.image_height * config.image_width * config.bit_depth / 8;
|
||||
auto ctx = zmq_ctx_new();
|
||||
zmq_ctx_set(ctx, ZMQ_IO_THREADS, ASSEMBLER_ZMQ_IO_THREADS);
|
||||
auto sender = BufferUtils::bind_socket(
|
||||
@@ -62,13 +59,14 @@ int main (int argc, char *argv[])
|
||||
cout << " || n_modules: " << config.n_modules;
|
||||
cout << " || img width: " << config.image_width;
|
||||
cout << " || img height: " << config.image_height;
|
||||
cout << " || bit_depth: " << config.bit_depth;
|
||||
cout << endl;
|
||||
#endif
|
||||
|
||||
const size_t FRAME_N_BYTES = MODULE_N_PIXELS * bit_depth / 8;
|
||||
const size_t FRAME_N_BYTES = MODULE_N_PIXELS * config.bit_depth / 8;
|
||||
const size_t N_PACKETS_PER_FRAME = FRAME_N_BYTES / DATA_BYTES_PER_PACKET;
|
||||
|
||||
EigerAssembler assembler(config.n_modules, bit_depth,
|
||||
EigerAssembler assembler(config.n_modules, config.bit_depth,
|
||||
config.image_width, config.image_height);
|
||||
|
||||
#ifdef DEBUG_OUTPUT
|
||||
|
||||
@@ -19,12 +19,14 @@ struct DetWriterConfig {
|
||||
config_parameters["detector_name"].GetString(),
|
||||
config_parameters["image_height"].GetInt(),
|
||||
config_parameters["image_width"].GetInt(),
|
||||
config_parameters["bit_depth"].GetInt(),
|
||||
};
|
||||
}
|
||||
|
||||
const std::string detector_name;
|
||||
const int image_height;
|
||||
const int image_width;
|
||||
const int bit_depth;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -18,19 +18,16 @@ using namespace live_writer_config;
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
if (argc != 2) {
|
||||
cout << endl;
|
||||
cout << "Usage: std_det_writer [detector_json_filename]"
|
||||
" [bit_depth]" << endl;
|
||||
cout << "Usage: std_det_writer [detector_json_filename]" << endl;
|
||||
cout << "\tdetector_json_filename: detector config file path." << endl;
|
||||
cout << "\tbit_depth: bit depth of the incoming udp packets." << endl;
|
||||
cout << endl;
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
auto const config = DetWriterConfig::from_json_file(string(argv[1]));
|
||||
const int bit_depth = atoi(argv[2]);
|
||||
|
||||
MPI_Init(nullptr, nullptr);
|
||||
|
||||
@@ -45,7 +42,7 @@ int main (int argc, char *argv[])
|
||||
auto receiver = BufferUtils::connect_socket(
|
||||
ctx, config.detector_name, "writer_agent");
|
||||
|
||||
const size_t IMAGE_N_BYTES = config.image_width * config.image_height * bit_depth / 8;
|
||||
const size_t IMAGE_N_BYTES = config.image_width * config.image_height * config.bit_depth / 8;
|
||||
RamBuffer image_buffer(config.detector_name + "_assembler",
|
||||
sizeof(ImageMetadata), IMAGE_N_BYTES, 1, RAM_BUFFER_N_SLOTS);
|
||||
|
||||
|
||||
@@ -50,11 +50,21 @@ void ZmqLiveSender::send(const ImageMetadata& meta, const char *data,
|
||||
|
||||
// TODO: Here we need to send to streamvis and live analysis metadata(probably need to operate still on them) and data(not every frame)
|
||||
header.AddMember("frame", meta.id, header_alloc);
|
||||
header.AddMember("is_good_frame", meta.status, header_alloc);
|
||||
header.AddMember("pulse_id", meta.id, header_alloc);
|
||||
// image status convention 0 == good, 1 == frames missing, 2 == different ids
|
||||
header.AddMember("is_good_frame", (meta.status == 0) ? 1 : 0, header_alloc);
|
||||
header.AddMember("flip_data", true, header_alloc);
|
||||
|
||||
rapidjson::Value detector_name;
|
||||
detector_name.SetString(det_name_.c_str(), header_alloc);
|
||||
header.AddMember("detector_name", detector_name, header_alloc);
|
||||
|
||||
#ifdef USE_EIGER
|
||||
header.AddMember("detector_name", "Eiger", header_alloc);
|
||||
#else
|
||||
rapidjson::Value detector_name;
|
||||
detector_name.SetString(det_name_.c_str(), header_alloc);
|
||||
header.AddMember("detector_name", detector_name, header_alloc);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
header.AddMember("htype", "array-1.0", header_alloc);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "stream_config.hpp"
|
||||
#include "ZmqLiveSender.hpp"
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace stream_config;
|
||||
@@ -14,12 +15,11 @@ using namespace buffer_config;
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
if (argc != 4) {
|
||||
if (argc != 3) {
|
||||
cout << endl;
|
||||
cout << "Usage: std_stream_send [detector_json_filename]"
|
||||
" [bit_depth] [stream_address]" << endl;
|
||||
" [stream_address]" << endl;
|
||||
cout << "\tdetector_json_filename: detector config file path." << endl;
|
||||
cout << "\tbit_depth: bit depth of the incoming udp packets." << endl;
|
||||
cout << "\tstream_address: address to bind the output stream." << endl;
|
||||
cout << endl;
|
||||
|
||||
@@ -27,7 +27,6 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
auto config = BufferUtils::read_json_config(string(argv[1]));
|
||||
const int bit_depth = atoi(argv[2]);
|
||||
const auto stream_address = string(argv[3]);
|
||||
|
||||
auto ctx = zmq_ctx_new();
|
||||
@@ -37,7 +36,7 @@ int main (int argc, char *argv[])
|
||||
auto receiver_assembler = BufferUtils::connect_socket(
|
||||
ctx, config.detector_name, "assembler");
|
||||
|
||||
const size_t IMAGE_N_BYTES = config.image_height * config.image_width * bit_depth / 8;
|
||||
const size_t IMAGE_N_BYTES = config.image_height * config.image_width * config.bit_depth / 8;
|
||||
|
||||
RamBuffer image_buffer(config.detector_name + "_assembler",
|
||||
sizeof(ImageMetadata), IMAGE_N_BYTES,
|
||||
@@ -52,7 +51,7 @@ int main (int argc, char *argv[])
|
||||
// gets the image data
|
||||
char* dst_data = image_buffer.get_slot_data(meta.id);
|
||||
// sends the json metadata with the data
|
||||
sender.send(meta, dst_data, IMAGE_N_BYTES);
|
||||
sender.send(meta, dst_data , IMAGE_N_BYTES);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ struct UdpRecvConfig {
|
||||
config_parameters["detector_name"].GetString(),
|
||||
config_parameters["detector_type"].GetString(),
|
||||
config_parameters["n_modules"].GetInt(),
|
||||
config_parameters["bit_depth"].GetInt(),
|
||||
config_parameters["start_udp_port"].GetInt(),
|
||||
};
|
||||
}
|
||||
@@ -27,6 +28,7 @@ struct UdpRecvConfig {
|
||||
const std::string detector_type;
|
||||
const int n_modules;
|
||||
const int start_udp_port;
|
||||
const int bit_depth;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -18,21 +18,18 @@ using namespace BufferUtils;
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
|
||||
if (argc != 4) {
|
||||
if (argc != 3) {
|
||||
cout << endl;
|
||||
cout << "Usage: std_udp_recv [detector_json_filename] [module_id] "
|
||||
"[bit_depth]";
|
||||
cout << "Usage: std_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;
|
||||
cout << "\tbit_depth: bit depth of the incoming udp packets." << endl;
|
||||
cout << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
const auto config = UdpRecvConfig::from_json_file(string(argv[1]));
|
||||
const int module_id = atoi(argv[2]);
|
||||
const int bit_depth = atoi(argv[3]);
|
||||
|
||||
if (DETECTOR_TYPE != config.detector_type) {
|
||||
throw runtime_error("UDP recv version for " + DETECTOR_TYPE +
|
||||
@@ -40,7 +37,7 @@ int main (int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
const auto udp_port = config.start_udp_port + module_id;
|
||||
const size_t FRAME_N_BYTES = MODULE_N_PIXELS * bit_depth / 8;
|
||||
const size_t FRAME_N_BYTES = MODULE_N_PIXELS * config.bit_depth / 8;
|
||||
const size_t N_PACKETS_PER_FRAME = FRAME_N_BYTES / DATA_BYTES_PER_PACKET;
|
||||
|
||||
FrameUdpReceiver receiver(udp_port, N_PACKETS_PER_FRAME);
|
||||
@@ -54,7 +51,7 @@ int main (int argc, char *argv[]) {
|
||||
|
||||
ModuleFrame meta;
|
||||
meta.module_id = module_id;
|
||||
meta.bit_depth = bit_depth;
|
||||
meta.bit_depth = config.bit_depth;
|
||||
|
||||
char* data = new char[FRAME_N_BYTES];
|
||||
|
||||
|
||||
@@ -17,12 +17,14 @@ struct UdpSyncConfig {
|
||||
|
||||
return {
|
||||
config_parameters["detector_name"].GetString(),
|
||||
config_parameters["n_modules"].GetInt()
|
||||
config_parameters["n_modules"].GetInt(),
|
||||
config_parameters["bit_depth"].GetInt()
|
||||
};
|
||||
}
|
||||
|
||||
const std::string detector_name;
|
||||
const int n_modules;
|
||||
const int bit_depth;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user