Index: firmware/App/Drivers/ConductivitySensors.c =================================================================== diff -u -r61a53c2d8fea7cf4e7f2aa90bbe341edee8a69d9 -r65aab053022c1cab102e503012833f4879501fd1 --- firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 61a53c2d8fea7cf4e7f2aa90bbe341edee8a69d9) +++ firmware/App/Drivers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 65aab053022c1cab102e503012833f4879501fd1) @@ -48,8 +48,7 @@ #define LOWER_WORD_SIZE 4 ///< Size in bytes of the lower word size for retrieving revision data. #define MID_WORD_SIZE 4 ///< Size in bytes of the middle word size for retrieving revision data. #define UPPER_WORD_SIZE 2 ///< Size in bytes of the upper word size for retrieving revision data. -#define MAX_CONDUCTIVITY_SENSOR_FAILURES 2 -#define MAX_CONDUCTIVITY_SENSOR_FAILURE_WINDOW_MS ( 60 * MS_PER_SECOND ) + #define MAX_ALLOWED_UNCHANGED_CONDUCTIVITY_READS ( 500 / TASK_PRIORITY_INTERVAL ) ///< New reading every 333ms, expect to get valid new reading in 500ms. #define SIEMENS_TO_MICROSIEMENS_CONVERSION 1000000 ///< Siemens to microSiemens conversion factor. #define COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Conductivity sensors FPGA error timeout in milliseconds. @@ -66,21 +65,19 @@ /// Conductivity Sensor Status group typedef struct { - U08 condReadCount; - U08 condErrorCount; - U08 tempReadCount; - U08 tempErrorCount; + U08 condReadCount; ///< Conductivity read count. + U08 condErrorCount; ///< Conductivity error count. U08 interalCondErrorCount; ///< Internal conductivity error count for stale data. + U08 tempReadCount; ///< Temperature read count. + U08 tempErrorCount; ///< Temperature error count. U08 interalTempErrorCount; ///< Internal temperature error count for stale data. U08 calMemCount; ///< Cal memory counter. U32 calData; ///< Cal word data storage. - BOOL hasCalSlotBeenRead[ NUM_OF_CONDUCTIVTY_CAL_IDXS ]; ///< Boolean array tracking which cal mem data has been read. - BOOL haveAllCalSlotsBeenRead; - BOOL calReadComplete; } CONDUCTIVITY_SENSOR_STATUS_T; // ********** private data ********** static CONDUCTIVITY_STATE_T currentConductivityState; ///< Current conductivity sensor state. + static OVERRIDE_F32_T currentConductivityReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Current conductivity sensor conductivity readings (overrideable). static OVERRIDE_F32_T currentTemperatureReadings[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Current conductivity sensor temperature readings (overrideable). static OVERRIDE_U32_T lastConductivityReadCounter[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Last conductivity sensor read count (Overrideable). @@ -92,17 +89,16 @@ static CONDUCTIVITY_COEFFICIENTS_T conductivitySensorCoefficients[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Conductivity sensor calibration coefficient data. static CONDUCTIVITY_REVISIONS_T conductivitySensorRevisions[ NUM_OF_CONDUCTIVITY_SENSORS ]; ///< Conductivity sensor revision and serial data. -// ********** private function prototypes ********** -static CONDUCTIVITY_STATE_T handleConductivityReadCalState( void ); -static CONDUCTIVITY_STATE_T handleConductivityReadDataState( void ); -static void checkCondCounters( U32 sensorId, U08 condReadCount, U08 condErrorCount, U08 tempReadCount, U08 tempErrorCount ); static U32 getConductivitySensorReadCount( CONDUCTIVITY_SENSORS_T sensor ); static U32 getConductivitySensorErrorCount( CONDUCTIVITY_SENSORS_T sensor ); static U32 getTemperatureSensorReadCount( CONDUCTIVITY_SENSORS_T sensor ); static U32 getTemperatureSensorErrorCount( CONDUCTIVITY_SENSORS_T sensor ); -static BOOL monitorCalDataReads( U32 sensorId ); -static BOOL checkConductivityCoefficientRanges( U32 sensorId ); +// ********** private function prototypes ********** +static CONDUCTIVITY_STATE_T handleConductivityReadCalState( void ); +static CONDUCTIVITY_STATE_T handleConductivityReadDataState( void ); +static void checkCondCounters( U32 sensorId, U08 condReadCount, U08 condErrorCount, U08 tempReadCount, U08 tempErrorCount ); + /*********************************************************************//** * @brief * The initConductivitySensors function initializes the ConductivitySensors unit. @@ -148,12 +144,14 @@ lastTemperatureErrorCounter[ sensor ].ovInitData = 0; lastTemperatureErrorCounter[ sensor ].override = OVERRIDE_RESET; + conductivitySensorStatus[ sensor ].condReadCount = 0; + conductivitySensorStatus[ sensor ].condErrorCount = 0; + conductivitySensorStatus[ sensor ].tempReadCount = 0; + conductivitySensorStatus[ sensor ].tempErrorCount = 0; conductivitySensorStatus[ sensor ].interalCondErrorCount = 0; conductivitySensorStatus[ sensor ].interalTempErrorCount = 0; conductivitySensorStatus[ sensor ].calMemCount = 0; conductivitySensorStatus[ sensor ].calData = 0; - conductivitySensorStatus[ sensor ].haveAllCalSlotsBeenRead = FALSE; - memset( conductivitySensorStatus[ sensor ].hasCalSlotBeenRead, 0 ,sizeof( conductivitySensorStatus[ sensor ].hasCalSlotBeenRead ) ); conductivitySensorCoefficients[ sensor ].K_high = 0; conductivitySensorCoefficients[ sensor ].alpha_high = 0.0F; @@ -174,7 +172,6 @@ } // Initialize the conductivity sensor FPGA alarms - initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CONDUCTIVITY_SENSOR_ERROR, MAX_CONDUCTIVITY_SENSOR_FAILURES, MAX_CONDUCTIVITY_SENSOR_FAILURE_WINDOW_MS ); initFPGAPersistentAlarm( FPGA_PERS_ERROR_D17_COND_SENSOR, ALARM_ID_DD_D17_COND_SENSOR_FPGA_FAULT, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ); initFPGAPersistentAlarm( FPGA_PERS_ERROR_D27_COND_SENSOR, ALARM_ID_DD_D27_COND_SENSOR_FPGA_FAULT, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ); initFPGAPersistentAlarm( FPGA_PERS_ERROR_D29_COND_SENSOR, ALARM_ID_DD_D29_COND_SENSOR_FPGA_FAULT, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ); @@ -186,15 +183,18 @@ /*********************************************************************//** * @brief - * The readConductivitySensorData function gets the current conductivity reading - * for all conductivity sensors from the FPGA. + * The readConductivitySensors function gets the current conductivity reading + * for all conductivity sensors from the FPGA and also reads the freshness + * and error counters to verify that the conductivity sensors are being read + * by the FPGA without issue. * @note This function should be called periodically to maintain fresh * sensor readings for all conductivity sensors. * @details \b Inputs: FPGA * @details \b Outputs: currentConductivityReadings[],currentTemperatureReadings[], + * lastConductivityReadCounter[],lastConductivityErrorCounter[]. * @return none *************************************************************************/ -void readConductivitySensorData( void ) +void readConductivitySensors( void ) { // Read raw conductivity currentConductivityReadings[ D17_COND ].data = (F32)getFPGAD17CondData(); @@ -213,19 +213,8 @@ currentTemperatureReadings[ D74_COND ].data = (F32)getFPGAD74CondTemp(); currentTemperatureReadings[ P9_COND ].data = (F32)getFPGAP9CondTemp(); currentTemperatureReadings[ P18_COND ].data = (F32)getFPGAP18CondTemp(); -} -/*********************************************************************//** - * @brief - * The readConductivitySensorReadCounts function gets the current conductivity read - * counters for all conductivity sensors from the FPGA. - * @details \b Inputs: FPGA - * @details \b Outputs: lastConductivityReadCounter[],lastTemperatureReadCounter[], - * @return none - *************************************************************************/ -static void readConductivitySensorReadCounts( void ) -{ - // Update read counters for each conductivity sensor + // Update read and error counters for each conductivity sensor lastConductivityReadCounter[ D17_COND ].data = (U32)getFPGAD17CondReadCount(); lastConductivityReadCounter[ D27_COND ].data = (U32)getFPGAD27CondReadCount(); lastConductivityReadCounter[ D29_COND ].data = (U32)getFPGAD29CondReadCount(); @@ -234,26 +223,6 @@ lastConductivityReadCounter[ P9_COND ].data = (U32)getFPGAP9CondReadCount(); lastConductivityReadCounter[ P18_COND ].data = (U32)getFPGAP18CondReadCount(); - lastTemperatureReadCounter[ D17_COND ].data = (U32)getFPGAD17TempReadCount(); - lastTemperatureReadCounter[ D27_COND ].data = (U32)getFPGAD27TempReadCount(); - lastTemperatureReadCounter[ D29_COND ].data = (U32)getFPGAD29TempReadCount(); - lastTemperatureReadCounter[ D43_COND ].data = (U32)getFPGAD43TempReadCount(); - lastTemperatureReadCounter[ D74_COND ].data = (U32)getFPGAD74TempReadCount(); - lastTemperatureReadCounter[ P9_COND ].data = (U32)getFPGAP9TempReadCount(); - lastTemperatureReadCounter[ P18_COND ].data = (U32)getFPGAP18TempReadCount(); -} - -/*********************************************************************//** - * @brief - * The readConductivitySensorErrorCounts function gets the current conductivity - * error counters for all conductivity sensors from the FPGA. - * @details \b Inputs: FPGA - * @details \b Outputs: lastConductivityReadCounter[],lastTemperatureReadCounter[], - * @return none - *************************************************************************/ -static void readConductivitySensorErrorCounts( void ) -{ - // Update error counters for each conductivity sensor lastConductivityErrorCounter[ D17_COND ].data = (U32)getFPGAD17CondErrorCount(); lastConductivityErrorCounter[ D27_COND ].data = (U32)getFPGAD27CondErrorCount(); lastConductivityErrorCounter[ D29_COND ].data = (U32)getFPGAD29CondErrorCount(); @@ -262,51 +231,24 @@ lastConductivityErrorCounter[ P9_COND ].data = (U32)getFPGAP9CondErrorCount(); lastConductivityErrorCounter[ P18_COND ].data = (U32)getFPGAP18CondErrorCount(); + lastTemperatureReadCounter[ D17_COND ].data = (U32)getFPGAD17TempReadCount(); + lastTemperatureReadCounter[ D27_COND ].data = (U32)getFPGAD27TempReadCount(); + lastTemperatureReadCounter[ D29_COND ].data = (U32)getFPGAD29TempReadCount(); + lastTemperatureReadCounter[ D43_COND ].data = (U32)getFPGAD43TempReadCount(); + lastTemperatureReadCounter[ D74_COND ].data = (U32)getFPGAD74TempReadCount(); + lastTemperatureReadCounter[ P9_COND ].data = (U32)getFPGAP9TempReadCount(); + lastTemperatureReadCounter[ P18_COND ].data = (U32)getFPGAP18TempReadCount(); + lastTemperatureErrorCounter[ D17_COND ].data = (U32)getFPGAD17TempErrorCount(); lastTemperatureErrorCounter[ D27_COND ].data = (U32)getFPGAD27TempErrorCount(); lastTemperatureErrorCounter[ D29_COND ].data = (U32)getFPGAD29TempErrorCount(); lastTemperatureErrorCounter[ D43_COND ].data = (U32)getFPGAD43TempErrorCount(); lastTemperatureErrorCounter[ D74_COND ].data = (U32)getFPGAD74TempErrorCount(); lastTemperatureErrorCounter[ P9_COND ].data = (U32)getFPGAP9TempErrorCount(); lastTemperatureErrorCounter[ P18_COND ].data = (U32)getFPGAP18TempErrorCount(); -} -/*********************************************************************//** - * @brief - * The readConductivitySensorErrorCounts function gets the current conductivity - * cal data and cal memory counter for all conductivity sensors from the FPGA. - * @details \b Inputs: FPGA - * @details \b Outputs: conductivitySensorStatus[] - * @return none - *************************************************************************/ -static void readConductivitySensorCalData( void ) -{ - // Update error counters for each conductivity sensor - conductivitySensorStatus[ D17_COND ].calData = (U32)getFPGAD17CondCalData(); - conductivitySensorStatus[ D27_COND ].calData = (U32)getFPGAD27CondCalData(); - conductivitySensorStatus[ D29_COND ].calData = (U32)getFPGAD29CondCalData(); - conductivitySensorStatus[ D43_COND ].calData = (U32)getFPGAD43CondCalData(); - conductivitySensorStatus[ D74_COND ].calData = (U32)getFPGAD74CondCalData(); - conductivitySensorStatus[ P9_COND ].calData = (U32)getFPGAP9CondCalData(); - conductivitySensorStatus[ P18_COND ].calData = (U32)getFPGAP18CondCalData(); - - conductivitySensorStatus[ D17_COND ].calMemCount = (U32)getFPGAD17CalMemCounter(); - conductivitySensorStatus[ D27_COND ].calMemCount = (U32)getFPGAD27CalMemCounter(); - conductivitySensorStatus[ D29_COND ].calMemCount = (U32)getFPGAD29CalMemCounter(); - conductivitySensorStatus[ D43_COND ].calMemCount = (U32)getFPGAD43CalMemCounter(); - conductivitySensorStatus[ D74_COND ].calMemCount = (U32)getFPGAD74CalMemCounter(); - conductivitySensorStatus[ P9_COND ].calMemCount = (U32)getFPGAP9CalMemCounter(); - conductivitySensorStatus[ P18_COND ].calMemCount = (U32)getFPGAP18CalMemCounter(); } -/*********************************************************************//** - * @brief - * The execConductivitySensors function executes the conductivity sensors driver. - * @details \b Inputs: currentConductivityState - * @details \b Outputs: currentConductivityState - * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when the state is not expected. - * @return none - *************************************************************************/ void execConductivitySensors( void ) { switch ( currentConductivityState ) @@ -318,161 +260,29 @@ currentConductivityState = handleConductivityReadDataState(); break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CONDUCTIVITY_SENSOR_ID, (U32)currentConductivityState ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CONDUCTIVITY_SENSOR_ID, (U32)currentConductivityState ) break; } } -/*********************************************************************//** - * @brief - * The handleConductivityReadCalState function handles reading the Cal data and - * tracking the Cal mem counter from the FPGA - * @details \b Inputs: FPGA. - * @details \b Outputs: conductivitySensorCoefficients[], conductivitySensorRevisions[] - * conductivitySensorStatus[] - * @return next state of the conductivity state machine. - *************************************************************************/ static CONDUCTIVITY_STATE_T handleConductivityReadCalState( void ) { CONDUCTIVITY_STATE_T state = CONDUCTIVITY_INIT_STATE; CONDUCTIVITY_SENSORS_T sensor; - BOOL calResult = TRUE; - readConductivitySensorCalData(); - - // Check which counter, assign it, and assign read bool to TRUE per sensor for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) { - if ( FALSE == conductivitySensorStatus[ sensor ].haveAllCalSlotsBeenRead ) - { - switch( conductivitySensorStatus[ sensor ].calMemCount ) - { - case CAL_DATA_1: - conductivitySensorCoefficients[ sensor ].K_high = (U32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_1 ] = TRUE; - break; - case CAL_DATA_2: - conductivitySensorCoefficients[ sensor ].alpha_high = (F32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_2 ] = TRUE; - break; - case CAL_DATA_3: - conductivitySensorCoefficients[ sensor ].eta_high = (F32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_3 ] = TRUE; - break; - case CAL_DATA_4: - conductivitySensorCoefficients[ sensor ].zeta_high = (S32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_4 ] = TRUE; - break; - case CAL_DATA_5: - conductivitySensorCoefficients[ sensor ].K_low = (U32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_5 ] = TRUE; - break; - case CAL_DATA_6: - conductivitySensorCoefficients[ sensor ].alpha_low = (F32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_6 ] = TRUE; - break; - case CAL_DATA_7: - conductivitySensorCoefficients[ sensor ].eta_low = (F32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_7 ] = TRUE; - break; - case CAL_DATA_8: - conductivitySensorCoefficients[ sensor ].zeta_low = (S32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_8 ] = TRUE; - break; - case CAL_DATA_9: - conductivitySensorCoefficients[ sensor ].beta = (F32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_9 ] = TRUE; - break; - case CAL_DATA_10: - conductivitySensorCoefficients[ sensor ].delta = (S32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_10 ] = TRUE; - break; - case CAL_DATA_11: - conductivitySensorCoefficients[ sensor ].reserved1 = (U32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_11 ] = TRUE; - break; - case CAL_DATA_12: - conductivitySensorCoefficients[ sensor ].reserved2 = (U32)conductivitySensorStatus[ sensor ].calData; - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ CAL_DATA_12 ] = TRUE; - break; - case SW_REV_LOWER_WORD: - memcpy( conductivitySensorRevisions[ sensor ].swRev, &conductivitySensorStatus[ sensor ].calData, sizeof( U32 ) ); - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ SW_REV_LOWER_WORD ] = TRUE; - break; - case SW_REV_MID_WORD: - memcpy( ( conductivitySensorRevisions[ sensor ].swRev + LOWER_WORD_SIZE ), &conductivitySensorStatus[ sensor ].calData, sizeof( U32 ) ); - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ SW_REV_MID_WORD ] = TRUE; - break; - case SW_REV_UPPER_WORD: - memcpy( ( conductivitySensorRevisions[ sensor ].swRev + ( LOWER_WORD_SIZE + MID_WORD_SIZE ) ), &conductivitySensorStatus[ sensor ].calData, sizeof( U16 ) ); - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ SW_REV_UPPER_WORD ] = TRUE; - break; - case HW_REV_LOWER_WORD: - memcpy( conductivitySensorRevisions[ sensor ].hwRev, &conductivitySensorStatus[ sensor ].calData, sizeof( U32 ) ); - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ SW_REV_LOWER_WORD ] = TRUE; - break; - case HW_REV_MID_WORD: - memcpy( ( conductivitySensorRevisions[ sensor ].hwRev + LOWER_WORD_SIZE ), &conductivitySensorStatus[ sensor ].calData, sizeof( U32 ) ); - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ SW_REV_MID_WORD ] = TRUE; - break; - case HW_REV_UPPER_WORD: - memcpy( ( conductivitySensorRevisions[ sensor ].hwRev + ( LOWER_WORD_SIZE + MID_WORD_SIZE ) ), &conductivitySensorStatus[ sensor ].calData, sizeof( U16 ) ); - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ SW_REV_UPPER_WORD ] = TRUE; - break; - case HW_SERIAL_LOWER_WORD: - memcpy( conductivitySensorRevisions[ sensor ].hwSerial, &conductivitySensorStatus[ sensor ].calData, sizeof( U32 ) ); - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ SW_REV_LOWER_WORD ] = TRUE; - break; - case HW_SERIAL_MID_WORD: - memcpy( ( conductivitySensorRevisions[ sensor ].hwSerial + LOWER_WORD_SIZE ), &conductivitySensorStatus[ sensor ].calData, sizeof( U32 ) ); - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ SW_REV_MID_WORD ] = TRUE; - break; - case HW_SERIAL_UPPER_WORD: - memcpy( ( conductivitySensorRevisions[ sensor ].hwRev + ( LOWER_WORD_SIZE + MID_WORD_SIZE ) ), &conductivitySensorStatus[ sensor ].calData, sizeof( U16 ) ); - conductivitySensorStatus[ sensor ].hasCalSlotBeenRead[ SW_REV_UPPER_WORD ] = TRUE; - break; - } - // check if we have finished reading all values. - conductivitySensorStatus[ sensor ].haveAllCalSlotsBeenRead = monitorCalDataReads( sensor ); - } - // Read all cal values. Check ranges. - else - { - conductivitySensorStatus[ sensor ].calReadComplete = checkConductivityCoefficientRanges( sensor ); - - if ( FALSE == conductivitySensorStatus[ sensor ].calReadComplete ) - { - calResult = FALSE; - } - } } - - if ( TRUE == calResult ) - { - // All cal data has been assigned and checks. - state = CONDUCTIVITY_READ_DATA_STATE; - } return state; } -/*********************************************************************//** - * @brief - * The handleConductivityReadDataState function handles reading data, read - * counters and error counters. - * @details \b Inputs: none. - * @details \b Outputs: conductivitySensorCoefficients, conductivitySensorRevisions - * @return next state of the conductivity state machine. - *************************************************************************/ static CONDUCTIVITY_STATE_T handleConductivityReadDataState( void ) { CONDUCTIVITY_STATE_T state = CONDUCTIVITY_READ_DATA_STATE; CONDUCTIVITY_SENSORS_T sensor; - readConductivitySensorData(); - readConductivitySensorReadCounts(); - readConductivitySensorErrorCounts(); - + readConductivitySensors(); for ( sensor = FIRST_DD_COND_SENSOR; sensor < NUM_OF_CONDUCTIVITY_SENSORS; sensor++ ) { checkCondCounters( sensor, getConductivitySensorReadCount( sensor ), getConductivitySensorErrorCount( sensor ), @@ -481,22 +291,13 @@ return state; } - -/*********************************************************************//** - * @brief - * The checkCondCounters function handles monitoring read and error counters - * @details \b Inputs: conductivitySensorStatus[] - * @details \b Outputs: conductivitySensorStatus[] - * @return none. - *************************************************************************/ -static void checkCondCounters( U32 sensorId, U08 condReadCount, U08 condErrorCount, U08 tempReadCount, U08 tempErrorCount ) +void checkCondCounters( U32 sensorId, U08 condReadCount, U08 condErrorCount, U08 tempReadCount, U08 tempErrorCount ) { if ( ( 0 == condErrorCount ) && ( 0 == tempErrorCount ) ) { if ( conductivitySensorStatus[ sensorId ].condReadCount != condReadCount ) { conductivitySensorStatus[ sensorId ].interalCondErrorCount = 0; - conductivitySensorStatus[ sensorId ].condReadCount = condReadCount; } else { @@ -509,7 +310,6 @@ if ( conductivitySensorStatus[ sensorId ].tempReadCount != tempReadCount ) { conductivitySensorStatus[ sensorId ].interalTempErrorCount = 0; - conductivitySensorStatus[ sensorId ].tempReadCount = tempReadCount; } else { @@ -519,132 +319,10 @@ } } } - else - { - if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CONDUCTIVITY_SENSOR_ERROR ) ) - { - SET_ALARM_WITH_1_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, sensorId ) - } - } } /*********************************************************************//** * @brief - * The monitorCalDataReads loops through hasCalSlotBeenRead to determine if all - * cal data has been read from the FPGA for a given conductivity sensor. - * @details \b Inputs: conductivitySensorStatus - * @details \b Outputs: none - * @param sensor ID of the conductivity sensor. - * @return True if all cal data has been read, false if not. - *************************************************************************/ -static BOOL monitorCalDataReads( U32 sensorId ) -{ - BOOL result = TRUE; - CONDUCTIVITY_CAL_IDX_T calIdx; - - for (calIdx = CAL_DATA_1; calIdx < NUM_OF_CONDUCTIVTY_CAL_IDXS; calIdx++ ) - { - if( FALSE == conductivitySensorStatus[ sensorId ].hasCalSlotBeenRead[ calIdx ] ) - { - result = FALSE; - } - } - return result; -} - -/*********************************************************************//** - * @brief - * The checkConductivityCoefficientRanges checks coefficient data to see if they - * are in range. - * @details \b Inputs: conductivitySensorCoefficients[] - * @details \b Outputs: conductivitySensorStatus[] - * @param sensor ID of the conductivity sensor. - * @return True if all cal data is in range, false if not. - *************************************************************************/ -static BOOL checkConductivityCoefficientRanges( U32 sensorId ) -{ - BOOL result = TRUE; - CONDUCTIVITY_CAL_IDX_T idx = CAL_DATA_1; - - // Check data for high and low ranges. - if( ( conductivitySensorCoefficients[ sensorId ].K_high <= CELL_COEFF_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].K_high >= CELL_COEFF_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_1; - } - - if( ( conductivitySensorCoefficients[ sensorId ].K_low <= CELL_COEFF_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].K_low >= CELL_COEFF_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_2; - } - - if( ( conductivitySensorCoefficients[ sensorId ].alpha_high <= TEMPERATURE_CORRECTION_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].alpha_high >= TEMPERATURE_CORRECTION_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_3; - } - - if( ( conductivitySensorCoefficients[ sensorId ].alpha_low <= TEMPERATURE_CORRECTION_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].alpha_low >= TEMPERATURE_CORRECTION_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_4; - } - - if( ( conductivitySensorCoefficients[ sensorId ].eta_high <= RESISTANCE_SCALE_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].eta_high >= RESISTANCE_SCALE_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_5; - } - - if( ( conductivitySensorCoefficients[ sensorId ].eta_low <= RESISTANCE_SCALE_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].eta_low >= RESISTANCE_SCALE_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_6; - } - if( ( conductivitySensorCoefficients[ sensorId ].zeta_high <= RESISTANCE_OFFSET_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].zeta_high >= RESISTANCE_OFFSET_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_7; - } - - if( ( conductivitySensorCoefficients[ sensorId ].zeta_low <= RESISTANCE_OFFSET_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].zeta_low >= RESISTANCE_OFFSET_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_8; - } - - if( ( conductivitySensorCoefficients[ sensorId ].beta <= TEMPERATURE_SCALE_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].beta >= TEMPERATURE_SCALE_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_9; - } - - if( ( conductivitySensorCoefficients[ sensorId ].delta <= TEMPERATURE_OFFSET_HIGH_BOUNDS ) && - ( conductivitySensorCoefficients[ sensorId ].delta >= TEMPERATURE_OFFSET_LOW_BOUNDS ) ) - { - result = FALSE; - idx = CAL_DATA_10; - } - - // Alarm if any data is out of range. - if ( FALSE == result ) - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, sensorId, ( U32 )idx ) - } - return result; -} -/*********************************************************************//** - * @brief * The getConductivitySensorReadCount function gets the current read count * for a given conductivity sensor. * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT if given sensor is invalid. @@ -787,7 +465,7 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CONDUCTIVITY_SENSOR_ID, sensor ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CONDUCTIVITY_SENSOR_ID, sensor ); } return result; @@ -817,7 +495,7 @@ } else { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CONDUCTIVITY_SENSOR_ID1, sensor ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_INVALID_CONDUCTIVITY_SENSOR_ID1, sensor ); } return result;