Project
Loading...
Searching...
No Matches
RunStatusChecker.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.
11
15
16using namespace o2::dcs;
17
19{
20 if (ts < 0) {
22 }
23 if (ts <= mLastTimeStampChecked) {
24 LOGP(alarm, "RunStatusChecker::check was called with decreasing timestamp {}, previous was {}", ts, mLastTimeStampChecked);
25 return nullptr;
26 }
27 mLastTimeStampChecked = ts;
28
30 bool fatalOn = mgr.getFatalWhenNull();
31 mgr.setFatalWhenNull(false);
32 if (mRunStatus == RunStatus::STOP) { // the STOP was detected at previous check
33 mRunFollowed = -1;
34 mRunStatus = RunStatus::NONE;
35 }
36 std::map<std::string, std::string> md;
37 if (mRunFollowed > 0) { // run start was seen
38 md["runNumber"] = std::to_string(mRunFollowed);
39 }
40 const auto* grp = mgr.getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, md);
41 if (grp) { // some object was returned
42 if (mRunFollowed > 0) {
43 if ((ts > grp->getTimeEnd()) && (grp->getTimeEnd() > grp->getTimeStart())) { // this means that the EOR was registered
44 mRunStatus = RunStatus::STOP;
45 } else { // run still continues
46 mRunStatus = RunStatus::ONGOING;
47 }
48 } else { // we were not following detector run, check if the current one has asked detectors
49 if ((grp->getDetsReadOut() & mDetMask) == mDetMask) { // we start following this run
50 if (grp->getTimeEnd() > grp->getTimeStart()) {
51 if (ts < grp->getTimeEnd()) { // only in tests with ad hoc ts the ts_EOR can be seen > ts
52 mRunStatus = RunStatus::START;
53 mRunFollowed = grp->getRun();
54 }
55 } else {
56 mRunStatus = RunStatus::START;
57 mRunFollowed = grp->getRun();
58 }
59 }
60 }
61 } else { // query did not return any GRP -> we are certainly not in the wanted detectors run
62 if (mRunFollowed > 0) { // normally this should not happen
63 LOGP(warning, "We were following {} run {} but the query at {} did not return any GRP, problem with EOR?", o2::detectors::DetID::getNames(mDetMask), mRunFollowed, ts);
64 mRunStatus = RunStatus::STOP;
65 }
66 }
67 mgr.setFatalWhenNull(fatalOn);
68 return mRunStatus == RunStatus::NONE ? nullptr : grp;
69}
static BasicCCDBManager & instance()
const o2::parameters::GRPECSObject * check(long ts=-1)
static std::string getNames(mask_t mask, char delimiter=',')
Definition DetID.cxx:74
long getCurrentTimestamp()
returns the timestamp in long corresponding to "now"
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52