Index: firmware/App/Controllers/ConductivitySensors.c =================================================================== diff -u -r256d5cb05f1ef09e19e2f2733a111f600c73a7ee -rad6b3443575d3f6bbac52237866e19a212d36bc1 --- firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision 256d5cb05f1ef09e19e2f2733a111f600c73a7ee) +++ firmware/App/Controllers/ConductivitySensors.c (.../ConductivitySensors.c) (revision ad6b3443575d3f6bbac52237866e19a212d36bc1) @@ -78,6 +78,7 @@ #define DATA_PUBLISH_COUNTER_START_COUNT 40 ///< Data publish counter start count. #define COND_SENSOR_BAD_STATUS_PERSISTENCE_PERIOD ( 1 * MS_PER_SECOND ) ///< Conductivity sensor bad status persistence period. +#define COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Conductivity sensors FPGA error timeout in milliseconds. #pragma pack(push,1) /// Emstat pico measurement data package structure @@ -146,7 +147,7 @@ static U32 prefixStrToSIFactor( U08 prefix ); static void processEmstatBoard( EMSTAT_BOARD_T board ); -static void processEmstatSensorRead( EMSTAT_READ_T* readPackage, U08 emstatByte, U16 fpgaReadCount, U08 fpgaErrorCount ); +static void processEmstatSensorRead( EMSTAT_READ_T* readPackage, U08 emstatByte ); static void processEmstatMeasurementDataPackets( U08 boardSensorIndex, EMSTAT_READ_T* readPackage, EMSTAT_VARIABLE_T* receivedPackets ); static F32 getCalibrationAppliedConductivityValue( U32 sensorId, F32 compensatedValue ); @@ -197,6 +198,10 @@ initPersistentAlarm( ALARM_ID_RO_REJECTION_RATIO_OUT_OF_RANGE, RO_REJECTION_RATIO_PERSISTENCE_PERIOD, RO_REJECTION_RATIO_PERSISTENCE_PERIOD ); initPersistentAlarm( ALARM_ID_DG_CONDUCTIVITY_SENSOR_BAD_STATUS, COND_SENSOR_BAD_STATUS_PERSISTENCE_PERIOD, COND_SENSOR_BAD_STATUS_PERSISTENCE_PERIOD ); initPersistentAlarm( ALARM_ID_DG_OUTLET_PRIMARY_CONDUCTIVITY_OUT_OF_RANGE, COND_SENSOR_PERSISTENCE_PERIOD, COND_SENSOR_PERSISTENCE_PERIOD ); + + // Initialize the conductivity sensors' FPGA alarms + initFPGAPersistentAlarm( FPGA_PERS_ERROR_CPI_CPO_COND_SENSORS, ALARM_ID_DG_CPI_CPO_SENSORS_FPGA_FAULT, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ); + initFPGAPersistentAlarm( FPGA_PERS_ERROR_CD1_CD2_COND_SENSORS, ALARM_ID_DG_CD1_CD2_SENSORS_FPGA_FAULT, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS, COND_SENSORS_FPGA_ERROR_TIMEOUT_MS ); } /*********************************************************************//** @@ -454,7 +459,7 @@ } else { - if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CONDUCTIVITY_SENSOR_ERROR ) ) // TODO remove time windowed + if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CONDUCTIVITY_SENSOR_ERROR ) ) { #ifndef _RELEASE_ if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_COND_SENSOR_CHECK ) != SW_CONFIG_ENABLE_VALUE ) @@ -508,22 +513,23 @@ { U08 emstatByte = 0; U08 fpgaErrorCount = 0; - U16 fpgaReadCount = 0; switch ( board ) { case EMSTAT_CPI_CPO_BOARD: emstatByte = getFPGAEmstatCPiCPoByteOut(); fpgaErrorCount = getFPGAEmstatCPiCPoRxErrCount(); - fpgaReadCount = getFPGAEmstatCPiCPoRxFifoCount(); - processEmstatSensorRead( &emstatBoardRead[ EMSTAT_CPI_CPO_BOARD ], emstatByte, fpgaReadCount, fpgaErrorCount ); + + checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_CPI_CPO_COND_SENSORS, fpgaErrorCount ); + processEmstatSensorRead( &emstatBoardRead[ EMSTAT_CPI_CPO_BOARD ], emstatByte ); break; case EMSTAT_CD1_CD2_BOARD: emstatByte = getFPGAEmstatCD1CD2OutByte(); fpgaErrorCount = getFPGAEmstatCD1CD2RxErrCount(); - fpgaReadCount = getFPGAEmstatCD1CD2RxFifoCount(); - processEmstatSensorRead( &emstatBoardRead[ EMSTAT_CD1_CD2_BOARD ], emstatByte, fpgaReadCount, fpgaErrorCount ); + + checkFPGAPersistentErrorCountAlarm( FPGA_PERS_ERROR_CD1_CD2_COND_SENSORS, fpgaErrorCount ); + processEmstatSensorRead( &emstatBoardRead[ EMSTAT_CD1_CD2_BOARD ], emstatByte ); break; default: @@ -540,11 +546,9 @@ * @details Outputs: none * @param read package the structure of each Emstat board * @param emstatByte the received byte from the sensor - * @param fpgaReadCount the FPGA read count - * @param fpgaErrorCount the FGPA error count * @return none *************************************************************************/ -static void processEmstatSensorRead( EMSTAT_READ_T* readPackage, U08 emstatByte, U16 fpgaReadCount, U08 fpgaErrorCount ) +static void processEmstatSensorRead( EMSTAT_READ_T* readPackage, U08 emstatByte ) { switch ( emstatByte ) { @@ -576,28 +580,6 @@ } break; } - -#ifndef DISABLE_FPGA_ALARMS_UNTIL_THE_NEW_PERSISTENT - // Only process the FPGA error and count values if the DG Software is not in the POST mode - if ( getCurrentOperationMode() != DG_MODE_INIT ) - { - if ( ( fpgaReadCount != readPackage->fpgaPreviousCount ) && ( 0 == ( fpgaReadCount & EMSTAT_PICO_FIFO_EMPTY_MASK ) ) && - ( fpgaErrorCount != readPackage->fpgaPreviousErrorCount ) ) - { - // Everything is fine update the previous read with the current read - readPackage->fpgaPreviousCount = fpgaReadCount; - } - else if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CONDUCTIVITY_SENSOR_ERROR ) ) // TODO remove time windowed - { -#ifndef _RELEASE_ - if ( getSoftwareConfigStatus( SW_CONFIG_DISABLE_COND_SENSOR_CHECK ) != SW_CONFIG_ENABLE_VALUE ) -#endif - { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_CONDUCTIVITY_SENSOR_FAULT, CONDUCTIVITYSENSORS_CD1_SENSOR, CONDUCTIVITYSENSORS_CD2_SENSOR ); - } - } - } -#endif } /*********************************************************************//**