Index: firmware/App/Controllers/AirTrap.c =================================================================== diff -u -r3d72b777cf1ceb673d118341c46e2d6d5b7b75f5 -r405d46b9b75630e35f003c42647d85c83d166b62 --- firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 3d72b777cf1ceb673d118341c46e2d6d5b7b75f5) +++ firmware/App/Controllers/AirTrap.c (.../AirTrap.c) (revision 405d46b9b75630e35f003c42647d85c83d166b62) @@ -14,30 +14,31 @@ * @date (original) 16-Sep-2020 * ***************************************************************************/ - -#include "AirTrap.h" -#include "AlarmMgmt.h" + +#include "AirTrap.h" +#include "AlarmMgmt.h" #include "FPGA.h" -#include "ModeTreatmentParams.h" -#include "OperationModes.h" -#include "SystemCommMessages.h" +#include "ModeTreatmentParams.h" +#include "OperationModes.h" +#include "SystemCommMessages.h" #include "TaskGeneral.h" -#include "TaskPriority.h" -#include "Timers.h" - -/** - * @addtogroup AirTrap - * @{ - */ - -// ********** private definitions ********** +#include "TaskPriority.h" +#include "Timers.h" -/// Interval (ms/task time) at which the air trap data is published on the CAN bus. +/** + * @addtogroup AirTrap + * @{ + */ + +// ********** private definitions ********** + +/// Interval (ms/task time) at which the air trap data is published on the CAN bus. #define AIR_TRAP_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) /// Persistence period for illegal level sensors fault. static const U32 AIR_TRAP_ILLEGAL_LEVELS_PERSISTENCE = ( MS_PER_SECOND * 2 / TASK_PRIORITY_INTERVAL ); /// Volume (in mL) of venous portion of blood circuit line. TODO - get actual volume from Systems. -#define VENOUS_LINE_VOLUME_ML ( 200.0 ) +#define VENOUS_LINE_VOLUME_ML ( 200.0 ) +#define DATA_PUBLISH_COUNTER_START_COUNT 7 ///< Data publish counter start count. /// Defined states for the air trap controller state machine. typedef enum AirTrap_States @@ -52,39 +53,39 @@ // ********** private data ********** static AIR_TRAP_STATE_T airTrapControllerState; ///< Current state of air trap controller state machine. -static U32 airTrapDataPublicationTimerCounter = 0; ///< Used to schedule air trap data publication to CAN bus. - +static U32 airTrapDataPublicationTimerCounter; ///< Used to schedule air trap data publication to CAN bus. + /// Interval (in ms) at which to publish air trap data to CAN bus. -static OVERRIDE_U32_T airTrapDataPublishInterval = { AIR_TRAP_DATA_PUB_INTERVAL, AIR_TRAP_DATA_PUB_INTERVAL, 0, 0 }; -static OVERRIDE_U32_T airTrapLevels[ NUM_OF_AIR_TRAP_LEVEL_SENSORS ]; ///< Detected air trap level for each level sensor. +static OVERRIDE_U32_T airTrapDataPublishInterval = { AIR_TRAP_DATA_PUB_INTERVAL, AIR_TRAP_DATA_PUB_INTERVAL, 0, 0 }; +static OVERRIDE_U32_T airTrapLevels[ NUM_OF_AIR_TRAP_LEVEL_SENSORS ]; ///< Detected air trap level for each level sensor. static BOOL pendingStartAirTrapController = FALSE; ///< Flag indicates an air trap controller start request is pending. static BOOL pendingStopAirTrapController = FALSE; ///< Flag indicates an air trap controller stop request is pending. static U32 fillStartTime = 0; ///< Time stamp for start of air trap fill. static U32 airTrapIllegalLevelSensorsCtr = 0; ///< Timer counter for illegal level sensor fault. - -// ********** private function prototypes ********** - -static AIR_TRAP_STATE_T handleAirTrapManualControlState( void ); -static AIR_TRAP_STATE_T handleAirTrapValveClosedState( void ); + +// ********** private function prototypes ********** + +static AIR_TRAP_STATE_T handleAirTrapManualControlState( void ); +static AIR_TRAP_STATE_T handleAirTrapValveClosedState( void ); static AIR_TRAP_STATE_T handleAirTrapValveOpenState( void ); -static void publishAirTrapData( void ); - -/*********************************************************************//** - * @brief - * The initAirTrap function initializes the Air Trap module. - * @details Inputs: none - * @details Outputs: Air Trap module initialized. - * @return none - *************************************************************************/ +static void publishAirTrapData( void ); + +/*********************************************************************//** + * @brief + * The initAirTrap function initializes the Air Trap module. + * @details Inputs: none + * @details Outputs: Air Trap module initialized. + * @return none + *************************************************************************/ void initAirTrap( void ) { U32 i; resetAirTrap(); - airTrapIllegalLevelSensorsCtr = 0; + airTrapIllegalLevelSensorsCtr = DATA_PUBLISH_COUNTER_START_COUNT; for ( i = 0; i < NUM_OF_AIR_TRAP_LEVEL_SENSORS; i++ ) { @@ -182,10 +183,14 @@ ( AIR_TRAP_LEVEL_FLUID == getAirTrapLevel( AIR_TRAP_LEVEL_SENSOR_UPPER ) ) ) { if ( ++airTrapIllegalLevelSensorsCtr >= AIR_TRAP_ILLEGAL_LEVELS_PERSISTENCE ) + { -#ifndef DISABLE_ILLEGAL_AIR_TRAP_ALARM - activateAlarmNoData( ALARM_ID_AIR_TRAP_ILLEGAL_LEVELS ); +#ifndef _RELEASE_ + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_ILLEGAL_AIR_TRAP_ALARM ) != SW_CONFIG_ENABLE_VALUE ) #endif + { + activateAlarmNoData( ALARM_ID_AIR_TRAP_ILLEGAL_LEVELS ); + } } } else @@ -215,9 +220,10 @@ if ( TRUE == didTimeout( fillStartTime, fillTimeoutMS ) ) { -#ifndef DISABLE_AIR_TRAP_LEVELING_ALARM - activateAlarmNoData( ALARM_ID_AIR_TRAP_FILL_DURING_TREATMENT ); -#endif + if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_AIR_TRAP_LEVELING_ALARM ) != SW_CONFIG_ENABLE_VALUE ) + { + activateAlarmNoData( ALARM_ID_AIR_TRAP_FILL_DURING_TREATMENT ); + } } } } @@ -519,4 +525,4 @@ return result; } -/**@}*/ +/**@}*/