Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r3f53d4aaf8840366306a6143eda9abf1a763bb73 -r26b65c70eca7d767f27a5cbbbd67a543ff9b5f26 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 26b65c70eca7d767f27a5cbbbd67a543ff9b5f26) @@ -18,8 +18,8 @@ #include "Buttons.h" #include "ModePreTreat.h" #include "OperationModes.h" -#include "TubeSetInstall.h" #include "Timers.h" +#include "TubeSetInstall.h" #include "TxParams.h" /** Index: firmware/App/Services/StateServices/TubeSetAutoEject.c =================================================================== diff -u -r3f53d4aaf8840366306a6143eda9abf1a763bb73 -r26b65c70eca7d767f27a5cbbbd67a543ff9b5f26 --- firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73) +++ firmware/App/Services/StateServices/TubeSetAutoEject.c (.../TubeSetAutoEject.c) (revision 26b65c70eca7d767f27a5cbbbd67a543ff9b5f26) @@ -40,7 +40,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 ejectComplete; ///< True once the service has finished successfully static TUBE_SET_AUTO_EJECT_STATE_T currentAutoEjectState; ///< Current Tube Set Auto Eject state @@ -51,6 +50,7 @@ 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 handleAutoEjectRetractingEjectorState( void ); +static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectCompleteState( void ); /*********************************************************************//** * @brief @@ -65,48 +65,48 @@ currentAutoEjectState = TUBE_SET_AUTO_EJECT_STATE_AWAIT_CONFIRMATION; autoEjectReqReceived = FALSE; autoEjectTimerCounter = 0; - ejectComplete = FALSE; } /*********************************************************************//** * @brief * The execTubeSetEject function executes the Tube Set Eject * state machine. * @details Inputs: currentAutoEjectState - * @details Outputs: currentAutoEjectState, ejectComplete. Advances the + * @details Outputs: currentAutoEjectState. Advances the * Tube Set Eject sub-state * @return none *************************************************************************/ void execTubeSetAutoEject( void ) { - if( FALSE == ejectComplete ) + switch ( currentAutoEjectState ) { - switch ( currentAutoEjectState ) - { - case TUBE_SET_AUTO_EJECT_STATE_AWAIT_CONFIRMATION: - currentAutoEjectState = handleAutoEjectAwaitConfirmState(); - break; + case TUBE_SET_AUTO_EJECT_STATE_AWAIT_CONFIRMATION: + currentAutoEjectState = handleAutoEjectAwaitConfirmState(); + break; - case TUBE_SET_AUTO_EJECT_STATE_HOMING: - currentAutoEjectState = handleAutoEjectHomingState(); - break; + case TUBE_SET_AUTO_EJECT_STATE_HOMING: + currentAutoEjectState = handleAutoEjectHomingState(); + break; - case TUBE_SET_AUTO_EJECT_STATE_EXTENDING_EJECTOR: - currentAutoEjectState = handleAutoEjectExtendingEjectorState(); - break; + case TUBE_SET_AUTO_EJECT_STATE_EXTENDING_EJECTOR: + currentAutoEjectState = handleAutoEjectExtendingEjectorState(); + break; - case TUBE_SET_AUTO_EJECT_STATE_EJECTING: - currentAutoEjectState = handleAutoEjectEjectingState(); - break; + case TUBE_SET_AUTO_EJECT_STATE_EJECTING: + currentAutoEjectState = handleAutoEjectEjectingState(); + break; - case TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR: - currentAutoEjectState = handleAutoEjectRetractingEjectorState(); - break; + case TUBE_SET_AUTO_EJECT_STATE_RETRACTING_EJECTOR: + currentAutoEjectState = handleAutoEjectRetractingEjectorState(); + break; - default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_POST_TX_AUTO_EJECT_INVALID_STATE, (U32)currentAutoEjectState ); - break; - } + case TUBE_SET_AUTO_EJECT_STATE_COMPLETE: + currentAutoEjectState = handleAutoEjectCompleteState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_POST_TX_AUTO_EJECT_INVALID_STATE, (U32)currentAutoEjectState ); + break; } } @@ -225,7 +225,7 @@ * Retracting Ejector state of the Tube Set Eject state * machine. Retracts the ejector pin (H5) after the tubeset has been ejected. * @details Inputs: autoEjectTimerCounter, getEjectorState() - * @details Outputs: autoEjectTimerCounter, ejectComplete + * @details Outputs: autoEjectTimerCounter * @return next Auto-Eject state *************************************************************************/ static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectRetractingEjectorState( void ) @@ -239,7 +239,6 @@ else if ( EJECTOR_STATE_RETRACTED == getEjectorState() ) { autoEjectTimerCounter = 0; - ejectComplete = TRUE; state = NUM_OF_TUBE_SET_AUTO_EJECT_SUB_STATES; } @@ -248,16 +247,29 @@ /*********************************************************************//** * @brief + * The handleAutoEjectCompleteState function handles the Complete state of + * the Tube Set Eject state machine. + * @details Inputs: none + * @details Outputs: none + * @return Auto-Eject complete state + *************************************************************************/ +static TUBE_SET_AUTO_EJECT_STATE_T handleAutoEjectCompleteState( void ) +{ + return TUBE_SET_AUTO_EJECT_STATE_COMPLETE; +} + +/*********************************************************************//** + * @brief * The isTubeSetEjectComplete function reports whether the eject * service has finished successfully. - * @details \b Inputs: ejectComplete + * @details \b Inputs: none * @details \b Outputs: none * @return TRUE if auto-eject completed and ejector is retracted, * FALSE otherwise. *************************************************************************/ BOOL isTubeSetAutoEjectComplete( void ) { - return ejectComplete; + return ( TUBE_SET_INSTALL_STATE_COMPLETE == currentAutoEjectState ? TRUE : FALSE ); } /*********************************************************************//** Index: firmware/App/Services/StateServices/TubeSetAutoEject.h =================================================================== diff -u -r3f53d4aaf8840366306a6143eda9abf1a763bb73 -r26b65c70eca7d767f27a5cbbbd67a543ff9b5f26 --- firmware/App/Services/StateServices/TubeSetAutoEject.h (.../TubeSetAutoEject.h) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73) +++ firmware/App/Services/StateServices/TubeSetAutoEject.h (.../TubeSetAutoEject.h) (revision 26b65c70eca7d767f27a5cbbbd67a543ff9b5f26) @@ -40,6 +40,7 @@ TUBE_SET_AUTO_EJECT_STATE_EXTENDING_EJECTOR, // Extending ejector state TUBE_SET_AUTO_EJECT_STATE_EJECTING, // Ejecting tubeset 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 }; /// Type for TD Tube Set Auto-Eject service enumeration 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 ); } /*********************************************************************//** Index: firmware/App/Services/StateServices/TubeSetInstall.h =================================================================== diff -u -r3f53d4aaf8840366306a6143eda9abf1a763bb73 -r26b65c70eca7d767f27a5cbbbd67a543ff9b5f26 --- firmware/App/Services/StateServices/TubeSetInstall.h (.../TubeSetInstall.h) (revision 3f53d4aaf8840366306a6143eda9abf1a763bb73) +++ firmware/App/Services/StateServices/TubeSetInstall.h (.../TubeSetInstall.h) (revision 26b65c70eca7d767f27a5cbbbd67a543ff9b5f26) @@ -36,9 +36,10 @@ enum Tube_Set_Install_States { TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION = 0, // Awaiting user confirmation that tubeset is placed. - TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE, // Waiting for blood pump door to be closed. + TUBE_SET_INSTALL_STATE_AWAIT_BP_DOOR_CLOSE, // Waiting for blood pump door to be closed. TUBE_SET_INSTALL_STATE_AUTO_LOAD, // Auto-Load the tubeset state TUBE_SET_INSTALL_STATE_AUTO_LOAD_BACK_OFF, // Auto-Load Back-off state + TUBE_SET_INSTALL_STATE_COMPLETE, // Install state complete NUM_OF_TUBE_SET_INSTALL_SUB_STATES, // Num of install sub-states }; /// Type for tube set install states enumeration