mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 15:14:12 +02:00
Merge branch 'eiger' of https://github.com/paulscherrerinstitute/sf_daq_buffer into eiger
This commit is contained in:
+5
-1
@@ -3,7 +3,11 @@ docker/
|
||||
docs/
|
||||
scripts/
|
||||
|
||||
debug.Dockerfile
|
||||
.idea/
|
||||
.dockerignore
|
||||
|
||||
build_buffer.sh
|
||||
README.md
|
||||
|
||||
# Include files:
|
||||
!docker/example_detector.json
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
FROM paulscherrerinstitute/std-daq-buffer-base:1.0.2
|
||||
|
||||
COPY . /std_daq_buffer/
|
||||
|
||||
RUN mkdir /std_daq_buffer/build && \
|
||||
cd /std_daq_buffer/build && \
|
||||
# Build the project
|
||||
cmake3 .. -DUSE_EIGER=1 && \
|
||||
make && \
|
||||
# Deploy the test config.
|
||||
cp /std_daq_buffer/docker/example_detector.json .
|
||||
|
||||
WORKDIR /std_daq_buffer/build
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION=1.0.0
|
||||
|
||||
docker build --no-cache=true -f buffer.Dockerfile -t paulscherrerinstitute/std-daq-buffer .
|
||||
docker tag paulscherrerinstitute/sf-daq-buffer paulscherrerinstitute/std-daq-buffer:$VERSION
|
||||
|
||||
docker login
|
||||
docker push paulscherrerinstitute/std-daq-buffer:$VERSION
|
||||
docker push paulscherrerinstitute/std-daq-buffer
|
||||
@@ -1,13 +0,0 @@
|
||||
FROM paulscherrerinstitute/sf-daq_phdf5:1.0.1
|
||||
|
||||
COPY . /sf_daq_buffer/
|
||||
|
||||
RUN mkdir /sf_daq_buffer/build && \
|
||||
cd /sf_daq_buffer/build && \
|
||||
# Build the project
|
||||
cmake3 .. -DUSE_EIGER=1 && \
|
||||
make && \
|
||||
# Deploy the test config.
|
||||
cp /sf_daq_buffer/docker/example_detector.json .
|
||||
|
||||
WORKDIR /sf_daq_buffer/build
|
||||
@@ -14,8 +14,4 @@ RUN wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.12/hdf5-1.12.0/sr
|
||||
./configure --enable-parallel && make install && \
|
||||
ln -v -s `pwd`/hdf5/lib/* /usr/lib64/ && \
|
||||
ln -v -s `pwd`/hdf5/include/* /usr/include/ && \
|
||||
ln -v -s /usr/include/mpich-x86_64/* /usr/include/ && \
|
||||
wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
|
||||
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
|
||||
rm ~/miniconda.sh && \
|
||||
/opt/conda/bin/conda clean -tipsy
|
||||
ln -v -s /usr/include/mpich-x86_64/* /usr/include/
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION=1.0.2
|
||||
|
||||
docker build --no-cache=true -f buffer-base.Dockerfile -t paulscherrerinstitute/std-daq-buffer-base .
|
||||
docker tag paulscherrerinstitute/std-daq-buffer-base paulscherrerinstitute/std-daq-buffer-base:$VERSION
|
||||
|
||||
docker login
|
||||
docker push paulscherrerinstitute/std-daq-buffer-base:$VERSION
|
||||
docker push paulscherrerinstitute/std-daq-buffer-base
|
||||
@@ -1,10 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION=1.0.1
|
||||
|
||||
docker build --no-cache=true -f phdf5.Dockerfile -t paulscherrerinstitute/sf-daq_phdf5 .
|
||||
docker tag paulscherrerinstitute/sf-daq_phdf5 paulscherrerinstitute/sf-daq_phdf5:$VERSION
|
||||
|
||||
docker login
|
||||
docker push paulscherrerinstitute/sf-daq_phdf5:$VERSION
|
||||
docker push paulscherrerinstitute/sf-daq_phdf5
|
||||
File diff suppressed because one or more lines are too long
@@ -52,7 +52,7 @@ int main (int argc, char *argv[])
|
||||
JFH5Writer writer(config.detector_name);
|
||||
WriterStats stats(config.detector_name, IMAGE_N_BYTES);
|
||||
|
||||
char recv_buffer[12288];
|
||||
char recv_buffer[8192];
|
||||
while (true) {
|
||||
zmq_recv(receiver, &recv_buffer, sizeof(recv_buffer), 0);
|
||||
|
||||
@@ -66,6 +66,14 @@ int main (int argc, char *argv[])
|
||||
const int run_id = document["run_id"].GetInt();
|
||||
const int i_image = document["i_image"].GetInt();
|
||||
const int n_images = document["n_images"].GetInt();
|
||||
|
||||
// i_image == n_images -> end of run.
|
||||
if (i_image == n_images) {
|
||||
writer.close_run();
|
||||
|
||||
stats.end_run();
|
||||
continue;
|
||||
}
|
||||
|
||||
// i_image == n_images -> end of run.
|
||||
if (i_image == n_images) {
|
||||
@@ -87,7 +95,7 @@ int main (int argc, char *argv[])
|
||||
image_meta->dtype);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Fair distribution of images among writers.
|
||||
if (i_image % n_writers == i_writer) {
|
||||
char* data = image_buffer.get_slot_data(image_id);
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
add_executable(std-udp-recv-tests main.cpp)
|
||||
|
||||
|
||||
target_link_libraries(std-udp-recv-tests
|
||||
core-buffer-lib
|
||||
std-udp-recv-lib
|
||||
gtest
|
||||
)
|
||||
|
||||
add_executable(std-udp-sim simulator.cpp)
|
||||
set_target_properties(std-udp-sim PROPERTIES OUTPUT_NAME std_udp_sim)
|
||||
target_link_libraries(std-udp-sim
|
||||
core-buffer-lib
|
||||
)
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include "../include/UdpRecvConfig.hpp"
|
||||
#include <netinet/in.h>
|
||||
#include <unistd.h>
|
||||
#include "mock/udp.hpp"
|
||||
|
||||
#ifdef USE_EIGER
|
||||
#include "eiger.hpp"
|
||||
#else
|
||||
#include "jungfrau.hpp"
|
||||
#endif
|
||||
|
||||
const int MAX_IMAGE_ID = 10000;
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
if (argc != 3) {
|
||||
cout << endl;
|
||||
cout << "Usage: std_udp_sim [detector_json_filename] [bit_depth]";
|
||||
cout << 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);
|
||||
}
|
||||
|
||||
const auto config = UdpRecvConfig::from_json_file(string(argv[1]));
|
||||
const int bit_depth = atoi(argv[2]);
|
||||
|
||||
if (DETECTOR_TYPE != config.detector_type) {
|
||||
throw runtime_error("UDP recv version for " + DETECTOR_TYPE +
|
||||
" but config for " + config.detector_type);
|
||||
}
|
||||
|
||||
const size_t FRAME_N_BYTES = MODULE_N_PIXELS * bit_depth / 8;
|
||||
const size_t N_PACKETS_PER_FRAME = FRAME_N_BYTES / DATA_BYTES_PER_PACKET;
|
||||
|
||||
int sockets[config.n_modules];
|
||||
sockaddr_in send_address[config.n_modules];
|
||||
|
||||
for (int i_module=0; i_module < config.n_modules; i_module++){
|
||||
send_address[i_module] =
|
||||
get_server_address(config.start_udp_port + i_module);
|
||||
|
||||
sockets[i_module] = socket(AF_INET,SOCK_DGRAM,0);
|
||||
if (sockets[i_module] < 0) {
|
||||
throw runtime_error("Cannot bind UDP socket.");
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t image_id = 0;
|
||||
while (true) {
|
||||
for (size_t i_packet = 0; i_packet < N_PACKETS_PER_FRAME; i_packet++) {
|
||||
for (int i_module = 0; i_module < config.n_modules; i_module++) {
|
||||
|
||||
det_packet send_udp_buffer;
|
||||
send_udp_buffer.packetnum = i_packet;
|
||||
|
||||
// framenum as image_id for the Eiger and bunchid for the JF
|
||||
#ifdef USE_EIGER
|
||||
send_udp_buffer.framenum = image_id;
|
||||
send_udp_buffer.bunchid = image_id + 100;
|
||||
#else
|
||||
send_udp_buffer.framenum = image_id+100;
|
||||
send_udp_buffer.bunchid = image_id;
|
||||
#endif
|
||||
|
||||
::sendto(
|
||||
sockets[i_module],
|
||||
&send_udp_buffer,
|
||||
BYTES_PER_PACKET,
|
||||
-1,
|
||||
(sockaddr *) &send_address[i_module],
|
||||
sizeof(sockaddr_in));
|
||||
}
|
||||
}
|
||||
|
||||
cout << "Sent image_id " << image_id << endl;
|
||||
// 10Hz == 100ms between images
|
||||
usleep(100 * 1000);
|
||||
|
||||
image_id = ++image_id % MAX_IMAGE_ID;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user