Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r8e50cc04fb92d9b4ee9045e445ca8451abe951ab -r7a7bf19d0cf16745566956f45cef57f8eb5df445 --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 8e50cc04fb92d9b4ee9045e445ca8451abe951ab) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 7a7bf19d0cf16745566956f45cef57f8eb5df445) @@ -31,6 +31,7 @@ #include "OperationModes.h" #include "SystemComm.h" #include "SystemCommMessages.h" +#include "TaskGeneral.h" #ifdef EMC_TEST_BUILD // TODO - test code #include "FPGA.h" #endif @@ -42,19 +43,27 @@ // ********** private definitions ********** +#define DISINFECTS_DATA_PUB_INTERVAL ( 1 * MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Disinfects data publish interval in counts. + // ********** private data ********** static HD_STANDBY_STATE_T currentStandbyState; ///< Current state (sub-mode) of standby mode. static BOOL treatStartReqReceived = FALSE; ///< Flag indicates user has requested initiation of a treatment +static U32 dataPublishCounter = 0; ///< Disinfects data publish counter. +/// Interval (in task intervals) at which to publish standby mode data to CAN bus. +static OVERRIDE_U32_T standbyModePublishInterval = { DISINFECTS_DATA_PUB_INTERVAL, DISINFECTS_DATA_PUB_INTERVAL, DISINFECTS_DATA_PUB_INTERVAL, 0 }; + // ********** private function prototypes ********** static HD_STANDBY_STATE_T handleStandbyWait4TreatmentState( void ); static HD_STANDBY_STATE_T handleStandbyDGFlushState( void ); static HD_STANDBY_STATE_T handleStandbyDGHeatDisinfectState( void ); static HD_STANDBY_STATE_T handleStandbyDGChemDisinfectState( void ); +static void publishDisinfectData( void ); + /*********************************************************************//** * @brief * The initStandbyMode function initializes the Standby Mode module. @@ -353,4 +362,74 @@ // Alarm actions not handled in Standby mode } +/*********************************************************************//** + * @brief + * The publishDisinfectData function publishes disinfects data at + * the set interval. + * @details Inputs: dataPublishCounter + * @details Outputs: dataPublishCounter + * @return: none + *************************************************************************/ +static void publishDisinfectData( void ) +{ + if ( ++dataPublishCounter > getU32OverrideValue( &standbyModePublishInterval ) ) + { + dataPublishCounter = 0; + // TODO - merge function code from Dara's branch + } +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testSetStandbyModePublishIntervalOverride function sets the override of the + * standby mode data publication interval. + * @details Inputs: none + * @details Outputs: standbyModePublishInterval + * @param ms milliseconds between standby mode broadcasts + * @return TRUE if override set successful, FALSE if not + *************************************************************************/ +BOOL testSetStandbyModePublishIntervalOverride( U32 ms ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + U32 intvl = ms / TASK_GENERAL_INTERVAL; + + result = TRUE; + standbyModePublishInterval.ovData = intvl; + standbyModePublishInterval.override = OVERRIDE_KEY; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetStandbyModePublishIntervalOverride function resets the override of the + * standby mode data publication interval. + * @details Inputs: none + * @details Outputs: standbyModePublishInterval + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetStandbyModePublishIntervalOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + standbyModePublishInterval.override = OVERRIDE_RESET; + standbyModePublishInterval.ovData = standbyModePublishInterval.ovInitData; + } + + return result; +} + /**@}*/