Simplify criteria.py file
Made the criteria.py file simpler to read and follow, no more lambda (or nested lambda) functions (there were at least 6), added more comments and simplified some functions. Also changed the name of the criteria.csv file to criteria_13kA.json so that it's obvious that it's only applicable to 13k circuits, and added 2 small tests to 13k circuits for the ST_RES_OVERVOLT case.
The code is now using powering's checks, as to not repeat the code and get the best out of their logs. For that, I needed to remove the conversion to seconds of the signals right after querying them, and now we're using nanoseconds. For the logger_adapter, and to avoid rewriting the same powering adapter here, it was also reused from lhcsmpowering.analyses.commons import start_logging_new_check. Finally, I've also added a "silent" logger for the "OR" criteria, where we only output the string representation of the relevant criteria.
As for the new criteria file, we're now using this json structure. The "link" was removed, some other fields were also deleted and the checks were "flattened". So we have one line per check. The "OR" link is now a list of "criteria", and the "AND" link doesn't exist anymore, as we always check if all the checks pass for each circuit anyway, so the default behaviour is always an "AND".
// this represents a "normal" criterion, where it's supposed to change in relation to FPA1
// inside the time_window specified.
// The "from_" and "to_" were removed, as "from_" == "!to_", and the "to_" state was changed to "status".
// we're also working now with bools instead of ints, to make it similar with the powering tests and
// to make it compatible with its checks.
{
"prefix": "",
"name": "ST_SW_Z_OPEN",
"criteria": [
{
"status": true,
"check_type": "change",
"reference_timestamp": "FPA1",
"time_window": {
"plus_ns": 60000000,
"minus_ns": 20000000
}
}
]
},
// this is a constant, so it means it must have the "status" for its full duration
{
"prefix": "",
"name": "ST_SOF_MDE_0",
"criteria": [
{
"status": true,
"check_type": "constant"
}
]
},
// and this represent the "OR". Essentially, everything that's inside the "criteria" is an "OR". That simple.
{
"prefix": "circ.DQS",
"name": "ST_SYST_OPEN",
"criteria": [
{
"status": true,
"check_type": "change",
"reference_timestamp": "FPA1",
"time_window": {
"plus_ns": 20000000,
"minus_ns": 10000000
}
},
{
"status": true,
"check_type": "constant"
}
]
},
For other MRs:
- TODO: make structure of checks similar to the powering one
- TODO: use start_logging_new_check from powering for the indentation
- TODO: reorganize tests