Index: firmware/App/Modes/ModeHeatDisinfect.c =================================================================== diff -u -r76105aa3acd8870d705ed4af84954b697477d6ef -re0265b8fad80add7a5d54db11ecc72fd6b1665a8 --- firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision 76105aa3acd8870d705ed4af84954b697477d6ef) +++ firmware/App/Modes/ModeHeatDisinfect.c (.../ModeHeatDisinfect.c) (revision e0265b8fad80add7a5d54db11ecc72fd6b1665a8) @@ -23,6 +23,8 @@ #include "OperationModes.h" #include "Pressures.h" #include "ROPump.h" +#include "SystemCommMessages.h" +#include "TaskGeneral.h" #include "TemperatureSensors.h" #include "Timers.h" #include "UVReactors.h" @@ -37,6 +39,8 @@ // General defines #define MAX_ALLOWED_STATE_TRIALS 1 ///< Max allowed trials on a state. This is general among all the states. +#define HEAT_DISINFECT_DATA_PUB_INTERVAL ( MS_PER_SECOND / \ + TASK_GENERAL_INTERVAL ) ///< Mode Heat Disinfect data publish interval in counts. // Start state defines #define MIN_INLET_PRESSURE_PSI 30.0 ///< Minimum water inlet pressure in psi. @@ -117,6 +121,7 @@ static U32 rsrvrsVolMonitorTimer = 0; ///< Reservoir 1 & 2 volume monitor timers during heat disinfect. static BOOL areRsrvrsLeaking = FALSE; ///< Reservoir 1 & 2 leak check flag during heat disinfect. static BOOL hasPostHeatDisinfectWaitStarted = FALSE; ///< Final delay at the end of heat disinfect and before flush flag. +static U32 dataPublishCounter = 0; ///< Heat Disinfect data publish counter. // ********** private function prototypes ********** @@ -144,27 +149,32 @@ static BOOL isRsrvrFull( RSRVRS_T r, F32 targetVol, U32 timeout, DG_HEAT_DISINFECT_STATE_T state ); static BOOL isRsrvrEmpty( RSRVRS_T r, U32 timeout, DG_HEAT_DISINFECT_STATE_T failedState ); static BOOL isStateHeatDisinfectComplete( DG_HEAT_DISINFECT_STATE_T state ); +static void publishHeatDisinfectData( void ); /*********************************************************************//** * @brief - * The initHeatDisinfectMode function initializes the heat disinfect mode module. - * @details Inputs: none TODO update as we go - * @details Outputs: Initialized heat disinfect mode module + * The initHeatDisinfectMode function initializes the heat disinfect mode + * module. + * @details Inputs: none + * @details Outputs: heatDisinfectState, stateTimer, isThisLastDrain, + * stateTrialCounter, areTempSensorsInRange, isR1Full, isR2Full, + * R1HeatDisinfectVol, R2HeatDisinfectVol, hasPostHeatDisinfectWaitStarted, + * overallHeatDisinfectTimer TODO fill up as we go * @return none *************************************************************************/ void initHeatDisinfectMode( void ) { - heatDisinfectState = DG_HEAT_DISINFECT_STATE_START; - - stateTimer = 0; - isThisLastDrain = FALSE; - stateTrialCounter = 0; - areTempSensorsInRange = FALSE; - isR1Full = FALSE; - isR2Full = FALSE; - R1HeatDisinfectVol = 0; - R2HeatDisinfectVol = 0; + heatDisinfectState = DG_HEAT_DISINFECT_STATE_START; + stateTimer = 0; + isThisLastDrain = FALSE; + stateTrialCounter = 0; + areTempSensorsInRange = FALSE; + isR1Full = FALSE; + isR2Full = FALSE; + R1HeatDisinfectVol = 0; + R2HeatDisinfectVol = 0; hasPostHeatDisinfectWaitStarted = FALSE; + overallHeatDisinfectTimer = getMSTimerCount(); } /*********************************************************************//** @@ -276,6 +286,8 @@ break; } + publishHeatDisinfectData(); + return heatDisinfectState; } @@ -1247,4 +1259,29 @@ return heatDisinfectStatus; } +/*********************************************************************//** + * @brief + * The publishHeatDisinfectData function publishes heat disinfect data at + * the set interval. + * @details Inputs: dataPublishCounter + * @details Outputs: dataPublishCounter + * @return: none + *************************************************************************/ +static void publishHeatDisinfectData( void ) +{ + if ( ++dataPublishCounter > HEAT_DISINFECT_DATA_PUB_INTERVAL ) + { + MODE_HEAT_DISINFECT_DATA_T data; + + data.heatDisinfectState = (U32)heatDisinfectState; + // Get the time elapsed so far and convert them to minutes + data.overallElapsedTime = calcTimeSince( overallHeatDisinfectTimer ) / ( 60 * MS_PER_SECOND ); + data.heatDisinfectElapsedTime = calcTimeSince( stateTimer ) / ( 60 * MS_PER_SECOND ); + + broadcastHeatDisinfectData( &data ); + + dataPublishCounter = 0; + } +} + /**@}*/