Index: firmware/App/Modes/TreatmentRecirc.c =================================================================== diff -u -r57eb6d533a74a212c81cec2baa5246399ffd8cb1 -r73b300baeac55bbcf4d231ced4ef6ea4af3c1840 --- firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 57eb6d533a74a212c81cec2baa5246399ffd8cb1) +++ firmware/App/Modes/TreatmentRecirc.c (.../TreatmentRecirc.c) (revision 73b300baeac55bbcf4d231ced4ef6ea4af3c1840) @@ -55,6 +55,7 @@ // ********** private function prototypes ********** static void resetTreatmentRecircFlags( void ); +static void setFullStop( void ); static void setupForRecirculationState( void ); static void setupForRecirculationStopState( void ); @@ -63,6 +64,7 @@ static TREATMENT_RECIRC_STATE_T handleRecircRecircState( void ); static TREATMENT_RECIRC_STATE_T handleRecircStoppedState( void ); static TREATMENT_RECIRC_STATE_T handleRecircReconnectPatientState( void ); +static TREATMENT_RECIRC_STATE_T handleTreatmentRecircOnOff( TREATMENT_RECIRC_STATE_T result ); static BOOL handleRecircReconnectUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ); static BOOL handleRecicConfirmReconnectUserAction( REQUEST_REJECT_REASON_CODE_T *rejReason ); @@ -105,6 +107,39 @@ /*********************************************************************//** * @brief + * The setFullStop function stops all HD activity. This function will be + * called by rinseback mode when an alarm (stop, noBloodRecirc, + * noDialysateRecirc) occurs or the user pressed the stop button. + * Rinseback may be resumed later. + * @details Inputs: none + * @details Outputs: Blood and dialysate pumps stopped. Heparin pump stopped. + * @return none + *************************************************************************/ +static void setFullStop( void ) +{ + // Tell DG to stop heating dialysate + cmdStopDGTrimmerHeater(); + + // Stop the peristaltic pumps + signalDialInPumpHardStop(); + signalDialOutPumpHardStop(); + signalBloodPumpHardStop(); + + // Set valves to safe state + // Dialysate in bypass + setValvePosition( VDI, VALVE_POSITION_C_CLOSE ); + setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); + // patient blood lines closed + setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); + setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); + + // Stop the ancillary pumps + stopSyringePump(); + endAirTrapControl(); +} + +/*********************************************************************//** + * @brief * The transitionToTreatmentRecirc function prepares for transition to treatment * re-circulate sub-mode. * @details Inputs: none @@ -170,6 +205,7 @@ { // Stop blood pump signalBloodPumpHardStop(); + // Close arterial and venous lines setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); @@ -223,6 +259,10 @@ // Broadcast recirc status publishTreatmentRecircData(); + + // Start/stop dialysate recirculation during rinseback mode based on active alarms that would block it + treatmentRecircState = handleTreatmentRecircOnOff( treatmentRecircState ); + } /*********************************************************************//** @@ -522,6 +562,31 @@ /*********************************************************************//** * @brief + * The handleTreatmentRecircOnOff function starts/stops recirculation + * during rinseback sub-mode based on active alarm properties. + * @details Inputs: none + * @details Outputs: dialysate recirculation started or stopped as appropriate + * @return none + *************************************************************************/ +static TREATMENT_RECIRC_STATE_T handleTreatmentRecircOnOff( TREATMENT_RECIRC_STATE_T result ) +{ + + // Stop recirc if blocked by alarm + if ( ( TRUE == isDialysateRecircBlocked() ) && ( TRUE == isDialInPumpRunning() ) ) + { + setFullStop( ); + result = TREATMENT_RECIRC_STOPPED_STATE; + } + else if ( ( isDialysateRecircBlocked() != TRUE ) && ( isDialInPumpRunning() != TRUE ) ) + { + setDialInPumpTargetFlowRate( DIALYSATE_FLOW_RATE_FOR_RECIRC, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_CLOSED_LOOP ); + cmdStartDGTrimmerHeater(); + } + return result; +} + +/*********************************************************************//** + * @brief * The publishTreatmentRecircData function publishes recirc progress to UI * at 1 Hz interval. * @details Inputs: recircPublishTimerCtr, recircTimerCtr