Project
Loading...
Searching...
No Matches
RunStatusChecker.h
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.
11
12#ifndef O2_RUN_STATUS_CHECKER_H
13#define O2_RUN_STATUS_CHECKER_H
14
16
19
20/*
21 Utility class to check the status of the run with particular detectors participating
22 Usage: first create an instance for the mask of detectors which must be in the run, e.g.
23
24 RunStatusChecker runChecker{ o2::detectors::DetID::getMask("EMC,PHS") };
25 const o2::parameters::GRPECSObject* myGRPECS = nullptr;
26
27 Then, periodically check:
28
29 myGRPECS = runChecker.check();
30
31 The check will set the status of the run with selected detectors (can be inspected by getRunStatus() method).
32
33 if (check.getRunStatus() == o2::dcs::RunStatusChecker::RunStatus::NONE) {
34 LOGP(info, "No run with {} is ongoing or finished", o2::detectors::DetID::getNames(checker->getDetectorsMask()) );
35 }
36 else if (check.getRunStatus() == o2::dcs::RunStatusChecker::RunStatus::START) { // saw new run with wanted detectors
37 LOGP(info, "Run {} with {} has started", checker.getFollowedRun(), o2::detectors::DetID::getNames(checker->getDetectorsMask()) );
38 }
39 else if (check.getRunStatus() == o2::dcs::RunStatusChecker::RunStatus::ONGOING) { // run which was already seen is still ongoing
40 LOGP(info, "Run {} with {} is still ongoing", checker.getFollowedRun(), o2::detectors::DetID::getNames(checker->getDetectorsMask()) );
41 }
42 else if (check.getRunStatus() == o2::dcs::RunStatusChecker::RunStatus::STOP) { // run which was already seen was stopped (EOR seen)
43 LOGP(info, "Run {} with {} was stopped", checker.getFollowedRun(), o2::detectors::DetID::getNames(checker->getDetectorsMask()) );
44 }
45
46 In all cases except RunStatusChecker::NONE a const non-null pointer on the GRP of the followed run will be returned.
47
48 By default the check will be done for the current timestamp, for test purposes one can call it with arbitrary increasing timestamps
49*/
50
51namespace o2::dcs
52{
53
55{
56 public:
57 enum class RunStatus { NONE, // check did not find onging run with current detector
58 START, // check found a new run started
59 ONGOING, // check found ongoing run which was already checked
60 STOP // check found that previously ongoing run was stopped
61 };
62
63 RunStatusChecker() = delete;
64 RunStatusChecker(o2::detectors::DetID::mask_t detmask) : mDetMask(detmask) {}
65
66 RunStatus getRunStatus() const { return mRunStatus; }
67 int getFollowedRun() const { return mRunFollowed; }
69 const o2::parameters::GRPECSObject* check(long ts = -1);
70
71 private:
72 RunStatus mRunStatus = RunStatus::NONE;
74 int mRunFollowed = -1; // particular run followed, assumption is that at the given moment there might be only run with particular detector
75 long mLastTimeStampChecked = -1;
76
77 ClassDefNV(RunStatusChecker, 0);
78};
79
80} // namespace o2::dcs
81
82#endif
Header of the AggregatedRunInfo struct.
RunStatus getRunStatus() const
RunStatusChecker(o2::detectors::DetID::mask_t detmask)
o2::detectors::DetID::mask_t getDetectorsMask() const
const o2::parameters::GRPECSObject * check(long ts=-1)