Project
Loading...
Searching...
No Matches
o2DummyCalibrationWorkflow.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
20#include <fairmq/Device.h>
21
22#include <iostream>
23#include <vector>
24
25using namespace o2::framework;
26
28
29// This is how you can define your processing in a declarative way
31{
33 .name = "counter",
34 .outputs = {OutputSpec{{"counter"}, "TST", "A1"}},
35 .algorithm = AlgorithmSpec{adaptStateless(
36 [](DataAllocator& outputs, ProcessingContext& pcx) {
37 static int counter = 0;
38 auto& aData = outputs.make<int>(OutputRef{"counter"});
39 aData = counter++;
40 if (counter == 10) {
41 pcx.services().get<ControlService>().endOfStream();
42 }
43 })},
44 };
45
47 .name = "aggregator",
48 .inputs = {InputSpec{"x", "TST", "A1", Lifetime::Timeframe}},
49 .outputs = {OutputSpec{{"average"}, "TST", "B1", Lifetime::Sporadic}},
50 .algorithm = adaptStateful([](CallbackService& callbacks) {
51 static int sum = 0;
52 auto eosCallback = [](EndOfStreamContext &ctx) {
53 auto& aData = ctx.outputs().make<int>(OutputRef{"average"});
54 aData = sum;
55 ctx.services().get<ControlService>().endOfStream();
56 };
57 callbacks.set<CallbackService::Id::EndOfStream>(eosCallback);
58 return adaptStateless([](Input<"x", int> const& x)
59 {
60 sum += x;
61 std::cout << "Sum: " << sum << std::endl;
62 }); })};
63
64 DataProcessorSpec c{.name = "publisher",
65 .inputs = {InputSpec{"average", "TST", "B1", Lifetime::Sporadic}},
66 .algorithm = adaptStateless([](Input<"average", int> const& counter) {
67 std::cout << "Counter to publish: " << counter << std::endl;
68 })};
69
73}
uint32_t c
Definition RawData.h:2
decltype(auto) make(const Output &spec, Args... args)
ServiceRegistryRef services()
The services registry associated with this processing context.
float sum(float s, o2::dcs::DataPointValue v)
Definition dcs-ccdb.cxx:39
GLint GLenum GLint x
Definition glcorearb.h:403
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLuint counter
Definition glcorearb.h:3987
WorkflowSpec concat(T &&t, ARGS &&... args)
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
AlgorithmSpec::ProcessCallback adaptStateless(LAMBDA l)
AlgorithmSpec::InitCallback adaptStateful(LAMBDA l)
WorkflowSpec defineDataProcessing(ConfigContext const &specs)
This function hooks up the the workflow specifications into the DPL driver.