Index: firmware/App/Modes/ModeDrain.c =================================================================== diff -u -r557f409455dde035899c9f89a8b93f57e8eb7f2b -ref46e2aa7eba74dabd99bfcd9e6b38b8ce77820c --- firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision 557f409455dde035899c9f89a8b93f57e8eb7f2b) +++ firmware/App/Modes/ModeDrain.c (.../ModeDrain.c) (revision ef46e2aa7eba74dabd99bfcd9e6b38b8ce77820c) @@ -250,13 +250,18 @@ if ( TRUE == isEmptyAcidBottle() ) { activateAlarmNoData( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ); // trigger empty acid bottle alarm + setBottlesNeedPrimeFlag( TRUE ); } else if ( TRUE == isEmptyBicarbBottle() ) { + setBottlesNeedPrimeFlag( TRUE ); activateAlarmNoData( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ); // trigger empty bicarb bottle alarm } - - requestNewOperationMode( DG_MODE_GENE ); + else if ( ( FALSE == isAlarmActive( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ) ) || + ( FALSE == isAlarmActive( ALARM_ID_DG_BICARB_BOTTLE_LOW_VOLUME ) ) ) + { + requestNewOperationMode( DG_MODE_GENE ); + } } } Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r557f409455dde035899c9f89a8b93f57e8eb7f2b -ref46e2aa7eba74dabd99bfcd9e6b38b8ce77820c --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 557f409455dde035899c9f89a8b93f57e8eb7f2b) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision ef46e2aa7eba74dabd99bfcd9e6b38b8ce77820c) @@ -414,7 +414,27 @@ /*********************************************************************//** * @brief - * The isEmptyBottle function returns the boolean flag that indicates + * The isBadFill function returns the boolean flag that indicates + * whether the bad fill is detected at the end of the fill mode. + * @details Inputs: none + * @details Outputs: none + * @return TRUE if bad fill, otherwise FALSE + *************************************************************************/ +BOOL isBadFill( void ) +{ + BOOL badFillFlag = FALSE; + + if ( TRUE == isAvgConductivityOutOfRange() ) + { + badFillFlag = TRUE; + } + + return badFillFlag; +} + +/*********************************************************************//** + * @brief + * The isEmptyAcidBottle function returns the boolean flag that indicates * whether the acid bottle is empty. * @details Inputs: none * @details Outputs: none @@ -427,7 +447,7 @@ /*********************************************************************//** * @brief - * The isEmptyBottle function returns the boolean flag that indicates + * The isEmptyBicarbBottle function returns the boolean flag that indicates * whether the bicarb bottle is empty. * @details Inputs: none * @details Outputs: none @@ -779,7 +799,7 @@ setValveState( VPO, VALVE_STATE_NOFILL_C_TO_NO ); //activateAlarmNoData( ALARM_ID_DG_ACID_BOTTLE_LOW_VOLUME ); // trigger empty acid bottle alarm at the end of drain mode and set both bottles need prime fillStatus.isThisFirstFill = TRUE; // empty bottles need replaced, set isThisFirstFill to FALSE so that prime, flush, acid & bicarb test are needed - fillStatus.fillEmtyAcidBottleDetected = TRUE; // set this variable to FALSE when user presses OK on the alarm to confirm bottle has been replaced and resume + fillStatus.fillEmtyAcidBottleDetected = TRUE; // set this variable to FALSE when user presses OK on the alarm to confirm bottle has been replaced and resume //requestNewOperationMode( DG_MODE_GENE ); } @@ -817,22 +837,23 @@ #ifndef DISABLE_DIALYSATE_CHECK // SRSDG 400 if ( TRUE == isValueWithinPercentRange( avgBicardConductivity, BICARB_NORMAL_CONDUCTIVITY, FIVE_PERCENT_FACTOR ) ) { - fillStatus.fillAvgConductivityOutOfRange = TRUE; // signal idle mode to handle bad fill + fillStatus.fillAvgConductivityOutOfRange = TRUE; // flag to signal idle mode to handle bad fill fillStatus.isThisFirstFill = TRUE; setBottlesNeedPrimeFlag( TRUE ); - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DIALYSATE_CONDUCTIVITY_FAULT, avgBicardConductivity, BICARB_NORMAL_CONDUCTIVITY ); - requestNewOperationMode( DG_MODE_GENE ); // leave fill mode if bad fill is detected due to avg bicarb is out of range + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_REPLACE_CONCENTRATE_BOTTLES, avgBicardConductivity, BICARB_NORMAL_CONDUCTIVITY ); // trigger replace bottles alarm #1 + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_CREATING_DIALYSATE_PLEASE_WAIT, avgBicardConductivity, BICARB_NORMAL_CONDUCTIVITY ); // immediately trigger wait for dialysate alarm #2 + requestNewOperationMode( DG_MODE_GENE ); // leave fill mode and go to idle } if ( TRUE == isValueWithinPercentRange( avgAcidConductivity, ACID_NORMAL_CONDUCTIVITY, FIVE_PERCENT_FACTOR ) ) { - fillStatus.fillAvgConductivityOutOfRange = TRUE; // signal idle mode to handle bad fill + fillStatus.fillAvgConductivityOutOfRange = TRUE; // flag to signal idle mode to handle bad fill fillStatus.isThisFirstFill = TRUE; setBottlesNeedPrimeFlag( TRUE ); - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DIALYSATE_CONDUCTIVITY_FAULT, avgAcidConductivity, ACID_NORMAL_CONDUCTIVITY ); - requestNewOperationMode( DG_MODE_GENE ); // leave fill mode if bad fill is detected due to avg acid out of range + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_REPLACE_CONCENTRATE_BOTTLES, avgAcidConductivity, ACID_NORMAL_CONDUCTIVITY ); // trigger replace bottles alarm #1 then + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_CREATING_DIALYSATE_PLEASE_WAIT, avgAcidConductivity, ACID_NORMAL_CONDUCTIVITY ); // immediately trigger wait for dialysate alarm #2 + requestNewOperationMode( DG_MODE_GENE ); // leave fill mode and go to idle } - #endif // Done with this fill. Calculate the average fill flow rate and average temperature // Reset the variables for the next fill Index: firmware/App/Modes/ModeFill.h =================================================================== diff -u -r557f409455dde035899c9f89a8b93f57e8eb7f2b -ref46e2aa7eba74dabd99bfcd9e6b38b8ce77820c --- firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision 557f409455dde035899c9f89a8b93f57e8eb7f2b) +++ firmware/App/Modes/ModeFill.h (.../ModeFill.h) (revision ef46e2aa7eba74dabd99bfcd9e6b38b8ce77820c) @@ -57,6 +57,8 @@ BOOL isEmptyBicarbBottle( void ); +BOOL isBadFill( void ); + BOOL isAvgConductivityOutOfRange( void ); BOOL testSetUsedAcidVolumeMLOverride( F32 value ); Index: firmware/App/Modes/ModeGenIdle.c =================================================================== diff -u -r557f409455dde035899c9f89a8b93f57e8eb7f2b -ref46e2aa7eba74dabd99bfcd9e6b38b8ce77820c --- firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision 557f409455dde035899c9f89a8b93f57e8eb7f2b) +++ firmware/App/Modes/ModeGenIdle.c (.../ModeGenIdle.c) (revision ef46e2aa7eba74dabd99bfcd9e6b38b8ce77820c) @@ -219,7 +219,7 @@ { DG_GEN_IDLE_MODE_STATE_T result = DG_GEN_IDLE_MODE_STATE_START; - if ( TRUE == isAvgConductivityOutOfRange() ) // bad fill due to conductivity is out of range and assume bottles need prime + if ( TRUE == isBadFill() ) // bad fill due to conductivity is out of range and assume bottles need prime { result = DG_GEN_IDLE_MODE_STATE_HANDLE_BAD_FILL ; } @@ -250,8 +250,8 @@ * @brief * The handleBadFillState function executes the bad fill state of the * generation idle mode state machine. - * @details Inputs: - * @details Outputs: + * @details Inputs: none + * @details Outputs: badFillState * @return the next state *************************************************************************/ static DG_GEN_IDLE_MODE_STATE_T handleBadFillState( void ) @@ -298,8 +298,8 @@ * @brief * The handleFirstDrainState function executes the first drain state of the * handle bad fill state machine. - * @details Inputs: - * @details Outputs: + * @details Inputs: none + * @details Outputs: none * @return the next state *************************************************************************/ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFirstDrainState( void ) @@ -316,8 +316,8 @@ * @brief * The handleFlushFillState function executes the flush fill state of the * handle bad fill state machine. - * @details Inputs: - * @details Outputs: + * @details Inputs: none + * @details Outputs: none * @return the next state *************************************************************************/ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleFlushFillState( void ) @@ -334,8 +334,8 @@ * @brief * The handleSecondDrainState function executes the second drain state of the * handle bad fill state machine. - * @details Inputs: - * @details Outputs: + * @details Inputs: none + * @details Outputs: none * @return the next state *************************************************************************/ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleSecondDrainState( void ) @@ -350,10 +350,10 @@ /*********************************************************************//** * @brief - * The handleRefillState function executes refill state of the - * handle bad fill state machine. - * @details Inputs: - * @details Outputs: + * The handleRefillState function executes refill state of the handle bad + * fill state machine. + * @details Inputs: none + * @details Outputs: none * @return the next state *************************************************************************/ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleRefillState( void ) @@ -370,15 +370,16 @@ * @brief * The handleClearAlarmState function executes the clear alarm state of the * handle bad fill state machine. - * @details Inputs: - * @details Outputs: + * @details Inputs: none + * @details Outputs: none * @return the next state *************************************************************************/ static DG_GEN_IDLE_MODE_BAD_FILL_STATE_T handleClearAlarmState( void ) { DG_GEN_IDLE_MODE_BAD_FILL_STATE_T result = DG_HANDLE_BAD_FILL_STATE_CLEAR_ALARM; - // clear "Wait for dialysate alarm" before resume to normal state + // clear wait for dialysate alarm condition to allow resume + clearAlarmCondition( ALARM_ID_CREATING_DIALYSATE_PLEASE_WAIT ); // resume option will appear requestNewOperationMode( DG_MODE_GENE ); // go to generation idle mode return result;