Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -reca8d3222a8fbcda268c8ea1c004dfe0a7ed30db -r965a35a61959999274bbff47c74e439639d32b1d --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision eca8d3222a8fbcda268c8ea1c004dfe0a7ed30db) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 965a35a61959999274bbff47c74e439639d32b1d) @@ -58,9 +58,11 @@ // 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 BOOL handleEmptyBottleFlag; ///< Internal siganl flag to handle empty bottle flag. static OVERRIDE_U32_T genIdleDataPublicationInterval = { BAD_FILL_SUBSTATES_PUB_INTERVAL, BAD_FILL_SUBSTATES_PUB_INTERVAL, 0, 0 }; ///< Interval (in ms) at which to publish bad fill sub-states to CAN bus. @@ -199,32 +201,6 @@ /*********************************************************************//** * @brief - * The setEmptyBottleDetectedFlag function sets a flag to indicate - * that empty bottle flag has been detected. - * @details Inputs: none - * @details Outputs: handleEmptyBottleFlag - * @param flag to TRUE if empty bottle flag is TRUE otherwise FALSE - *************************************************************************/ -void setEmptyBottleDetectedFlag( BOOL emptyBottleFlag ) -{ - handleEmptyBottleFlag = emptyBottleFlag; -} - -/*********************************************************************//** - * @brief - * The getEmpytBottleDetectedFlag function returns the status of the empty - * bottle detected flag. - * @details Inputs: handleEmptyBottleFlag - * @details Outputs: none - * @return the status of the empty bottle flag - *************************************************************************/ -BOOL getEmpytBottleDetectedFlag( void ) -{ - return handleEmptyBottleFlag; -} - -/*********************************************************************//** - * @brief * The execGenIdleMode function executes the generation idle mode state machine. * @details Inputs: genIdleState * @details Outputs: Check water quality, generation idle mode state machine executed @@ -296,6 +272,12 @@ { badFillState = DG_HANDLE_BAD_FILL_STATE_START; result = DG_GEN_IDLE_MODE_STATE_FLUSH_WATER; + + if ( ( TRUE == handleEmptyBottleFlag ) && ( DG_MODE_FILL == getPreviousOperationMode() ) ) + { + handleEmptyBottleFlag = FALSE; + clearAlarmCondition( ALARM_ID_DG_CREATING_DIALYSATE_PLEASE_WAIT ); + } } return result; @@ -313,10 +295,16 @@ { DG_GEN_IDLE_MODE_STATE_T result = DG_GEN_IDLE_MODE_STATE_FLUSH_WATER; - if ( TRUE == handleEmptyBottleFlag ) + if ( ( TRUE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) || ( TRUE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) { // Empty bottle flag is TRUE and HD is on pause. So HD will not request a fill and it is // commanded to fill. + handleEmptyBottleFlag = TRUE; + } + else if ( ( TRUE == handleEmptyBottleFlag ) && + ( FALSE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) && + ( FALSE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) + { requestNewOperationMode( DG_MODE_FILL ); }