Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r8afe61f9833d9184c3ac0a430186dcb9aed7d468 -r2f4f66fcceb986cc592693b08f1b57767cb1c515 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 8afe61f9833d9184c3ac0a430186dcb9aed7d468) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 2f4f66fcceb986cc592693b08f1b57767cb1c515) @@ -1,19 +1,19 @@ /************************************************************************** - * - * Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. - * - * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN - * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. - * - * @file ModePreTreat.c - * - * @author (last) Dara Navaei - * @date (last) 03-Jan-2023 - * - * @author (original) Dara Navaei - * @date (original) 05-Nov-2019 - * - ***************************************************************************/ +* +* Copyright (c) 2019-2023 Diality Inc. - All Rights Reserved. +* +* THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN +* WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. +* +* @file ModePreTreat.c +* +* @author (last) Sean Nash +* @date (last) 31-Jan-2023 +* +* @author (original) Dara Navaei +* @date (original) 05-Nov-2019 +* +***************************************************************************/ #include "AlarmMgmt.h" #include "Buttons.h" @@ -142,7 +142,7 @@ { int reservoirIndex = 0; - currentPreTreatmentState = HD_PRE_TREATMENT_START_STATE; + currentPreTreatmentState = HD_PRE_TREATMENT_WATER_SAMPLE_STATE; currentReservoirMgmtState = PRE_TREATMENT_RESERVOIR_MGMT_START_STATE; setUFVolStatus = FALSE; patientConnectionConfirm = FALSE; @@ -218,6 +218,9 @@ doorClosedRequired( FALSE, FALSE ); + // Start pre-treatment mode in sample water state + transitionToSampleWater(); + return currentPreTreatmentState; } @@ -240,16 +243,6 @@ // execute mode state machine switch ( currentPreTreatmentState ) { - case HD_PRE_TREATMENT_START_STATE: -#ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_SAMPLE_WATER ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - transitionToSampleWater(); - } - currentPreTreatmentState = HD_PRE_TREATMENT_WATER_SAMPLE_STATE; - break; - case HD_PRE_TREATMENT_WATER_SAMPLE_STATE: currentPreTreatmentState = handleWaterSampleState(); break; @@ -666,7 +659,7 @@ patientConnectionConfirm = FALSE; treatmentStartRequested = FALSE; - doorClosedRequired( FALSE, FALSE ); + doorClosedRequired( TRUE, TRUE ); for ( valve = VDI; valve < NUM_OF_VALVES; ++valve ) { @@ -698,27 +691,25 @@ if ( SAMPLE_WATER_COMPLETE_STATE == getSampleWaterState() ) { - { - cmdDGSampleWater( SAMPLE_WATER_CMD_END ); + cmdDGSampleWater( SAMPLE_WATER_CMD_END ); - if ( SELF_TEST_STATUS_PASSED == getSampleWaterResult() ) + if ( SELF_TEST_STATUS_PASSED == getSampleWaterResult() ) + { + if ( ( DG_MODE_STAN == dgOpMode ) && ( DG_STANDBY_MODE_STATE_IDLE == dgSubMode ) ) { - if ( ( DG_MODE_STAN == dgOpMode ) && ( DG_STANDBY_MODE_STATE_IDLE == dgSubMode ) ) - { - state = HD_PRE_TREATMENT_SELF_TEST_CONSUMABLE_STATE; - cmdStartDG(); - transitionToConsumableSelfTest(); - } - else - { - cmdStopDG(); - } + state = HD_PRE_TREATMENT_SELF_TEST_CONSUMABLE_STATE; + cmdStartDG(); + transitionToConsumableSelfTest(); } else { - requestNewOperationMode( MODE_STAN ); + cmdStopDG(); } } + else + { + requestNewOperationMode( MODE_STAN ); + } } return state; @@ -926,7 +917,7 @@ * @brief * The handlePatientConnectionState function handles patient connection state * during pre-treatment mode. - * @details Inputs: none + * @details Inputs: alarmActionResumeReceived * @details Outputs: requested mode transition to treatment mode * @return current state (sub-mode) *************************************************************************/ @@ -940,6 +931,19 @@ requestNewOperationMode( MODE_TREA ); } + if ( TRUE == doesAlarmStatusIndicateStop() ) + { + signalDialInPumpHardStop(); + cmdStopDGTrimmerHeater(); + } + else if ( TRUE == alarmActionResumeReceived ) + { + alarmActionResumeReceived = FALSE; + //setDialInPumpTargetFlowRate( DIP_PATIENT_CONNECTION_FLOW_RATE_ML_MIN, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); + setDialInPumpTargetFlowRate( 250, MOTOR_DIR_FORWARD, PUMP_CONTROL_MODE_OPEN_LOOP ); // TODO remove this line once the new flow control is implemented + cmdStartDGTrimmerHeater(); + } + return HD_PRE_TREATMENT_PATIENT_CONNECTION_STATE; }