Index: firmware/App/Modes/SelfTests.c =================================================================== diff -u -rf673a49d52be60f2b75f41b2ff713cd520e634bf -rcd5be724d5a3ba7457e761191d82f278654d7f5c --- firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision f673a49d52be60f2b75f41b2ff713cd520e634bf) +++ firmware/App/Modes/SelfTests.c (.../SelfTests.c) (revision cd5be724d5a3ba7457e761191d82f278654d7f5c) @@ -1,14 +1,14 @@ /************************************************************************** * -* Copyright (c) 2021-2023 Diality Inc. - All Rights Reserved. +* Copyright (c) 2021-2024 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 SelfTests.c * -* @author (last) Michael Garthwaite -* @date (last) 29-Jul-2023 +* @author (last) Bill Bracken +* @date (last) 18-Oct-2023 * * @author (original) Quang Nguyen * @date (original) 28-Jan-2021 @@ -43,8 +43,8 @@ #define PUMP_RUN_SELF_TEST_TIME_MS ( 15 * MS_PER_SECOND ) ///< Self-test time to run pumps in ms. #define PUMP_SELF_TEST_FLOW_RATE_ML_MIN 100 ///< Self-test pump flow rate in mL/min. -#define BLOOD_PUMP_PRESSURE_SELF_TEST_FLOW 100 -#define DIAL_IN_PUMP_PRESSURE_SELF_TEST_FLOW 400 +#define BLOOD_PUMP_PRESSURE_SELF_TEST_FLOW 100 ///< Pressure self-test BP flow rate in mL/min. +#define DIAL_IN_PUMP_PRESSURE_SELF_TEST_FLOW 400 ///< Pressure self-test DPi flow rate in mL/min. #define SYRINGE_PUMP_OCCLUSION_CHECK_DELAY ( 1 * MS_PER_SECOND ) ///< Delay 1 second then check for syringe pump prime occlusion. #define PRE_NORMAL_PRESSURE_SELF_TEST_DELAY_MS ( 5 * MS_PER_SECOND ) ///< Delay 5 second prior to getting initial normal baseline pressures. @@ -127,6 +127,7 @@ static U32 bloodLeakDebubbleStartTimeMS; ///< Blood leak detector debubble start time in milliseconds. static BOOL useHeparin; ///< Flag indicates the user of heparin. +static BOOL heparinOcclusionTestRun; ///< Flag indicates whether the heparin occlusion test has been run. static BOOL selfTestsResumeRequested; ///< Flag indicates user requesting self-tests resume. static BOOL cartridgeUsedTestRun; ///< Flag indicates whether the used cartridge test has been run. static BOOL occlusionBaselineWasSet; ///< Flag indicates whether the blood pump occlusion baseline for installed cartridge has been set. @@ -220,7 +221,7 @@ * @brief * The setupForSelfTestsStop function sets actuators appropriately for self-tests * states. - * @details Inputs: none + * @details Inputs: dryPressureTestsCompleted, PreTreatmentSubState * @details Outputs: All pumps stopped * @return none *************************************************************************/ @@ -242,9 +243,21 @@ setValvePosition( VDI, VALVE_POSITION_A_INSERT_EJECT ); setValvePosition( VDO, VALVE_POSITION_A_INSERT_EJECT ); - setValvePosition( VBA, VALVE_POSITION_A_INSERT_EJECT ); setValvePosition( VBV, VALVE_POSITION_A_INSERT_EJECT ); - setValveAirTrap( STATE_CLOSED ); + + // If the HD has finished no cart s.t. but not dry pressure tests, Open VBT to vent pressure + // to prevent air going to the Saline bag. + if ( ( HD_PRE_TREATMENT_SELF_TEST_DRY_STATE == getPreTreatmentSubState() ) && ( FALSE == dryPressureTestsCompleted ) ) + { + setValvePosition( VBA, VALVE_POSITION_B_OPEN ); + setValveAirTrap( STATE_OPEN ); + } + + else + { + setValvePosition( VBA, VALVE_POSITION_A_INSERT_EJECT ); + setValveAirTrap( STATE_CLOSED ); + } } /*********************************************************************//** @@ -426,6 +439,7 @@ dryPressureTestsCompleted = FALSE; cartridgeUsedTestRun = FALSE; occlusionBaselineWasSet = FALSE; + heparinOcclusionTestRun = FALSE; selfTestStartTime = getMSTimerCount(); selfTestPreviousPublishDataTime = getMSTimerCount(); selfTestCartridgeSettleTime = getMSTimerCount(); @@ -608,6 +622,8 @@ setValvePosition( VBA, VALVE_POSITION_C_CLOSE ); setValvePosition( VBV, VALVE_POSITION_C_CLOSE ); + setCurrent4thLevelState( currentWetSelfTestsState ); + resetSelfTestsFlags(); } @@ -969,14 +985,11 @@ state = DRY_SELF_TESTS_WAIT_FOR_DOOR_CLOSE_STATE; } } - else + + if ( TRUE == doesAlarmStatusIndicateStop() ) { - // doorClosedRequired() will trigger alarms if pumpTrack is open - if ( TRUE == doesAlarmStatusIndicateStop() ) - { - state = DRY_SELF_TESTS_STOPPED_STATE; - setupForSelfTestsStop(); - } + state = DRY_SELF_TESTS_STOPPED_STATE; + setupForSelfTestsStop(); } return state; @@ -1535,8 +1548,8 @@ * @brief * The handleDrySelfTestSyringePumpOcclusionDetectionState function handles * occlusion detection after prime has completed. - * @details Inputs: none - * @details Outputs: none + * @details Inputs: syringeOcclusionDelayStartTime + * @details Outputs: heparinOcclusionTestRun * @return the next state of dry self-tests state machine *************************************************************************/ static DRY_SELF_TESTS_STATE_T handleDrySelfTestSyringePumpOcclusionDetectionState( void ) @@ -1549,6 +1562,7 @@ { state = DRY_SELF_TESTS_COMPLETE_STATE; } + heparinOcclusionTestRun = TRUE; } if ( TRUE == doesAlarmStatusIndicateStop() ) @@ -1565,7 +1579,7 @@ * The handleDrySelfTestStoppedState function handles the stopped dry self-tests * operation. * @details Inputs: selfTestsResumeRequested, occlusionBaselineWasSet, - * dryPressureTestsCompleted, cartridgeUsedTestRun + * dryPressureTestsCompleted, cartridgeUsedTestRun, heparinOcclusionTestRun * @details Outputs: selfTestsResumeRequested, selfTestStartTime, selfTestCartridgeSettleTime * @return the next state of dry self-tests state machine *************************************************************************/ @@ -1593,6 +1607,23 @@ } } + // if heparin occlusin alarm, keep calling check function so alarm condition will clear when resolved + if ( TRUE == isAlarmActive( ALARM_ID_HD_SYRINGE_PUMP_OCCLUSION ) ) + { + checkForSyringeOcclusion( FALSE ); + } + + // Set VBA to Pos A and close VBT after we have + // depressurized the line from failed pressure self tests. + if ( FALSE == dryPressureTestsCompleted ) + { + if ( getFilteredVenousPressure() <= NORMAL_PRESSURE_DIFF_TOLERANCE_MMHG ) + { + setValvePosition( VBA, VALVE_POSITION_A_INSERT_EJECT ); + setValveAirTrap( STATE_CLOSED ); + } + } + // if resume request, resume dry self-tests if ( TRUE == selfTestsResumeRequested ) { @@ -1602,8 +1633,12 @@ selfTestCartridgeSettleTime = getMSTimerCount(); doorClosedRequired( TRUE, TRUE ); - if ( TRUE == dryPressureTestsCompleted ) + if ( TRUE == heparinOcclusionTestRun ) { + state = DRY_SELF_TESTS_COMPLETE_STATE; + } + else if ( TRUE == dryPressureTestsCompleted ) + { state = DRY_SELF_TESTS_SYRINGE_PUMP_PRIME_STATE; } else @@ -1648,9 +1683,9 @@ setValvePosition( VDO, VALVE_POSITION_C_CLOSE ); // if user set a Heparin bolus volume, request bolus to be initiated now - if ( ( bolusVol > 0.0F ) && ( getSyringePumpVolumeDelivered() < bolusVol ) ) + if ( bolusVol > 0.0F ) { - startHeparinBolus(); // moved here from startHeparinPump() in Dialysis.c + startHeparinBolus(); // Function will only start bolus if necessary } if ( TRUE == doesAlarmStatusIndicateStop() ) @@ -1819,6 +1854,7 @@ { if ( TRUE == hasBloodLeakZeroSequenceFailed() ) { + zeroBloodLeakReset(); #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_BLOOD_LEAK_ALARM ) != SW_CONFIG_ENABLE_VALUE ) #endif @@ -2165,6 +2201,7 @@ static WET_SELF_TESTS_STATE_T handleWetSelfTestStoppedState( void ) { WET_SELF_TESTS_STATE_T state = WET_SELF_TESTS_STOPPED_STATE; + F32 bolusVol = getTreatmentParameterF32( TREATMENT_PARAM_HEPARIN_BOLUS_VOLUME ); setAlarmResumePerDoorAndLatch(); doorClosedRequired( FALSE, FALSE ); @@ -2183,6 +2220,12 @@ doorClosedRequired( TRUE, TRUE ); selfTestsResumeRequested = FALSE; + // if user set a Heparin bolus volume, request bolus to be initiated now + if ( bolusVol > 0.0F ) + { + startHeparinBolus(); // Function will only start bolus if necessary + } + switch( checkpointWetSelfTestsState ) { case WET_SELF_TESTS_BUBBLE_CHECK_SETUP_STATE: