Index: firmware/App/Controllers/AirPump.c =================================================================== diff -u -r984bd22d53c604713e6b3a22a536c64a920e9100 -r88083999c2b4ef605de99209a6873421c7428952 --- firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 984bd22d53c604713e6b3a22a536c64a920e9100) +++ firmware/App/Controllers/AirPump.c (.../AirPump.c) (revision 88083999c2b4ef605de99209a6873421c7428952) @@ -161,15 +161,22 @@ break; } - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_AIR_PUMP_TIMEOUT, getAirPumpMotorState() ) ) - { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_AIR_PUMP_TIMEOUT, getAirPumpMotorState() ); - setAirPumpState(AIR_PUMP_STATE_OFF); - } - + execAirPumpMonitor(); publishAirPumpData(); + } +void execAirPumpMonitor( void ) +{ + if ( MODE_TREA == getCurrentOperationMode() ) + { + if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_AIR_PUMP_TIMEOUT, getAirPumpMotorState() ) ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_AIR_PUMP_TIMEOUT, getAirPumpMotorState() ); + setAirPumpState(AIR_PUMP_STATE_OFF); + } + } +} /*********************************************************************//** * @brief * The handleAirPumpStartState function starts the air pump state machine. Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -r984bd22d53c604713e6b3a22a536c64a920e9100 -r88083999c2b4ef605de99209a6873421c7428952 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 984bd22d53c604713e6b3a22a536c64a920e9100) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 88083999c2b4ef605de99209a6873421c7428952) @@ -351,47 +351,50 @@ { #ifndef _RELEASE_ if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) - { #endif + { if ( AIR_PUMP_STATE_OFF == getAirPumpState() ) { setAirPumpState( AIR_PUMP_STATE_ON ); } - else - { - airPumpUpperlevelctr--; - } -#ifndef _RELEASE_ } -#endif } else if ( ( AIR_TRAP_LEVEL_AIR == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_UPPER ) ) ) { #ifndef _RELEASE_ if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) - { #endif + { + if ( AIR_PUMP_STATE_ON == getAirPumpState() ) { airPumpUpperlevelctr++; // Turn air pump off once we detect air at upper level and exceed persistence // But first, open the air valve. if ( airPumpUpperlevelctr >= AIR_PUMP_UPPER_LEVEL_PERSISTENCE ) { - setValveAirTrap( STATE_OPEN ); - result = AIR_TRAP_VALVE_OPEN_STATE; + setAirPumpState( AIR_PUMP_STATE_OFF ); + airPumpUpperlevelctr = 0; } } -#ifndef _RELEASE_ } -#endif } // Transition to open valve state when air detected at lower level else if ( AIR_TRAP_LEVEL_AIR == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_LOWER ) ) { +#ifndef _RELEASE_ + if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) +#endif + { + if ( AIR_PUMP_STATE_ON == getAirPumpState() ) + { + setAirPumpState( AIR_PUMP_STATE_OFF ); + airPumpUpperlevelctr = 0; + } + } setValveAirTrap( STATE_OPEN ); fillStartTime = getMSTimerCount(); result = AIR_TRAP_VALVE_OPEN_STATE; @@ -418,22 +421,6 @@ pendingStopAirTrapController = FALSE; result = AIR_TRAP_MANUAL_CONTROL_STATE; } - // Turn air pump off once we detect air at upper level. - else if ( AIR_TRAP_LEVEL_AIR == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_UPPER ) ) - { -#ifndef _RELEASE_ - if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) - { -#endif - if ( AIR_PUMP_STATE_ON == getAirPumpState() ) - { - setAirPumpState( AIR_PUMP_STATE_OFF ); - airPumpUpperlevelctr = 0; - } -#ifndef _RELEASE_ - } -#endif - } // Transition to closed valve state when fluid detected at lower level else if ( AIR_TRAP_LEVEL_FLUID == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_LOWER ) ) { @@ -445,15 +432,13 @@ { #ifndef _RELEASE_ if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) - { #endif + { if ( AIR_PUMP_STATE_ON == getAirPumpState() ) { setAirPumpState( AIR_PUMP_STATE_OFF ); } -#ifndef _RELEASE_ } -#endif } return result; } Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -r984bd22d53c604713e6b3a22a536c64a920e9100 -r88083999c2b4ef605de99209a6873421c7428952 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 984bd22d53c604713e6b3a22a536c64a920e9100) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision 88083999c2b4ef605de99209a6873421c7428952) @@ -96,7 +96,8 @@ static const U32 EMPTY_SALINE_BAG_PERSISTENCE = ( 250 / TASK_GENERAL_INTERVAL ); ///< Time that saline bag looks empty before saying it is empty. #define PRES_ALARM_PERSISTENCE ( 1 * MS_PER_SECOND ) ///< Alarm persistence period for pressure alarms. -#define VEN_OCCL_ALARM_PERSISTENCE 100 ///< Alarm persistence period for venous occlusion alarm. +#define VEN_OCCL_ALARM_PERSISTENCE 100 ///< Alarm persistence period for venous occlusion alarm. +#define AIR_PUMP_TOLERANCE_TIMEOUT_MS (1 * MS_PER_SECOND ) /// Measured arterial pressure is filtered w/ 10 second moving average for pressure compensation of flow. #define SIZE_OF_LONG_ART_ROLLING_AVG ( ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) * 10 ) @@ -143,6 +144,8 @@ static F32 longFilteredArterialPressure; ///< Measured arterial pressure after long (10 s) filter. static F32 shortFilteredArterialPressure; ///< Measured arterial pressure after short (1 s) filter. static F32 shortFilteredVenousPressure; ///< Measured venous pressure after short (1 s) filter. +static BOOL airPumpOpenToleranceFlag; +static U32 airPumpOpenToleranceTimer; static U32 bloodPumpOcclusionAfterCartridgeInstall; ///< Measured blood pump occlusion reading taken after cartridge install. @@ -222,6 +225,8 @@ presOcclDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; presOcclState = PRESSURE_WAIT_FOR_POST_STATE; presOcclPostState = PRESSURE_SELF_TEST_STATE_START; + airPumpOpenToleranceFlag = FALSE; + airPumpOpenToleranceTimer = 0; #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_PRESSURE_CHECKS ) != SW_CONFIG_ENABLE_VALUE ) @@ -568,8 +573,29 @@ if ( AIR_PUMP_STATE_ON == getAirPumpState() ) { venHighLimit = (F32)getS32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT ) + VENOUS_OFFSET_WITH_AIRPUMP_MMHG; + airPumpOpenToleranceFlag = TRUE; + airPumpOpenToleranceTimer = getMSTimerCount(); } + //air pump is off. + else + { + //air pump was previously on. + if ( TRUE == airPumpOpenToleranceFlag ) + { + venHighLimit = (F32)getS32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT ) + VENOUS_OFFSET_WITH_AIRPUMP_MMHG; + // have we been off for at least 1s? Then reset timer, flag, and parameter. + if ( TRUE == didTimeout( airPumpOpenToleranceTimer, AIR_PUMP_TOLERANCE_TIMEOUT_MS ) ) + { + airPumpOpenToleranceFlag = FALSE; + venHighLimit = (F32)getS32TreatmentParamUpperRangeLimit( TREATMENT_PARAM_VEN_PRESSURE_HIGH_LIMIT ); + + } + } + + // we start the timer. + } + // Cannot monitor for low venous pressure while venting air trap if ( getValveAirTrapStatus() != STATE_OPEN ) { Index: firmware/App/Modes/ModePreTreat.c =================================================================== diff -u -r5ce2656c662525e10acd1e55f16f7aca5ce9b4d6 -r88083999c2b4ef605de99209a6873421c7428952 --- firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 5ce2656c662525e10acd1e55f16f7aca5ce9b4d6) +++ firmware/App/Modes/ModePreTreat.c (.../ModePreTreat.c) (revision 88083999c2b4ef605de99209a6873421c7428952) @@ -700,6 +700,11 @@ state = HD_PRE_TREATMENT_SELF_TEST_NO_CART_STATE; fillReservoirOneStartRequested = TRUE; transitionToNoCartSelfTests(); +#ifndef _RELEASE_ + if ( SW_CONFIG_DISABLE_VALUE == getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_PUMP ) ) +#endif + { + signalActionToResumeFill(); } }