Index: firmware/App/Services/StateServices/TubeSetInstall.c =================================================================== diff -u -rb74d08ff24839ebbea51582772ed2b9588558ea0 -r3f53d4aaf8840366306a6143eda9abf1a763bb73 --- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision b74d08ff24839ebbea51582772ed2b9588558ea0) +++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include "AlarmMgmt.h" +#include "AlarmMgmtTD.h" #include "BloodFlow.h" #include "Messaging.h" #include "OperationModes.h" @@ -24,7 +24,7 @@ #include "TaskGeneral.h" #include "TDDefs.h" #include "Timers.h" -#include "StateServices/TubeSetInstall.h" +#include "TubeSetInstall.h" /** * @addtogroup TubeSetInstall @@ -53,6 +53,7 @@ // ********** private function prototypes ********** static TUBE_SET_INSTALL_STATE_T handleAwaitTubesetConfirmationState( void ); ///< Handle Await Tubset Install Confirmation sub-state +static TUBE_SET_INSTALL_STATE_T handleAwaitBPDoorCloseState( void ); ///< Handle Await Blood Pump Door Close sub-state. static TUBE_SET_INSTALL_STATE_T handleAutoLoadState( void ); ///< Handle Auto-Load sub-state static TUBE_SET_INSTALL_STATE_T handleAutoLoadBackOffState( void ); ///< Handle Auto-Load Back-off sub-state @@ -83,40 +84,41 @@ *************************************************************************/ void execTubeSetInstall( void ) { - if( TRUE == installComplete ) + if ( FALSE == installComplete ) { - return; - } + switch( currentInstallState ) + { + case TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION: + currentInstallState = handleAwaitTubesetConfirmationState(); + break; - switch( currentInstallState ) - { - case TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION: - currentInstallState = handleAwaitTubesetConfirmationState(); - break; + case TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE: + currentInstallState = handleAwaitBPDoorCloseState(); + break; - case TUBE_SET_INSTALL_STATE_AUTO_LOAD: - currentInstallState = handleAutoLoadState(); - break; + case TUBE_SET_INSTALL_STATE_AUTO_LOAD: + currentInstallState = handleAutoLoadState(); + break; - case TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF: - currentInstallState = handleAutoLoadBackOffState(); - break; + case TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF: + currentInstallState = handleAutoLoadBackOffState(); + break; - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_PRE_TX_INSTALL_INVALID_STATE, (U32)currentInstallState ); - break; + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_PRE_TX_INSTALL_INVALID_STATE, (U32)currentInstallState ); + break; + } } } /*********************************************************************//** * @brief * The handleAwaitTubesetConfirmationState function handles the Await * tubeset confirmation state of Tubing Set install state machine. - * Should wait for the user to confirm the tubeset is placed, and - * verifies that the blood pump door (H9) is closed. - * @details Inputs: confirmTubsetPlaced, H9_SWCH state + * Should wait for the user to confirm the tubeset is placed + * @details Inputs: confirmTubsetPlaced * @details Outputs: confirmTubesetPlaced - * return next Pre-Treatment Install sub-state + * return next Install sub-state *************************************************************************/ static TUBE_SET_INSTALL_STATE_T handleAwaitTubesetConfirmationState( void ) { @@ -126,13 +128,30 @@ { // Door closed required from Auto-loading onwards, set to false if not required in subsequent states doorClosedRequired( TRUE ); + confirmTubesetPlaced = FALSE; + state = TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE; + } - if ( STATE_CLOSED == getSwitchState( H9_SWCH ) ) - { - confirmTubesetPlaced = FALSE; - setBloodPumpTargetFlowRate( AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - state = TUBE_SET_INSTALL_STATE_AUTO_LOAD; - } + return state; +} + +/*********************************************************************//** + * @brief + * The handleAwaitBPDoorCloseState function handles the Await Blood Pump + * Door Close state of Tubing Set install state machine. + * Should wait until blood pump door (H9) is closed. + * @details Inputs: H9_SWCH state + * @details Outputs: none + * return next Install sub-state + *************************************************************************/ +static TUBE_SET_INSTALL_STATE_T handleAwaitBPDoorCloseState( void ) +{ + TUBE_SET_INSTALL_STATE_T state = TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE; + + if ( STATE_CLOSED == getSwitchState( H9_SWCH ) ) + { + setBloodPumpTargetFlowRate( AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + state = TUBE_SET_INSTALL_STATE_AUTO_LOAD; } return state; @@ -145,7 +164,7 @@ * @details Inputs: bloodPumpTimerCounter, getMeasuredBloodPumpTorque() * isPeristalticPumpHome() * @details Outputs: bloodPumpTimerCounter, installComplete - * return next Pre-Treatment Install sub-state + * return next Install sub-state *************************************************************************/ static TUBE_SET_INSTALL_STATE_T handleAutoLoadState( void ) { @@ -170,8 +189,8 @@ { signalBloodPumpHardStop(); bloodPumpTimerCounter = 0; - installComplete = TRUE; - state = NUM_OF_TUBE_SET_INSTALL_SUB_STATES; + installComplete = TRUE; + state = NUM_OF_TUBE_SET_INSTALL_SUB_STATES; } return state; @@ -183,7 +202,7 @@ * state of Tube Set install state. * @details Inputs: bloodPumpTimerCounter, isPeristalticPumpHome() * @details Outputs: bloodPumpTimerCounter - * return next install sub-state + * return next Install sub-state *************************************************************************/ static TUBE_SET_INSTALL_STATE_T handleAutoLoadBackOffState( void ) { @@ -251,8 +270,8 @@ } else { - confirmTubesetPlaced = TRUE; - result = TRUE; + confirmTubesetPlaced = TRUE; + result = TRUE; } } else