Index: firmware/App/Services/StateServices/TubeSetInstall.c =================================================================== diff -u -r3f53d4aaf8840366306a6143eda9abf1a763bb73 -r26b65c70eca7d767f27a5cbbbd67a543ff9b5f26 --- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73) +++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 26b65c70eca7d767f27a5cbbbd67a543ff9b5f26) @@ -46,7 +46,6 @@ static BOOL confirmTubesetPlaced; ///< Flag indicating user has confirmed tubeset is placed static U32 bloodPumpTimerCounter; ///< Blood Pump timer counter -static BOOL installComplete; ///< True once the service has finished successfully static TUBE_SET_INSTALL_STATE_T currentInstallState; ///< Current Tubing Set Install sub-state @@ -56,6 +55,7 @@ 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 +static TUBE_SET_INSTALL_STATE_T handleInstallCompleteState( void ); ///< Handle Install complete state /*********************************************************************//** * @brief @@ -70,44 +70,44 @@ currentInstallState = TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION; confirmTubesetPlaced = FALSE; bloodPumpTimerCounter = 0; - installComplete = FALSE; } /*********************************************************************//** * @brief * The execTubeSetInstall function executes the Tube Set Install * state machine. * @details Inputs: currentInstallState - * @details Outputs: currentInstallState, installComplete. Advances the + * @details Outputs: currentInstallState. Advances the * Tube Set Install sub-state * @return none *************************************************************************/ void execTubeSetInstall( void ) { - if ( FALSE == installComplete ) + switch( currentInstallState ) { - switch( currentInstallState ) - { - case TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION: - currentInstallState = handleAwaitTubesetConfirmationState(); - break; + 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_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; - } + case TUBE_SET_INSTALL_STATE_COMPLETE: + currentInstallState = handleInstallCompleteState(); + 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; } } @@ -148,10 +148,10 @@ { TUBE_SET_INSTALL_STATE_T state = TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE; - if ( STATE_CLOSED == getSwitchState( H9_SWCH ) ) + if ( FALSE == isAlarmActive( ALARM_ID_TD_CARTRIDGE_DOOR_OPENED ) ) { setBloodPumpTargetFlowRate( AUTO_LOAD_BLOOD_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); - state = TUBE_SET_INSTALL_STATE_AUTO_LOAD; + state = TUBE_SET_INSTALL_STATE_AUTO_LOAD; } return state; @@ -163,7 +163,7 @@ * Tube Set install state. * @details Inputs: bloodPumpTimerCounter, getMeasuredBloodPumpTorque() * isPeristalticPumpHome() - * @details Outputs: bloodPumpTimerCounter, installComplete + * @details Outputs: bloodPumpTimerCounter * return next Install sub-state *************************************************************************/ static TUBE_SET_INSTALL_STATE_T handleAutoLoadState( void ) @@ -189,8 +189,7 @@ { signalBloodPumpHardStop(); bloodPumpTimerCounter = 0; - installComplete = TRUE; - state = NUM_OF_TUBE_SET_INSTALL_SUB_STATES; + state = TUBE_SET_INSTALL_STATE_COMPLETE; } return state; @@ -230,15 +229,28 @@ /*********************************************************************//** * @brief + * The handleInstallCompleteState function handles the Install Complete + * state of Tube Set install state. + * @details Inputs: none + * @details Outputs: none + * return install complete state + *************************************************************************/ +static TUBE_SET_INSTALL_STATE_T handleInstallCompleteState( void ) +{ + return TUBE_SET_INSTALL_STATE_COMPLETE; +} + +/*********************************************************************//** + * @brief * The isTubeSetInstallComplete function reports whether the install * service has finished successfully. - * @details \b Inputs: installComplete + * @details \b Inputs: none * @details \b Outputs: none * @return TRUE if auto-load completed and pump is at home, FALSE otherwise. *************************************************************************/ BOOL isTubeSetInstallComplete( void ) { - return installComplete; + return ( TUBE_SET_INSTALL_STATE_COMPLETE == currentInstallState ? TRUE : FALSE ); } /*********************************************************************//**