|
| 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 | + |
| 12 | +#ifndef QC_CORE_LATETASKRUNNER_H |
| 13 | +#define QC_CORE_LATETASKRUNNER_H |
| 14 | + |
| 15 | +/// |
| 16 | +/// \file LateTaskRunner.h |
| 17 | +/// \author Piotr Konopka |
| 18 | +/// |
| 19 | + |
| 20 | +#include <Framework/Task.h> |
| 21 | +#include <Framework/DataProcessorSpec.h> |
| 22 | +#include <Framework/CompletionPolicy.h> |
| 23 | + |
| 24 | +#include "QualityControl/LateTaskRunnerConfig.h" |
| 25 | + |
| 26 | +namespace o2::quality_control::core { |
| 27 | + |
| 28 | +class LateTaskInterface; |
| 29 | +class ObjectsManager; |
| 30 | + |
| 31 | +class LateTaskRunner : public framework::Task |
| 32 | +{ |
| 33 | + /// \brief Number of bytes in data description used for hashing of Task names. See HashDataDescription.h for details |
| 34 | + static constexpr size_t taskDescriptionHashLength = 4; |
| 35 | + static_assert(taskDescriptionHashLength <= o2::header::DataDescription::size); |
| 36 | + |
| 37 | + public: |
| 38 | + explicit LateTaskRunner(const LateTaskRunnerConfig& config); |
| 39 | + ~LateTaskRunner() override = default; |
| 40 | + |
| 41 | + /// \brief LateTaskRunner's init callback |
| 42 | + void init(framework::InitContext& iCtx) override; |
| 43 | + /// \brief LateTaskRunner's process callback |
| 44 | + void run(framework::ProcessingContext& pCtx) override; |
| 45 | + /// \brief LateTaskRunner's finaliseCCDB callback |
| 46 | + // void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) override; |
| 47 | + |
| 48 | + std::string getDeviceName() const { return mTaskConfig.deviceName; }; |
| 49 | + const framework::Inputs& getInputsSpecs() const { return mTaskConfig.inputSpecs; }; |
| 50 | + const framework::OutputSpec& getOutputSpec() const { return mTaskConfig.moSpec; }; |
| 51 | + const framework::Options& getOptions() const { return mTaskConfig.options; }; |
| 52 | + |
| 53 | + /// \brief Data Processor Label to identify all Late Task Runners |
| 54 | + static framework::DataProcessorLabel getLabel() { return { "qc-late-task" }; } |
| 55 | + /// \brief ID string for all LateTaskRunner devices |
| 56 | + static std::string createIdString(); |
| 57 | + /// \brief Unified DataOrigin for Quality Control tasks |
| 58 | + static header::DataOrigin createDataOrigin(const std::string& detectorCode); |
| 59 | + /// \brief Unified DataDescription naming scheme for all tasks |
| 60 | + static header::DataDescription createDataDescription(const std::string& taskName); |
| 61 | + |
| 62 | + /// \brief Callback for CallbackService::Id::EndOfStream |
| 63 | + // void endOfStream(framework::EndOfStreamContext& eosContext) override; |
| 64 | + |
| 65 | + private: |
| 66 | + /// \brief Callback for CallbackService::Id::Start (DPL) a.k.a. RUN transition (FairMQ) |
| 67 | + // void start(framework::ServiceRegistryRef services); |
| 68 | + /// \brief Callback for CallbackService::Id::Stop (DPL) a.k.a. STOP transition (FairMQ) |
| 69 | + // void stop(framework::ServiceRegistryRef services); |
| 70 | + /// \brief Callback for CallbackService::Id::Reset (DPL) a.k.a. RESET DEVICE transition (FairMQ) |
| 71 | + // void reset(); |
| 72 | + |
| 73 | + void startOfActivity(); |
| 74 | + void endOfActivity(); |
| 75 | + int publish(framework::DataAllocator& outputs); |
| 76 | + // void publishCycleStats(); |
| 77 | + // void updateMonitoringStats(framework::ProcessingContext& pCtx); |
| 78 | + // void registerToBookkeeping(); |
| 79 | + |
| 80 | + private: |
| 81 | + LateTaskRunnerConfig mTaskConfig; |
| 82 | + // std::shared_ptr<monitoring::Monitoring> mCollector; |
| 83 | + std::shared_ptr<LateTaskInterface> mTask; |
| 84 | + std::shared_ptr<ObjectsManager> mObjectsManager; |
| 85 | + // std::shared_ptr<Timekeeper> mTimekeeper; |
| 86 | + Activity mActivity; |
| 87 | + ValidityInterval mValidity; |
| 88 | + |
| 89 | + // stats |
| 90 | + // int mNumberMessagesReceivedInCycle = 0; |
| 91 | + // int mNumberObjectsPublishedInCycle = 0; |
| 92 | + // int mTotalNumberObjectsPublished = 0; // over a run |
| 93 | + // double mLastPublicationDuration = 0; |
| 94 | + // uint64_t mDataReceivedInCycle = 0; |
| 95 | +}; |
| 96 | + |
| 97 | + |
| 98 | +} |
| 99 | +#endif //QC_CORE_LATETASKRUNNER_H |
0 commit comments