From b8a56a646d647ecdd34e63c706c99f54a0e9c19d Mon Sep 17 00:00:00 2001 From: "m.marn" <m.marn@gsi.de> Date: Mon, 8 Jan 2024 14:51:23 +0100 Subject: [PATCH] Add setup and cleanup. --- .../AllTypesFESA/RealTime/RTDeviceClass.cpp | 32 +++++++++++-------- .../RealTime/StatusUpdateAction.cpp | 18 +---------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/test/AllTypesFESA/src/AllTypesFESA/RealTime/RTDeviceClass.cpp b/test/AllTypesFESA/src/AllTypesFESA/RealTime/RTDeviceClass.cpp index b54fd64..2dd0363 100644 --- a/test/AllTypesFESA/src/AllTypesFESA/RealTime/RTDeviceClass.cpp +++ b/test/AllTypesFESA/src/AllTypesFESA/RealTime/RTDeviceClass.cpp @@ -6,6 +6,8 @@ #include <AllTypesFESA/GeneratedCode/ServiceLocator.h> #include <fesa-core/Core/AbstractEvent.h> +#include <AllTypesFESA/Common/AllTypesFESA.h> + #include <cmw-log/Logger.h> #include <string> @@ -30,6 +32,7 @@ RTDeviceClass::RTDeviceClass () : RTDeviceClass::~RTDeviceClass() { + AllTypesFESA::cleanup(); } RTDeviceClass* RTDeviceClass::getInstance() @@ -54,23 +57,24 @@ void RTDeviceClass::releaseInstance() // You can write code that initializes devices in the loop below. void RTDeviceClass::specificInit() { - const Devices& deviceCol = AllTypesFESAServiceLocator_->getDeviceCollection(); - for (Devices::const_iterator it = deviceCol.begin(); it != deviceCol.end(); ++it) + try { - try - { - Device* device = *it; - static_cast<void>(device); // This line prevents an "unused variable" warning, it can be removed safely. - // Write here some code to initialize devices - - } - catch (const fesa::FesaException& exception) + if (!AllTypesFESA::isInitialized()) { - LOG_ERROR_IF(logger, exception.getMessage()); - // Re-throwing the exception prevents the process from starting up. - throw; + AllTypesFESA::setup(this->AllTypesFESAServiceLocator_); } - } + } + catch(std::exception& ex) + { + // required to trace failures on logstash.acc.gsi.de + LOG_ERROR_IF(logger, ex.what()); + throw; + } + catch(...) + { + LOG_ERROR_IF(logger, "Unexpected error. Please notify support"); + throw; + } } void RTDeviceClass::specificShutDown() diff --git a/test/AllTypesFESA/src/AllTypesFESA/RealTime/StatusUpdateAction.cpp b/test/AllTypesFESA/src/AllTypesFESA/RealTime/StatusUpdateAction.cpp index 210fd3e..29cdeb2 100644 --- a/test/AllTypesFESA/src/AllTypesFESA/RealTime/StatusUpdateAction.cpp +++ b/test/AllTypesFESA/src/AllTypesFESA/RealTime/StatusUpdateAction.cpp @@ -49,23 +49,7 @@ StatusUpdateAction::~StatusUpdateAction() // of this real time action is there. void StatusUpdateAction::execute(fesa::RTEvent* pEvt) { - const fesa::MultiplexingContext* context = pEvt->getMultiplexingContext(); - static_cast<void>(context); // This line prevents an "unused variable" warning, it can be removed safely. - const Devices& devices = getFilteredDeviceCollection(pEvt); - for (Devices::const_iterator it = devices.begin(); it != devices.end(); ++it) - { - try - { - Device* device = *it; - static_cast<void>(device); // This line prevents an "unused variable" warning, it can be removed safely. - // Write here some code to process devices - - } - catch (const fesa::FesaException& exception) - { - LOG_ERROR_IF(logger, exception.getMessage()); - } - } + // We don't need the status action, however it's left here for compliance with the FESA GSI template. } } // AllTypesFESA -- GitLab