Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -rbd4f21cec7b0d25c6a83a53a15220550d4e7bda3 -r5003153f03d3ec0e831d5db6bb4c88fbed1c6a99 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision bd4f21cec7b0d25c6a83a53a15220550d4e7bda3) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 5003153f03d3ec0e831d5db6bb4c88fbed1c6a99) @@ -700,7 +700,7 @@ patientConnectionConfirm = FALSE; treatmentStartRequested = FALSE; - doorClosedRequired( FALSE, TRUE ); + doorClosedRequired( TRUE, TRUE ); for ( valve = VDI; valve < NUM_OF_VALVES; ++valve ) { @@ -1003,26 +1003,47 @@ /*********************************************************************//** * @brief + * The handlePatientConnectionDoorOpened function handles the check + * for door opened in pre-treatment patient connection + * sub-mode. + * @details Inputs: none + * @details Outputs: doorOpened + * @return none + *************************************************************************/ +static void handlePatientConnectionDoorOpened( void ) +{ + // Look for cartridge door to open (indicating user inverting dialyzer) + if ( STATE_OPEN == getSwitchStatus( FRONT_DOOR ) ) + { + doorOpened = TRUE; + cmdStopDGTrimmerHeater(); + signalDialInPumpHardStop(); + } + else + { + setDialInPumpTargetFlowRate( DIP_PATIENT_CONNECTION_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + cmdStartDGTrimmerHeater(); + } +} + +/*********************************************************************//** + * @brief * The handlePatientConnectionWait4UFVolState function handles the wait * for ultrafiltration volume setting state of pre-treatment patient connection * sub-mode. * @details Inputs: setUFVolStatus - * @details Outputs: setUFVolStatus, doorOpened + * @details Outputs: setUFVolStatus * @return next patient connection state *************************************************************************/ static HD_PRE_TREATMENT_PAT_CONN_STATE_T handlePatientConnectionWait4UFVolState( void ) { HD_PRE_TREATMENT_PAT_CONN_STATE_T nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_UF_VOL_STATE; - // Look for cartridge door to open (indicating user inverting dialyzer) - if ( STATE_OPEN == getSwitchStatus( FRONT_DOOR ) ) - { - doorOpened = TRUE; - } // If UF volume set by user, move on to next state if ( TRUE == setUFVolStatus ) { setUFVolStatus = FALSE; + doorClosedRequired( FALSE, TRUE ); nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_DLZR_INVERT_STATE; } @@ -1035,18 +1056,16 @@ * for dialyzer invert confirmation state of pre-treatment patient connection * sub-mode. * @details Inputs: doorOpened - * @details Outputs: doorOpened + * @details Outputs: none * @return next patient connection state *************************************************************************/ static HD_PRE_TREATMENT_PAT_CONN_STATE_T handlePatientConnectionWait4DialyzerInvertState( void ) { HD_PRE_TREATMENT_PAT_CONN_STATE_T nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_DLZR_INVERT_STATE; // Look for cartridge door to open and then close (indicating user inverted dialyzer) - if ( STATE_OPEN == getSwitchStatus( FRONT_DOOR ) ) - { - doorOpened = TRUE; - } + handlePatientConnectionDoorOpened(); + if ( ( TRUE == doorOpened ) && ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) ) { nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_USER_CONFIRM_STATE; @@ -1068,10 +1087,16 @@ { HD_PRE_TREATMENT_PAT_CONN_STATE_T nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_USER_CONFIRM_STATE; + // Look for cartridge door to open and then close (indicating user inverted dialyzer) + handlePatientConnectionDoorOpened(); + if ( TRUE == patientConnectionConfirm ) { doorClosedRequired( TRUE, TRUE ); - nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_TREATMENT_START_STATE; + if ( STATE_CLOSED == getSwitchStatus( FRONT_DOOR ) ) + { + nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_TREATMENT_START_STATE; + } } return nextState;