Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -r46bf7baaa9d8095e0405b018fcd4bc594907797e -r4e11c80367b5ae522aa34fb137079e516c98831b --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 46bf7baaa9d8095e0405b018fcd4bc594907797e) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 4e11c80367b5ae522aa34fb137079e516c98831b) @@ -44,6 +44,8 @@ #define MAX_WATER_SAMPLE_TIME_MS ( 10 * MS_PER_SECOND ) ///< Maximum duration of water sample state (in ms). #define FLUSH_EXPIRATION_TIME_MS ( 10 * SEC_PER_MIN * MS_PER_SECOND ) ///< Duration in which a filter flush is valid (in ms). #define FILTER_FLUSH_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Filter flush data broadcast interval. +// Milliseconds was too big, greater than U32 +#define DG_SRVC_TIME_INTERVAL_S ( 6 * 30 * SECONDS_IN_A_DAY ) ///< DG service interval in seconds. ( 6 months with 30 days each). // ********** private data ********** @@ -71,6 +73,9 @@ static DG_STANDBY_MODE_STATE_T handleStandbyFlushFilterIdleState( void ); static DG_STANDBY_MODE_STATE_T handleStandbySampleWaterState( void ); +static BOOL isDisinfectValid( void ); +static BOOL isServiceTimeValid( void ); + /*********************************************************************//** * @brief * The initStandbyMode function initializes the standby mode module. @@ -152,7 +157,7 @@ default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_STANDBY_MODE_INVALID_EXEC_STATE, standbyState ) - standbyState = DG_STANDBY_MODE_STATE_START; + standbyState = DG_STANDBY_MODE_STATE_IDLE; break; } @@ -317,6 +322,60 @@ /*********************************************************************//** * @brief + * The isDisinfectValid function checks whether the last disinfect has been + * voided or not + * @details Inputs: none + * @details Outputs: none + * @return TRUE if the disinfect is still valid otherwise, FALSE + ***********************************************************************/ +static BOOL isDisinfectValid( void ) +{ + BOOL status = TRUE; + DG_USAGE_INFO_RECORD_T dgUsageInfo; + + // No need to check the CRC of the record because the record'sCRC has been checked in NV POST. + getNVRecord2Driver( GET_USAGE_RECORD, (U08*)&dgUsageInfo, sizeof( DG_USAGE_INFO_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + if ( FALSE == dgUsageInfo.isDisinfected ) + { + status = FALSE; + + activateAlarmNoData( ALARM_ID_DG_DISINFECT_HAS_BEEN_EXPIRED ); + } + + return status; +} + +/*********************************************************************//** + * @brief + * The isServiceTimeValid function checks whether the last service time is + * still within the interval or not. + * @details Inputs: none + * @details Outputs: none + * @return TRUE if the service time is still valid otherwise, FALSE + ***********************************************************************/ +static BOOL isServiceTimeValid( void ) +{ + BOOL status = TRUE; + DG_SERVICE_RECORD_T dgServiceRecord; + + // No need to check the CRC of the record because the record'sCRC has been checked in NV POST. + getNVRecord2Driver( GET_SRV_RECORD, (U08*)&dgServiceRecord, sizeof( DG_SERVICE_RECORD_T ), 0, ALARM_ID_NO_ALARM ); + + if ( ( ( getRTCTimestamp() - dgServiceRecord.lastServiceEpochDate ) / MS_PER_SECOND > DG_SRVC_TIME_INTERVAL_S ) || + ( 0 == dgServiceRecord.lastServiceEpochDate ) ) + { + // Compare the current time in epoch to the last service data in epoch and convert them to seconds + status = FALSE; + + activateAlarmNoData( ALARM_ID_DG_SERIVCE_TIME_INTERVAL_HAS_ELAPSED ); + } + + return status; +} + +/*********************************************************************//** + * @brief * The requestWaterSample function handles an HD request to sample water. * @details Inputs: standbyState * @details Outputs: pendingSampleWaterRequest @@ -385,10 +444,25 @@ *************************************************************************/ BOOL requestDGStart( void ) { - BOOL result = FALSE; + BOOL result = FALSE; + BOOL disinfectStatus = FALSE; + BOOL serviceStatus = FALSE; - if ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_SERVICE_AND_DISINFECT_CHECK ) ) { + disinfectStatus = TRUE; + serviceStatus = TRUE; + } + else +#endif + { + disinfectStatus = isDisinfectValid(); + serviceStatus = isServiceTimeValid(); + } + + if ( ( DG_STANDBY_MODE_STATE_IDLE == standbyState ) && ( TRUE == disinfectStatus ) && ( TRUE == serviceStatus ) ) + { result = TRUE; pendingStartDGRequest = TRUE;