Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r35a326b0f9f2fd83bac4be54e67ebde2d3f2c7e1 -rd49b9342b9ae67284d9423224f96838f91f8a1aa --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 35a326b0f9f2fd83bac4be54e67ebde2d3f2c7e1) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision d49b9342b9ae67284d9423224f96838f91f8a1aa) @@ -7,8 +7,8 @@ * * @file ModePreTreat.c * -* @author (last) Dara Navaei -* @date (last) 04-May-2023 +* @author (last) Darren Cox +* @date (last) 16-May-2023 * * @author (original) Dara Navaei * @date (original) 05-Nov-2019 @@ -991,22 +991,45 @@ /*********************************************************************//** * @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; - } + // Look for cartridge door to open and then close (indicating user inverted dialyzer) + handlePatientConnectionDoorOpened(); + // If UF volume set by user, move on to next state if ( TRUE == setUFVolStatus ) { @@ -1023,20 +1046,20 @@ * 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 ) ) ) { + doorClosedRequired( TRUE, TRUE ); + doorOpened = FALSE; nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_USER_CONFIRM_STATE; } @@ -1058,7 +1081,7 @@ if ( TRUE == patientConnectionConfirm ) { - doorClosedRequired( TRUE, TRUE ); + patientConnectionConfirm = FALSE; nextState = PRE_TREATMENT_PAT_CONN_WAIT_FOR_TREATMENT_START_STATE; }