/************************************************************************** * * Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file ModeStandby.c * * @author (last) Michael Garthwaite * @date (last) 28-Feb-2025 * * @author (original) Michael Garthwaite * @date (original) 28-Feb-2025 * ***************************************************************************/ #include "ModeStandby.h" #include "ModeWaterPreGen.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "SystemCommRO.h" #include "TaskGeneral.h" /** * @addtogroup ROStandbyMode * @{ */ // ********** private definitions ********** // ********** private data ********** static RO_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. // ********** private function prototypes ********** static RO_STANDBY_MODE_STATE_T handleStandbyIdleState( void ); /*********************************************************************//** * @brief * The initStandbyMode function initializes the standby mode unit. * @details \b Inputs: none * @details \b Outputs:unit variables initialized. * @return none *************************************************************************/ void initStandbyMode( void ) { standbyState = RO_STANDBY_MODE_STATE_IDLE; } /*********************************************************************//** * @brief * The transitionToStandbyMode function prepares for transition to standby mode. * while transition, deenergize all actuators. * @details \b Inputs: none * @details \b Outputs: Re-initialized standby mode * @return initial state *************************************************************************/ U32 transitionToStandbyMode( void ) { initStandbyMode(); return standbyState; } /*********************************************************************//** * @brief * The execStandbyMode function executes the standby mode state machine. * @details \b Inputs: none * @details \b Outputs: Standby mode state machine executed * @details \b Alarm: ALARM_ID_RO_SOFTWARE_FAULT if standbyState is invalid. * @return current state *************************************************************************/ U32 execStandbyMode( void ) { // execute current Standby state switch ( standbyState ) { case RO_STANDBY_MODE_STATE_IDLE: standbyState = handleStandbyIdleState(); break; default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_MODE_STANDBY_INVALID_STATE, standbyState ) standbyState = RO_STANDBY_MODE_STATE_IDLE; break; } return standbyState; } /*********************************************************************//** * @brief * The handleStandbyIdleState function executes the idle state of the * standby mode state machine. * @details \b Inputs: * @details \b Outputs: * @details \b Message \Sent: * @return the next state *************************************************************************/ static RO_STANDBY_MODE_STATE_T handleStandbyIdleState( void ) { RO_STANDBY_MODE_STATE_T state = RO_STANDBY_MODE_STATE_IDLE; if ( TRUE == getPreGenRequest() ) { requestNewOperationMode( RO_MODE_PGEN ); } return state; } /*********************************************************************//** * @brief * The getCurrentStandbyState function returns the current state of standby mode. * @details \b Inputs: standbyState * @details \b Outputs: none * @return the current state of standby mode. *************************************************************************/ RO_STANDBY_MODE_STATE_T getCurrentStandbyState( void ) { return standbyState; } /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ /**@}*/