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?