mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-23 01:32:42 +02:00
Remove alvra specific writer
This commit is contained in:
@@ -1,109 +0,0 @@
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "H5Format.hpp"
|
||||
|
||||
using namespace std;
|
||||
using s_ptr = shared_ptr<h5_base>;
|
||||
|
||||
class AlvraFormat : public H5Format
|
||||
{
|
||||
shared_ptr<unordered_map<string, DATA_TYPE>> input_value_type = NULL;
|
||||
shared_ptr<unordered_map<string, boost::any>> default_values = NULL;
|
||||
shared_ptr<unordered_map<string, std::string>> dataset_move_mapping = NULL;
|
||||
shared_ptr<h5_parent> file_format = NULL;
|
||||
|
||||
public:
|
||||
~AlvraFormat(){};
|
||||
|
||||
AlvraFormat(const string& dataset_name, int n_bad_modules)
|
||||
{
|
||||
// Input values definition type.
|
||||
// Which type should be the parameters you receive over the REST api.
|
||||
input_value_type.reset(
|
||||
new unordered_map<string, DATA_TYPE>({
|
||||
{"general/created", NX_DATE_TIME},
|
||||
{"general/user", NX_CHAR},
|
||||
{"general/process", NX_CHAR},
|
||||
{"general/instrument", NX_CHAR}
|
||||
}));
|
||||
|
||||
// Default values used in the file format.
|
||||
default_values.reset(new std::unordered_map<string, boost::any>(
|
||||
{
|
||||
{"general/n_bad_modules", n_bad_modules},
|
||||
{"general/detector_name", dataset_name}
|
||||
}));
|
||||
|
||||
// After format has been writen, where to move the raw datasets.
|
||||
dataset_move_mapping.reset(new std::unordered_map<string, string>(
|
||||
{
|
||||
{config::raw_image_dataset_name, "data/" + dataset_name + "/data"},
|
||||
{"pulse_id", "data/" + dataset_name + "/pulse_id"},
|
||||
{"frame", "data/" + dataset_name + "/frame"},
|
||||
{"is_good_frame", "data/" + dataset_name + "/is_good_frame"},
|
||||
{"missing_packets_1", "data/" + dataset_name + "/missing_packets_1"},
|
||||
{"missing_packets_2", "data/" + dataset_name + "/missing_packets_2"},
|
||||
{"daq_recs", "data/" + dataset_name + "/daq_recs"},
|
||||
{"daq_rec", "data/" + dataset_name + "/daq_rec"},
|
||||
{"framenum_diff", "data/" + dataset_name + "/framenum_diff"},
|
||||
{"pulse_ids", "data/" + dataset_name + "/pulse_ids"},
|
||||
{"framenums", "data/" + dataset_name + "/framenums"},
|
||||
{"pulse_id_diff", "data/" + dataset_name + "/pulse_id_diff"},
|
||||
{"module_number", "data/" + dataset_name + "/module_number"},
|
||||
}));
|
||||
|
||||
// Definition of the file format.
|
||||
file_format.reset(
|
||||
new h5_parent("", EMPTY_ROOT, {
|
||||
s_ptr(new h5_group("general", {
|
||||
s_ptr(new h5_dataset("created", "general/created", NX_DATE_TIME)),
|
||||
s_ptr(new h5_dataset("user", "general/user", NX_CHAR)),
|
||||
s_ptr(new h5_dataset("process", "general/process", NX_CHAR)),
|
||||
s_ptr(new h5_dataset("instrument", "general/instrument", NX_CHAR)),
|
||||
})),
|
||||
|
||||
s_ptr(new h5_group("data", {
|
||||
s_ptr(new h5_group(dataset_name, {}))
|
||||
}))
|
||||
}));
|
||||
}
|
||||
|
||||
const h5_parent& get_format_definition() const override
|
||||
{
|
||||
return *file_format;
|
||||
}
|
||||
|
||||
const unordered_map<string, boost::any>& get_default_values() const override
|
||||
{
|
||||
return *default_values;
|
||||
}
|
||||
|
||||
void add_calculated_values(unordered_map<string, boost::any>& values) const override
|
||||
{
|
||||
// No calculated values.
|
||||
}
|
||||
|
||||
void add_input_values(unordered_map<string, boost::any>& values,
|
||||
const unordered_map<string, boost::any>& input_values) const override
|
||||
{
|
||||
// Input value mapping is 1:1.
|
||||
for (const auto& input_value : input_values) {
|
||||
const auto& name = input_value.first;
|
||||
const auto& value = input_value.second;
|
||||
|
||||
values[name] = value;
|
||||
}
|
||||
}
|
||||
|
||||
const std::unordered_map<string, DATA_TYPE>& get_input_value_type() const override
|
||||
{
|
||||
return *input_value_type;
|
||||
}
|
||||
|
||||
const unordered_map<string, string>& get_dataset_move_mapping() const override {
|
||||
return *dataset_move_mapping;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -1,34 +0,0 @@
|
||||
SRC_DIR = .
|
||||
OBJ_DIR = ./obj
|
||||
BIN_DIR = ./bin
|
||||
MKDIR = mkdir -p
|
||||
|
||||
CC = g++
|
||||
CFLAGS = -Wall -Wfatal-errors -std=c++11 -I${CONDA_PREFIX}/include -I${CONDA_PREFIX}/include/cpp_h5_writer
|
||||
LDFLAGS = -L${CONDA_PREFIX}/lib -L/usr/lib64 -lcpp_h5_writer -lzmq -lhdf5 -lhdf5_hl -lhdf5_cpp -lhdf5_hl_cpp -lboost_system -lboost_regex -lboost_thread -lpthread
|
||||
|
||||
HEADERS = $(wildcard $(SRC_DIR)/*.hpp)
|
||||
SRCS = $(wildcard $(SRC_DIR)/*.cpp)
|
||||
OBJS = $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRCS))
|
||||
|
||||
alvra_h5_writer: export LD_LIBRARY_PATH=${CONDA_PREFIX}/lib
|
||||
alvra_h5_writer: lib build_dirs $(OBJS)
|
||||
$(CC) $(LDFLAGS) -o $(BIN_DIR)/alvra_h5_writer $(OBJS) $(LDFLAGS)
|
||||
|
||||
lib:
|
||||
$(MAKE) -C ../lib deploy
|
||||
|
||||
debug: CFLAGS += -DDEBUG_OUTPUT -g
|
||||
debug: alvra_h5_writer
|
||||
|
||||
deploy: alvra_h5_writer
|
||||
cp bin/* ${CONDA_PREFIX}/bin
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -c -o $@ $<
|
||||
|
||||
build_dirs:
|
||||
$(MKDIR) $(OBJ_DIR) $(BIN_DIR)
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR) $(BIN_DIR)
|
||||
@@ -1,77 +0,0 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "config.hpp"
|
||||
#include "WriterManager.hpp"
|
||||
#include "ZmqReceiver.hpp"
|
||||
#include "ProcessManager.hpp"
|
||||
|
||||
#include "AlvraFormat.cpp"
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
if (argc != 10) {
|
||||
cout << endl;
|
||||
cout << "Usage: alvra_h5_writer [connection_address] [output_file] [n_frames]";
|
||||
cout << " [rest_port] [user_id] [bsread_address] [n_modules] [n_bad_modules] [detector_name]" << endl;
|
||||
cout << "\tconnection_address: Address to connect to the stream (PULL). Example: tcp://127.0.0.1:40000" << endl;
|
||||
cout << "\toutput_file: Name of the output file." << endl;
|
||||
cout << "\tn_frames: Number of images to acquire. 0 for infinity (until /stop is called)." << endl;
|
||||
cout << "\trest_port: Port to start the REST Api on." << endl;
|
||||
cout << "\tuser_id: uid under which to run the writer. -1 to leave it as it is." << endl;
|
||||
cout << "\tbsread_address: HTTP address of the bsread REST api." << endl;
|
||||
cout << "\tn_modules: Number of detector modules to be written." << endl;
|
||||
cout << "\tn_bad_modules: Number of detector modules which has more then half bad pixels" << endl;
|
||||
cout << "\tdetector_name: Name of the detector, data will be written as data/detector_name/ " << endl;
|
||||
cout << endl;
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
string connect_address = string(argv[1]);
|
||||
string output_file = string(argv[2]);
|
||||
int n_frames = atoi(argv[3]);
|
||||
int rest_port = atoi(argv[4]);
|
||||
int user_id = atoi(argv[5]);
|
||||
string bsread_rest_address = string(argv[6]);
|
||||
int n_modules = atoi(argv[7]);
|
||||
int n_bad_modules = atoi(argv[8]);
|
||||
string detector_name = string(argv[9]);
|
||||
|
||||
if (user_id != -1) {
|
||||
writer_utils::set_process_id(user_id);
|
||||
}
|
||||
|
||||
writer_utils::create_destination_folder(output_file);
|
||||
|
||||
auto header_values = shared_ptr<unordered_map<string, HeaderDataType>>(new unordered_map<string, HeaderDataType> {
|
||||
{"pulse_id", HeaderDataType("uint64")},
|
||||
{"frame", HeaderDataType("uint64")},
|
||||
{"is_good_frame", HeaderDataType("uint64")},
|
||||
{"daq_rec", HeaderDataType("int64")},
|
||||
|
||||
{"pulse_id_diff", HeaderDataType("int64", n_modules)},
|
||||
{"framenum_diff", HeaderDataType("int64", n_modules)},
|
||||
|
||||
{"missing_packets_1", HeaderDataType("uint64", n_modules)},
|
||||
{"missing_packets_2", HeaderDataType("uint64", n_modules)},
|
||||
{"daq_recs", HeaderDataType("uint64", n_modules)},
|
||||
|
||||
{"pulse_ids", HeaderDataType("uint64", n_modules)},
|
||||
{"framenums", HeaderDataType("uint64", n_modules)},
|
||||
|
||||
{"module_number", HeaderDataType("uint64", n_modules)}
|
||||
});
|
||||
|
||||
AlvraFormat format(detector_name, n_bad_modules);
|
||||
|
||||
WriterManager writer_manager(format.get_input_value_type(), output_file, n_frames);
|
||||
ZmqReceiver receiver(connect_address, config::zmq_n_io_threads, config::zmq_receive_timeout, header_values);
|
||||
RingBuffer ring_buffer(config::ring_buffer_n_slots);
|
||||
|
||||
ProcessManager process_manager(writer_manager, receiver, ring_buffer, format, rest_port, bsread_rest_address);
|
||||
process_manager.run_writer();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
make
|
||||
|
||||
cp bin/* ${PREFIX}/bin
|
||||
@@ -1,26 +0,0 @@
|
||||
package:
|
||||
name: alvra_h5_writer
|
||||
version: 0.0.1
|
||||
|
||||
build:
|
||||
number: 0
|
||||
|
||||
source:
|
||||
path: ..
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- make
|
||||
- gcc
|
||||
- cppzmq ==4.2.1
|
||||
- hdf5 ==1.10.1
|
||||
- boost ==1.61.0
|
||||
|
||||
run:
|
||||
- cppzmq ==4.2.1
|
||||
- hdf5 ==1.10.1
|
||||
- boost ==1.61.0
|
||||
|
||||
|
||||
about:
|
||||
summary: "Alvra ZMQ to H5 writer."
|
||||
Reference in New Issue
Block a user