Index: firmware/App/Modes/TreatmentStop.c =================================================================== diff -u -r1f91b5a53bda942b0967817bbd5e68a499dbf816 -r75e1ae332d1446dddf9b8d4ce6e8317449c57d67 --- firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 1f91b5a53bda942b0967817bbd5e68a499dbf816) +++ firmware/App/Modes/TreatmentStop.c (.../TreatmentStop.c) (revision 75e1ae332d1446dddf9b8d4ce6e8317449c57d67) @@ -37,8 +37,6 @@ /// Treatment stop status broadcast interval. #define TREATMENT_STOP_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) -/// Target flow rate for re-circulation of saline on blood-side circuit. -#define RECIRC_BP_FLOW_RATE_ML_MIN 100 // ********** private data ********** @@ -71,7 +69,7 @@ *************************************************************************/ void initTreatmentStop( void ) { - currentTxStopState = TREATMENT_STOP_RECIRC_STATE; + currentTxStopState = TREATMENT_STOP_RECIRC_STATE; // Assume blood and dialysate will recirculate initially - will stop pump(s) as appropriate in state machine bloodSittingTimerCtr = 0; stopPublishTimerCtr = TREATMENT_STOP_DATA_PUBLISH_INTERVAL; } @@ -102,9 +100,6 @@ 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 ); @@ -160,12 +155,23 @@ *************************************************************************/ static void setupForBloodRecirculationState( void ) { + PUMP_CONTROL_MODE_T mode = PUMP_CONTROL_MODE_CLOSED_LOOP; + +#ifndef _RELEASE_ + if ( SW_CONFIG_ENABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_ENABLE_BLOOD_PUMP_OPEN_LOOP ) ) + { + mode = PUMP_CONTROL_MODE_OPEN_LOOP; + } +#endif + doorClosedRequired( TRUE, TRUE ); // Open VBA and VBV valves to patient for blood recirculation setValvePosition( VBA, VALVE_POSITION_B_OPEN ); setValvePosition( VBV, VALVE_POSITION_B_OPEN ); - // Start blood pump at re-circulate flow rate - setBloodPumpTargetFlowRate( RECIRC_BP_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + // Start blood pump at prescribed flow rate + setBloodPumpTargetFlowRate( getTreatmentParameterU32( TREATMENT_PARAM_BLOOD_FLOW ), MOTOR_DIR_FORWARD, mode ); + // Start Heparin pump as appropriate + startHeparinPump(); // Start air trap leveling control startAirTrapControl(); // Reset blood sitting timer, it is now circulating @@ -201,6 +207,8 @@ { // Stop blood pump signalBloodPumpHardStop(); + // Stop syringe pump + stopSyringePump(); // Close arterial and venous lines setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); @@ -267,36 +275,34 @@ BOOL dialysateRecircBlocked = isDialysateRecircBlocked(); // Both unblocked and not in recirculate both state - if ( (TREATMENT_STOP_RECIRC_STATE != state) && ( FALSE == dialysateRecircBlocked ) - && ( FALSE == bloodRecircBlocked ) ) + if ( ( TREATMENT_STOP_RECIRC_STATE != state ) && ( FALSE == dialysateRecircBlocked ) && ( FALSE == bloodRecircBlocked ) ) { setupForBloodRecirculationState(); setupForDialysateRecirculationState(); result = TREATMENT_STOP_RECIRC_STATE; } // Both blocked and not in stopped state - if ( (TREATMENT_STOP_NO_RECIRC_STATE != state) && ( TRUE == dialysateRecircBlocked ) - && ( TRUE == bloodRecircBlocked ) ) + if ( ( TREATMENT_STOP_NO_RECIRC_STATE != state ) && ( TRUE == dialysateRecircBlocked ) && ( TRUE == bloodRecircBlocked ) ) { setupForBloodRecirculationStopState(); setupForDialysateRecirculationStopState(); result = TREATMENT_STOP_NO_RECIRC_STATE; } // Dialysate recirculation blocked and not in blood recirc state - if ( ( TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE != state ) - && ( TRUE == dialysateRecircBlocked ) - && ( FALSE == bloodRecircBlocked ) ) + if ( ( TREATMENT_STOP_RECIRC_BLOOD_ONLY_STATE != state ) && + ( TRUE == dialysateRecircBlocked ) && + ( FALSE == 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 == bloodRecircBlocked ) - && ( FALSE == dialysateRecircBlocked ) ) + if ( ( TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE != state ) && + ( TRUE == bloodRecircBlocked ) && + ( FALSE == dialysateRecircBlocked ) ) { setupForBloodRecirculationStopState(); result = TREATMENT_STOP_RECIRC_DIALYSATE_ONLY_STATE; @@ -408,6 +414,7 @@ bloodSittingTimerCtr = 0; } } + /*********************************************************************//** * @brief * The getCurrentTreatmentStopState function returns the current state of the