-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathRunStatusChecker.cxx
More file actions
69 lines (65 loc) · 2.89 KB
/
RunStatusChecker.cxx
File metadata and controls
69 lines (65 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// 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 "DetectorsDCS/RunStatusChecker.h"
#include "CCDB/BasicCCDBManager.h"
#include "CCDB/CCDBTimeStampUtils.h"
using namespace o2::dcs;
const o2::parameters::GRPECSObject* RunStatusChecker::check(long ts)
{
if (ts < 0) {
ts = o2::ccdb::getCurrentTimestamp();
}
if (ts <= mLastTimeStampChecked) {
LOGP(alarm, "RunStatusChecker::check was called with decreasing timestamp {}, previous was {}", ts, mLastTimeStampChecked);
return nullptr;
}
mLastTimeStampChecked = ts;
auto& mgr = o2::ccdb::BasicCCDBManager::instance();
bool fatalOn = mgr.getFatalWhenNull();
mgr.setFatalWhenNull(false);
if (mRunStatus == RunStatus::STOP) { // the STOP was detected at previous check
mRunFollowed = -1;
mRunStatus = RunStatus::NONE;
}
std::map<std::string, std::string> md;
if (mRunFollowed > 0) { // run start was seen
md["runNumber"] = std::to_string(mRunFollowed);
}
const auto* grp = mgr.getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, md);
if (grp) { // some object was returned
if (mRunFollowed > 0) {
if ((ts > grp->getTimeEnd()) && (grp->getTimeEnd() > grp->getTimeStart())) { // this means that the EOR was registered
mRunStatus = RunStatus::STOP;
} else { // run still continues
mRunStatus = RunStatus::ONGOING;
}
} else { // we were not following detector run, check if the current one has asked detectors
if ((grp->getDetsReadOut() & mDetMask) == mDetMask) { // we start following this run
if (grp->getTimeEnd() > grp->getTimeStart()) {
if (ts < grp->getTimeEnd()) { // only in tests with ad hoc ts the ts_EOR can be seen > ts
mRunStatus = RunStatus::START;
mRunFollowed = grp->getRun();
}
} else {
mRunStatus = RunStatus::START;
mRunFollowed = grp->getRun();
}
}
}
} else { // query did not return any GRP -> we are certainly not in the wanted detectors run
if (mRunFollowed > 0) { // normally this should not happen
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);
mRunStatus = RunStatus::STOP;
}
}
mgr.setFatalWhenNull(fatalOn);
return mRunStatus == RunStatus::NONE ? nullptr : grp;
}