1919// / \code{.sh}
2020// / o2-qc-run-producer | o2-qc --config json://${QUALITYCONTROL_ROOT}/etc/basic.json
2121// / \endcode
22+ // / Check out the help message to see how to configure data rate and message size.
2223// /
2324// / If you have glfw installed, you should see a window with the workflow visualization and sub-windows for each Data
2425// / Processor where their logs can be seen. The processing will continue until the main window it is closed. Regardless
2526// / of glfw being installed or not, in the terminal all the logs will be shown as well.
2627
27- #include < random >
28- #include < Framework/runDataProcessing .h>
28+ #include < vector >
29+ #include < Framework/ConfigParamSpec .h>
2930
3031using namespace o2 ;
3132using namespace o2 ::framework;
3233
33- // clang-format off
34- WorkflowSpec defineDataProcessing (const ConfigContext&)
34+ void customize (std::vector<ConfigParamSpec>& workflowOptions)
3535{
36- WorkflowSpec specs;
36+ workflowOptions.push_back (
37+ ConfigParamSpec{ " min-size" , VariantType::Int, 1 , { " Minimum size in bytes of produced messages." } });
38+ workflowOptions.push_back (
39+ ConfigParamSpec{ " max-size" , VariantType::Int, 10000 , { " Maximum size in bytes of produced messages." } });
40+ workflowOptions.push_back (
41+ ConfigParamSpec{ " empty" , VariantType::Bool, false , { " Don't fill messages with random data." } });
42+ workflowOptions.push_back (
43+ ConfigParamSpec{ " message-rate" , VariantType::Double, 10.0 , { " Rate of messages per second." } });
44+ workflowOptions.push_back (
45+ ConfigParamSpec{ " producers" , VariantType::Int, 1 , { " Number of producers. Each will have unique SubSpec, counting from 0." } });
46+ workflowOptions.push_back (
47+ ConfigParamSpec{ " monitoring-url" , VariantType::String, " " , { " URL of the Monitoring backend" } });
48+ }
3749
38- // The producer to generate some data in the workflow
39- DataProcessorSpec producer{
40- " producer" ,
41- Inputs{},
42- Outputs{
43- { " TST" , " RAWDATA" , 0 } },
44- AlgorithmSpec{
45- (AlgorithmSpec::InitCallback)[](InitContext&){
46- // this is the initialization code
47- std::default_random_engine generator (11 );
50+ #include < Framework/runDataProcessing.h>
51+ #include " QualityControl/DataProducer.h"
4852
49- // after the initialization, we return the processing callback
50- return (AlgorithmSpec::ProcessCallback)[generator](ProcessingContext & processingContext) mutable
51- {
52- // everything inside this lambda function is invoked in a loop, because it this Data Processor has no inputs
53- usleep (100000 );
53+ using namespace o2 ::quality_control::core;
5454
55- size_t length = generator () % 10000 ;
56- auto data = processingContext.outputs ().make <char >(Output{ " TST" , " RAWDATA" }, length);
57- for (auto && item : data) {
58- item = static_cast <char >(generator ());
59- }
60- };
61- }
62- }
63- };
64- specs.push_back (producer);
55+ WorkflowSpec defineDataProcessing (const ConfigContext& config)
56+ {
57+ size_t minSize = config.options ().get <int >(" min-size" );
58+ size_t maxSize = config.options ().get <int >(" max-size" );
59+ bool fill = !config.options ().get <bool >(" empty" );
60+ double rate = config.options ().get <double >(" message-rate" );
61+ size_t producers = config.options ().get <int >(" producers" );
62+ std::string monitoringUrl = config.options ().get <std::string>(" monitoring-url" );
6563
64+ WorkflowSpec specs;
65+ for (size_t i = 0 ; i < producers; i++) {
66+ specs.push_back (getDataProducerSpec (minSize, maxSize, rate, fill, i, monitoringUrl));
67+ }
6668 return specs;
67- }
68- // clang-format on
69+ }
0 commit comments