Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -r395522dffef1348e176564925656012f529c1910 -rfbbf8c0ed6f55670242c972094b443f67f61996c --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 395522dffef1348e176564925656012f529c1910) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision fbbf8c0ed6f55670242c972094b443f67f61996c) @@ -38,6 +38,7 @@ #define AIR_TRAP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the air trap data is published on the CAN bus. #define AIR_TRAP_FILL_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Air trap fill timeout period (in ms). +#define AIR_TRAP_LOWER_TIMEOUT_MS ( 10 * MS_PER_SECOND ) ///< Air trap lower timeout period (in ms). #define AIR_PUMP_ON_DELAY_TIME_MS ( 10 * MS_PER_SECOND ) ///< Delay between air pump On (in ms). #define AIR_PUMP_LOWER_OP_TIME_MIN_MS 200 ///< Air trap lower operation minimum time (in ms). #define AIR_PUMP_ON_ERROR_MAX_CNT 6 ///< Maximum number of air pump on events within time window before alarm triggered. Do not exceed MAX_TIME_WINDOWED_COUNT. @@ -127,6 +128,8 @@ airTrapLowerDelayStartTime = 0; airTrapLowerStartTime = 0; airTrapHasDetectedFaultMode = FALSE; + + initPersistentAlarm( ALARM_ID_TD_AIR_TRAP_ILLEGAL_LEVELS, AIR_TRAP_ILLEGAL_LEVELS_TIMEOUT_MS, AIR_TRAP_ILLEGAL_LEVELS_TIMEOUT_MS ); } /*********************************************************************//** @@ -238,9 +241,11 @@ * @brief * The execAirTrapMonitorTreatment function executes the air trap monitor * for treatment mode. - * @details \b Alarm: ALARM_ID_TD_AIR_TRAP_FILL_DURING_TREATMENT if air trap + * @details \b Alarm: ALARM_ID_TD_AIR_TRAP_LEVEL_HIGH if air trap * fill exceeds maximum allowed time to complete. - * @details \b Inputs: airTrapControllerState, fillStartTime + * @details \b Alarm: ALARM_ID_TD_AIR_TRAP_LEVEL_LOW if air trap + * lowering time exceeds maximum allowed time to complete. + * @details \b Inputs: airTrapControllerState, airTrapFillStartTime, airTrapLowerStartTime * @details \b Outputs: none * @return none *************************************************************************/ @@ -256,11 +261,26 @@ #endif { #ifndef TEST_UI_ONLY - activateAlarmNoData( ALARM_ID_TD_AIR_TRAP_FILL_DURING_TREATMENT ); + activateAlarmNoData( ALARM_ID_TD_AIR_TRAP_LEVEL_HIGH ); #endif } } } + // Check air trap lower timeout during treatment + else if ( AIR_TRAP_LOWER_LEVEL_STATE == airTrapControllerState ) + { + if ( TRUE == didTimeout( airTrapLowerStartTime, AIR_TRAP_FILL_TIMEOUT_MS ) ) + { +#ifndef _RELEASE_ +// if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_TRAP_LEVELING_ALARM ) != SW_CONFIG_ENABLE_VALUE ) +#endif + { +#ifndef TEST_UI_ONLY + activateAlarmNoData( ALARM_ID_TD_AIR_TRAP_LEVEL_LOW ); +#endif + } + } + } } /*********************************************************************//** @@ -439,9 +459,10 @@ { AIR_TRAP_STATE_T result = AIR_TRAP_LOWER_LEVEL_STATE; // Air pump stop time based on the blood flow rate - S32 qB = 500; // TODO abs( getTargetBloodFlowRate() ); + S32 qB = getTargetBloodFlowRate(); + // MIN_SET_BLOOD_FLOW_RATE-> #include "BloodFlow.h" U32 qBx = ( 0 == qB ? MIN_SET_BLOOD_FLOW_RATE : (U32)qB ); - U32 airPumpStopTime = 1000; //AIR_PUMP_LOWER_OP_TIME_MIN_MS + ( ( qBx - MIN_SET_BLOOD_FLOW_RATE ) / 2 ); + U32 airPumpStopTime = AIR_PUMP_LOWER_OP_TIME_MIN_MS + ( ( qBx - MIN_SET_BLOOD_FLOW_RATE ) / 2 ); // Transition to manual valve control state when requested if ( TRUE == pendingStopAirTrapController ) @@ -451,7 +472,7 @@ set3WayValveState( H13_VALV, VALVE_3WAY_COMMON_TO_CLOSED_STATE ); result = AIR_TRAP_MANUAL_CONTROL_STATE; } - // Transition back to closed state when air trap lower level operation completed when air detected at upper level + // Transition back to closed state when air trap lower level operation completed and air detected at upper level else if ( ( TRUE == didTimeout( airTrapLowerStartTime, airPumpStopTime ) ) || ( AIR_TRAP_LEVEL_AIR == getRawLevelSensorState( H16_LEVL ) ) ) { @@ -461,10 +482,6 @@ signalLowVenousPressureCheck(); SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_AIR_TRAP_LOWER, OFF, 0 ); // if lower level operation times out, alarm - if ( TRUE == didTimeout( airTrapLowerStartTime, airPumpStopTime ) ) - { - // TODO - alarm??? - } result = AIR_TRAP_CLOSED_STATE; }