Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -r5109bb981cab2025fcb9de33e303d046085efa18 -r5857de39a15c4c373c853e0856a7d7f06665848e --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 5109bb981cab2025fcb9de33e303d046085efa18) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 5857de39a15c4c373c853e0856a7d7f06665848e) @@ -58,6 +58,9 @@ // NOTE: the bad fill state must be initialized here and not in the transition function since in case of a bad fill, the transition function is called // several times to drain and fill and handle a bad fill. static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T badFillState = DG_HANDLE_BAD_FILL_STATE_START; ///< Initialize bad fill sub-state. +// NOTE: the empty bottle flag must be initialized here and not in transition function since this flag must be set to false once the empty bottle +// fill is finished. +static BOOL handleEmptyBottleFlag = FALSE; ///< Internal siganl flag to handle empty bottle flag. static U32 hdLostCommStartTime_ms; ///< Lost communication with HD start time in ms. static BOOL handleBadFillFlag; ///< Internal signal flag to handle bad fill. static OVERRIDE_U32_T genIdleDataPublicationInterval = { BAD_FILL_SUBSTATES_PUB_INTERVAL, @@ -187,7 +190,7 @@ * The setBadAvgConductivityDetectedFlag function sets a flag to indicate * that bad average conductivity is detected. * @details Inputs: none - * @details Outputs: none + * @details Outputs: handleBadFillFlag, badFillState * @param flag to TRUE if bad avg conductivity otherwise FALSE *************************************************************************/ void setBadAvgConductivityDetectedFlag( BOOL badAvgConducitivyflag ) @@ -253,8 +256,8 @@ * @brief * The handleIdleStartState function executes the start state of the * generation idle mode state machine. - * @details Inputs: none - * @details Outputs: none + * @details Inputs: handleEmptyBottleFlag + * @details Outputs: handleEmptyBottleFlag, handleBadFillFlag, badFillState * @return the next state *************************************************************************/ static DG_GEN_IDLE_MODE_STATE_T handleIdleStartState( void ) @@ -269,6 +272,14 @@ { badFillState = DG_HANDLE_BAD_FILL_STATE_START; result = DG_GEN_IDLE_MODE_STATE_FLUSH_WATER; + + if ( ( TRUE == handleEmptyBottleFlag ) && ( DG_MODE_FILL == getPreviousOperationMode() ) ) + { + // If the previous mode was fill and the empty bottle flag was TRUE, set it to FALSE and clear the informative alarm + // Done with the empty bottle handling + handleEmptyBottleFlag = FALSE; + clearAlarmCondition( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT ); + } } return result; @@ -278,14 +289,28 @@ * @brief * The handleFlushWaterState function executes the flush water state * generation idle mode state machine. - * @details Inputs: none - * @details Outputs: none + * @details Inputs: handleEmptyBottleFlag + * @details Outputs: handleEmptyBottleFlag * @return the next state *************************************************************************/ static DG_GEN_IDLE_MODE_STATE_T handleFlushWaterState( void ) { DG_GEN_IDLE_MODE_STATE_T result = DG_GEN_IDLE_MODE_STATE_FLUSH_WATER; + if ( ( TRUE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) || ( TRUE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) + { + // The empty bottle alarms are active set the empty bottle alarm to TRUE. + handleEmptyBottleFlag = TRUE; + } + else if ( ( TRUE == handleEmptyBottleFlag ) && + ( FALSE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) && + ( FALSE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) + { + // The empty bottle flag is TRUE and alarms are not active anymore. This means the user has presumably inserted the new acid and + // bicarb bottles and has hit resume. Since HD is on pause, DG has to request fill by itself. + requestNewOperationMode( DG_MODE_FILL ); + } + return result; }