Index: firmware/App/Controllers/SyringePump.c =================================================================== diff -u -r120487ddf3e3d69d1de5094d5252c037588e2ed8 -r53ded5e26646574d5bae2cebd5de47a2ac5a3c2d --- firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 120487ddf3e3d69d1de5094d5252c037588e2ed8) +++ firmware/App/Controllers/SyringePump.c (.../SyringePump.c) (revision 53ded5e26646574d5bae2cebd5de47a2ac5a3c2d) @@ -1150,6 +1150,19 @@ /*********************************************************************//** * @brief + * The isSyringePumpPositionKnown function returns whether the syringe + * pump position is known. + * @details \b Inputs: syringePumpPositionKnown + * @details \b Outputs: none + * @return TRUE if syringe pump position is known, otherwise FALSE. + *************************************************************************/ +BOOL isSyringePumpPositionKnown( void ) +{ + return syringePumpPositionKnown; +} + +/*********************************************************************//** + * @brief * The execSyringePumpMonitor function executes the syringe pump monitor. * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_RUNNING_WHILE_BP_OFF_ERROR * if syringe pump is running while the blood pump is off Index: firmware/App/Controllers/SyringePump.h =================================================================== diff -u -r120487ddf3e3d69d1de5094d5252c037588e2ed8 -r53ded5e26646574d5bae2cebd5de47a2ac5a3c2d --- firmware/App/Controllers/SyringePump.h (.../SyringePump.h) (revision 120487ddf3e3d69d1de5094d5252c037588e2ed8) +++ firmware/App/Controllers/SyringePump.h (.../SyringePump.h) (revision 53ded5e26646574d5bae2cebd5de47a2ac5a3c2d) @@ -143,6 +143,7 @@ BOOL isSyringePumpRunning( void ); BOOL isSyringePumpPreLoaded( void ); F32 getSyringePumpVolumeDelivered( void ); +BOOL isSyringePumpPositionKnown( void ); BOOL testSyringePumpOperationRequest( MESSAGE_T *message ); BOOL testSyringePumpDataPublishIntervalOverride( MESSAGE_T *message ); Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r9c96ad1bd9f61a3c6f979aebb1d9ccf1ec5529d7 -r53ded5e26646574d5bae2cebd5de47a2ac5a3c2d --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 9c96ad1bd9f61a3c6f979aebb1d9ccf1ec5529d7) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 53ded5e26646574d5bae2cebd5de47a2ac5a3c2d) @@ -196,6 +196,10 @@ // No action required. break; + case TD_PRE_TREATMENT_HEPARIN_SETUP_STATE: + // Heparin Setup transition is already handled in handleRxState(). + break; + case TD_PRE_TREATMENT_RECIRCULATE_STATE: // No action required. break; Index: firmware/App/Modes/StatePreTxHeparinSetup.c =================================================================== diff -u -r9c96ad1bd9f61a3c6f979aebb1d9ccf1ec5529d7 -r53ded5e26646574d5bae2cebd5de47a2ac5a3c2d --- firmware/App/Modes/StatePreTxHeparinSetup.c (.../StatePreTxHeparinSetup.c) (revision 9c96ad1bd9f61a3c6f979aebb1d9ccf1ec5529d7) +++ firmware/App/Modes/StatePreTxHeparinSetup.c (.../StatePreTxHeparinSetup.c) (revision 53ded5e26646574d5bae2cebd5de47a2ac5a3c2d) @@ -50,6 +50,8 @@ static BOOL heparinSetupResumeRequested; ///< Flag indicates alarm requesting to resume pre-treatment heparin setup. static BOOL syringeLoadConfirmed; ///< Flag indicates user confirmed syringe load. +static BOOL syringeRetractStarted; ///< Flag indicating syringe retract has been initiated. +static BOOL syringePreloadStarted; ///< Flag indicating syringe preload has been initiated. // ********** private function prototypes ********** @@ -68,14 +70,19 @@ * @brief * The initPreTxHeparinSetup function initializes the pre-treatment * heparin setup state machine. - * @details Inputs: none - * @details Outputs: Pre-treatment heparin setup initialized. - * @return none + * @details \b Inputs: none. + * @details \b Outputs: currentPreTxHeparinSetupState, + * interruptedPreTxHeparinSetupState, syringeRetractStarted, + * syringePreloadStarted, heparinSetupResumeRequested, and + * syringeLoadConfirmed. + * @return none. *************************************************************************/ void initPreTxHeparinSetup( void ) { currentPreTxHeparinSetupState = PRE_TX_HEPARIN_SETUP_PRELOAD_STATE; interruptedPreTxHeparinSetupState = PRE_TX_HEPARIN_SETUP_PRELOAD_STATE; + syringeRetractStarted = FALSE; + syringePreloadStarted = FALSE; resetPreTxHeparinSetupFlags(); } @@ -84,22 +91,29 @@ * @brief * The transitionToPreTxHeparinSetup function prepares for transition * into the pre-treatment heparin setup state. - * @details Inputs: none - * @details Outputs: Heparin setup initialized. - * @return none + * @details \b Inputs: currentPreTxHeparinSetupState. + * @details \b Outputs: resume alarm user action enabled and current + * pre-treatment substate. + * @return none. *************************************************************************/ void transitionToPreTxHeparinSetup( void ) { + setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, TRUE ); + setCurrentSubState( (U32)currentPreTxHeparinSetupState ); } /*********************************************************************//** * @brief * The execPreTxHeparinSetup function executes the pre-treatment heparin * setup state machine. - * @details Inputs: currentPreTxHeparinSetupState - * @details Outputs: currentPreTxHeparinSetupState - * @return none + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if the current + * pre-treatment heparin setup state is invalid. + * @details \b Inputs: currentPreTxHeparinSetupState. + * @details \b Outputs: currentPreTxHeparinSetupState, current substate, + * TD_EVENT_SUB_STATE_CHANGE event, heparinSetupResumeRequested, and + * syringeLoadConfirmed. + * @return none. *************************************************************************/ void execPreTxHeparinSetup( void ) { @@ -154,8 +168,8 @@ * @brief * The getPreTxHeparinSetupState function returns the current state of the * pre-treatment heparin setup state machine. - * @details Inputs: currentPreTxHeparinSetupState - * @details Outputs: none + * @details \b Inputs: currentPreTxHeparinSetupState. + * @details \b Outputs: none. * @return Current pre-treatment heparin setup state. *************************************************************************/ U32 getPreTxHeparinSetupState( void ) @@ -167,9 +181,9 @@ * @brief * The signalResumePreTxHeparinSetup function signals a resume request for * the pre-treatment heparin setup state machine. - * @details Inputs: none - * @details Outputs: heparinSetupResumeRequested - * @return none + * @details \b Inputs: none. + * @details \b Outputs: heparinSetupResumeRequested. + * @return none. *************************************************************************/ void signalResumePreTxHeparinSetup( void ) { @@ -194,9 +208,9 @@ * @brief * The signalPreTxHeparinSyringeLoadConfirmed function signals that the * user confirmed syringe load. - * @details Inputs: none - * @details Outputs: syringeLoadConfirmed - * @return none + * @details \b Inputs: none. + * @details \b Outputs: syringeLoadConfirmed. + * @return none. *************************************************************************/ void signalPreTxHeparinSyringeLoadConfirmed( void ) { @@ -207,9 +221,10 @@ * @brief * The resetPreTxHeparinSetupFlags function resets all signal flags used by * the pre-treatment heparin setup state machine. - * @details Inputs: none - * @details Outputs: Signal flags reset. - * @return none + * @details \b Inputs: none. + * @details \b Outputs: heparinSetupResumeRequested and + * syringeLoadConfirmed. + * @return none. *************************************************************************/ static void resetPreTxHeparinSetupFlags( void ) { @@ -221,9 +236,10 @@ * @brief * The setupPreTxHeparinState function configures the syringe pump for the * specified pre-treatment heparin setup state. - * @details Inputs: state - * @details Outputs: Syringe pump configured for the specified state. - * @return none + * @details \b Inputs: none. + * @details \b Outputs: syringe pump operating state. + * @param state Pre-treatment heparin setup state to configure. + * @return none. *************************************************************************/ static void setupPreTxHeparinState( PRE_TX_HEPARIN_SETUP_STATE_T state ) { @@ -232,9 +248,9 @@ switch ( state ) { case PRE_TX_HEPARIN_SETUP_PRELOAD_STATE: - resetPreLoadStatus(); - preloadSyringePlunger(); - break; + // Retract and preload sequencing is handled by + // handlePreTxHeparinPreloadState(). + break; case PRE_TX_HEPARIN_SETUP_SEEK_STATE: seekSyringePlunger(); @@ -263,9 +279,16 @@ /*********************************************************************//** * @brief - * The handlePreTxHeparinPreloadState function handles the preload state. - * @details \b Inputs: none - * @details \b Outputs: Next pre-treatment heparin setup state. + * The handlePreTxHeparinPreloadState function handles the syringe pump + * retract and preload sequence. + * @details \b Alarm: ALARM_ID_UI_RESERVED_127 when syringe preload is + * complete and syringe loading confirmation is required. + * @details \b Inputs: syringeRetractStarted, syringePreloadStarted, + * alarm stop status, syringe pump position, preload status, and syringe + * pump operating status. + * @details \b Outputs: interruptedPreTxHeparinSetupState, + * syringeRetractStarted, syringePreloadStarted, syringe pump operating + * state, and preload status. * @return Current or next pre-treatment heparin setup state. *************************************************************************/ static PRE_TX_HEPARIN_SETUP_STATE_T handlePreTxHeparinPreloadState( void ) @@ -278,25 +301,38 @@ setupPreTxHeparinState( PRE_TX_HEPARIN_SETUP_PAUSED_STATE ); state = PRE_TX_HEPARIN_SETUP_PAUSED_STATE; } - else if ( ( FALSE == isSyringePumpRunning() ) && ( FALSE == isSyringePumpPreLoaded() ) ) - { - setupPreTxHeparinState( PRE_TX_HEPARIN_SETUP_PRELOAD_STATE ); - } else if ( TRUE == isSyringePumpPreLoaded() ) { activateAlarmNoData( ALARM_ID_UI_RESERVED_127 ); state = PRE_TX_HEPARIN_SETUP_AWAIT_SYRINGE_LOAD_CONFIRMATION_STATE; } + else if ( FALSE == isSyringePumpPositionKnown() ) + { + if ( ( FALSE == syringeRetractStarted ) && ( FALSE == isSyringePumpRunning() ) ) + { + syringeRetractStarted = retractSyringePump(); + } + } + else if ( FALSE == syringePreloadStarted ) + { + if ( FALSE == isSyringePumpRunning() ) + { + resetPreLoadStatus(); + syringePreloadStarted = preloadSyringePlunger(); + } + } + return state; } /*********************************************************************//** * @brief * The handlePreTxHeparinAwaitSyringeLoadConfirmationState function handles * the await syringe load confirmation state. - * @details \b Inputs: none - * @details \b Outputs: Next pre-treatment heparin setup state. + * @details \b Inputs: syringeLoadConfirmed and alarm stop status. + * @details \b Outputs: interruptedPreTxHeparinSetupState and syringe + * pump operating state. * @return Current or next pre-treatment heparin setup state. *************************************************************************/ static PRE_TX_HEPARIN_SETUP_STATE_T handlePreTxHeparinAwaitSyringeLoadConfirmationState( void ) @@ -320,11 +356,12 @@ /*********************************************************************//** * @brief - * The handlePreTxHeparinSeekState function handles the seek state. - * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_NOT_ENOUGH_HEPARIN_ALARM - * if the syringe contains insufficient heparin for the prescribed treatment. - * @details \b Inputs: none - * @details \b Outputs: Next pre-treatment heparin setup state. + * The handlePreTxHeparinSeekState function handles the syringe plunger + * seek state. + * @details \b Inputs: alarm stop status, syringe plunger status, and + * syringe volume adequacy status. + * @details \b Outputs: interruptedPreTxHeparinSetupState and syringe + * pump operating state. * @return Current or next pre-treatment heparin setup state. *************************************************************************/ static PRE_TX_HEPARIN_SETUP_STATE_T handlePreTxHeparinSeekState( void ) @@ -357,9 +394,11 @@ /*********************************************************************//** * @brief - * The handlePreTxHeparinPrimeState function handles the prime state. - * @details \b Inputs: none - * @details \b Outputs: Next pre-treatment heparin setup state. + * The handlePreTxHeparinPrimeState function handles the syringe pump + * prime state. + * @details \b Inputs: alarm stop status and syringe pump prime status. + * @details \b Outputs: interruptedPreTxHeparinSetupState and syringe + * pump operating state. * @return Current or next pre-treatment heparin setup state. *************************************************************************/ static PRE_TX_HEPARIN_SETUP_STATE_T handlePreTxHeparinPrimeState( void ) @@ -385,10 +424,12 @@ * @brief * The handlePreTxHeparinOcclusionCheckState function handles the heparin * pump occlusion check state. - * @details \b Alarms: ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION if the - * heparin pump occlusion check fails. - * @details \b Inputs: none - * @details \b Outputs: Next pre-treatment heparin setup state. + * @details \b Alarm: ALARM_ID_TD_SYRINGE_PUMP_OCCLUSION if the syringe + * pump occlusion check fails. + * @details \b Inputs: alarm stop status, syringe pump occlusion status, + * and TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME. + * @details \b Outputs: interruptedPreTxHeparinSetupState, syringe pump + * operating state, and pre-treatment continuation request. * @return Current or next pre-treatment heparin setup state. *************************************************************************/ static PRE_TX_HEPARIN_SETUP_STATE_T handlePreTxHeparinOcclusionCheckState( void ) @@ -427,9 +468,11 @@ /*********************************************************************//** * @brief - * The handlePreTxHeparinBolusState function handles the bolus state. - * @details \b Inputs: none - * @details \b Outputs: Next pre-treatment heparin setup state. + * The handlePreTxHeparinBolusState function handles the heparin bolus + * state. + * @details \b Inputs: alarm stop status and syringe pump stop status. + * @details \b Outputs: interruptedPreTxHeparinSetupState, syringe pump + * operating state, and pre-treatment continuation request. * @return Current or next pre-treatment heparin setup state. *************************************************************************/ static PRE_TX_HEPARIN_SETUP_STATE_T handlePreTxHeparinBolusState( void ) @@ -452,11 +495,14 @@ /*********************************************************************//** * @brief - * The handlePreTxHeparinPausedState function handles the paused state. - * @details \b Inputs: heparinSetupResumeRequested, - * interruptedPreTxHeparinSetupState - * @details \b Outputs: Next pre-treatment heparin setup state and - * syringe pump operation. + * The handlePreTxHeparinPausedState function handles the paused + * pre-treatment heparin setup state. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if the interrupted + * pre-treatment heparin setup state is invalid. + * @details \b Inputs: heparinSetupResumeRequested and + * interruptedPreTxHeparinSetupState. + * @details \b Outputs: syringeRetractStarted, syringePreloadStarted, + * preload status, and syringe pump operating state. * @return Current or next pre-treatment heparin setup state. *************************************************************************/ static PRE_TX_HEPARIN_SETUP_STATE_T handlePreTxHeparinPausedState( void ) @@ -472,7 +518,11 @@ case PRE_TX_HEPARIN_SETUP_PRELOAD_STATE: case PRE_TX_HEPARIN_SETUP_AWAIT_SYRINGE_LOAD_CONFIRMATION_STATE: case PRE_TX_HEPARIN_SETUP_SEEK_STATE: - retractSyringePump(); + syringeRetractStarted = FALSE; + syringePreloadStarted = FALSE; + resetPreLoadStatus(); + syringeRetractStarted = retractSyringePump(); + state = PRE_TX_HEPARIN_SETUP_PRELOAD_STATE; break;