From a92b745ac9ab3d322df4c950cd2758fb1bf80f64 Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Tue, 21 Apr 2020 10:57:13 +0200 Subject: [PATCH] Undo previous commit --- sf-writer/CMakeLists.txt | 6 ++++ sf-writer/sf_h5_writer.cpp | 66 ++++++++++++++------------------------ 2 files changed, 30 insertions(+), 42 deletions(-) diff --git a/sf-writer/CMakeLists.txt b/sf-writer/CMakeLists.txt index 5afa7d1..422d96d 100644 --- a/sf-writer/CMakeLists.txt +++ b/sf-writer/CMakeLists.txt @@ -1,10 +1,16 @@ +find_package(MPI REQUIRED) + file(GLOB SOURCES *.cpp) add_executable(sf-writer sf_h5_writer.cpp) set_target_properties(sf-writer PROPERTIES OUTPUT_NAME sf_h5_writer) +target_include_directories(sf-writer PRIVATE ${MPI_CXX_INCLUDE_PATH}) +target_compile_options(sf-writer PRIVATE ${MPI_CXX_COMPILE_FLAGS}) + target_link_libraries(sf-writer + ${MPI_CXX_LIBRARIES} ${MPI_CXX_LINK_FLAGS} core-writer external zmq diff --git a/sf-writer/sf_h5_writer.cpp b/sf-writer/sf_h5_writer.cpp index 07c8cf2..0b34769 100644 --- a/sf-writer/sf_h5_writer.cpp +++ b/sf-writer/sf_h5_writer.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "mpi.h" #include "config.hpp" #include "SfFormat.cpp" @@ -12,59 +13,40 @@ using namespace std; int main (int argc, char *argv[]) { - if (argc != 6) { + if (argc != 5) { cout << endl; - cout << "Usage: sf_h5_writer [connection_address] [rest_port]"; - cout << " [bsread_address] [n_modules] [n_bad_modules] [detector_name]"; + cout << "Usage: sf_h5_writer [device_name]"; + cout << " [output_file] [start_pulse_id] [stop_pulse_id]"; cout << endl; - cout << "\tconnection_address: Address to connect to the stream"; - cout << " (PULL). Example: tcp://127.0.0.1:40000" << endl; - cout << "\trest_port: Port to start the REST Api on." << endl; - cout << "\tn_modules: Number of detector modules to be written." << endl; - cout << "\tn_bad_modules: Number of detector modules which"; - cout << " has more then half bad pixels" << endl; - cout << "\tdetector_name: Name of the detector,"; - cout << " data will be written as data/detector_name/" << endl; + cout << "\tdevice_name: Name of detector to write."; + cout << "\toutput_file: Complete path to the output file."; + cout << "\tstart_pulse_id: Start pulse_id of retrieval." << endl; + cout << "\tstop_pulse_id: Stop pulse_id of retrieval." << endl; cout << endl; exit(-1); } - string connect_address = string(argv[1]); - int rest_port = atoi(argv[2]); - int n_modules = atoi(argv[3]); - int n_bad_modules = atoi(argv[4]); - string detector_name = string(argv[5]); + string device_name = string(argv[1]); + string output_file = string(argv[2]); + uint64_t start_pulse_id = (uint64_t) atoi(argv[3]); + uint64_t stop_pulse_id = (uint64_t) atoi(argv[4]); - unordered_map header_values { - {"pulse_id", HeaderDataType("uint64")}, - {"frame", HeaderDataType("uint64")}, - {"is_good_frame", HeaderDataType("uint64")}, - {"daq_rec", HeaderDataType("int64")}, + if (MPI_Init ( &argc, &argv ) != MPI_SUCCESS) { + throw runtime_error("Cannot MPI init."); + } - {"pulse_id_diff", HeaderDataType("int64", n_modules)}, - {"framenum_diff", HeaderDataType("int64", n_modules)}, + int rank_id; + if(MPI_Comm_rank (MPI_COMM_WORLD, &rank_id) != MPI_SUCCESS) { + throw runtime_error("Cannot get the MPI rank."); + } - {"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)} + + + + if (MPI_Finalize() != MPI_SUCCESS) { + throw runtime_error("Cannot finalize MPI."); }; - SfFormat format(detector_name, n_bad_modules); - RingBuffer ring_buffer(config::ring_buffer_n_slots); - - ZmqRecvModule recv_module(ring_buffer, header_values); - H5WriteModule write_module(ring_buffer, header_values, format); - - recv_module.start_recv(connect_address, 1); - - ProcessManager process_manager(write_module, recv_module); - process_manager.start_rest_api(rest_port); - return 0; }