24 #include "cheetah/exporters/DataExportConfig.h" 25 #include "cheetah/exporters/OcldFileStreamerConfig.h" 26 #include "cheetah/exporters/SclFileStreamerConfig.h" 27 #include "cheetah/exporters/SpCclFileStreamerConfig.h" 28 #include "cheetah/exporters/SpCandidateDataStreamerConfig.h" 30 #include "cheetah/exporters/SpCclSpeadStreamerConfig.h" 31 #endif // ENABLE_SPEAD 32 #include "cheetah/exporters/SpCclSigProcConfig.h" 33 #include "cheetah/sigproc/WriterConfig.h" 34 #include "panda/ChannelInfo.h" 35 #include "panda/ChannelId.h" 42 DataExportConfig::SinkConfigs::SinkConfigs()
43 : panda::ConfigModule(
"sink_configs")
47 void DataExportConfig::SinkConfigs::add_options(OptionsDescriptionEasyInit& )
51 DataExportConfig::DataExportConfig( std::string
const& tag)
53 , _exporters_init(false)
58 _sink_configs.add_factory(
"sigproc", []() {
return new sigproc::WriterConfig(); });
59 _sink_configs.add_factory(
"spccl_files", []() {
return new SpCclFileStreamerConfig(); });
60 _sink_configs.add_factory(
"sp_candidate_data", []() {
return new SpCandidateDataStreamerConfig(); });
61 _sink_configs.add_factory(
"ocld_files", []() {
return new OcldFileStreamerConfig(); });
62 _sink_configs.add_factory(
"scl_files", []() {
return new SclFileStreamerConfig(); });
63 _sink_configs.add_factory(
"spccl_sigproc_files", []() {
return new SpCclSigProcConfig(); });
65 _sink_configs.add_factory(
"spccl_spead", []() {
return new SpCclSpeadStreamerConfig(); });
66 #endif // ENABLE_SPEAD 67 _sink_configs.add_default_function([](std::string
const& tag) {
68 PANDA_LOG_WARN <<
"unknown sink type: " << tag;
72 DataExportConfig::~DataExportConfig()
78 panda::ProcessingEngineConfig config(number_of_threads);
79 config.number_of_threads(number_of_threads);
80 _switch_config.set_engine_config(config);
85 for(
auto const& stream : streams) {
86 _switch_config.activate_channel(panda::ChannelId(stream));
90 void DataExportConfig::activate(panda::ChannelId
const& stream)
92 _switch_config.activate_channel(stream);
97 _sinks.emplace_back(exporter_config);
102 return _switch_config.engine(
id);
107 if( ! _exporters_init ) {
108 _exporters_init =
true;
109 for( panda::ChannelInfo
const* channel : _channel_config.channels() ) {
110 if(channel->active()) {
111 _switch_config.activate_channel(channel->id());
113 _switch_config.deactivate_channel(channel->id());
115 for(
auto const& sink_id : channel->sinks() ) {
118 for(
auto const& section : _sink_configs.subsections() )
120 auto it=_sink_configs.subsection(section);
121 while(it != _sink_configs.subsection_end()) {
122 if(it->id() == sink_id) {
125 , _switch_config.engine(channel->id())
133 PANDA_LOG_ERROR <<
"Channel error (" << channel->id().to_string() <<
"): sink with id=" << sink_id <<
" not found";
142 void DataExportConfig::add_options(OptionsDescriptionEasyInit& add_options)
145 (
"threads", boost::program_options::value<unsigned>()->default_value(0u)->notifier(std::bind(&
DataExportConfig::number_of_threads,
this, std::placeholders::_1)),
"set the number of dedicated threads to run data export services");
150 return _switch_config;
153 void DataExportConfig::parse_property_tree(boost::property_tree::ptree
const& pt, boost::program_options::variables_map& vm)
155 utils::Config::parse_property_tree(pt, vm);
160 return _switch_config.engine_config(channel_id);
165 _switch_config.set_engine_config(channel_id, config);
170 _switch_config.set_engine_config(config);
175 _channel_config.channel(channel);
178 void DataExportConfig::add_sink(std::string
const& tag, std::function<panda::ConfigModule*()>
const& cm)
180 _sink_configs.add_factory(tag, cm);
183 void DataExportConfig::add_sink(panda::ConfigModule& cm)
185 _sink_configs.add(cm);
void channel(panda::ChannelInfo const &)
explicity add a channel configuration
std::vector< DataExportStreamConfig > const & exporters() const
return a list of configured export streamer configurations
void activate_streams(std::vector< std::string > const &streams)
mark the provided streams as active
Base class for module configuration.
panda::Engine & engine(panda::ChannelId const &)
return the engine allocated to the specified channel
Defines the mapping of a sinks configuration block with the sink type, and the channel to associate i...
void set_engine_config(panda::ChannelId const &channel_id, panda::ProcessingEngineConfig const &config)
set the engine confugration for a specified channel
void add_exporter(DataExportStreamConfig)
set an export streamer configurations
Some limits and constants for FLDO.
string based tag for refering to the type of Exporter, based on a std::string
panda::ProcessingEngineConfig const & engine_config(panda::ChannelId const &channel_id) const
return the processing engine configuration associated with the specified channel
panda::DataSwitchConfig & switch_config() const
return the configuration suitable for sending to a panda::DataSwitch
void number_of_threads(unsigned const &number_of_threads)
set the number of dedicated threads to service exporters export (default 0)