Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r8e1228bfe377a61aa0c2bc9df0f0abc4b4d4ab71 -r1ed47b02f061edc8f7012f5dfc880676b010c3e3 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 8e1228bfe377a61aa0c2bc9df0f0abc4b4d4ab71) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 1ed47b02f061edc8f7012f5dfc880676b010c3e3) @@ -99,6 +99,13 @@ } setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, TRUE ); + // Ensure syringe pump is stopped + stopSyringePump(); + + // Set Dialysate valves to bypass filter for recirculation + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + setupForBloodRecirculationState(); setupForDialysateRecirculationState(); @@ -136,9 +143,6 @@ // Re-circulate dialysate side of dialyzer w/ heating to maintain temperature setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); cmdStartDGTrimmerHeater(); - // Set Dialysate valves to bypass filter for recirculation - setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); - setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); } /*********************************************************************//** @@ -155,8 +159,6 @@ // Open VBA and VBV valves to patient for blood recirculation setValvePosition( VBA, VALVE_POSITION_B_OPEN ); setValvePosition( VBV, VALVE_POSITION_B_OPEN ); - // Ensure syringe pump is stopped - stopSyringePump(); // Start blood pump at re-circulate flow rate setBloodPumpTargetFlowRate( RECIRC_BP_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); // Start air trap leveling control @@ -179,9 +181,6 @@ // Stop dialysate side of dialyzer and heating signalDialInPumpHardStop(); cmdStopDGTrimmerHeater(); - // Set Dialysate valves to bypass filter for recirculation - setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); - setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); } /*********************************************************************//** @@ -202,8 +201,6 @@ setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); // Stop air trap leveling control endAirTrapControl(); - // Ensure syringe pump is stopped - stopSyringePump(); } /*********************************************************************//** @@ -255,19 +252,21 @@ static TREATMENT_STOP_STATE_T handleTreatmentStopAlarmsAndSignals( TREATMENT_STOP_STATE_T state ) { TREATMENT_STOP_STATE_T result = state; + bool bloodRecircBlocked = isBloodRecircBlocked(); + bool dialysateRecircBlocked = isDialysateRecircBlocked(); // Both unblocked and not in recirculate both state - if ( (TREATMENT_STOP_RECIRC_STATE != state) && ( FALSE == isDialysateRecircBlocked() ) - && ( FALSE == isBloodRecircBlocked() ) ) + if ( (TREATMENT_STOP_RECIRC_STATE != state) && ( dialysateRecircBlocked ) + && ( bloodRecircBlocked ) ) { setupForBloodRecirculationState(); setupForDialysateRecirculationState(); result = TREATMENT_STOP_RECIRC_STATE; } // Both blocked and not in stopped state - if ( (TREATMENT_STOP_NO_RECIRC_STATE != state) && ( TRUE == isDialysateRecircBlocked() ) - && ( TRUE == isBloodRecircBlocked() ) ) + if ( (TREATMENT_STOP_NO_RECIRC_STATE != state) && ( dialysateRecircBlocked ) + && ( bloodRecircBlocked ) ) { setupForBloodRecirculationStopState(); setupForDialysateRecirculationStopState(); @@ -276,17 +275,17 @@ // Dialysate recirculation blocked and not in blood recirc state if ( ( TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE != state ) - && ( TRUE == isDialysateRecircBlocked() ) - && ( FALSE == isBloodRecircBlocked() ) ) + && ( dialysateRecircBlocked ) + && ( bloodRecircBlocked ) ) { setupForDialysateRecirculationStopState(); result = TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE; } // Blood recirculation blocked and not in dialysate recirc state if ( ( TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE != state ) - && ( TRUE == isBloodRecircBlocked() ) - && ( FALSE == isDialysateRecircBlocked() ) ) + && ( bloodRecircBlocked ) + && ( dialysateRecircBlocked ) ) { setupForBloodRecirculationStopState(); result = TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE; @@ -429,7 +428,7 @@ if ( getRinsebackCompleted() != TRUE ) { - if (0 < bloodSittingTimerCtr) + if ( bloodSittingTimerCtr > 0 ) { data.timeout = MAX_TIME_BLOOD_SITTING / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ); data.countdown = ( bloodSittingTimerCtr >= MAX_TIME_BLOOD_SITTING ? 0 : ( MAX_TIME_BLOOD_SITTING - bloodSittingTimerCtr ) / ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) );