Skip to content

Commit ca0b6d0

Browse files
authored
Merge pull request #282 from sy-c/master
v2.26..0
2 parents a60a11d + abd22fd commit ca0b6d0

File tree

4 files changed

+46
-41
lines changed

4 files changed

+46
-41
lines changed

doc/releaseNotes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,3 +635,7 @@ This file describes the main feature changes for each readout.exe released versi
635635

636636
## v2.25.1 - 26/06/224
637637
- o2-readout-status: updated list of P2 FLPs.
638+
639+
## v2.26.0 - 26/07/2024
640+
- Error reporting: fatal error messages logged to operator when there is a state transition error. The first error (if any) that happened is added to the message.
641+
This covers the cases of (among many others): wrong CRU fw version, inconsistent first orbits, no links enabled.

src/ReadoutVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
1111

12-
#define READOUT_VERSION "2.25.1"
12+
#define READOUT_VERSION "2.26.0"
1313

src/mainReadout.cxx

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "DataBlock.h"
3939
#include "DataBlockContainer.h"
4040
#include "DataSet.h"
41+
#include "readoutErrorCodes.h"
4142

4243
#ifdef WITH_ZMQ
4344
#include "ZmqServer.hxx"
@@ -314,59 +315,50 @@ class Readout
314315
}
315316
return -1;
316317
}
317-
int configure(const boost::property_tree::ptree& properties) {
318+
319+
// Wrapper function to catch exception and report fatal errors
320+
int executeFunction(std::string actionName, std::function<int()> f) {
321+
// theLog.log(LogDebugDevel, "Calling function for %s",actionName.c_str());
322+
int err = -1;
318323
try {
319-
return _configure(properties);
324+
err = f();
320325
}
321326
catch (const std::exception& e) {
322327
theLog.log(LogErrorSupport_(3245), "Exception : %s", e.what());
323328
}
324-
return -1;
329+
if (err) {
330+
std::vector<std::string> m;
331+
theLog.historyGetSummary(m);
332+
std::string reason = "Readout failed in " + actionName + ". Please check previous messages.";
333+
if (m.size()) {
334+
reason += " First error logged was " + m[0];
335+
}
336+
theLog.log(LogFatalOps, "%s", reason.c_str());
337+
}
338+
return err;
339+
}
340+
341+
int configure(const boost::property_tree::ptree& properties) {
342+
theLog.historyReset(1);
343+
return executeFunction("CONFIGURE", std::bind(&Readout::_configure, this, properties));
325344
}
326345
int reset() { // as opposed to configure()
327-
try {
328-
return _reset();
329-
}
330-
catch (const std::exception& e) {
331-
theLog.log(LogErrorSupport_(3245), "Exception : %s", e.what());
332-
}
333-
return -1;
346+
theLog.historyReset(1);
347+
return executeFunction("RESET", std::bind(&Readout::_reset, this));
334348
}
335349
int start() {
336-
try {
337-
return _start();
338-
}
339-
catch (const std::exception& e) {
340-
theLog.log(LogErrorSupport_(3245), "Exception : %s", e.what());
341-
}
342-
return -1;
350+
theLog.historyReset(1);
351+
return executeFunction("START", std::bind(&Readout::_start, this));
343352
}
344353
int stop() { // as opposed to start()
345-
try {
346-
return _stop();
347-
}
348-
catch (const std::exception& e) {
349-
theLog.log(LogErrorSupport_(3245), "Exception : %s", e.what());
350-
}
351-
return -1;
354+
theLog.historyReset(1);
355+
return executeFunction("STOP", std::bind(&Readout::_stop, this));
352356
}
353357
int iterateRunning() {
354-
try {
355-
return _iterateRunning();
356-
}
357-
catch (const std::exception& e) {
358-
theLog.log(LogErrorSupport_(3245), "Exception : %s", e.what());
359-
}
360-
return -1;
358+
return executeFunction("RUNNING", std::bind(&Readout::_iterateRunning, this));
361359
}
362360
int iterateCheck() {
363-
try {
364-
return _iterateCheck();
365-
}
366-
catch (const std::exception& e) {
367-
theLog.log(LogErrorSupport_(3245), "Exception : %s", e.what());
368-
}
369-
return -1;
361+
return executeFunction("CHECK", std::bind(&Readout::_iterateCheck, this));
370362
}
371363

372364
void loopRunning(); // called in state "running"
@@ -2261,6 +2253,9 @@ int main(int argc, char* argv[])
22612253
// initialize logging
22622254
theLogContext.setField(InfoLoggerContext::FieldName::Facility, "readout");
22632255
theLog.setContext(theLogContext);
2256+
for(const auto &c : readoutErrorCodes) {
2257+
theLog.registerErrorCodes({ {std::get<0>(c), std::get<1>(c) } });
2258+
}
22642259

22652260
// create readout instance
22662261
std::unique_ptr<Readout> theReadout = std::make_unique<Readout>();

src/readoutErrorCodes.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
// cf infoLogger/infoLoggerErrorCodes.h
1515
// Definitions below should be copied there
1616

17-
/*
17+
18+
#include <tuple>
19+
#include <vector>
20+
#include <string>
21+
22+
const std::vector<std::tuple<int, const char *, const char *>> readoutErrorCodes = {
23+
1824
{ 3001, "Trace for readout process status", nullptr},
1925
{ 3002, "Trace for readout configuration", nullptr},
2026
{ 3003, "Trace for readout counters", nullptr},
@@ -53,5 +59,5 @@
5359
{ 3243, "Control problem", nullptr},
5460
{ 3244, "Should not happen problem", nullptr},
5561
{ 3245, "Unhandled exception", nullptr},
56-
*/
5762

63+
};

0 commit comments

Comments
 (0)