|
| 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. |
| 11 | +#include "Framework/ConfigParamSpec.h" |
| 12 | +#include "Framework/DataTakingContext.h" |
| 13 | +#include "Framework/CompletionPolicyHelpers.h" |
| 14 | +#include "Framework/DeviceSpec.h" |
| 15 | +#include "Framework/RawDeviceService.h" |
| 16 | +#include "Framework/ControlService.h" |
| 17 | +#include "Framework/Configurable.h" |
| 18 | +#include "Framework/RunningWorkflowInfo.h" |
| 19 | +#include "Framework/RateLimiter.h" |
| 20 | +#include <fairmq/Device.h> |
| 21 | + |
| 22 | +#include <iostream> |
| 23 | +#include <chrono> |
| 24 | +#include <thread> |
| 25 | +#include <vector> |
| 26 | + |
| 27 | +using namespace o2::framework; |
| 28 | + |
| 29 | +#include "Framework/runDataProcessing.h" |
| 30 | + |
| 31 | +// This is how you can define your processing in a declarative way |
| 32 | +WorkflowSpec defineDataProcessing(ConfigContext const& specs) |
| 33 | +{ |
| 34 | + DataProcessorSpec a{ |
| 35 | + .name = "A", |
| 36 | + .outputs = {OutputSpec{{"a1"}, "TST", "A1"}, |
| 37 | + OutputSpec{{"a2"}, "TST", "A2"}}, |
| 38 | + .algorithm = AlgorithmSpec{adaptStateless( |
| 39 | + [](DataAllocator& outputs, RawDeviceService& device, DataTakingContext& context, ProcessingContext& pcx) { |
| 40 | + outputs.make<int>(OutputRef{"a1"}, 1); |
| 41 | + static int i = 0; |
| 42 | + outputs.make<int>(OutputRef{"a1"}, 1); |
| 43 | + if (i++ % 2 == 0) { |
| 44 | + outputs.make<int>(OutputRef{"a2"}, 1); |
| 45 | + } |
| 46 | + })}, |
| 47 | + }; |
| 48 | + DataProcessorSpec d{ |
| 49 | + .name = "D", |
| 50 | + .inputs = {InputSpec{"a1", "TST", "A1"}, |
| 51 | + InputSpec{"a2", "TST", "A2"}}, |
| 52 | + .algorithm = AlgorithmSpec{adaptStateless( |
| 53 | + [](InputRecord& inputs) { |
| 54 | + auto ref = inputs.get("a1"); |
| 55 | + auto header = o2::header::get<const DataProcessingHeader*>(ref.header); |
| 56 | + LOG(info) << "Start time: " << header->startTime; |
| 57 | + })}, |
| 58 | + }; |
| 59 | + |
| 60 | + return workflow::concat(WorkflowSpec{a}, |
| 61 | + WorkflowSpec{d}); |
| 62 | +} |
0 commit comments