Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DPL TestWorkflows: add example for two synchronized timers #12818

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Framework/TestWorkflows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ o2_add_dpl_workflow(diamond-workflow
SOURCES src/o2DiamondWorkflow.cxx
COMPONENT_NAME TestWorkflows)

o2_add_dpl_workflow(two-timers
SOURCES src/o2TwoTimers.cxx
COMPONENT_NAME TestWorkflows)

o2_add_dpl_workflow(dummy-calibration-workflow
SOURCES src/o2DummyCalibrationWorkflow.cxx
COMPONENT_NAME TestWorkflows)
Expand Down
61 changes: 61 additions & 0 deletions Framework/TestWorkflows/src/o2TwoTimers.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/ConfigParamSpec.h"
#include "Framework/DataTakingContext.h"
#include "Framework/CompletionPolicyHelpers.h"
#include "Framework/DeviceSpec.h"
#include "Framework/RawDeviceService.h"
#include "Framework/ControlService.h"
#include "Framework/Configurable.h"
#include "Framework/RunningWorkflowInfo.h"
#include "Framework/CallbackService.h"
#include "Framework/RateLimiter.h"
#include "Framework/ConfigContext.h"
#include <fairmq/Device.h>

#include <iostream>
#include <chrono>
#include <thread>
#include <vector>

using namespace o2::framework;
#include "Framework/runDataProcessing.h"

// This is how you can define your processing in a declarative way
WorkflowSpec defineDataProcessing(ConfigContext const& specs)
{
DataProcessorSpec timer1{
.name = "timer1",
.inputs = {InputSpec{"x", "TIM", "A1", Lifetime::Timer}},
.outputs = {OutputSpec{{"output"}, "TST", "A1"}},
.algorithm = AlgorithmSpec{adaptStateless(
[](DataAllocator& outputs, RawDeviceService& device, DataTakingContext& context, ProcessingContext& pcx) {
auto& aData = outputs.make<int>(OutputRef{"output"}, 1);
LOG(info) << "timer1: " << aData[0];
})},
.options = {
ConfigParamSpec{"some-device-param", VariantType::Int, 1, {"Some device parameter"}},
}};
DataProcessorSpec timer2{
.name = "timer2",
.inputs = {InputSpec{"x", "TIM", "A1", Lifetime::Timer}},
.outputs = {OutputSpec{{"output"}, "TST", "A2"}},
.algorithm = AlgorithmSpec{adaptStateless(
[](DataAllocator& outputs, RawDeviceService& device, DataTakingContext& context, ProcessingContext& pcx) {
auto& aData = outputs.make<int>(OutputRef{"output"}, 1);
LOG(info) << "timer2: " << aData[0];
})},
.options = {
ConfigParamSpec{"some-device-param", VariantType::Int, 1, {"Some device parameter"}},
}};

return workflow::concat(WorkflowSpec{timer1, timer2});
}
Loading