Index: firmware/App/Services/StateServices/TubeSetInstall.c =================================================================== diff -u -r9c833ef5623ce842267e284d958820ac0dc3a7fc -r06462a7f903d6ac4835125746b6b6394be4601ae --- firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 9c833ef5623ce842267e284d958820ac0dc3a7fc) +++ firmware/App/Services/StateServices/TubeSetInstall.c (.../TubeSetInstall.c) (revision 06462a7f903d6ac4835125746b6b6394be4601ae) @@ -17,6 +17,7 @@ #include "AlarmMgmtTD.h" #include "BloodFlow.h" +#include "DDInterface.h" #include "Messaging.h" #include "OperationModes.h" #include "PeristalticPump.h" @@ -25,6 +26,7 @@ #include "TDDefs.h" #include "Timers.h" #include "TubeSetInstall.h" +#include "TxParams.h" /** * @addtogroup TubeSetInstall @@ -42,6 +44,7 @@ // ********** private data ********** static BOOL confirmTubesetPlaced; ///< Flag indicating user has confirmed tubeset is placed +static BOOL setupConnectionsConfirmed; ///< Flag indicating user has confirmed setup connections are complete. static U32 bloodPumpTimerCounter; ///< Blood Pump timer counter static BOOL bpLastHome; ///< Flag for blood pump last home (for rising-edge) static U32 bpLeftHomeTimerCounter; ///< Timer counter to measure how long BP has been away from home @@ -51,11 +54,12 @@ // ********** 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 -static TUBE_SET_INSTALL_STATE_T handleInstallCompleteState( void ); ///< Handle Install complete state +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 handleAwaitSetupConnectionConfirmationState( void ); ///< Handle Await Setup Connection Confirmation 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 @@ -67,12 +71,13 @@ **************************************************************************/ void initTubeSetInstall( void ) { - previousInstallState = TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION; - currentInstallState = TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION; - confirmTubesetPlaced = FALSE; - bloodPumpTimerCounter = 0; - bpLastHome = TRUE; - bpLeftHomeTimerCounter = 0; + previousInstallState = TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION; + currentInstallState = TUBE_SET_INSTALL_STATE_AWAIT_TUBE_SET_CONFIRMATION; + confirmTubesetPlaced = FALSE; + setupConnectionsConfirmed = FALSE; + bloodPumpTimerCounter = 0; + bpLastHome = TRUE; + bpLeftHomeTimerCounter = 0; } /*********************************************************************//** @@ -104,6 +109,10 @@ currentInstallState = handleAutoLoadBackOffState(); break; + case TUBE_SET_INSTALL_STATE_AWAIT_SETUP_CONNECTION_CONFIRMATION: + currentInstallState = handleAwaitSetupConnectionConfirmationState(); + break; + case TUBE_SET_INSTALL_STATE_COMPLETE: currentInstallState = handleInstallCompleteState(); break; @@ -204,7 +213,7 @@ signalBloodPumpHardStop(); bloodPumpTimerCounter = 0; bpLeftHomeTimerCounter = 0; - state = TUBE_SET_INSTALL_STATE_COMPLETE; + state = TUBE_SET_INSTALL_STATE_AWAIT_SETUP_CONNECTION_CONFIRMATION; } else { @@ -223,6 +232,40 @@ /*********************************************************************//** * @brief + * The handleAwaitSetupConnectionConfirmationState function handles the + * Await Setup Connection Confirmation state of Tube Set install state. + * @details \b Inputs: setupConnectionsConfirmed + * @details \b Outputs: setupConnectionsConfirmed + * @return next Install sub-state + *************************************************************************/ +static TUBE_SET_INSTALL_STATE_T handleAwaitSetupConnectionConfirmationState( void ) +{ + TUBE_SET_INSTALL_STATE_T state = TUBE_SET_INSTALL_STATE_AWAIT_SETUP_CONNECTION_CONFIRMATION; + F32 bicarbConvFactor = BICARBONATE_CONVERSION_FACTOR; + + if ( TRUE == setupConnectionsConfirmed ) + { + setupConnectionsConfirmed = FALSE; + + // Request DD to generate dialysate with Qd = 600 mL/min, + // Quf = 0, and dialyzer bypassed. + cmdStartGenerateDialysate( 600.0F, + 0.0F, + getTreatmentParameterF32( TREATMENT_PARAM_DIALYSATE_TEMPERATURE ), + TRUE, + getTreatmentParameterF32( TREATMENT_PARAM_ACID_CONCENTRATE_CONV_FACTOR ), + bicarbConvFactor, + getTreatmentParameterU32( TREATMENT_PARAM_SODIUM ), + getTreatmentParameterU32( TREATMENT_PARAM_BICARBONATE ) ); + + state = TUBE_SET_INSTALL_STATE_COMPLETE; + } + + return state; +} + +/*********************************************************************//** + * @brief * The handleAutoLoadBackOffState function handles the Auto-Load Back-Off * state of Tube Set install state. * @details \b Inputs: bloodPumpTimerCounter @@ -332,4 +375,45 @@ return result; } +/*********************************************************************//** + * @brief + * The handleSetupConnectionConfirmRequest function handles a UI request + * to confirm setup connections are complete. + * @details \b Inputs: none + * @details \b Outputs: setupConnectionsConfirmed + * @param message UI message which includes the user confirmation of + * setup connections completion. + * @return TRUE if confirmation accepted, FALSE otherwise. + *************************************************************************/ +BOOL handleSetupConnectionConfirmRequest( MESSAGE_T *message ) +{ + BOOL result = FALSE; + UI_RESPONSE_PAYLOAD_T response; + + response.rejectionReason = REQUEST_REJECT_REASON_NONE; + + if ( 0 == message->hdr.payloadLen ) + { + if ( TUBE_SET_INSTALL_STATE_AWAIT_SETUP_CONNECTION_CONFIRMATION == currentInstallState ) + { + setupConnectionsConfirmed = TRUE; + result = TRUE; + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_NOT_ALLOWED_IN_CURRENT_MODE; + } + } + else + { + response.rejectionReason = REQUEST_REJECT_REASON_INVALID_REQUEST_FORMAT; + } + + response.accepted = result; + + sendMessage( MSG_ID_TD_SETUP_CONNECTION_CONFIRM_RESPONSE, COMM_BUFFER_OUT_CAN_TD_2_UI, (U08*)&response, sizeof( UI_RESPONSE_PAYLOAD_T ) ); + + return result; +} + /**@}*/