Index: firmware/App/Modes/ModeFill.c =================================================================== diff -u -r9c3746ecf75ef64d6fc0e0e9510af9d84763cb18 -ra06e2c94a2c49609972b28f7ccd0647baabdb9b1 --- firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision 9c3746ecf75ef64d6fc0e0e9510af9d84763cb18) +++ firmware/App/Modes/ModeFill.c (.../ModeFill.c) (revision a06e2c94a2c49609972b28f7ccd0647baabdb9b1) @@ -83,6 +83,7 @@ static DG_FILL_MODE_STATE_T handleAcidPumpCheckState( void ); static DG_FILL_MODE_STATE_T handleDialysateProductionState( void ); static DG_FILL_MODE_STATE_T handleDeliverDialysateState( void ); +static DG_FILL_MODE_STATE_T handlePausedState( void ); static void handleDialysateMixing( void ); @@ -183,6 +184,10 @@ fillState = handleDeliverDialysateState(); break; + case DG_FILL_MODE_STATE_PAUSED: + fillState = handlePausedState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_FILL_MODE_INVALID_EXEC_STATE, fillState ) fillState = DG_FILL_MODE_STATE_START; @@ -363,7 +368,7 @@ * @brief * The handleDialysateProductionState function executes the dialysate production * state of the fill mode state machine. - * @details Inputs: none + * @details Inputs: Dialysate conditions * @details Outputs: none * @return the next state *************************************************************************/ @@ -381,14 +386,47 @@ result = DG_FILL_MODE_STATE_DELIVER_DIALYSATE; } + if ( checkDialysateConductivity() != TRUE ) + { + if ( ( TRUE == isAlarmActive( ALARM_ID_ACID_CONDUCTIVITY_OUT_OF_RANGE ) ) || + ( TRUE == isAlarmActive( ALARM_ID_DIALYSATE_CONDUCTIVITY_OUT_OF_RANGE ) ) ) + { + result = DG_FILL_MODE_STATE_PAUSED; + } + } + return result; } /*********************************************************************//** * @brief + * The handlePausedState function executes the paused state of the fill + * mode state machine. + * @details Inputs: Dialysate conditions + * @details Outputs: none + * @return the next state + *************************************************************************/ +static DG_FILL_MODE_STATE_T handlePausedState( void ) +{ + DG_FILL_MODE_STATE_T result = DG_FILL_MODE_STATE_PAUSED; + + if ( TRUE == checkDialysateConductivity() ) + { + if ( ( isAlarmActive( ALARM_ID_ACID_CONDUCTIVITY_OUT_OF_RANGE ) != TRUE ) && + ( isAlarmActive( ALARM_ID_DIALYSATE_CONDUCTIVITY_OUT_OF_RANGE ) ) != TRUE ) + { + result = DG_FILL_MODE_STATE_CHECK_INLET_WATER; + } + } + + return result; +} + +/*********************************************************************//** + * @brief * The handleDeliverDialysateState function executes the deliver dialysate * state of the fill mode state machine. - * @details Inputs: none + * @details Inputs: Dialysate conditions * @details Outputs: Deliver dialysate * @return the next state *************************************************************************/ @@ -412,7 +450,7 @@ #endif } - if ( getReservoirWeight( inactiveReservoir ) >= ONE_LITER_WEIGHT_GRAMS ) + if ( ( getReservoirWeight( inactiveReservoir ) - reservoirBaseWeight ) >= ONE_LITER_WEIGHT_GRAMS ) { avgDialysateConductivity = dialysateConductivityTotal / dialysateConductivitySampleCount;