From eae14de9f45cfdab2c8ed74e03bcb2fd9e1e97cd Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Thu, 19 Jul 2018 14:34:21 +0200 Subject: [PATCH] Remove alvra specific writer --- sf_alvra/AlvraFormat.cpp | 109 -------------------------------- sf_alvra/Makefile | 34 ---------- sf_alvra/alvra_h5_writer.cpp | 77 ---------------------- sf_alvra/conda-recipe/build.sh | 3 - sf_alvra/conda-recipe/meta.yaml | 26 -------- 5 files changed, 249 deletions(-) delete mode 100644 sf_alvra/AlvraFormat.cpp delete mode 100644 sf_alvra/Makefile delete mode 100644 sf_alvra/alvra_h5_writer.cpp delete mode 100644 sf_alvra/conda-recipe/build.sh delete mode 100644 sf_alvra/conda-recipe/meta.yaml diff --git a/sf_alvra/AlvraFormat.cpp b/sf_alvra/AlvraFormat.cpp deleted file mode 100644 index 93dca93..0000000 --- a/sf_alvra/AlvraFormat.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include - -#include "config.hpp" -#include "H5Format.hpp" - -using namespace std; -using s_ptr = shared_ptr; - -class AlvraFormat : public H5Format -{ - shared_ptr> input_value_type = NULL; - shared_ptr> default_values = NULL; - shared_ptr> dataset_move_mapping = NULL; - shared_ptr 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({ - {"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( - { - {"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( - { - {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& get_default_values() const override - { - return *default_values; - } - - void add_calculated_values(unordered_map& values) const override - { - // No calculated values. - } - - void add_input_values(unordered_map& values, - const unordered_map& 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& get_input_value_type() const override - { - return *input_value_type; - } - - const unordered_map& get_dataset_move_mapping() const override { - return *dataset_move_mapping; - } - -}; diff --git a/sf_alvra/Makefile b/sf_alvra/Makefile deleted file mode 100644 index 94404e2..0000000 --- a/sf_alvra/Makefile +++ /dev/null @@ -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) \ No newline at end of file diff --git a/sf_alvra/alvra_h5_writer.cpp b/sf_alvra/alvra_h5_writer.cpp deleted file mode 100644 index c4daac5..0000000 --- a/sf_alvra/alvra_h5_writer.cpp +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include -#include - -#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>(new unordered_map { - {"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; -} \ No newline at end of file diff --git a/sf_alvra/conda-recipe/build.sh b/sf_alvra/conda-recipe/build.sh deleted file mode 100644 index 679c2e5..0000000 --- a/sf_alvra/conda-recipe/build.sh +++ /dev/null @@ -1,3 +0,0 @@ -make - -cp bin/* ${PREFIX}/bin \ No newline at end of file diff --git a/sf_alvra/conda-recipe/meta.yaml b/sf_alvra/conda-recipe/meta.yaml deleted file mode 100644 index 621edb4..0000000 --- a/sf_alvra/conda-recipe/meta.yaml +++ /dev/null @@ -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."