Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -racc8c3eb9d40711058bd214251d7554ab50b3836 -r8dc6572eca96163f165be33a4c58d77bb4a53b44 --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision acc8c3eb9d40711058bd214251d7554ab50b3836) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 8dc6572eca96163f165be33a4c58d77bb4a53b44) @@ -15,6 +15,7 @@ * ***************************************************************************/ +#include "BloodFlow.h" #include "Buttons.h" #include "ModePostTreat.h" #include "OperationModes.h" @@ -47,7 +48,7 @@ **************************************************************************/ void initPostTreatmentMode( void ) { - currentPostTreatmentState = TD_POST_TREATMENT_AUTO_EJECT_STATE; + currentPostTreatmentState = TD_POST_TREATMENT_AUTO_EJECT_STATE; } /*********************************************************************//** Index: firmware/App/Services/StateServices/TubeSetAutoEject.c =================================================================== diff -u -r08662b6d28ebfd8f41b56b1792648deb99dca5e4 -r8dc6572eca96163f165be33a4c58d77bb4a53b44 --- firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision 08662b6d28ebfd8f41b56b1792648deb99dca5e4) +++ firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision 8dc6572eca96163f165be33a4c58d77bb4a53b44) @@ -46,7 +46,6 @@ static BOOL autoEjectReqReceived; ///< Flag indicating that user confirmed to eject tubeset static U32 autoEjectTimerCounter; ///< Timer counter shared across all auto-eject states static BOOL bpLastHome; ///< Flag for Blood Pump last home (for rising-edge) -static BOOL backOffAfterRetract; ///< Flag indicating back-off required after retract. static TUBE_SET_AUTO_EJECT_STATE_T currentAutoEjectState; ///< Current Tube Set Auto Eject state @@ -74,7 +73,6 @@ autoEjectReqReceived = FALSE; autoEjectTimerCounter = 0; bpLastHome = TRUE; - backOffAfterRetract = FALSE; } /*********************************************************************//** @@ -219,9 +217,11 @@ * The handleAutoEjectEjectingState function handles the Ejecting state * of the Tube Set Eject state machine. Rotates the blood pump (H4) * forward at 100 mL/min with the ejector extended to push the tubeset - * out of the rotor. + * out of the rotor. If torque exceeds the limit, stops the pump, triggers + * the High Blood Pump Torque Alarm, and retracts the ejector for back-off + * recovery. Otherwise waits for one full rotation. * @details \b Inputs: autoEjectTimerCounter, bpLastHome - * @details \b Outputs: autoEjectTimerCounter, bpLastHome, backOffAfterRetract + * @details \b Outputs: autoEjectTimerCounter, bpLastHome * @return next Auto-Eject state *************************************************************************/ static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectEjectingState( void ) @@ -242,7 +242,6 @@ SET_ALARM_WITH_1_F32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BLOOD_TUBE_SET_FAILURE, bpTorque ); retractEjector(); autoEjectTimerCounter = 0; - backOffAfterRetract = TRUE; state = TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR; } // BP home position check (rising edge: motor must leave home and return) @@ -267,9 +266,12 @@ * @brief * The handleAutoEjectRetractingEjectorState function handles the * Retracting Ejector state of the Tube Set Eject state machine. - * Retracts the ejector pin (H5) after the tubeset has been ejected. - * @details \b Inputs: autoEjectTimerCounter, backOffAfterRetract - * @details \b Outputs: autoEjectTimerCounter, backOffAfterRetract + * Retracts the ejector pin (H5) after the tubeset has been ejected. Once + * retracted, command H4 to rotate reverse at 100 mL/min and transitions to + * Back-Off state if the High Blood Pump Torque Alarm is active, or completes + * the Auto-Eject service. + * @details \b Inputs: autoEjectTimerCounter + * @details \b Outputs: autoEjectTimerCounter * @return next Auto-Eject state *************************************************************************/ static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectRetractingEjectorState( void ) @@ -284,10 +286,9 @@ { autoEjectTimerCounter = 0; - if ( TRUE == backOffAfterRetract ) + if ( TRUE == isAlarmActive( ALARM_ID_TD_AUTO_LOAD_EJECT_BLOOD_TUBE_SET_FAILURE ) ) { setBloodPumpTargetFlowRate( AUTO_EJECT_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_REVERSE, PUMP_CONTROL_MODE_OPEN_LOOP ); - backOffAfterRetract = FALSE; state = TUBE_SET_AUTO_EJECT_STATE_BACK_OFF; } else @@ -306,7 +307,10 @@ /*********************************************************************//** * @brief * The handleAutoEjectBackOffState function handles the Auto-Eject Back-Off - * state of Tube Set Eject state machine. + * state of Tube Set Eject state machine. Waits for the blood pump to + * reverse to the home position, then stops the pump and clears the + * High Blood Pump Torque Alarm condition. Once the user acknowledges + * the alarm, transitions to Await Confirmation state to allow retry. * @details \b Inputs: autoEjectTimerCounter * @details \b Outputs: autoEjectTimerCounter * @return next Auto-Eject state