Index: firmware/App/Services/StateServices/TubeSetAutoEject.c =================================================================== diff -u -racc8c3eb9d40711058bd214251d7554ab50b3836 -rb314f68347ca0720d370fd5ace385a2d8d92fabe --- firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision acc8c3eb9d40711058bd214251d7554ab50b3836) +++ firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision b314f68347ca0720d370fd5ace385a2d8d92fabe) @@ -15,6 +15,7 @@ * ***************************************************************************/ +#include "AlarmMgmtTD.h" #include "BloodFlow.h" #include "Ejector.h" #include "Messaging.h" @@ -37,6 +38,9 @@ ///< Blood pump flow rate (mL/min) for the ejecting operation #define AUTO_EJECT_BLOOD_FLOW_RATE_ML_MIN 100U +/// Blood pump torque threshold (mN.m) above which a tube-set jam is declared +#define BP_TORQUE_LIMIT_MNM 9999.0F // TODO: Replace with lab characterized value + // ********** private data ********** static BOOL autoEjectReqReceived; ///< Flag indicating that user confirmed to eject tubeset @@ -51,6 +55,7 @@ static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectHomingState( void ); static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectExtendingEjectorState( void ); static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectEjectingState( void ); +static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectBackOffState( void ); static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectRetractingEjectorState( void ); static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectCompleteState( void ); @@ -72,7 +77,7 @@ /*********************************************************************//** * @brief - * The execTubeSetEject function executes the Tube Set Eject + * The execTubeSetAutoEject function executes the Tube Set Eject * state machine. * @details \b Inputs: currentAutoEjectState * @details \b Outputs: currentAutoEjectState. Advances the @@ -99,6 +104,10 @@ currentAutoEjectState = handleAutoEjectEjectingState(); break; + case TUBE_SET_AUTO_EJECT_STATE_BACK_OFF: + currentAutoEjectState = handleAutoEjectBackOffState(); + break; + case TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR: currentAutoEjectState = handleAutoEjectRetractingEjectorState(); break; @@ -142,7 +151,7 @@ * The handleAutoEjectHomingState function handles the Homing state * of the Tube Set Eject state machine. * Homes the blood pump (H4) - * @details \b Inputs: autoEjectTimerCounter, isPeristalticPumpHome() + * @details \b Inputs: autoEjectTimerCounter * @details \b Outputs: autoEjectTimerCounter * @return next Auto-Eject state *************************************************************************/ @@ -176,7 +185,7 @@ * The handleAutoEjectExtendingEjectorState function handles the * Extending Ejector state of the Tube Set Eject Service * state machine. Extends the ejector pin (H5) to engage the tubeset. - * @details \b Inputs: autoEjectTimerCounter, getEjectorState() + * @details \b Inputs: autoEjectTimerCounter * @details \b Outputs: autoEjectTimerCounter * @return next Auto-Eject state *************************************************************************/ @@ -209,20 +218,30 @@ * 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. - * @details \b Inputs: autoEjectTimerCounter, isPeristalticPumpHome() - * @details \b Outputs: autoEjectTimerCounter + * @details \b Inputs: autoEjectTimerCounter, bpLastHome + * @details \b Outputs: autoEjectTimerCounter, bpLastHome * @return next Auto-Eject state *************************************************************************/ static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectEjectingState( void ) { TUBE_SET_AUTO_EJECT_STATE_T state = TUBE_SET_AUTO_EJECT_STATE_EJECTING; BOOL bpCurrentHome = isPeristalticPumpHome(); + F32 bpTorque = getMeasuredBloodPumpTorque(); if ( ++autoEjectTimerCounter >= AUTO_EJECT_OPERATION_TIMEOUT_INTERVAL ) { signalBloodPumpHardStop(); SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BP_TIMEOUT, isPeristalticPumpHome(), autoEjectTimerCounter ); } + // Torque jam check. If measured torque exceeds the limit, the tubing set is likely jammed in the rotor. + else if ( bpTorque > BP_TORQUE_LIMIT_MNM ) + { + signalBloodPumpHardStop(); + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BLOOD_TUBE_SET_FAILURE, bpTorque ); + setBloodPumpTargetFlowRate( AUTO_EJECT_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_REVERSE, PUMP_CONTROL_MODE_OPEN_LOOP ); + autoEjectTimerCounter = 0; + state = TUBE_SET_AUTO_EJECT_STATE_BACK_OFF; + } // BP home position check (rising edge: motor must leave home and return) else if ( ( TRUE == bpCurrentHome ) && ( FALSE == bpLastHome ) ) { @@ -243,10 +262,46 @@ /*********************************************************************//** * @brief + * The handleAutoEjectBackOffState function handles the Auto-Eject Back-Off + * state of Tube Set Eject state machine. + * @details \b Inputs: autoEjectTimerCounter + * @details \b Outputs: autoEjectTimerCounter + * @return next Auto-Eject state + *************************************************************************/ +static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectBackOffState( void ) +{ + TUBE_SET_AUTO_EJECT_STATE_T state = TUBE_SET_AUTO_EJECT_STATE_BACK_OFF; + + if ( ++autoEjectTimerCounter >= AUTO_EJECT_OPERATION_TIMEOUT_INTERVAL ) + { + signalBloodPumpHardStop(); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BP_TIMEOUT, isPeristalticPumpHome(), autoEjectTimerCounter ); + } + else if ( TRUE == isPeristalticPumpHome() ) + { + signalBloodPumpHardStop(); + clearAlarmTD( ALARM_ID_TD_AUTO_LOAD_EJECT_BLOOD_TUBE_SET_FAILURE ); + + if ( FALSE == isAlarmActive( ALARM_ID_TD_AUTO_LOAD_EJECT_BLOOD_TUBE_SET_FAILURE ) ) + { + autoEjectTimerCounter = 0; + state = TUBE_SET_AUTO_EJECT_STATE_AWAIT_CONFIRMATION; + } + } + else + { + // No action required + } + + return state; +} + +/*********************************************************************//** + * @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, getEjectorState() + * 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 * @details \b Outputs: autoEjectTimerCounter * @return next Auto-Eject state *************************************************************************/ @@ -307,7 +362,7 @@ * The handleAutoEjectRequest function handles a UI request to remove the * disposable tubeset. * @details \b Message \b Sent: MSG_ID_TD_ADJUST_DISPOSABLES_REMOVAL_CONFIRM_RESPONSE - * @details \b Inputs: currentAutoEjectState, getCurrentOperationMode() + * @details \b Inputs: currentAutoEjectState * @details \b Outputs: autoEjectReqReceived * @param message UI message which includes the user confirmation to * eject the tubeset Index: firmware/App/Services/StateServices/TubeSetAutoEject.h =================================================================== diff -u -r253979e460b82c6d038e0a566f3be8c6df0a28c9 -rb314f68347ca0720d370fd5ace385a2d8d92fabe --- firmware/App/Services/StateServices/TubeSetAutoEject.h (.../TubeSetAutoEject.h) (revision 253979e460b82c6d038e0a566f3be8c6df0a28c9) +++ firmware/App/Services/StateServices/TubeSetAutoEject.h (.../TubeSetAutoEject.h) (revision b314f68347ca0720d370fd5ace385a2d8d92fabe) @@ -39,6 +39,7 @@ TUBE_SET_AUTO_EJECT_STATE_HOMING, // Homing blood pump TUBE_SET_AUTO_EJECT_STATE_EXTENDING_EJECTOR, // Extending ejector state TUBE_SET_AUTO_EJECT_STATE_EJECTING, // Ejecting tubeset state + TUBE_SET_AUTO_EJECT_STATE_BACK_OFF, // Auto-Eject Back-off state TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR, // Retracting ejector state TUBE_SET_AUTO_EJECT_STATE_COMPLETE, // Auto-Eject complete state NUM_OF_TUBE_SET_AUTO_EJECT_SUB_STATES, // Num of auto-eject sub-states Index: firmware/App/Services/StateServices/TubeSetInstall.c =================================================================== diff -u -racc8c3eb9d40711058bd214251d7554ab50b3836 -rb314f68347ca0720d370fd5ace385a2d8d92fabe --- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision acc8c3eb9d40711058bd214251d7554ab50b3836) +++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision b314f68347ca0720d370fd5ace385a2d8d92fabe) @@ -40,7 +40,7 @@ #define AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN 100U /// Blood pump torque threshold (mN.m) above which a tube-set jam is declared -#define INSTALL_AUTO_LOAD_TORQUE_LIMIT_MNM 9999.0F // TODO: Replace with lab characterized value +#define BP_TORQUE_LIMIT_MNM 9999.0F // TODO: Replace with lab characterized value // ********** private data ********** @@ -120,7 +120,7 @@ * Should wait for the user to confirm the tubeset is placed * @details \b Inputs: confirmTubsetPlaced * @details \b Outputs: confirmTubesetPlaced - * return next Install sub-state + * @return next Install sub-state *************************************************************************/ static TUBE_SET_INSTALL_STATE_T handleAwaitTubesetConfirmationState( void ) { @@ -144,7 +144,7 @@ * Should wait until blood pump door (H9) is closed. * @details \b Inputs: H9_SWCH state * @details \b Outputs: none - * return next Install sub-state + * @return next Install sub-state *************************************************************************/ static TUBE_SET_INSTALL_STATE_T handleAwaitBPDoorCloseState( void ) { @@ -164,10 +164,9 @@ * @brief * The handleAutoLoadState function handles the Auto-Load state of * Tube Set install state. - * @details \b Inputs: bloodPumpTimerCounter, getMeasuredBloodPumpTorque() - * isPeristalticPumpHome() - * @details \b Outputs: bloodPumpTimerCounter - * return next Install sub-state + * @details \b Inputs: bloodPumpTimerCounter, bpLastHome + * @details \b Outputs: bloodPumpTimerCounter, bpLastHome + * @return next Install sub-state *************************************************************************/ static TUBE_SET_INSTALL_STATE_T handleAutoLoadState( void ) { @@ -182,10 +181,10 @@ SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BP_TIMEOUT, isPeristalticPumpHome(), bloodPumpTimerCounter ); } // Torque jam check. If measured torque exceeds the limit, the tubing set is likely jammed in the rotor. - else if ( bpTorque > INSTALL_AUTO_LOAD_TORQUE_LIMIT_MNM ) + else if ( bpTorque > BP_TORQUE_LIMIT_MNM ) { signalBloodPumpHardStop(); - SET_ALARM_WITH_1_F32_DATA( ALARM_ID_TD_AUTO_LOAD_BLOOD_TUBE_SET_FAILURE, bpTorque ); + SET_ALARM_WITH_1_F32_DATA( ALARM_ID_TD_AUTO_LOAD_EJECT_BLOOD_TUBE_SET_FAILURE, bpTorque ); setBloodPumpTargetFlowRate( AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_REVERSE, PUMP_CONTROL_MODE_OPEN_LOOP ); bloodPumpTimerCounter = 0; state = TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF; @@ -211,9 +210,9 @@ * @brief * The handleAutoLoadBackOffState function handles the Auto-Load Back-Off * state of Tube Set install state. - * @details \b Inputs: bloodPumpTimerCounter, isPeristalticPumpHome() + * @details \b Inputs: bloodPumpTimerCounter * @details \b Outputs: bloodPumpTimerCounter - * return next Install sub-state + * @return next Install sub-state *************************************************************************/ static TUBE_SET_INSTALL_STATE_T handleAutoLoadBackOffState( void ) { @@ -226,11 +225,11 @@ } else if ( TRUE == isPeristalticPumpHome() ) { - clearAlarmTD( ALARM_ID_TD_AUTO_LOAD_BLOOD_TUBE_SET_FAILURE ); + signalBloodPumpHardStop(); + clearAlarmTD( ALARM_ID_TD_AUTO_LOAD_EJECT_BLOOD_TUBE_SET_FAILURE ); - if ( FALSE == isAlarmActive( ALARM_ID_TD_AUTO_LOAD_BLOOD_TUBE_SET_FAILURE ) ) + if ( FALSE == isAlarmActive( ALARM_ID_TD_AUTO_LOAD_EJECT_BLOOD_TUBE_SET_FAILURE ) ) { - signalBloodPumpHardStop(); bloodPumpTimerCounter = 0; state = TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION; } @@ -249,7 +248,7 @@ * state of Tube Set install state. * @details \b Inputs: none * @details \b Outputs: none - * return install complete state + * @return install complete state *************************************************************************/ static TUBE_SET_INSTALL_STATE_T handleInstallCompleteState( void ) {