Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -re5988dee900797f8e2b40b3e72d18f390d7b7402 -rf054fdd3579dacb03b5b41a363e259949ff63965 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision e5988dee900797f8e2b40b3e72d18f390d7b7402) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision f054fdd3579dacb03b5b41a363e259949ff63965) @@ -21,6 +21,7 @@ #include "ModePreTreat.h" #include "OperationModes.h" #include "PeristalticPump.h" +#include "Switches.h" #include "TaskGeneral.h" #include "TDDefs.h" #include "Timers.h" @@ -210,7 +211,7 @@ break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_PRE_TREATMENT_INVALID_STATE, (U32)currentPreTxInstallState ); + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_PRE_TX_INSTALL_INVALID_STATE, (U32)currentPreTxInstallState ); break; } @@ -221,20 +222,30 @@ * @brief * The handleAwaitTubesetConfirmationState function handles the Await * tubeset confirmation state of Pre-Treatement mode install state - * machine. Should wait for the user to confirm the tubeset is placed. - * @details Inputs: confirmTubsetPlaced - * @details Outputs: confirmTubsetPlaced, autoLoadHomePosCleared - * returns next Pre-Treatment install sub-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 + * @details Outputs: confirmTubesetPlaced, autoLoadHomePosCleared + * return next Pre-Treatment install sub-state *************************************************************************/ static PRE_TX_INSTALL_STATE_T handleAwaitTubesetConfirmationState( void ) { PRE_TX_INSTALL_STATE_T subState = PRE_TX_INSTALL_STATE_AWAIT_TUBING_SET_CONFIRMATION; if ( TRUE == confirmTubesetPlaced ) { - confirmTubesetPlaced = FALSE; - autoLoadHomePosCleared = FALSE; - subState = PRE_TX_INSTALL_STATE_AUTO_LOAD; + //BP door close check + if ( STATE_CLOSED == getSwitchState( H9_SWCH ) ) + { + doorClosedRequired(TRUE); + confirmTubesetPlaced = FALSE; + autoLoadHomePosCleared = FALSE; + subState = PRE_TX_INSTALL_STATE_AUTO_LOAD; + } + else + { + activateAlarmNoData( ALARM_ID_TD_CARTRIDGE_DOOR_OPENED ); + } } return subState; @@ -246,7 +257,7 @@ * Pre-Treatement mode install state. * @details Inputs: autoLoadHomePosCleared, autoLoadTimerCounter * @details Outputs: autoLoadHomePosCleared, autoLoadTimerCounter - * returns next Pre-Treatment install sub-state + * return next Pre-Treatment install sub-state *************************************************************************/ static PRE_TX_INSTALL_STATE_T handleAutoLoadState( void ) { @@ -274,6 +285,13 @@ else if ( TRUE == isPeristalticPumpHome() ) { signalBloodPumpHardStop(); + + // Send auto-load completion message + UI_RESPONSE_PAYLOAD_T response; + response.accepted = TRUE; + response.rejectionReason = REQUEST_REJECT_REASON_NONE; + sendMessage( MSG_ID_TD_ADJUST_DISPOSABLES_CONFIRM_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&response), sizeof( UI_RESPONSE_PAYLOAD_T ) ); + subState = NUM_OF_PRE_TX_INSTALL_SUB_STATES; } } @@ -283,24 +301,36 @@ /*********************************************************************//** * @brief - * The signalUserConfirmTubesetInstallation function sets the user - * confirmation flag signaling user has confirmed tubset installation + * The handleAutoLoadRequest function handles a UI request to + * confirm tubeset installation. * @details Inputs: none * @details Outputs: confirmTubesetPlaced - * @param message confirmation message from UI which includes the user - * confirmation of tubset installation. + * @param message UI message which includes the user confirmation of + * tubset installation. * @return TRUE if confirmation/rejection accepted, FALSE if not *************************************************************************/ -BOOL signalUserConfirmTubesetInstallation( MESSAGE_T *message ) +BOOL handleAutoLoadRequest( MESSAGE_T *message ) { BOOL confirmed = FALSE; BOOL result = FALSE; + TD_OP_MODE_T mode = getCurrentOperationMode(); + UI_RESPONSE_PAYLOAD_T response; + response.accepted = FALSE; + response.rejectionReason = REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; + if ( sizeof( BOOL ) == message->hdr.payloadLen ) { memcpy( &confirmed, message->payload, sizeof( BOOL ) ); - if ( TRUE == confirmed ) + BOOL notInValidState = ( ( TD_PRE_TREATMENT_TUBING_SET_INSTALL_STATE != currentPreTreatmentState ) || + ( PRE_TX_INSTALL_STATE_AWAIT_TUBING_SET_CONFIRMATION != currentPreTxInstallState ) ); + + if ( ( mode != MODE_PRET ) || ( TRUE == notInValidState ) ) { + sendMessage( MSG_ID_TD_ADJUST_DISPOSABLES_CONFIRM_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)(&response), sizeof( UI_RESPONSE_PAYLOAD_T ) ); + } + else if ( TRUE == confirmed ) + { confirmTubesetPlaced = TRUE; result = TRUE; }