From a8103884149f97df363a63111d7a7e5a07a2abb3 Mon Sep 17 00:00:00 2001 From: Piotr Konopka Date: Tue, 10 Dec 2024 12:39:29 +0100 Subject: [PATCH] [occ] do not call iterateCheck when in ERROR There is no point in asking the controlled task for a health check if it's still in ERROR. The task can go to healthy state by requesting a recover transition, which gives a success or failure as a return value. OCTRL-958 --- occ/occlib/OccServer.cxx | 24 +++++++++++++----------- occ/occlib/RuntimeControlledObject.h | 4 ++-- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/occ/occlib/OccServer.cxx b/occ/occlib/OccServer.cxx index fd0208a0..6947624c 100644 --- a/occ/occlib/OccServer.cxx +++ b/occ/occlib/OccServer.cxx @@ -437,17 +437,19 @@ void OccServer::runChecker() } } - // execute periodic check, in any state - int err = m_rco->iterateCheck(); - // if there's an error but the SM hasn't been moved to t_State::error yet - if (err && (m_rco->getState() != t_State::error)) { - updateState(t_State::error); - - // the above publishes a state change event to the StateStream, but we also push an exception event on the - // EventStream because the transition was initiated by the task - auto taskErrorEvent = new pb::DeviceEvent; - taskErrorEvent->set_type(pb::TASK_INTERNAL_ERROR); - pushEvent(taskErrorEvent); + // execute periodic check, in any state except ERROR + if (m_rco->getState() != t_State::error) { + int err = m_rco->iterateCheck(); + // if there's an error but the SM hasn't been moved to t_State::error yet + if (err) { + updateState(t_State::error); + + // the above publishes a state change event to the StateStream, but we also push an exception event on the + // EventStream because the transition was initiated by the task + auto taskErrorEvent = new pb::DeviceEvent; + taskErrorEvent->set_type(pb::TASK_INTERNAL_ERROR); + pushEvent(taskErrorEvent); + } } m_mu.unlock(); diff --git a/occ/occlib/RuntimeControlledObject.h b/occ/occlib/RuntimeControlledObject.h index 3002606d..97706383 100644 --- a/occ/occlib/RuntimeControlledObject.h +++ b/occ/occlib/RuntimeControlledObject.h @@ -268,12 +268,12 @@ class OCC_EXPORT RuntimeControlledObject { virtual int iterateRunning(); /** - * Perform periodic checks during every state. + * Perform periodic checks during every state except ERROR. * * @return 0 if the check completed successfully and the machine can stay in the current state, * or any other value to immediately trigger a transition to the error state. * - * This function is called continuously by OccServer::runChecker in any state, including + * This function is called continuously by OccServer::runChecker in any state except ERROR, including * t_State::running. Its purpose is for the implementer to report an unusual condition in * order to trigger a transition to t_State::error. */