/************************************************************************** * * Copyright (c) 2019-2022 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 NVDataMgmtDGRecords.h * * @author (last) Sean Nash * @date (last) 12-Nov-2021 * * @author (original) Dara Navaei * @date (original) 12-Feb-2021 * ***************************************************************************/ #ifndef FWCOMMON_NVDATAMGMTDGRECORDS_H_ #define FWCOMMON_NVDATAMGMTDGRECORDS_H_ #include "Common.h" /** * @defgroup NVDataMgmt NVDataMgmt * @brief Non-volatile DG data records including calibration records, system records, * service records, and the scheduled runs record. * * @addtogroup NVDataMgmt * @{ */ // ********** public definitions ********** #define MAX_TOP_LEVEL_PN_CHARS 10U ///< Max number of characters for top level part number. #define MAX_TOP_LEVEL_SN_CHARS 15U ///< Max number of characters for top level serial number. /// DG available NV data to get typedef enum dg_nv_commands { GET_CAL_PRESSURE_SENOSRS = 0, ///< Get pressure sensors calibration data. GET_CAL_LOAD_CELL_SENSORS, ///< Get load cell sensors calibration data. GET_CAL_FLOW_SENSORS, ///< Get flow sensors calibration data. GET_CAL_ACID_CONCENTREATES, ///< Get acid concentrates calibration data. GET_CAL_BICARB_CONCENTRATES, ///< Get bicarb concentrates calibration data. GET_INF_HEATERS_RECORD, ///< Get heaters information form the the last run. GET_MFG_RECORD, ///< Get manufacturing record. GET_SYS_RECORD, ///< Get system record. GET_SRV_RECORD, ///< Get service record. GET_SRR_RECORD, ///< Get scheduled runs record. NUM_OF_NV_DG_DATA ///< Number of non-volatile data. } NV_DATA_T; /// DG pressure sensors enumeration. typedef enum dg_pressure_sensors { CAL_DATA_RO_PUMP_INLET_PRES_SENSOR = 0, ///< DG calibration data RO pump inlet pressure sensor. CAL_DATA_RO_PUMP_OUTLET_PRES_SENSOR, ///< DG calibration data RO pump outlet pressure sensor. CAL_DATA_DRAIN_PUMP_INLET_PRES_SENSOR, ///< DG calibration data drain pump inlet pressure sensor. CAL_DATA_DRAIN_PUMP_OUTLET_PRES_SENSOR, ///< DG calibration data drain pump outlet pressure sensor. NUM_OF_CAL_DATA_PRES_SENSORS, ///< Number of calibration data pressure sensors. } CAL_DATA_DG_PRES_SENSORS_T; /// DG flow sensors enumeration. typedef enum dg_flow_sensors { CAL_DATA_RO_PUMP_FLOW_SENSOR = 0, ///< RO pump flow sensor. CAL_DATA_DIALYSATE_FLOW_SENSOR, ///< RO pump dialysate flow sensor. NUM_OF_CAL_DATA_FLOW_SENSORS, ///< Number of flow sensors. } CAL_DATA_DG_FLOW_SENSORS_T; /// DG load cells enumeration. typedef enum dg_load_cells { CAL_DATA_LOAD_CELL_A1 = 0, ///< Load cell A1. CAL_DATA_LOAD_CELL_A2, ///< Load cell A2. CAL_DATA_LOAD_CELL_B1, ///< Load cell B1. CAL_DATA_LOAD_CELL_B2, ///< Load cell B2. NUM_OF_CAL_DATA_LOAD_CELLS, ///< Number of load cells. } CAL_DATA_DG_LOAD_CELLS_T; /// DG temperature sensors enumeration. typedef enum dg_temperature_sensors { CAL_DATA_FPGA_BOARD_TEMP = 0, ///< FPGA board temperature sensor. CAL_DATA_LOAD_CELL_A1_B1_TEMP, ///< Load cell A1/B1 temperature sensor. CAL_DATA_LOAD_CELL_A2_B2_TEMP, ///< Load cell A2/B2 temperature sensor. CAL_DATA_INTERNAL_THDO_RTD_TEMP, ///< Internal THDO RTC temperature sensor. CAL_DATA_INTERNAL_TDI_RTD_TEMP, ///< Internal TDI RTD temperature sensor. CAL_DATA_INTERNAL_COND_SENSOR_TEMP, ///< Internal conductivity sensor temperature sensor. CAL_DATA_THERMISTOR_DG_ONBOARD_NTC_TEMP, ///< DG onboard NTC thermistor. CAL_DATA_THERMISTOR_POWER_SUPPLY_1_TEMP, ///< Power supply 1 thermistor. CAL_DATA_THERMISTOR_POWER_SUPPLY_2_TEMP, ///< Power supply 2 thermistor. CAL_DATA_OUTLET_REDUNDANT_TEMP, ///< Outlet redundant temperature sensor. CAL_DATA_INLET_DIALYSATE_TEMP, ///< Inlet dialysate temperature sensor. CAL_DATA_INLET_PRIMARY_HEATER_TEMP, ///< Inlet primary heater temperature sensor. CAL_DATA_OUTLET_PRIMARY_HEATER_TEMP, ///< Outlet primary heater temperature sensor. CAL_DATA_COND_SENSOR_1_TEMP, ///< Conductivity sensor 1 temperature sensor. CAL_DATA_COND_SENSOR_2_TEMP, ///< Conductivity sensor 2 temperature sensor. NUM_OF_CAL_DATA_TEMP_SENSORS, ///< Number of temperature sensors. } CAL_DATA_DG_TEMP_SENSORS_T; /// DG conductivity sensors enumeration. typedef enum dg_conductivity_sensors { CAL_DATA_CPI_COND_SENSOR = 0, ///< CPi conductivity sensor. CAL_DATA_CPO_COND_SENSOR, ///< CPo conductivity sensor. CAL_DATA_CD1_COND_SENSOR, ///< CD1 conductivity sensor. CAL_DATA_CD2_COND_SENSOR, ///< CD2 conductivity sensor. NUM_OF_CAL_DATA_COND_SENSORS, ///< Number of conductivity sensors. } CAL_DATA_DG_COND_SENSORS_T; /// DG pumps enumeration. typedef enum dg_pumps { CAL_DATA_CONC_PUMP_CP1 = 0, ///< Concentrate pump 1. CAL_DATA_CONC_PUMP_CP2, ///< Concentrate pump 2. NUM_OF_CAL_DATA_DG_CONC_PUMPS ///< Number of DG concentrate pumps. } CAL_DATA_DG_PUMPS_T; /// DG reservoirs enumeration. typedef enum dg_reservoirs { CAL_DATA_RSRVR_1 = 0, ///< Reservoir 1. CAL_DATA_RSRVR_2, ///< Reservoir 2. NUM_OF_CAL_DATA_RSRVRS ///< Number of reservoirs. } CAL_DATA_DG_RESERVOIRS_T; /// DG acid concentrate enumeration. typedef enum dg_acid_concentrate { CAL_DATA_ACID_CONCENTRATE_1 = 0, ///< Acid concentrate 1. CAL_DATA_ACID_CONCENTRATE_2, ///< Acid concentrate 2. CAL_DATA_ACID_CONCENTRATE_3, ///< Acid concentrate 3. CAL_DATA_ACID_CONCENTRATE_4, ///< Acid concentrate 4. CAL_DATA_ACID_CONCENTRATE_5, ///< Acid concentrate 5. NUM_OF_CAL_DATA_ACID_CONCENTRATES ///< Number of acid concentrates. } CAL_DATA_DG_ACID_CONCENTRATES_T; /// DG bicarb concentrate enumeration. typedef enum dg_bicarb_concentrate { CAL_DATA_BICARB_CONCENTRATE_1 = 0, ///< Bicarb concentrate 1. CAL_DATA_BICARB_CONCENTRATE_2, ///< Bicarb concentrate 2. CAL_DATA_BICARB_CONCENTRATE_3, ///< Bicarb concentrate 3. CAL_DATA_BICARB_CONCENTRATE_4, ///< Bicarb concentrate 4. CAL_DATA_BICARB_CONCENTRATE_5, ///< Bicarb concentrate 5. NUM_OF_CAL_DATA_BICARB_CONCENTRATES ///< Number of bicarb concentrates. } CAL_DATA_DG_BICARB_CONCENTRATES_T; /// DG scheduled runs enumeration. typedef enum dg_scheduled_runs { FLUSH = 0, ///< Flush run. HEAT_DISINFECT, ///< Heat disinfect run. CHEMICAL_DISINFECT, ///< Chemical disinfect run. NUM_OF_DG_SCHEDULED_RUNS ///< Number of DG scheduled runs. } SCHEDULED_DG_RUNS_T; #pragma pack(push, 1) /// Polynomial calibration structure typedef struct { F32 fourthOrderCoeff; ///< Fourth order coefficient. F32 thirdOrderCoeff; ///< Third order coefficient. F32 secondOrderCoeff; ///< Second order coefficient. F32 gain; ///< Gain. F32 offset; ///< Offset. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC for the polynomial calibration payload. } POLYNOMIAL_CAL_PAYLOAD_T; /// DG concentrate pumps one-gain payload typedef struct { F32 stepSpeed2FlowRatio; ///< Step speed to flow ratio. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC for the DG concentrate pumps calibration data. } DG_CONC_PUMPS_CAL_DATA_T; /// DG concentrate pumps calibration record typedef struct { DG_CONC_PUMPS_CAL_DATA_T concentratePumps[ NUM_OF_CAL_DATA_DG_CONC_PUMPS ]; ///< DG concentrate pumps calibration data. } DG_CONC_PUMPS_CAL_RECORD_T; /// DG drain pump two-gain payload typedef struct { F32 voltage2SpeedRatio; ///< Voltage to speed ratio. F32 stepSpeed2FlowRatio; ///< Step speed to flow ratio. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC for the drain pump structure. } DG_DRAIN_PUMP_CAL_RECORD_T; /// DG RO pump calibration structure. typedef struct { F32 gain1Ratio; ///< RO pump gain1 ratio. F32 gain2Ratio; ///< RO pump gain2 ratio. F32 gain3Ratio; ///< RO pump gain3 ratio. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC for the DG RO pump calibration structure. } DG_RO_PUMP_CAL_RECORD_T; /// Pressure sensors calibration structure typedef struct { POLYNOMIAL_CAL_PAYLOAD_T pressureSensors[ NUM_OF_CAL_DATA_PRES_SENSORS ]; ///< Pressure sensors to calibrate. // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be // reduced, so #define was not used for the size of the array POLYNOMIAL_CAL_PAYLOAD_T reservedSpace[ 6 ]; ///< Reserved space for future pressure sensors. } DG_PRES_SENSORS_CAL_RECORD_T; /// Flow sensors calibration structure typedef struct { POLYNOMIAL_CAL_PAYLOAD_T flowSensors[ NUM_OF_CAL_DATA_FLOW_SENSORS ]; ///< Flow sensors to calibrate. // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be // reduced, so #define was not used for the size of the array POLYNOMIAL_CAL_PAYLOAD_T reservedSpace[ 2 ]; ///< Reserved space for future flow sensors. } DG_FLOW_SENSORS_CAL_RECORD_T; /// Load cells calibration structure typedef struct { POLYNOMIAL_CAL_PAYLOAD_T loadCells[ NUM_OF_CAL_DATA_LOAD_CELLS ]; ///< Load cells to calibrate. } DG_LOAD_CELLS_CAL_RECORD_T; /// Temperature sensors calibration structure typedef struct { POLYNOMIAL_CAL_PAYLOAD_T tempSensors[ NUM_OF_CAL_DATA_TEMP_SENSORS ]; ///< Temperature sensors to calibrate. // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be // reduced, so #define was not used for the size of the array POLYNOMIAL_CAL_PAYLOAD_T reservedSpace[ 5 ]; ///< Reserved space for future temperature sensors. } DG_TEMP_SENSORS_CAL_RECORD_T; /// Conductivity sensors calibration structure typedef struct { POLYNOMIAL_CAL_PAYLOAD_T condSensors[ NUM_OF_CAL_DATA_COND_SENSORS ]; ///< Conductivity sensors to calibrate. // NOTE: The reserved space is for 6 sensors. This portion of the struct should be eventually be // reduced, so #define was not used for the size of the array POLYNOMIAL_CAL_PAYLOAD_T reservedSpace[ 2 ]; ///< Reserved space for future conductivity sensors. } DG_COND_SENSORS_CAL_RECORD_T; /// Drain line volume calibration structure typedef struct { F32 volume; ///< DG Drain line volume. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC. } DG_DRAIN_LINE_VOLUME_T; /// DG pre RO purge volume calibration structure typedef struct { F32 pressure2FlowRatio; ///< Pressure to flow ratio. F32 volume; ///< Volume. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC. } DG_PRE_RO_PURGE_VOLUME_T; /// DG reservoir volume calibration structure typedef struct { F32 rsrvrVolume; ///< Reservoir volume. F32 normalFillVolume; ///< Normal fill volume. F32 maxResidualFluid; ///< Max residual fluid. F32 rsrvrUnfilledWeight; ///< Reservoir unfilled weight. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC. } DG_RESERVOIR_VOLUME_DATA_T; /// DG reservoir volume record typedef struct { DG_RESERVOIR_VOLUME_DATA_T reservoir[ NUM_OF_CAL_DATA_RSRVRS ]; ///< DG reservoir volume data. } DG_RESERVOIR_VOLUME_RECORD_T; /// DG generic volumes (reserved space) typedef struct { F32 volume; ///< Volume. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC. } DG_GENERIC_VOLUME_DATA_T; /// DG generic volume record typedef struct { DG_GENERIC_VOLUME_DATA_T genericVolume[ 4 ]; ///< DG generic volume record. }DG_GENERIC_VOLUME_RECORD_T; /// DG acid concentrate typedef struct { F32 acidConcMixRatio; ///< Acid concentrate mix ratio. F32 startVolume; ///< Start volume. F32 reserverdSpace; ///< Reserved space. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC. } DG_ACID_CONCENTRATE_T; /// DG bicarb concentrate typedef struct { F32 bicarbConcMixRatio; ///< Bicarb concentrate mix ratio. F32 startVolume; ///< Start volume. F32 reservedSpace; ///< Reserved space. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC. } DG_BICARB_CONCENTRATE_T; /// DG acid concentrates typedef struct { DG_ACID_CONCENTRATE_T acidConcentrate[ NUM_OF_CAL_DATA_ACID_CONCENTRATES ]; ///< DG acid concentrates. } DG_ACID_CONCENTRATES_RECORD_T; /// DG bicarb concentrates typedef struct { DG_BICARB_CONCENTRATE_T bicarbConcentrate[ NUM_OF_CAL_DATA_BICARB_CONCENTRATES ]; ///< DG bicarb concentrates. } DG_BICARB_CONCENTRATES_RECORD_T; /// DG filter calibration record typedef struct { F32 reservedSpace1; ///< DG filter reserved space 1. F32 reservedSpace2; ///< DG filter reserved space 2. F32 reservedSpace3; ///< DG filter reserved space 3 U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC. } DG_FILTER_CAL_RECORD_T; /// DG filters calibration data structure typedef struct { DG_FILTER_CAL_RECORD_T roFilter; ///< RO filter. DG_FILTER_CAL_RECORD_T ultraFilter; ///< Ultra filter. DG_FILTER_CAL_RECORD_T sedimentFilter; ///< Sediment filter. DG_FILTER_CAL_RECORD_T carbonFilter; ///< Carbon filter. DG_FILTER_CAL_RECORD_T carbonPolishFilter; ///< Carbon polish filter. } DG_FILTERS_CAL_RECORD_T; /// DG fan calibration data structure typedef struct { F32 reservedSpace1; ///< Reserved space 1. F32 reservedSpace2; ///< Reserved space 2. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC. } DG_FAN_CAL_RECORD_T; /// DG fans calibration data structure typedef struct { DG_FAN_CAL_RECORD_T fan1; ///< Fan 1. DG_FAN_CAL_RECORD_T fan2; ///< Fan 2. } DG_FANS_CAL_RECORD_T; /// HD accelerometer sensor calibration record typedef struct { F32 accelXOffset; ///< DG accelerometer X axis offset. F32 accelYOffset; ///< DG accelerometer Y axis offset. F32 accelZOffset; ///< DG accelerometer Z axis offset. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC for the DG accelerometer sensor. } DG_ACCEL_SENSOR_CAL_RECORD_T; /// DG systems record structure typedef struct { char topLevelPN[ MAX_TOP_LEVEL_PN_CHARS ]; ///< DG top level part number. char topLevelSN[ MAX_TOP_LEVEL_SN_CHARS ]; ///< DG top level serial number. U08 mfgLocation; ///< DG manufacturing location. U32 mfgDate; ///< DG manufacturing date. U16 crc; ///< CRC for the DG system record structure. } DG_SYSTEM_RECORD_T; /// DG service record structure typedef struct { U08 serviceLoc; ///< DG service location. U32 lastServiceEpochDate; ///< DG last service date in epoch. U32 serviceIntervalSeconds; ///< DG service interval in seconds. U16 crc; ///< CRC for the DG service record structure. } DG_SERVICE_RECORD_T; /// DG scheduled runs record structure typedef struct { U32 lastRunTime; ///< DG scheduled run last run time. U16 crc; ///< CRC for the DG scheduled run record structure. } DG_SCHEDULED_RUN_T; /// DG scheduled run record structure typedef struct { DG_SCHEDULED_RUN_T dgScheduledRun[ NUM_OF_DG_SCHEDULED_RUNS ]; ///< DG scheduled run. } DG_SCHEDULED_RUN_RECORD_T; /// DG usage info structure. typedef struct { U32 waterConsumption; ///< Water consumption. U16 crc; ///< CRC for the DG usage info structure. } DG_USAGE_INFO_RECORD_T; /// DG heaters information structure typedef struct { F32 averageFillFlow; ///< Average fill flow rate. } DG_HEATERS_RECORD_T; #pragma pack(pop) /**@}*/ #endif