Index: NVDataMgmt.c =================================================================== diff -u -r9cd19f7a9e131bcb1f956a4b32d8796b456698fe -r429bfd62d1cd6ee73c7381a449cde036b3e53632 --- NVDataMgmt.c (.../NVDataMgmt.c) (revision 9cd19f7a9e131bcb1f956a4b32d8796b456698fe) +++ NVDataMgmt.c (.../NVDataMgmt.c) (revision 429bfd62d1cd6ee73c7381a449cde036b3e53632) @@ -156,6 +156,8 @@ #define DEFAULT_BIC_TEST_ACID_SNSR_US_PER_CM 0.0F ///< Bicarb test acid sensor conductivity uS/cm. #define DEFAULT_BIC_TEST_BIC_SNSR_US_PER_CM 3890.0F ///< Bicarb test bicarb sensor conductivity uS/cm. + +#define DEFAULT_COND_SENSOR_TEMP_COMP_COEEF 0.0207F ///< Conductivity sensor temperature compensation coefficient. #endif /// NVDataMgmt self-test states enumeration. @@ -298,6 +300,7 @@ DG_LOAD_CELLS_CAL_RECORD_T loadCellsCalRecord; ///< DG load cells. DG_TEMP_SENSORS_CAL_RECORD_T tempSensorsCalRecord; ///< DG temperature sensors. DG_COND_SENSORS_CAL_RECORD_T condSensorsCalRecord; ///< DG conductivity sensors. + DG_COND_SENSORS_TEMP_COMP_CAL_RECORD_T condSensorsTempCompCalRecord; ///< DG conductivity sensors temperature compensation. DG_CONC_PUMPS_CAL_RECORD_T concentratePumpsRecord; ///< DG concentrate pumps. DG_DRAIN_PUMP_CAL_RECORD_T drainPumpRecord; ///< DG drain pump. DG_RO_PUMP_CAL_RECORD_T roPumpRecord; ///< DG RO pump. @@ -596,6 +599,7 @@ static BOOL isDGAccelerometerSensorRecordValid( DG_ACCEL_SENSOR_CAL_RECORD_T* record ); static BOOL isDGHeatingCalRecordValid( DG_HEATING_CAL_RECORD_T* record ); static BOOL isDGFillConductiviesRecordValid( DG_ACID_BICARB_FILL_COND_VALUES_T* record, DG_FILL_COND_OPS_T test, DG_ACID_TYPES_T acidType ); +static BOOL isDGCondSensorsTemperatureCompensationRecordValid( DG_COND_SENSOR_TEMP_COMP_CAL_PAYLOAD_T* record ); #endif #ifdef _HD_ @@ -1137,6 +1141,13 @@ isNVDataInvalid |= ( 0 == dgCalibrationRecord.dgCalibrationGroups.condSensorsCalRecord.condSensors[ i ].calibrationTime ? TRUE : FALSE ); break; + case GET_CAL_CONDUCTIVITY_SENSORS_TEMP_COMP: + nvDataStartPtr = (U08*)&dgCalibrationRecord.dgCalibrationGroups.condSensorsTempCompCalRecord; + nvDataLength = sizeof( dgCalibrationRecord.dgCalibrationGroups.condSensorsTempCompCalRecord ); + for ( i = 0; i < numOfSnsrs2Check; i++ ) + isNVDataInvalid |= ( 0 == dgCalibrationRecord.dgCalibrationGroups.condSensorsTempCompCalRecord.condSensorsTempComp[ i ].calibrationTime ? TRUE : FALSE ); + break; + case GET_CAL_TEMP_SENSORS: nvDataStartPtr = (U08*)&dgCalibrationRecord.dgCalibrationGroups.tempSensorsCalRecord; nvDataLength = sizeof( dgCalibrationRecord.dgCalibrationGroups.tempSensorsCalRecord ); @@ -3017,6 +3028,13 @@ isCalRecordValid = isCalRecordValid == FALSE ? FALSE : isHardwareRecordValid; } + DG_COND_SENSORS_TEMP_COMP_CAL_RECORD_T* condTemp = &dgCalibrationRecord.dgCalibrationGroups.condSensorsTempCompCalRecord; + for ( i = 0; i < NUM_OF_CAL_DATA_COND_SENSORS_TEMP_COMP; i++ ) + { + isHardwareRecordValid = isDGCondSensorsTemperatureCompensationRecordValid( &condTemp->condSensorsTempComp[ i ] ); + isCalRecordValid = isCalRecordValid == FALSE ? FALSE : isHardwareRecordValid; + } + DG_CONC_PUMPS_CAL_RECORD_T* concPump = &dgCalibrationRecord.dgCalibrationGroups.concentratePumpsRecord; for ( i = 0; i < NUM_OF_CAL_DATA_DG_CONC_PUMPS; i++ ) { @@ -3611,6 +3629,38 @@ return status; } + +/*********************************************************************//** + * @brief + * The isDGCondSensorsTemperatureCompensationRecordValid function checks whether + * the conductivity sensors temperature compensation record is valid or not + * @details Inputs: none + * @details Outputs: none + * @param record: DG_COND_SENSOR_TEMP_COMP_CAL_PAYLOAD_T pointer containing the + * conductivity sensors temperature compensation calibration payload + * @return TRUE if the record is valid otherwise FALSE + *************************************************************************/ +static BOOL isDGCondSensorsTemperatureCompensationRecordValid( DG_COND_SENSOR_TEMP_COMP_CAL_PAYLOAD_T* record ) +{ + BOOL status = TRUE; + U16 calcCRC = crc16 ( (U08*)record, sizeof(DG_COND_SENSOR_TEMP_COMP_CAL_PAYLOAD_T) - sizeof(U16) ); + U16 recordCRC = record->crc; + + if ( calcCRC != recordCRC ) + { + // CRC did not pass so set all values to default + record->gain = RECORD_DEFAULT_GAIN; + record->coefficient = DEFAULT_COND_SENSOR_TEMP_COMP_COEEF; + record->offset = RECORD_DEFAULT_OFFSET; + record->calibrationTime = RECORD_DEFAULT_TIME; + record->crc = crc16 ( (U08*)record, sizeof(DG_COND_SENSOR_TEMP_COMP_CAL_PAYLOAD_T) - sizeof(U16) ); + + // Set the to FALSE since the record is not valid + status = FALSE; + } + + return status; +} #endif #ifdef _HD_ /*********************************************************************//** Index: NVDataMgmtDGRecords.h =================================================================== diff -u -rcc6261f66d7ad49efe9483d354166f03a5254a3d -r429bfd62d1cd6ee73c7381a449cde036b3e53632 --- NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision cc6261f66d7ad49efe9483d354166f03a5254a3d) +++ NVDataMgmtDGRecords.h (.../NVDataMgmtDGRecords.h) (revision 429bfd62d1cd6ee73c7381a449cde036b3e53632) @@ -81,6 +81,7 @@ GET_CAL_BICARB_CONCENTRATES, ///< Get bicarb concentrates calibration data. GET_CAL_ACCEL_SENSORS, ///< Get accelerometers calibration data. GET_CAL_CONDUCTIVITY_SENSORS, ///< Get conductivity sensors calibration data. + GET_CAL_CONDUCTIVITY_SENSORS_TEMP_COMP, ///< Get conductivity sensors temperature compensation calibration data. GET_CAL_TEMP_SENSORS, ///< Get temperature sensors calibration data. GET_CAL_RSRVRS_VOL_RECORD, ///< Get reservoirs volume record. GET_CAL_HEATING_RECORD, ///< Get heating calibration record. @@ -165,6 +166,16 @@ NUM_OF_CAL_DATA_COND_SENSORS, ///< Number of conductivity sensors. } CAL_DATA_DG_COND_SENSORS_T; +/// DG conductivity sensors compensation values enumeration. +typedef enum dg_conductivity_sensors_comp +{ + CAL_DATA_CPI_COND_SENSOR_TEMP_COMP = 0, ///< CPi conductivity sensor temperature compensation value. + CAL_DATA_CPO_COND_SENSOR_TEMP_COMP, ///< CPo conductivity sensor temperature compensation value. + CAL_DATA_CD1_COND_SENSOR_TEMP_COMP, ///< CD1 conductivity sensor temperature compensation value. + CAL_DATA_CD2_COND_SENSOR_TEMP_COMP, ///< CD2 conductivity sensor temperature compensation value. + NUM_OF_CAL_DATA_COND_SENSORS_TEMP_COMP, ///< Number of conductivity sensors temperature compensation value. +} CAL_DATA_DG_COND_SENSORS_TEMP_COMP_T; + /// DG pumps enumeration. typedef enum dg_pumps { @@ -276,6 +287,16 @@ U16 crc; ///< CRC for the polynomial calibration payload. } POLYNOMIAL_CAL_PAYLOAD_T; +/// DG calibration sensor temperature compensation calibration structure +typedef struct +{ + F32 gain; ///< Gain. + F32 coefficient; ///< Coefficient. + F32 offset; ///< Offset. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the conductivity sensors temperature compensation cal payload. +} DG_COND_SENSOR_TEMP_COMP_CAL_PAYLOAD_T; + /// DG concentrate pumps one-gain payload typedef struct { @@ -342,6 +363,12 @@ POLYNOMIAL_CAL_PAYLOAD_T condSensors[ NUM_OF_CAL_DATA_COND_SENSORS ]; ///< Conductivity sensors to calibrate. } DG_COND_SENSORS_CAL_RECORD_T; +/// Conductivity sensors temperature compensation calibration structure +typedef struct +{ + DG_COND_SENSOR_TEMP_COMP_CAL_PAYLOAD_T condSensorsTempComp[ NUM_OF_CAL_DATA_COND_SENSORS_TEMP_COMP ]; ///< Conductivity sensors temperature compensation calibration. +} DG_COND_SENSORS_TEMP_COMP_CAL_RECORD_T; + /// Drain line volume calibration structure typedef struct {