Index: firmware/App/Controllers/BloodFlow.c =================================================================== diff -u -ra20840954a7862bcf0b7acb6c7b5742d088c1b53 -r0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3 --- firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision a20840954a7862bcf0b7acb6c7b5742d088c1b53) +++ firmware/App/Controllers/BloodFlow.c (.../BloodFlow.c) (revision 0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3) @@ -417,9 +417,13 @@ *************************************************************************/ BOOL homeBloodPump( void ) { +// BOOL result = FALSE; + if ( BLOOD_PUMP_OFF_STATE == bloodPumpState ) { bpHomeRequested = TRUE; +// bpHomeStartTime = getMSTimerCount(); +// result = setBloodPumpTargetRPM( BP_HOME_SPEED, MOTOR_DIR_FORWARD ); } else { Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -r9cc543b1c2508280767573e20eddd94e68be1fb5 -r0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3 --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 9cc543b1c2508280767573e20eddd94e68be1fb5) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision 0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3) @@ -20,7 +20,9 @@ #include "ModePostTreat.h" #include "OperationModes.h" #include "Switches.h" +#include "SyringePump.h" #include "TubeSetAutoEject.h" +#include "TxParams.h" /** * @addtogroup TDPostTreatmentMode @@ -29,6 +31,9 @@ // ********** private definitions ********** +static BOOL patientDisconnectionConfirmed; ///< Flag indicates user confirms patient disconnection. +static bool patientDisconnectHandled; ///< Flag indicates patient disconnect actions have been handled +static BOOL disposableRemovalConfirmed; ///< Flag indicates user confirms disposable removal. static TD_POST_TREATMENT_STATE_T currentPostTreatmentState; ///< Current Post-Treatment sub-state // ********** private function prototypes ********** @@ -48,6 +53,9 @@ **************************************************************************/ void initPostTreatmentMode( void ) { + patientDisconnectionConfirmed = FALSE; + patientDisconnectHandled = FALSE; + disposableRemovalConfirmed = FALSE; currentPostTreatmentState = TD_POST_TREATMENT_AUTO_EJECT_STATE; } @@ -122,21 +130,25 @@ switch ( currentPostTreatmentState ) { case TD_POST_TREATMENT_PATIENT_DISCONNECTION_STATE: - //currentPostTreatmentState = handlePatientDisconnectionState(); + currentPostTreatmentState = handlePatientDisconnectionState(); break; case TD_POST_TREATMENT_AUTO_EJECT_STATE: currentPostTreatmentState = handleAutoEjectState(); break; case TD_POST_TREATMENT_DISPOSABLE_REMOVAL_STATE: - //currentPostTreatmentState = handleDisposableRemovalState(); + currentPostTreatmentState = handleDisposableRemovalState(); break; case TD_POST_TREATMENT_VERIFY_STATE: - //currentPostTreatmentState = handleVerifyState(); + currentPostTreatmentState = handleVerifyState(); break; + case TD_POST_TREATMENT_DISINFECTION_STATE: + //currentPostTreatmentState = handleDisinfectionState(); + break; + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_MODE_POST_TREATMENT_INVALID_STATE, currentPostTreatmentState ); break; @@ -152,19 +164,58 @@ /*********************************************************************//** * @brief + * The checkPostTreatmentPatientDisconnect function checks UI patient + * disconnect and handles valve release, pump homing, door requirement. + * @details \b Inputs: patientDisconnectionConfirmed, patientDisconnectHandled + * @details \b Outputs: patientDisconnectHandled, home pumps, open valves, + * retract syringe, door closed requirement. + * @return none + *************************************************************************/ +static void checkPostTreatmentPatientDisconnect( void ) +{ +// VALVE_T valve; + + if ( ( TRUE == patientDisconnectionConfirmed ) && ( FALSE == patientDisconnectHandled ) ) + { + // home valves and pumps while front door is still closed. + homeBloodPump(); +// for ( valve = VDI; valve < NUM_OF_VALVES; valve++ ) + { +// setValvePosition( valve, VALVE_POSITION_A_INSERT_EJECT ); + } + if ( ( getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ) > 0.0 ) || + ( getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_DELIVERY_RATE ) > 0.0 ) ) + { + retractSyringePump(); + } + doorClosedRequired( FALSE ); + // NOTE: patientDisconnectionConfirmed is NOT reset because + // Patient Disconnect State needs it to move to next state + patientDisconnectHandled = TRUE; + } +} + +/*********************************************************************//** + * @brief * The handlePatientDisconnectionState function executes the Post-Treatment * mode Patient Disconnection state machine. - * @details \b Inputs: TODO fill up if any - * @details \b Outputs: TODO fill up if any + * @details \b Inputs: none + * @details \b Outputs: processed patient disconnection confirmation * @return next post-treatment mode state *************************************************************************/ static TD_POST_TREATMENT_STATE_T handlePatientDisconnectionState( void ) { TD_POST_TREATMENT_STATE_T state = TD_POST_TREATMENT_PATIENT_DISCONNECTION_STATE; - // TODO: Transition to Auto Eject state on completion when implemented - // state = TD_POST_TREATMENT_AUTO_EJECT_STATE; + checkPostTreatmentPatientDisconnect(); + if ( TRUE == patientDisconnectionConfirmed ) + { + patientDisconnectionConfirmed = FALSE; + patientDisconnectHandled = FALSE; + state = TD_POST_TREATMENT_DISPOSABLE_REMOVAL_STATE; + } + return state; } @@ -196,16 +247,19 @@ * @brief * The handleDisposableRemovalState function executes the Post-Treatment * mode Disposable Removal state machine. - * @details \b Inputs: TODO fill up if any - * @details \b Outputs: TODO fill up if any + * @details \b Inputs: disposableRemovalConfirmed + * @details \b Outputs: processed disposable removal confirmation * @return next post-treatment mode state *************************************************************************/ static TD_POST_TREATMENT_STATE_T handleDisposableRemovalState( void ) { TD_POST_TREATMENT_STATE_T state = TD_POST_TREATMENT_DISPOSABLE_REMOVAL_STATE; - // TODO: Transition to Verify state on completion when implemented - // state = TD_POST_TREATMENT_VERIFY_STATE; + if ( TRUE == disposableRemovalConfirmed ) + { + disposableRemovalConfirmed = FALSE; + state = TD_POST_TREATMENT_VERIFY_STATE; + } return state; } @@ -227,4 +281,30 @@ return state; } +/*********************************************************************//** + * @brief + * The signalUserConfirmPatientDisconnection signals post-treatment mode + * user has confirmed patient disconnection. + * @details \b Inputs: none + * @details \b Outputs: patientDisconnectedConfirm + * @return none + *************************************************************************/ +void signalUserConfirmPatientDisconnection( void ) +{ + patientDisconnectionConfirmed = TRUE; +} + +/*********************************************************************//** + * @brief + * The signalUserConfirmDisposableRemoval signals post-treatment mode + * user has confirmed disposable removal. + * @details \b Inputs: none + * @details \b Outputs: disposableRemovalConfirmed + * @return none + *************************************************************************/ +void signalUserConfirmDisposableRemoval( void ) +{ + disposableRemovalConfirmed = TRUE; +} + /**@}*/ Index: firmware/App/Modes/ModePostTreat.h =================================================================== diff -u -r9cc543b1c2508280767573e20eddd94e68be1fb5 -r0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3 --- firmware/App/Modes/ModePostTreat.h (.../ModePostTreat.h) (revision 9cc543b1c2508280767573e20eddd94e68be1fb5) +++ firmware/App/Modes/ModePostTreat.h (.../ModePostTreat.h) (revision 0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3) @@ -34,6 +34,7 @@ void initPostTreatmentMode( void ); // Initialize this module U32 transitionToPostTreatmentMode( void ); // Prepares for transition to post-treatment mode U32 execPostTreatmentMode( void ); // Execute the post-treatment mode state machine (call from OperationModes) +void signalUserConfirmPatientDisconnection( void ); /**@}*/ Index: firmware/App/Services/Messaging.c =================================================================== diff -u -rde6b47e92a4bffac2ae7238aba9d522bda3ae4df -r0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3 --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision de6b47e92a4bffac2ae7238aba9d522bda3ae4df) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3) @@ -116,6 +116,7 @@ { MSG_ID_UI_VERSION_INFO_RESPONSE, &handleUIVersionResponse }, { MSG_ID_DD_GEN_DIALYSATE_MODE_DATA, &setDialysateData }, { MSG_ID_DD_PRESSURES_DATA, &setDialysatePressure }, + { MSG_ID_UI_PATIENT_DISCONNECT_CONFIRM_REQUEST, &handlePatientDisconnectionConfirmCmd }, { MSG_ID_UI_TREATMENT_PARAMS_TO_VALIDATE, &validateAndSetTreatmentParameters }, { MSG_ID_UI_TREATMENT_UF_VOLUME_VALIDATE_REQUEST, &validateAndSetUFVolume }, { MSG_ID_UI_ULTRAFILTRATION_CHANGE_CONFIRM_REQUEST, &signalUserConfirmationOfUFVolume }, @@ -141,6 +142,7 @@ { MSG_ID_FFU_SIGNAL_TD_UPDATE_AVAILABLE, &handleUpdateAvailable }, { MSG_ID_UI_FLUID_BOLUS_REQUEST, &handleFluidBolusRequest }, { MSG_ID_UI_GENERIC_CONFIRMATION_RESULT_RESPONSE, &handleUIConfirmationResponse }, + { MSG_ID_UI_POST_TREATMENT_DISPOSABLE_REMOVAL_CONFIRM_REQUEST, &handleDisposableRemovalConfirmCmd }, { MSG_ID_TD_SOFTWARE_RESET_REQUEST, &testTDSoftwareResetRequest }, { MSG_ID_TD_BUBBLE_OVERRIDE_REQUEST, &testBubbleDetectOverride }, { MSG_ID_TD_BUBBLE_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testBubblesDataPublishIntervalOverride }, @@ -533,8 +535,8 @@ * @brief * The handleUIVersionResponse function handles a response to request for * UI version information. - * @details Inputs: none - * @details Outputs: none + * @details \b Inputs: none + * @details \b Outputs: none * @param message a pointer to the message to handle. * @return none *************************************************************************/ @@ -554,6 +556,48 @@ return result; } +/*********************************************************************//** + * @brief + * The handlePatientDisconnectionConfirmCmd function handles user confirms + * patient disconnection. + * @details \b Inputs: none + * @details \b Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handlePatientDisconnectionConfirmCmd( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmPatientDisconnection(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_TD_2_UI, FALSE ); + } +} + +/*********************************************************************//** + * @brief + * The handleDisposableRemovalConfirmCmd function handles user confirms + * disposable removal. + * @details \b Inputs: none + * @details \b Outputs: message handled + * @param message a pointer to the message to handle + * @return none. + *************************************************************************/ +void handleDisposableRemovalConfirmCmd( MESSAGE_T *message ) +{ + if ( 0 == message->hdr.payloadLen ) + { + signalUserConfirmDisposableRemoval(); + } + else + { + sendAckResponseMsg( (MSG_ID_T)message->hdr.msgID, COMM_BUFFER_OUT_CAN_TD_2_UI, FALSE ); + } +} + // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // *********************************************************************** Index: firmware/App/Services/Messaging.h =================================================================== diff -u -rde6b47e92a4bffac2ae7238aba9d522bda3ae4df -r0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3 --- firmware/App/Services/Messaging.h (.../Messaging.h) (revision de6b47e92a4bffac2ae7238aba9d522bda3ae4df) +++ firmware/App/Services/Messaging.h (.../Messaging.h) (revision 0cc67ce4bbaac3aeae8a3324e50e1b31e5ab49c3) @@ -144,6 +144,8 @@ BOOL handleTesterLogInRequest( MESSAGE_T *message ); BOOL handleUpdateAvailable( MESSAGE_T *message ); BOOL handleUIVersionResponse( MESSAGE_T *message ); +void handlePatientDisconnectionConfirmCmd( MESSAGE_T *message ); +void handleDisposableRemovalConfirmCmd( MESSAGE_T *message ); // Test send message helper functions BOOL sendEvent( TD_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 );