Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r4f719d9dfc6b14be6601d7aa1b3dabb5eb3af73a -r7c8d739514d6c314aef7e7c2d26be41c81ff1236 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 4f719d9dfc6b14be6601d7aa1b3dabb5eb3af73a) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 7c8d739514d6c314aef7e7c2d26be41c81ff1236) @@ -23,6 +23,7 @@ #include "DialOutFlow.h" #include "ModeTreatment.h" #include "OperationModes.h" +#include "Reservoirs.h" #include "SystemCommMessages.h" #include "TaskGeneral.h" #include "TreatmentStop.h" Index: firmware/App/Services/Reservoirs.c =================================================================== diff -u -r4f719d9dfc6b14be6601d7aa1b3dabb5eb3af73a -r7c8d739514d6c314aef7e7c2d26be41c81ff1236 --- firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 4f719d9dfc6b14be6601d7aa1b3dabb5eb3af73a) +++ firmware/App/Services/Reservoirs.c (.../Reservoirs.c) (revision 7c8d739514d6c314aef7e7c2d26be41c81ff1236) @@ -106,7 +106,7 @@ static void calculateActiveReservoirCycleTime( void ); static F32 getReservoirRecirculationMaxPercent( void ); static void publishReservoirData( void ); -static BOOL isDialysateTempAlarmsActive( void ); +static BOOL isDialysateTempAlarmActive( void ); static TREATMENT_RESERVOIR_MGMT_STATE_T handleReservoirMgmtStartState( void ); static TREATMENT_RESERVOIR_MGMT_STATE_T handleReservoirMgmtDrainState( void ); @@ -552,6 +552,14 @@ cmdStartDGFill( FILL_RESERVOIR_TO_VOLUME_ML, targetFillFlowRateLPM ); } } + // If we have active dialysate temp alarms, we want to fill immediately. + else if ( TRUE == isDialysateTempAlarmActive() ) + { + if ( DG_GEN_IDLE_MODE_STATE_FLUSH_WATER == dgSubMode ) + { + cmdStartDGFill( FILL_RESERVOIR_TO_VOLUME_ML, targetFillFlowRateLPM ); + } + } else { // Time to wait prior to next fill is depletion time - the whole group of how much time is needed to fill a reservoir + @@ -635,33 +643,55 @@ dilutionLevelPct = volSpentUFML / (F32)FILL_RESERVOIR_TO_VOLUME_ML; // Wait for the reservoir to settle and then send the commands to switch the active reservoir - if ( ( TRUE == didTimeout( reservoirSwitchStartTimeMS, RESERVOIR_FRESH_SETTLE_TIME_MS ) ) && - ( ( dilutionLevelPct >= MAX_RESERVOIR_DILUTION ) || ( volSpentML >= (F32)FILL_RESERVOIR_TO_VOLUME_ML ) || ( getReservoirWeight( active ) > MAX_RESERVOIR_VOL_BEFORE_SWITCH_ML ) ) ) + if ( TRUE == didTimeout( reservoirSwitchStartTimeMS, RESERVOIR_FRESH_SETTLE_TIME_MS ) ) { DG_SWITCH_RSRVRS_CMD_T rsrvrCmd; DG_RESERVOIR_ID_T inactiveRes = getDGInactiveReservoir(); rsrvrCmd.reservoirID = (U32)inactiveRes; rsrvrCmd.useLastTrimmerHeaterDC = TRUE; - // Signal dialysis sub-mode to capture baseline volume for next reservoir. - setStartReservoirVolume( inactiveRes ); + if( ( dilutionLevelPct >= MAX_RESERVOIR_DILUTION ) || ( volSpentML >= (F32)FILL_RESERVOIR_TO_VOLUME_ML ) || ( getReservoirWeight( active ) > MAX_RESERVOIR_VOL_BEFORE_SWITCH_ML ) ) + { + // Signal dialysis sub-mode to capture baseline volume for next reservoir. + setStartReservoirVolume( inactiveRes ); - // Command DG to switch reservoirs - cmdSetDGActiveReservoir( &rsrvrCmd ); + // Command DG to switch reservoirs + cmdSetDGActiveReservoir( &rsrvrCmd ); - // Signal dialysis sub-mode to switch reservoirs - signalReservoirsSwitched(); + // Signal dialysis sub-mode to switch reservoirs + signalReservoirsSwitched(); - // Get ready for the next delivery - volSpentML = 0.0; + // Get ready for the next delivery + volSpentML = 0.0; - // Wait for used reservoir to settle - reservoirSwitchStartTimeMS = getMSTimerCount(); + // Wait for used reservoir to settle + reservoirSwitchStartTimeMS = getMSTimerCount(); - state = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE; + state = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE; + } + else if ( TRUE == isDialysateTempAlarmActive() ) + { + // Signal dialysis sub-mode to capture baseline volume for next reservoir. + setStartReservoirVolume( inactiveRes ); + + // Command DG to switch reservoirs + cmdSetDGActiveReservoir( &rsrvrCmd ); + + // Signal dialysis sub-mode to switch reservoirs + signalReservoirsSwitched(); + + // Get ready for the next delivery + volSpentML = 0.0; + + // Wait for used reservoir to settle + reservoirSwitchStartTimeMS = getMSTimerCount(); + + state = TREATMENT_RESERVOIR_MGMT_WAIT_FOR_SWITCH_SETTLE_STATE; + } } + return state; } @@ -696,18 +726,19 @@ /*********************************************************************//** * @brief - * The isDialysateTempAlarmsActive function checks for active dialysate + * The isDialysateTempAlarmActive function checks for active dialysate * temperature alarms * @details Inputs: none * @details Outputs: none * @return True if dialysate temperature alarm is active. False if not. *************************************************************************/ -static BOOL isDialysateTempAlarmsActive( void ) +static BOOL isDialysateTempAlarmActive( void ) { BOOL result = FALSE; - if ( TRUE == isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP ) || + if ( ( TREATMENT_STOP_STATE == getTreatmentState() ) && + ( TRUE == isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_BELOW_TARGET_TEMP ) || TRUE == isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_SAFETY_TEMP ) || - TRUE == isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP ) ) + TRUE == isAlarmActive( ALARM_ID_HD_DIALYSATE_TEMP_ABOVE_TARGET_TEMP ) ) ) { result = TRUE; }