/************************************************************************** * * Copyright (c) 2024-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 Pressure.c * * @author (last) Vinayakam Mani * @date (last) 04-Sep-2024 * * @author (original) Vinayakam Mani * @date (original) 04-Sep-2024 * ***************************************************************************/ #include "AlarmMgmtDD.h" #include "Messaging.h" #include "Pressure.h" #include "PersistentAlarm.h" #include "TaskPriority.h" #include "Valves.h" /** * @addtogroup Pressure * @{ */ // ********** private definitions ********** //TODO : Increasing the publish interval #define PRESSURES_DATA_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval (ms/task time) at which the pressures data is published on the CAN bus. #define DATA_PUBLISH_COUNTER_START_COUNT ( 5 ) ///< Data publish counter start count. #define PRESSURE_SAMPLE_FILTER_MS ( 50 ) ///< Filter pressure data for given time #define PRESSURE_TEMP_SAMPLE_FILTER_MS ( 50 ) //#define PRESSURE_SAMPLE_FILTER_MS ( 200 ) ///< Filter pressure data for given time //#define PRESSURE_TEMP_SAMPLE_FILTER_MS ( 200 ) ///< Filter temperature data for given time #define SIZE_OF_PRESSURE_ROLLING_AVG ( PRESSURE_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered pressure moving average. #define SIZE_OF_PRESSURETEMP_ROLLING_AVG ( PRESSURE_TEMP_SAMPLE_FILTER_MS / TASK_PRIORITY_INTERVAL ) ///< Filtered pressure temprature w/ 1 second moving average. #define MMHG_TO_PSI_CONVERSION 0.0193368F ///< MMHG to PSI conversion. #define BAR_TO_PSI_CONVERSION 14.5038F ///< MMHG to PSI conversion. #define MIN_INLET_WATER_PRESSURE_WARNING_LOW_PSIG 20.0F ///< Minimum allowed Input low pressure value in psig. #define MAX_INLET_WATER_PRESSURE_WARNING_HIGH_PSIG 80.0F ///< Maximum allowed Input high pressure value in psig. #define MIN_INLET_PRESSURE_TO_CLEAR_WARINING_PSIG 24.0F ///< Minimum allowed Input low pressure value in psig ( to clear alarm) #define MIN_INLET_WATER_PRESSURE_WARNING_HIGH_PSIG 78.0F ///< Minimum allowed Input high pressure value in psig. #define INLET_WATER_PRES_OUT_OF_RANGE_TIMEOUT_MS ( 20 * MS_PER_SECOND ) ///< Persistence period for pressure out of range error in milliseconds. #define INLET_WATER_PRES_OUT_OF_RANGE_CLEAR_MS ( 10 * MS_PER_SECOND ) ///< Persistence period for pressure out of range clear in milliseconds. #define MIN_INLET_WATER_PRES_OUT_WARNING_LOW_PSIG 10.0F ///< Minimum allowed output low pressure value in psig. #define MAX_INLET_WATER_PRES_OUT_WARNING_HIGH_PSIG 20.0F ///< Maximum allowed output high pressure value in psig. #define MIN_INLET_PRES_OUT_TO_CLEAR_WARINING_PSIG 11.0F ///< Minimum allowed output low pressure value in psig ( to clear alarm) #define MIN_INLET_WATER_PRES_OUT_WARNING_HIGH_PSIG 18.0F ///< Minimum allowed output high pressure value in psig. /// Defined states for the pressures monitor state machine. typedef enum PresMonitor_States { PRESSURE_INIT_STATE = 0, ///< Initialization state. PRESSURE_CONTINUOUS_READ_STATE, ///< Continuous read sensors state. NUM_OF_PRESSURE_STATES ///< Number of pressure monitor states. } PRESSURE_STATE_T; /// Filter pressure reading. typedef struct { F32 pressureReadings[ SIZE_OF_PRESSURE_ROLLING_AVG ]; ///< Holds pressure sample rolling average. U32 pressureReadingsIdx; ///< Index for next sample in rolling average array. F32 pressureReadingsTotal; ///< Rolling total - used to calc average. U32 pressureReadingsCount; ///< Number of samples in rolling average buffer }FILTER_PRESSURE_READINGS_T; /// Filter pressuretemperature reading. typedef struct { F32 pressureTempReadings[ SIZE_OF_PRESSURETEMP_ROLLING_AVG ]; ///< Holds pressure temperature sample rolling average. U32 pressureTempReadingsIdx; ///< Index for next sample in rolling average array. F32 pressureTempReadingsTotal; ///< Rolling total - used to calc average. U32 pressureTempReadingsCount; ///< Number of samples in rolling average buffer }FILTER_PRESSURE_TEMPERATURE_READINGS_T; // ********** private data ********** static OVERRIDE_F32_T filteredcurrentPressureReadings[ NUM_OF_PRESSURE_SENSORS ]; ///< filtered current pressure sensor pressure readings (overrideable). static OVERRIDE_F32_T filteredcurrentPresTempReadings[ NUM_OF_PRESSURE_SENSORS ]; ///< filtered current pressure sensor temperature readings (overrideable). //static DD_PRES_SENSORS_CAL_RECORD_T pressuresCalRecord; ///< Pressures calibration record. static FILTER_PRESSURE_READINGS_T filteredPressureReadings[NUM_OF_PRESSURE_SENSORS]; ///< Filtered pressure reading for pressure sensors. static FILTER_PRESSURE_TEMPERATURE_READINGS_T filteredPressureTempReadings[NUM_OF_PRESSURE_SENSORS]; ///< Filtered pressure reading for pressure sensors. static PRESSURE_STATE_T pressuresState; ///< current state of pressure monitor state machine. static U32 pressuresDataPublicationTimerCounter; ///< used to schedule pressure data publication to CAN bus. static OVERRIDE_U32_T pressuresDataPublishInterval = { PRESSURES_DATA_PUB_INTERVAL, PRESSURES_DATA_PUB_INTERVAL, 0, 0 }; ///< Pressure data publish interval. // ********** private function prototypes ********** static void filterPressureSensorReadings( void ); static void filterPressureSensorTemperatureReadings( void ); //static F32 getCalibrationAppliedPressure( U08 sensorId, F32 pressure ); static F32 getConvertedPressure( PRESSURE_SENSORS_T sensor, F32 pressure ); static PRESSURE_STATE_T handlePressuresInitState( void ); static PRESSURE_STATE_T handlePressuresContReadState( void ); static void publishPressuresData( void ); /*********************************************************************//** * @brief * The initPressureSensor function initializes the Pressure Sensor unit. * @details \b Inputs: none * @details \b Outputs: Pressure Sensor unit is initialized. * @return none *************************************************************************/ void initPressure( void ) { U32 i; pressuresState = PRESSURE_INIT_STATE; pressuresDataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; initPressureSensor(); // Initialize override structures for each pressure sensor for ( i = (U32)PRESSURE_SENSOR_FIRST; i < (U32)NUM_OF_PRESSURE_SENSORS; i++ ) { filteredcurrentPressureReadings[ i ].data = 0.0F; filteredcurrentPressureReadings[ i ].ovData = 0.0F; filteredcurrentPressureReadings[ i ].ovInitData = 0.0F; filteredcurrentPressureReadings[ i ].override = OVERRIDE_RESET; filteredcurrentPresTempReadings[ i ].data = 0.0F; filteredcurrentPresTempReadings[ i ].ovData = 0.0F; filteredcurrentPresTempReadings[ i ].ovInitData = 0.0F; filteredcurrentPresTempReadings[ i ].override = OVERRIDE_RESET; filteredPressureReadings[i].pressureReadingsCount = 0; filteredPressureReadings[i].pressureReadingsIdx = 0; filteredPressureReadings[i].pressureReadingsTotal = 0.0F; filteredPressureTempReadings[i].pressureTempReadingsCount = 0; filteredPressureTempReadings[i].pressureTempReadingsIdx = 0; filteredPressureTempReadings[i].pressureTempReadingsTotal = 0.0F; } initPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_IN_LOW_RANGE, INLET_WATER_PRES_OUT_OF_RANGE_CLEAR_MS, INLET_WATER_PRES_OUT_OF_RANGE_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_IN_HIGH_RANGE, INLET_WATER_PRES_OUT_OF_RANGE_CLEAR_MS, INLET_WATER_PRES_OUT_OF_RANGE_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_LOW_RANGE, INLET_WATER_PRES_OUT_OF_RANGE_CLEAR_MS, INLET_WATER_PRES_OUT_OF_RANGE_TIMEOUT_MS ); initPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_HIGH_RANGE, INLET_WATER_PRES_OUT_OF_RANGE_CLEAR_MS, INLET_WATER_PRES_OUT_OF_RANGE_TIMEOUT_MS ); } /*********************************************************************//** * @brief * The filterPressureSensors function gets averages the raw pressure and * temperature readings. * @note This function should be called periodically to maintain fresh * sensor filtered readings for all pressure sensors. * @details \b Inputs: currentPressureReadings[],currentPresTempReadings[], * @details \b Outputs: filteredPressureReadings[], filteredPressureTempReadings[] * @return none *************************************************************************/ static void filterPressureSensors( void ) { //Filter pressure sensor reading filterPressureSensorReadings(); //Filter pressure sensor temperature reading filterPressureSensorTemperatureReadings(); } /*********************************************************************//** * @brief * The getFilteredPressure function gets the filtered current pressure (in mmHg) * for a given pressure sensor. * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT if given sensor is invalid. * @details \b Inputs: filteredcurrentPressureReadings * @details \b Outputs: none * @param sensor ID of pressure sensor to get pressure reading for. * @return The filtered current pressure (in mmHg) of the given pressure sensor. *************************************************************************/ F32 getFilteredPressure( PRESSURE_SENSORS_T sensor ) { F32 result = 0.0F; if ( sensor < NUM_OF_PRESSURE_SENSORS ) { result = filteredcurrentPressureReadings[ sensor ].data; if ( OVERRIDE_KEY == filteredcurrentPressureReadings[ sensor ].override ) { result = filteredcurrentPressureReadings[ sensor ].ovData; } } else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_PRESSURE_SENSOR_INVALID_SENSOR5, sensor ) } return result; } /*********************************************************************//** * @brief * The getFilteredPressureSensorTemperature function gets the filtered current * pressure sensor temperature (in deg C) for a given pressure sensor. * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT if given sensor is invalid. * @details \b Inputs: currentPresTempReadings * @details \b Outputs: none * @param sensor ID of pressure sensor to get temperature reading for. * @return The filtered current pressure sensor temperature (in deg C) of the given pressure sensor. *************************************************************************/ F32 getFilteredPressureSensorTemperature( PRESSURE_SENSORS_T sensor ) { F32 result = 0.0F; if ( sensor < NUM_OF_PRESSURE_SENSORS ) { result = filteredcurrentPresTempReadings[ sensor ].data; if ( OVERRIDE_KEY == filteredcurrentPresTempReadings[ sensor ].override ) { result = filteredcurrentPresTempReadings[ sensor ].ovData; } } else { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_PRESSURE_SENSOR_INVALID_SENSOR6, sensor ) } return result; } /*********************************************************************//** * @brief * The checkInletWaterPressure function checks inlet water pressure value * and triggers an alarm when pressure value is out of allowed range. * @details \b Inputs: RO pump inlet pressure sensor value * @details \b Outputs: Triggers low pressure persistent alarm * @details \b Alarms: ALARM_ID_DD_INLET_WATER_PRESSURE_IN_LOW_RANGE when * the inlet water pressure is less than the low limit. * @details \b Alarms: ALARM_ID_DD_INLET_WATER_PRESSURE_IN_HIGH_RANGE when * the inlet water pressure is greater than the high limit. * @return none *************************************************************************/ void checkInletWaterPressure( void ) { F32 pressureIn = getFilteredPressure( M1_PRES ); F32 PressureOut = getFilteredPressure( M3_PRES ); //Check Water Inlet Input pressure range if ( VALVE_STATE_OPEN == getValveStateName( M4_VALV ) ) { BOOL isPressureTooLow; BOOL isPressureTooHigh; F32 maxInletWaterPressureWarningLow = MIN_INLET_WATER_PRESSURE_WARNING_LOW_PSIG; F32 minInletWaterPressureWarningLow = MIN_INLET_PRESSURE_TO_CLEAR_WARINING_PSIG; isPressureTooLow = ( pressureIn < maxInletWaterPressureWarningLow ? TRUE : FALSE ); isPressureTooHigh = ( pressureIn > MAX_INLET_WATER_PRESSURE_WARNING_HIGH_PSIG ? TRUE : FALSE ); if ( TRUE == isAlarmActive( ALARM_ID_DD_INLET_WATER_PRESSURE_IN_LOW_RANGE ) ) { isPressureTooLow = ( pressureIn >= minInletWaterPressureWarningLow ? FALSE : TRUE ); } checkPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_IN_LOW_RANGE, isPressureTooLow, pressureIn, maxInletWaterPressureWarningLow ); if ( TRUE == isAlarmActive( ALARM_ID_DD_INLET_WATER_PRESSURE_IN_HIGH_RANGE ) ) { isPressureTooHigh = ( pressureIn <= MIN_INLET_WATER_PRESSURE_WARNING_HIGH_PSIG ? FALSE : TRUE ); } checkPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_IN_HIGH_RANGE, isPressureTooHigh, pressureIn, MAX_INLET_WATER_PRESSURE_WARNING_HIGH_PSIG ); } else { // M4_VALV is closed - clear all alarms checkPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_IN_LOW_RANGE, FALSE, pressureIn, MIN_INLET_WATER_PRESSURE_WARNING_LOW_PSIG ); checkPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_IN_HIGH_RANGE, FALSE, pressureIn, MAX_INLET_WATER_PRESSURE_WARNING_HIGH_PSIG ); } //Check Water Inlet Output pressure range if ( VALVE_STATE_OPEN == getValveStateName( M4_VALV ) ) { BOOL isPressureTooLow; BOOL isPressureTooHigh; F32 maxInletWaterPressureWarningLow = MIN_INLET_WATER_PRES_OUT_WARNING_LOW_PSIG; F32 minInletWaterPressureWarningLow = MIN_INLET_PRES_OUT_TO_CLEAR_WARINING_PSIG; isPressureTooLow = ( PressureOut < maxInletWaterPressureWarningLow ? TRUE : FALSE ); isPressureTooHigh = ( PressureOut > MAX_INLET_WATER_PRES_OUT_WARNING_HIGH_PSIG ? TRUE : FALSE ); if ( TRUE == isAlarmActive( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_LOW_RANGE ) ) { isPressureTooLow = ( PressureOut >= minInletWaterPressureWarningLow ? FALSE : TRUE ); } checkPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_LOW_RANGE, isPressureTooLow, PressureOut, maxInletWaterPressureWarningLow ); if ( TRUE == isAlarmActive( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_HIGH_RANGE ) ) { isPressureTooHigh = ( PressureOut <= MIN_INLET_WATER_PRES_OUT_WARNING_HIGH_PSIG ? FALSE : TRUE ); } checkPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_HIGH_RANGE, isPressureTooHigh, PressureOut, MAX_INLET_WATER_PRES_OUT_WARNING_HIGH_PSIG ); } else { // M4_VALV is closed - clear all alarms checkPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_LOW_RANGE, FALSE, PressureOut, MIN_INLET_WATER_PRES_OUT_WARNING_LOW_PSIG ); checkPersistentAlarm( ALARM_ID_DD_INLET_WATER_PRESSURE_OUT_HIGH_RANGE, FALSE, PressureOut, MAX_INLET_WATER_PRES_OUT_WARNING_HIGH_PSIG ); } } /*********************************************************************//** * @brief * The execPressureSensor function executes the pressure monitor state machine * and publish pressure data. * @details \b Inputs: pressuresState * @details \b Outputs: pressuresState * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT if invalid pressure state seen * @return none *************************************************************************/ void execPressureSensor( void ) { // state machine switch ( pressuresState ) { case PRESSURE_INIT_STATE: pressuresState = handlePressuresInitState(); break; case PRESSURE_CONTINUOUS_READ_STATE: pressuresState = handlePressuresContReadState(); break; default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_PRESSURE_INVALID_EXEC_STATE, pressuresState ) pressuresState = PRESSURE_INIT_STATE; break; } // publish pressure/occlusion data on interval publishPressuresData(); } /*********************************************************************//** * @brief * The filterPressureSensorReadings function filters the pressures for * defined interval to get average pressure reading. * @details \b Inputs: filteredPressureReadings,currentPressureReadings * @details \b Outputs: filteredPressureReadings,filteredcurrentPressureReadings * @return none *************************************************************************/ static void filterPressureSensorReadings( void ) { PRESSURE_SENSORS_T i; for ( i = PRESSURE_SENSOR_FIRST; i < NUM_OF_PRESSURE_SENSORS; i++ ) { F32 pressureinPSI = getPressure( i ); F32 pressure = getConvertedPressure( i, pressureinPSI ); if ( filteredPressureReadings[i].pressureReadingsCount >= SIZE_OF_PRESSURE_ROLLING_AVG ) { filteredPressureReadings[i].pressureReadingsTotal -= filteredPressureReadings[i].pressureReadings[ filteredPressureReadings[i].pressureReadingsIdx ]; } filteredPressureReadings[i].pressureReadings[ filteredPressureReadings[i].pressureReadingsIdx ] = pressure; filteredPressureReadings[i].pressureReadingsTotal += pressure; filteredPressureReadings[i].pressureReadingsIdx = INC_WRAP( filteredPressureReadings[i].pressureReadingsIdx, 0, SIZE_OF_PRESSURE_ROLLING_AVG - 1 ); filteredPressureReadings[i].pressureReadingsCount = INC_CAP( filteredPressureReadings[i].pressureReadingsCount, SIZE_OF_PRESSURE_ROLLING_AVG ); filteredcurrentPressureReadings[i].data = filteredPressureReadings[i].pressureReadingsTotal / (F32)filteredPressureReadings[i].pressureReadingsCount; } } /*********************************************************************//** * @brief * The filterPressureSensorTemperatureReadings function filters the pressure sensor * temperature for defined interval to get average temperature reading. * @details \b Inputs: filteredPressureTempReadings,currentPresTempReadings * @details \b Outputs: filteredPressureTempReadings,filteredcurrentPresTempReadings * @return none *************************************************************************/ static void filterPressureSensorTemperatureReadings( void ) { PRESSURE_SENSORS_T i; for ( i = PRESSURE_SENSOR_FIRST; i < NUM_OF_PRESSURE_SENSORS; i++ ) { F32 pressureTemperature = getPressureSensorTemperature( i ); if ( filteredPressureTempReadings[i].pressureTempReadingsCount >= SIZE_OF_PRESSURETEMP_ROLLING_AVG ) { filteredPressureTempReadings[i].pressureTempReadingsTotal -= filteredPressureTempReadings[i].pressureTempReadings[ filteredPressureTempReadings[i].pressureTempReadingsIdx ]; } filteredPressureTempReadings[i].pressureTempReadings[ filteredPressureTempReadings[i].pressureTempReadingsIdx ] = pressureTemperature; filteredPressureTempReadings[i].pressureTempReadingsTotal += pressureTemperature; filteredPressureTempReadings[i].pressureTempReadingsIdx = INC_WRAP( filteredPressureTempReadings[i].pressureTempReadingsIdx, 0, SIZE_OF_PRESSURETEMP_ROLLING_AVG - 1 ); filteredPressureTempReadings[i].pressureTempReadingsCount = INC_CAP( filteredPressureTempReadings[i].pressureTempReadingsCount, SIZE_OF_PRESSURETEMP_ROLLING_AVG ); filteredcurrentPresTempReadings[i].data = filteredPressureTempReadings[i].pressureTempReadingsTotal / (F32)filteredPressureTempReadings[i].pressureTempReadingsCount; } } /*********************************************************************//** * @brief * The getConvertedPressure function converts the pressure in PSI unit and * calibration applied to it. * @details \b Inputs: none * @details \b Outputs: none * @param sensor sesnor id for the calibration to be applied for * @param pressure pressure (mmHG) to be converted in PSI * @return converted pressure in PSI. *************************************************************************/ static F32 getConvertedPressure( PRESSURE_SENSORS_T sensor, F32 pressure ) { F32 baroPressurePSI = getPressure( BARO_PRES ) * MMHG_TO_PSI_CONVERSION; // calibrated pressure //F32 calPressure = getCalibrationAppliedPressure( sensor, pressure ); return pressure; //return calPressure; } /*********************************************************************//** * @brief * The getCalibrationAppliedPressure function applies the calibration values * to the provided pressure and returns the values. * @details \b Inputs: pressuresCalRecord * @details \b Outputs: none * @param sensorId the ID of the pressure sensor * @param pressure the pressure before applying calibration to it * @return calibration applied pressure *************************************************************************/ //static F32 getCalibrationAppliedPressure( U08 sensorId, F32 pressure ) //{ // F32 calPressure = pow( pressure, 4 ) * pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].fourthOrderCoeff + // pow( pressure, 3 ) * pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].thirdOrderCoeff + // pow( pressure, 2 ) * pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].secondOrderCoeff + // pressure * pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].gain + // pressuresCalRecord.pressureSensors[ (PRESSURE_SENSORS_T)sensorId ].offset; // return calPressure; //} /*********************************************************************//** * @brief * The handlePressuresInitState function handles the pressures initialize state * of the pressures monitor state machine. * @details \b Inputs: none * @details \b Outputs: none * @return next state *************************************************************************/ static PRESSURE_STATE_T handlePressuresInitState( void ) { return PRESSURE_CONTINUOUS_READ_STATE; } /*********************************************************************//** * @brief * The handlePressuresContReadState function handles the continuous read state * of the pressures monitor state machine. * @details \b Inputs: pressureFilterCounter * @details \b Outputs: pressure sensor values updated * @return next state *************************************************************************/ static PRESSURE_STATE_T handlePressuresContReadState( void ) { PRESSURE_STATE_T result = PRESSURE_CONTINUOUS_READ_STATE; //Get raw pressure value readPressureSensors(); // filter pressure readings filterPressureSensors(); return result; } /*********************************************************************//** * @brief * The publishPressuresData function publishes DD pressures data at a set interval. * @details \b Inputs: pressuresDataPublicationTimerCounter * @details \b Outputs: pressuresDataPublicationTimerCounter * @details \b Message \b Sent: MSG_ID_DD_PRESSURES_DATA to publish pressure data. * @return none *************************************************************************/ static void publishPressuresData( void ) { // publish pressure/occlusion data on interval if ( ++pressuresDataPublicationTimerCounter >= getU32OverrideValue( &pressuresDataPublishInterval ) ) { PRESSURE_TEMP_DATA_T data; data.m1Pressure = getFilteredPressure( M1_PRES ); data.m3Pressure = getFilteredPressure( M3_PRES ); data.d9Pressure = getFilteredPressure( D9_PRES ); data.d66Pressure = getFilteredPressure( D66_PRES ); data.d51Pressure = getFilteredPressure( D51_PRES ); data.d18Pressure = getFilteredPressure( D18_PRES ); data.d41Pressure = getFilteredPressure( D41_PRES ); data.m1PresTemp = getFilteredPressureSensorTemperature( M1_PRES ); data.m3PresTemp = getFilteredPressureSensorTemperature( M3_PRES ); data.d9PresTemp = getFilteredPressureSensorTemperature( D9_PRES ); data.d66PresTemp = getFilteredPressureSensorTemperature( D66_PRES ); data.d51PresTemp = getFilteredPressureSensorTemperature( D51_PRES ); data.d18PresTemp = getFilteredPressureSensorTemperature( D18_PRES ); data.d41PresTemp = getFilteredPressureSensorTemperature( D41_PRES ); pressuresDataPublicationTimerCounter = 0; broadcastData( MSG_ID_DD_PRESSURES_DATA, COMM_BUFFER_OUT_CAN_DD_BROADCAST, (U08*)&data, sizeof( PRESSURE_TEMP_DATA_T ) ); } } /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ /*********************************************************************//** * @brief * The testPressureSensorDataPublishIntervalOverride function overrides the * pressure sensor data publish interval. * @details \b Inputs: none * @details \b Outputs: pressuresDataPublishInterval * @param message Override message from Dialin which includes the value * that override valves states publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testPressureSensorDataPublishIntervalOverride( MESSAGE_T *message ) { BOOL result = u32BroadcastIntervalOverride( message, &pressuresDataPublishInterval, TASK_PRIORITY_INTERVAL ); return result; } /*********************************************************************//** * @brief * The testPressureSensorFilteredReadingsOverride function overrides the * filtered value of the specified pressure sensor with a given value. * @details \b Inputs: none * @details \b Outputs: filteredcurrentPressureReadings[] * @param message Override message from Dialin which includes an sensor * ID and override value of the pressure sensor. * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testPressureSensorFilteredReadingsOverride( MESSAGE_T *message ) { BOOL result = f32ArrayOverride( message, &filteredcurrentPressureReadings[0], NUM_OF_PRESSURE_SENSORS - 1 ); return result; } /*********************************************************************//** * @brief * The testPressureSensorFilteredTemperatureReadingsOverride function overrides the * value of the specified pressure sensor filtered temperature with a given value. * @details \b Inputs: none * @details \b Outputs: currentPresTempReadings[] * @param message Override message from Dialin which includes an sensor * ID and override value of the pressure sensor temperature. * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testPressureSensorFilteredTemperatureReadingsOverride( MESSAGE_T *message ) { BOOL result = f32ArrayOverride( message, &filteredcurrentPresTempReadings[0], NUM_OF_PRESSURE_SENSORS - 1 ); return result; } /**@}*/