Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -rc3ad9ff5401aed42da66a2f47c7d02332f9fd1b5 -r0b800d3abb747d0f1f3dc8f67777efb9631c18e0 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision c3ad9ff5401aed42da66a2f47c7d02332f9fd1b5) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 0b800d3abb747d0f1f3dc8f67777efb9631c18e0) @@ -410,11 +410,14 @@ *************************************************************************/ void signalBloodPumpHardStop( void ) { - targetBloodFlowRate = 0; - stopBloodPump(); - bloodPumpState = BLOOD_PUMP_OFF_STATE; + bloodPumpControlMode = PUMP_CONTROL_MODE_OPEN_LOOP; + bloodPumpDirection = MOTOR_DIR_FORWARD; bloodPumpPWMDutyCyclePct = BP_PWM_ZERO_OFFSET; + bloodPumpState = BLOOD_PUMP_OFF_STATE; bpControlTimerCounter = 0; + targetBloodFlowRate = 0; + resetBloodPumpRPMMovingAverage(); + stopBloodPump(); resetPIController( PI_CONTROLLER_ID_BLOOD_FLOW, MIN_BLOOD_PUMP_PWM_DUTY_CYCLE ); } Index: firmware/App/Controllers/DialInFlow.c =================================================================== diff -u -r9353792f6dbd624a1d55cf1e87fa848e8fbaea71 -r0b800d3abb747d0f1f3dc8f67777efb9631c18e0 --- firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 9353792f6dbd624a1d55cf1e87fa848e8fbaea71) +++ firmware/App/Controllers/DialInFlow.c (.../DialInFlow.c) (revision 0b800d3abb747d0f1f3dc8f67777efb9631c18e0) @@ -406,11 +406,14 @@ *************************************************************************/ void signalDialInPumpHardStop( void ) { - targetDialInFlowRate = 0; - stopDialInPump(); - dialInPumpState = DIAL_IN_PUMP_OFF_STATE; + dialInPumpControlMode = PUMP_CONTROL_MODE_OPEN_LOOP; + dialInPumpDirection = MOTOR_DIR_FORWARD; dialInPumpPWMDutyCyclePct = DIP_PWM_ZERO_OFFSET; + dialInPumpState = DIAL_IN_PUMP_OFF_STATE; dipControlTimerCounter = 0; + targetDialInFlowRate = 0; + resetDialInFlowMovingAverage(); + stopDialInPump(); resetPIController( PI_CONTROLLER_ID_DIALYSATE_FLOW, MIN_DIAL_IN_PUMP_PWM_DUTY_CYCLE ); } Index: firmware/App/Controllers/DialOutFlow.c =================================================================== diff -u -r9353792f6dbd624a1d55cf1e87fa848e8fbaea71 -r0b800d3abb747d0f1f3dc8f67777efb9631c18e0 --- firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 9353792f6dbd624a1d55cf1e87fa848e8fbaea71) +++ firmware/App/Controllers/DialOutFlow.c (.../DialOutFlow.c) (revision 0b800d3abb747d0f1f3dc8f67777efb9631c18e0) @@ -434,11 +434,14 @@ *************************************************************************/ void signalDialOutPumpHardStop( void ) { - lastGivenRate = 0; - stopDialOutPump(); - dialOutPumpState = DIAL_OUT_PUMP_OFF_STATE; + dialOutPumpControlMode = PUMP_CONTROL_MODE_OPEN_LOOP; + dialOutPumpDirection = MOTOR_DIR_FORWARD; dialOutPumpPWMDutyCyclePct = DOP_PWM_ZERO_OFFSET; + dialOutPumpState = DIAL_OUT_PUMP_OFF_STATE; + dopControlSignal = FALSE; + lastGivenRate = 0; resetDialOutFlowMovingAverage(); + stopDialOutPump(); } /*********************************************************************//** Index: firmware/App/Modes/TreatmentRecirc.c =================================================================== diff -u -r98cc51d12256e9e9d63632d0206e9cd6e5b92429 -r0b800d3abb747d0f1f3dc8f67777efb9631c18e0 --- firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 98cc51d12256e9e9d63632d0206e9cd6e5b92429) +++ firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 0b800d3abb747d0f1f3dc8f67777efb9631c18e0) @@ -51,13 +51,15 @@ static BOOL recircBackToTreatmenRequested; ///< Flag indicates user requesting to go back to treatment (confirming re-connected). static BOOL recircResumeRequested; ///< Flag indicates user requesting resumption of re-circulating. static BOOL recircEndTreatmentRequested; ///< Flag indicates user requesting end of treatment. +static BOOL recircStopTreatmentRequested; ///< Flag indicates user requesting end of treatment. // ********** private function prototypes ********** static void resetTreatmentRecircFlags( void ); static void setupForRecirculationState( void ); -static void setupForRecirculationStopState( void ); +static void setupForBloodRecirculationStopState( void ); +static void setupForDialysateRecirculationStopState( void ); static TREATMENT_RECIRC_STATE_T handleRecircDisconnectPatientState( void ); static TREATMENT_RECIRC_STATE_T handleRecircRecircState( void ); @@ -101,6 +103,7 @@ recircBackToTreatmenRequested = FALSE; recircResumeRequested = FALSE; recircEndTreatmentRequested = FALSE; + recircStopTreatmentRequested = ( ( FALSE == isBloodRecircBlocked() ) || ( FALSE == isDialysateRecircBlocked() ) )? FALSE:recircStopTreatmentRequested; } /*********************************************************************//** @@ -117,21 +120,13 @@ setCurrentSubState( (U32)treatmentRecircState ); doorClosedRequired( TRUE, TRUE ); - // Set valves to safe state - setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); - setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); - setupForRecirculationStopState(); - // Disable venous bubble detection while recirculating setVenousBubbleDetectionEnabled( FALSE ); // Ensure syringe pump is stopped stopSyringePump(); // Stop air trap leveling control endAirTrapControl(); - // 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 user alarm recovery actions allowed in this sub-mode setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); @@ -150,6 +145,15 @@ *************************************************************************/ static void setupForRecirculationState( void ) { + + // Set valves to safe state, Dialysate bypass + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + + // 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(); + // Open VBA and VBV valves to allow flow from saline bag and to patient venous line setValvePosition( VBA, VALVE_POSITION_B_OPEN ); setValvePosition( VBV, VALVE_POSITION_B_OPEN ); @@ -159,17 +163,34 @@ /*********************************************************************//** * @brief - * The setupForRecirculationStopState function sets actuators appropriately + * The setupForDialysateRecirculationStopState function sets actuators appropriately * for re-circulation stopped state. * @details Inputs: none + * @details Outputs: DialIn pump stopped and Heater off + * @return none + *************************************************************************/ +static void setupForDialysateRecirculationStopState( void ) +{ + // Stop dialysate side of dialyzer and heating + signalDialInPumpHardStop(); + cmdStopDGTrimmerHeater(); + +} + +/*********************************************************************//** + * @brief + * The setupForBloodRecirculationStopState function sets actuators appropriately + * for re-circulation stopped state. + * @details Inputs: none * @details Outputs: Blood pump stopped, arterial and venous lines closed, - * and air trap leveling control is stopped. + * and air trap leveling control is stopped. DialIn Pump and Heater off * @return none *************************************************************************/ -static void setupForRecirculationStopState( void ) +static void setupForBloodRecirculationStopState( void ) { // Stop blood pump signalBloodPumpHardStop(); + // Close arterial and venous lines setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); @@ -261,19 +282,19 @@ // Is alarm stop? if ( TRUE == doesAlarmStatusIndicateStop() ) { - setupForRecirculationStopState(); + setupForBloodRecirculationStopState(); result = TREATMENT_RECIRC_STOPPED_STATE; } // Is user reconnect requested? else if ( TRUE == recircReconnectRequested ) { - setupForRecirculationStopState(); + setupForBloodRecirculationStopState(); result = TREATMENT_RECIRC_RECONNECT_PATIENT_STATE; } // Is end treatment requested? else if ( TRUE == recircEndTreatmentRequested ) { - setupForRecirculationStopState(); + setupForBloodRecirculationStopState(); signalEndTreatment(); // signal end Tx sub-mode } @@ -292,6 +313,14 @@ { TREATMENT_RECIRC_STATE_T result = TREATMENT_RECIRC_STOPPED_STATE; + // Both blocked and not in stopped state + if ( ( FALSE == recircStopTreatmentRequested ) && ( TRUE == isDialysateRecircBlocked() ) && ( TRUE == isBloodRecircBlocked() ) ) + { + setupForBloodRecirculationStopState(); + setupForDialysateRecirculationStopState(); + recircStopTreatmentRequested = TRUE; + } + // Is end treatment requested? if ( TRUE == recircEndTreatmentRequested ) { @@ -327,7 +356,7 @@ // Is end treatment requested? else if ( TRUE == recircEndTreatmentRequested ) { - setupForRecirculationStopState(); + setupForBloodRecirculationStopState(); signalEndTreatment(); // signal end Tx sub-mode } // Is re-circ resume requested?