mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-03 09:14:14 +02:00
Add configuration loading code to core-buffer
This commit is contained in:
@@ -6,6 +6,20 @@
|
||||
|
||||
namespace BufferUtils
|
||||
{
|
||||
|
||||
struct DetectorConfig {
|
||||
const std::string streamvis_address;
|
||||
const int reduction_factor_streamvis;
|
||||
const std::string live_analysis_address;
|
||||
const int reduction_factor_live_analysis;
|
||||
const std::string PEDE_FILENAME;
|
||||
const std::string GAIN_FILENAME;
|
||||
const std::string DETECTOR_NAME;
|
||||
const int n_modules;
|
||||
const std::string pulse_address;
|
||||
};
|
||||
|
||||
|
||||
std::string get_filename(
|
||||
const std::string& detector_folder,
|
||||
const std::string& module_name,
|
||||
@@ -23,6 +37,8 @@ namespace BufferUtils
|
||||
void* ctx, const std::string& detector_name, const int source_id);
|
||||
void* connect_socket(
|
||||
void* ctx, const std::string& detector_name, const int source_id);
|
||||
|
||||
DetectorConfig read_json_config(const std::string& filename);
|
||||
}
|
||||
|
||||
#endif //BUFFER_UTILS_HPP
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
#include <sstream>
|
||||
#include <buffer_config.hpp>
|
||||
#include <zmq.h>
|
||||
#include <fstream>
|
||||
#include <rapidjson/istreamwrapper.h>
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace buffer_config;
|
||||
@@ -122,3 +126,23 @@ void* BufferUtils::bind_socket(
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
BufferUtils::DetectorConfig read_json_config(const std::string& filename)
|
||||
{
|
||||
std::ifstream ifs(filename);
|
||||
rapidjson::IStreamWrapper isw(ifs);
|
||||
rapidjson::Document config_parameters;
|
||||
config_parameters.ParseStream(isw);
|
||||
|
||||
return {
|
||||
config_parameters["streamvis_stream"].GetString(),
|
||||
config_parameters["streamvis_rate"].GetInt(),
|
||||
config_parameters["live_stream"].GetString(),
|
||||
config_parameters["live_rate"].GetInt(),
|
||||
config_parameters["pedestal_file"].GetString(),
|
||||
config_parameters["gain_file"].GetString(),
|
||||
config_parameters["detector_name"].GetString(),
|
||||
config_parameters["n_modules"].GetInt(),
|
||||
"tcp://127.0.0.1:51234"
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user