Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -r24e8fcb5744724be72ea26bebd95ec594c2c26fe -ra1452dc7f16d37db53930c3d73992098709d7915 --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 24e8fcb5744724be72ea26bebd95ec594c2c26fe) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision a1452dc7f16d37db53930c3d73992098709d7915) @@ -47,10 +47,14 @@ #define TARGET_FLUSH_LINES_RO_FLOW_RATE_L 0.6 ///< Target flow rate for RO pump. +/// The time of HD lost comm before DG transition back to standby. +#define HD_LOST_COMM_TIMEOUT_MS (5 * SEC_PER_MIN * MS_PER_SECOND ) + // ********** private data ********** static DG_GEN_IDLE_MODE_STATE_T genIdleState; ///< Currently active generation idle state. static F32 flushLinesVolumeL = 0.0; ///< Volume of water pumped by RO pump during flush lines state. +static U32 hdLostCommStartTime_ms = 0; ///< Lost communication with HD start time in ms. // ********** private function prototypes ********** @@ -68,6 +72,7 @@ { genIdleState = DG_GEN_IDLE_MODE_STATE_START; flushLinesVolumeL = 0.0; + hdLostCommStartTime_ms = 0; } /*********************************************************************//** @@ -123,10 +128,17 @@ checkRORejectionRatio(); // Transition to standby mode when HD is not communicating - if ( FALSE == isHDCommunicating() ) + if ( TRUE == isHDCommunicating() ) { - requestNewOperationMode( DG_MODE_STAN ); + hdLostCommStartTime_ms = getMSTimerCount(); } + else + { + if ( TRUE == didTimeout( hdLostCommStartTime_ms, HD_LOST_COMM_TIMEOUT_MS ) ) + { + requestNewOperationMode( DG_MODE_STAN ); + } + } // Execute current generation idle state switch ( genIdleState )