mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-21 14:44:36 +02:00
Use core-buffer load config
This commit is contained in:
@@ -2,32 +2,13 @@
|
||||
#define SF_DAQ_BUFFER_ZMQLIVESENDER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <rapidjson/istreamwrapper.h>
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
#include <rapidjson/writer.h>
|
||||
|
||||
#include "formats.hpp"
|
||||
#include "BufferUtils.hpp"
|
||||
|
||||
|
||||
struct LiveStreamConfig {
|
||||
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;
|
||||
};
|
||||
|
||||
LiveStreamConfig read_json_config(const std::string filename);
|
||||
|
||||
class ZmqLiveSender {
|
||||
const void* ctx_;
|
||||
const LiveStreamConfig config_;
|
||||
const BufferUtils::DetectorConfig config_;
|
||||
|
||||
void* socket_streamvis_;
|
||||
void* socket_live_;
|
||||
@@ -35,7 +16,7 @@ class ZmqLiveSender {
|
||||
|
||||
public:
|
||||
ZmqLiveSender(void* ctx,
|
||||
const LiveStreamConfig& config);
|
||||
const BufferUtils::DetectorConfig& config);
|
||||
~ZmqLiveSender();
|
||||
|
||||
void send(const ImageMetadata& meta, const char* data);
|
||||
|
||||
@@ -3,33 +3,16 @@
|
||||
|
||||
#include "zmq.h"
|
||||
#include <stdexcept>
|
||||
#include <rapidjson/document.h>
|
||||
#include <rapidjson/stringbuffer.h>
|
||||
#include <rapidjson/writer.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace stream_config;
|
||||
|
||||
LiveStreamConfig 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"
|
||||
};
|
||||
}
|
||||
|
||||
ZmqLiveSender::ZmqLiveSender(
|
||||
void* ctx,
|
||||
const LiveStreamConfig& config) :
|
||||
const BufferUtils::DetectorConfig& config) :
|
||||
ctx_(ctx),
|
||||
config_(config)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <string>
|
||||
#include <zmq.h>
|
||||
#include <RamBuffer.hpp>
|
||||
#include <BufferUtils.hpp>
|
||||
|
||||
#include "buffer_config.hpp"
|
||||
#include "stream_config.hpp"
|
||||
@@ -17,17 +18,16 @@ int main (int argc, char *argv[])
|
||||
if (argc != 2) {
|
||||
cout << endl;
|
||||
cout << "Usage: sf_stream ";
|
||||
cout << " [config_json_file]";
|
||||
cout << " [detector_json_filename]";
|
||||
cout << endl;
|
||||
cout << "\tconfig_json_file: json file with the configuration "
|
||||
"parameters(detector name, number of modules, pedestal and "
|
||||
"gain files" << endl;
|
||||
cout << "\tdetector_json_filename: json file with the configuration "
|
||||
"of the detector." << endl;
|
||||
cout << endl;
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
auto config = read_json_config(string(argv[1]));
|
||||
auto config = BufferUtils::read_json_config(string(argv[1]));
|
||||
string RECV_IPC_URL = BUFFER_LIVE_IPC_URL + config.DETECTOR_NAME + "-";
|
||||
|
||||
auto ctx = zmq_ctx_new();
|
||||
|
||||
Reference in New Issue
Block a user