Index: firmware/App/Modes/ModePostTreat.c =================================================================== diff -u -ra57af2726f27208a2de96e9331678caf022d927d -rf4da3db4393f4f58c032365580cdba1e1e20d2e8 --- firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision a57af2726f27208a2de96e9331678caf022d927d) +++ firmware/App/Modes/ModePostTreat.c (.../ModePostTreat.c) (revision f4da3db4393f4f58c032365580cdba1e1e20d2e8) @@ -45,9 +45,7 @@ static TD_POST_TREATMENT_STATE_T currentPostTreatmentState; ///< Current Post-Treatment sub-state 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 BOOL ddStandbyCommandSent; ///< Flag indicates DD Standby command has been sent. static DISINFECT_SELECTION_T selectedDisinfectionSelection; ///< Selected disinfection option from UI. static BOOL disinfectionSelectionReceived; static volatile U32 postTreatmentStateBroadcastTimer; ///< Timer counter for pending power off request. @@ -71,9 +69,7 @@ { currentPostTreatmentState = TD_POST_TREATMENT_PATIENT_DISCONNECTION_STATE; patientDisconnectionConfirmed = FALSE; - patientDisconnectHandled = FALSE; disposableRemovalConfirmed = FALSE; - ddStandbyCommandSent = FALSE; disinfectionSelectionReceived = FALSE; selectedDisinfectionSelection = DISINFECT_SEL_SKIP; postTreatmentStateBroadcastTimer = 0; @@ -90,6 +86,7 @@ **************************************************************************/ U32 transitionToPostTreatmentMode( void ) { + cmdSendDDCommand( DD_CMD_GOTO_POST_GENERATE ); initPostTreatmentMode(); initTubeSetAutoEject(); doorClosedRequired(TRUE); @@ -222,42 +219,36 @@ * @brief * The handlePatientDisconnectionState function executes the Post-Treatment * mode Patient Disconnection state machine. - * @details \b Inputs: none - * @details \b Outputs: processed patient disconnection confirmation - * @return next post-treatment mode state + * @details \b Inputs: patientDisconnectionConfirmed. + * @details \b Outputs: Requests DD Post-Generate and processes 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; - VALVE_T valve; - if ( ( TRUE == patientDisconnectionConfirmed ) && ( FALSE == patientDisconnectHandled ) ) + if ( TRUE == patientDisconnectionConfirmed ) { - // home valves and pumps while front door is still closed. + patientDisconnectionConfirmed = FALSE; + + // Home valves and pumps while front door is still closed. homeBloodPump(); + for ( valve = H1_VALV; 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 ); - // Patient has been disconnected. DD no longer needs to remain - // in Generate Dialysate mode. - cmdSendDDCommand( DD_CMD_GOTO_POST_GENERATE ); - - patientDisconnectHandled = TRUE; - } - if ( TRUE == patientDisconnectionConfirmed ) - { - patientDisconnectionConfirmed = FALSE; - patientDisconnectHandled = FALSE; - state = TD_POST_TREATMENT_AUTO_EJECT_STATE; } @@ -292,42 +283,21 @@ * @brief * The handleDisposableRemovalState function executes the Post-Treatment * Disposable Removal state. - * @details \b Inputs: disposableRemovalConfirmed and DD operation mode. - * @details \b Outputs: Requests DD transition from Post-Generate to - * Standby and advances to Disinfection after DD reaches Standby. + * @details \b Inputs: disposableRemovalConfirmed. + * @details \b Outputs: Processes disposable removal confirmation and + * advances to Disinfection Selection. * @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; - DD_CMD_RESPONSE_T ddCmdResp; + TD_POST_TREATMENT_STATE_T state = + TD_POST_TREATMENT_DISPOSABLE_REMOVAL_STATE; if ( TRUE == disposableRemovalConfirmed ) { - // Wait until DD has completed the transition to Post-Generate - // before requesting DD Standby. - if ( FALSE == ddStandbyCommandSent ) - { - if ( DD_MODE_POSG == getDDOpMode() ) - { - cmdSendDDCommand( DD_CMD_GOTO_STANDBY ); - ddStandbyCommandSent = TRUE; - } - } - else if ( TRUE == getDDCommandResponse( DD_CMD_GOTO_STANDBY, - &ddCmdResp ) ) - { - // Command was accepted. Wait for the DD operation-mode - // broadcast confirming DD has actually reached Standby. - if ( ( FALSE == ddCmdResp.rejected ) && - ( DD_MODE_STAN == getDDOpMode() ) ) - { - disposableRemovalConfirmed = FALSE; - ddStandbyCommandSent = FALSE; + disposableRemovalConfirmed = FALSE; - state = TD_POST_TREATMENT_DISINFECTION_STATE; - } - } + state = TD_POST_TREATMENT_DISINFECTION_STATE; } return state; @@ -373,10 +343,13 @@ if ( DD_CMD_NONE != command ) { - // Save selected disinfection option in Standby. + // Save selected disinfection option for Standby. signalStandbyDisinfectionSelection( command ); - // Transition TD to Standby. + // Request DD transition from Post-Generate to Standby. + cmdSendDDCommand( DD_CMD_GOTO_STANDBY ); + + // Request TD transition from Post-Treatment to Standby. requestNewOperationMode( MODE_STAN ); }