Index: firmware/App/Services/NVRecordsDD.h =================================================================== diff -u -r1e809a81cb8831f5aa5938bd333cc374920d5b87 -r1e1a8756efda753c29d6a5dcfb8410451132a43a --- firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision 1e809a81cb8831f5aa5938bd333cc374920d5b87) +++ firmware/App/Services/NVRecordsDD.h (.../NVRecordsDD.h) (revision 1e1a8756efda753c29d6a5dcfb8410451132a43a) @@ -1,502 +1,324 @@ /************************************************************************** * -* Copyright (c) 2026-2027 Diality Inc. - All Rights Reserved. +* Copyright (c) 2026-2026 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 NVRecordsDD.h * +* @author (last) Arpita Srivastava +* @date (last) 27-Jul-2026 +* * @author (original) Arpita Srivastava -* @date (original) 31-Mar-2026 +* @date (original) 06-Apr-2026 * ***************************************************************************/ #ifndef _NV_RECORDS_DD_H_ #define _NV_RECORDS_DD_H_ #include "Common.h" +#include "ConcentratePumps.h" #include "DDDefs.h" +#include "DialysatePumps.h" +#include "FlowSensor.h" +#include "FluidPump.h" +#include "NVDriver.h" +#include "PressureSensor.h" +#include "RinsePump.h" +#include "TemperatureSensors.h" +#include "Utilities.h" +/** + * @defgroup NVRecordsDD NVRecordsDD + * @brief + * This module handles Non-Volatile data management including record + * validation, self-test execution, and update of system, service, + * usage, institutional, and calibration records. It ensures data + * integrity using CRC checks and updates invalid records with + * default values. + * + * @addtogroup NVRecordsDD + * @{ + */ + // ********** public definitions ********** -#define MAX_TOP_LEVEL_PN_CHARS 10U ///< Max number of characters for top level part number. -#define MAX_TOP_LEVEL_SN_CHARS 20U ///< Max number of characters for top level serial number. -#define PRES_SENSORS_RESERVED_SPACE_COUNT 5 ///< Pressure sensors reserved space count. -#define FLOW_SENSROS_RESERVED_SPACE_COUNT 2 ///< Flow sensors reserved space count. -#define TEMP_SENSORS_RESERVED_SPACE_COUNT 2 ///< Temperature sensors reserved space count. -#define GENERIC_VOL_RESERVED_SPACE_COUNT 4 ///< Generic volumes reserved space count. +#define MAX_TOP_LEVEL_PN_CHARS 10U ///< Max number of characters for top level part number. +#define MAX_TOP_LEVEL_SN_CHARS 20U ///< Max number of characters for top level serial number. +#define PRES_SENSORS_RESERVED_SPACE_COUNT 5 ///< Pressure sensors reserved space count. +#define FLOW_SENSROS_RESERVED_SPACE_COUNT 2 ///< Flow sensors reserved space count. +#define TEMP_SENSORS_RESERVED_SPACE_COUNT 2 ///< Temperature sensors reserved space count. +#define GENERIC_VOL_RESERVED_SPACE_COUNT 4 ///< Generic volumes reserved space count. - -#define MAX_EEPROM_WRITE_BUFFER_BYTES 16U ///< Max allowed bytes for an EEPROM write (16 bytes). - -#ifndef _RELEASE_ -/// Software configuration enums -typedef enum software_configurations +/// Enum for all the subcomponents for the DD calibration record +typedef enum DD_Cal_Records_Type { - SW_CONFIG_DISABLE_TRIMMER_HEATER = 0, ///< Software configuration disable trimmer heater. - SW_CONFIG_DISABLE_ACCELS, ///< Software configuration disable accelerometers. - SW_CONFIG_DISABLE_CAL_CHECK, ///< Software configuration disable calibration check. - SW_CONFIG_DISABLE_HEATERS_MONITOR, ///< Software configuration disable heaters monitor. - SW_CONFIG_DISABLE_DRAIN_PUMP_MONITOR, ///< Software configuration disable drain pump monitor. - SW_CONFIG_DISABLE_RO_PUMP_MONITOR, ///< Software configuration disable RO pump monitor. - SW_CONFIG_DISABLE_RO_RATIO_CHECK, // TODO remove ///< Software configuration disable RO ratio check - SW_CONFIG_DISABLE_COND_SENSOR_CHECK, ///< Software configuration disable conductivity sensor check. - SW_CONFIG_DISABLE_WATER_QUALITY_CHECK, ///< Software configuration disable water quality check. - SW_CONFIG_DISABLE_FLOW_VS_LOAD_CELL_CHECK_IN_FILL, ///< Software configuration disable flow vs. load cell check in fill. - SW_CONFIG_DISABLE_HEATERS_EFFICIENCY, ///< Software configuration disable heaters efficiency. - SW_CONFIG_DISABLE_DISINFECT_CONDUCTIVITY_CHECK, ///< Software configuration disable disinfect conductivity check. - SW_CONFIG_DISABLE_CONC_PUMPS, ///< Software configuration disable concentrate pumps. - SW_CONFIG_DISABLE_CAPS_MONITOR, ///< Software configuration disable cap monitor. - SW_CONFIG_DISABLE_UV_REACTORS, ///< Software configuration disable UV reactors. - SW_CONFIG_DISABLE_VOLTAGES_MONITOR, ///< Software configuration disable voltages monitor. - SW_CONFIG_DISABLE_BICARB_ALARMS, ///< Software configuration disable bicarb alarms. - SW_CONFIG_DISABLE_EMPTY_BOTTLES_ALARM, ///< Software configuration disable empty bottle alarms. - SW_CONFIG_DISABLE_BICARB_CONDUCTIVITY_TEST, // TODO remove ///< Software configuration disable bicarb conductivity test. - SW_CONFIG_DISABLE_ACID_CONDUCTIVITY_TEST, // TODO remove ///< Software configuration disable acid conductivity test. - SW_CONFIG_DISABLE_CONC_PUMPS_SPEED_ALARM, ///< Software configuration disable concentrate pumps speed alarm. - SW_CONFIG_DISABLE_MIXING_IN_FILL, // TODO remove ///< Software configuration disable mixing in fill. - SW_CONFIG_DISABLE_TEMPERATURE_SENSORS_ALARM, ///< Software configuration disable temperature sensors alarm. - SW_CONFIG_DISABLE_CONCENTRATE_PUMPS_PARK, ///< Software configuration disable concentrate pumps park feature. - SW_CONFIG_ENABLE_USING_TPO_FOR_PRIMARY_HEATER_CONTROL, ///< Software configuration enable TPo for primary heater control. - NUM_OF_SW_CONFIGS ///< Number of software configurations. -} SOFTWARE_CONFIG_T; -#endif + DD_CAL_RECORD_PRESSURE_SENSOR = 0, ///< Index for pressure sensors calibration data. + DD_CAL_FIRST_RECORD = DD_CAL_RECORD_PRESSURE_SENSOR, ///< First component of the calibration data. + DD_CAL_RECORD_TEMPERATURE_SENSOR, ///< Index for temperature sensors calibration data. + DD_CAL_RECORD_CONCENTRATE_PUMP, ///< Index for concentrate pumps calibration record. + DD_CAL_RECORD_D12_PUMP, ///< Index for D12 dialysate pump calibration record. + DD_CAL_RECORD_D48_PUMP, ///< Index for D48 dialysate pump calibration record. + DD_CAL_RECORD_ACID_CONCENTRATE, ///< Index for acid concentrates calibration data. + DD_CAL_RECORD_BICARB_CONCENTRATE, ///< Index for bicarb concentrates calibration data. + DD_CAL_RECORD_ACCELEROMETER_SENSOR, ///< Index for accelerometers calibration data. + DD_CAL_RECORD_BLLOD_LEAK_SENSOR, ///< Index for blood leak sensor calibration data. + NUM_OF_CAL_RECORD_TYPE ///< Total number of components in calibration record +}DD_CAL_REC_TYPE; -/// DG available NV data to get -typedef enum DD_nv_commands +/// Enum for all the subcomponents for the DD institutional record +typedef enum DD_Instit_Records_Type { - 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_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. - GET_CAL_DRAIN_LINE_VOLUME_RECORD, ///< Get drain line volume record. - GET_CAL_RO_PUMP_RECORD, ///< Get RO pump calibration record. - GET_CAL_CONCENTRATE_PUMPS_RECORD, ///< Get concentrate pumps calibration record. - GET_CAL_DRAIN_PUMP_RECORD, ///< Get drain pump calibration record. - GET_CAL_FANS_RECORD, ///< Get fans calibration record. - GET_CAL_PRE_RO_PURGE_VOLUME_RECORD, ///< Get pre RO purge volume record. - GET_CAL_FILTERS_RECORD, ///< Get filters record. - GET_CAL_FILL_CONDUCTIVITIES_RECORD, ///< Get fill conductivities record. - GET_INF_HEATERS_RECORD, ///< Get heaters information form the the last run. - GET_SYS_RECORD, ///< Get system record. - GET_SRV_RECORD, ///< Get service record. - GET_SRR_RECORD, ///< Get scheduled runs record. - GET_USAGE_RECORD, ///< Get usage record. - NUM_OF_NV_DD_DATA ///< Number of non-volatile data. -} NV_DATA_T; + DD_INSTIT_MIN_DIALYSATE_FLOW_MLPM = 0, ///< Index for Min dialysate flow in mL/min. + DD_INSTIT_FIRST_PARAM = DD_INSTIT_MIN_DIALYSATE_FLOW_MLPM, ///< First Parameter of the Institutional record. + DD_INSTIT_MAX_DIALYSATE_FLOW_MLPM, ///< Index for Max dialysate flow in mL/min. + DD_INSTIT_MIN_DIALYSATE_TEMP_C, ///< Index for Min dialysate temperature in C. + DD_INSTIT_MAX_DIALYSATE_TEMP_C, ///< Index for Max dialysate temperature in C. + DD_INSTIT_MIN_ACID_CONCENTRATE, ///< Index for Min acid concentrate + DD_INSTIT_MAX_ACID_CONCENTRATE, ///< Index for Max acid concentrate + DD_INSTIT_MIN_BICARB_CARTRIDGE_SIZE_G, ///< Index for Min bicarbonate cartridge size in grams. + DD_INSTIT_MAX_BICARB_CARTRIDGE_SIZE_G, ///< Index for Max bicarbonate cartridge size in grams. + DD_INSTIT_MIN_SODIUM_MEQL, ///< Index for Min sodium in mEq/L + DD_INSTIT_MAX_SODIUM_MEQL, ///< Index for Max sodium in mEq/L + DD_INSTIT_MIN_BICARBONATE_MEQL, ///< Index for Min bicarbonate in mEq/L + DD_INSTIT_MAX_BICARBONATE_MEQL, ///< Index for Max bicarbonate in mEq/L + DD_INSTIT_MIN_RO_REJECTION_RATIO_PCT, ///< Index for Min RO rejection ratio in percent. + DD_INSTIT_DISINFECTION_FREQUENCY, ///< Index for Disinfection days between cycles. + DD_INSTIT_DISINFECTION_CYCLE_TIME, ///< Index for Disinfection Cycle Time + DD_INSTIT_MIN_INLET_WATER_COND_ALARM_LIMIT_USPCM, ///< Index for Min inlet water conductivity alarm limit in uS/cm. + DD_INSTIT_MAX_INLET_WATER_COND_ALARM_LIMIT_USPCM, ///< Index for Max inlet water conductivity alarm limit in uS/cm. + DD_INSTIT_ACID_CONCENTRATE_JUG_SIZE_L, ///< Index for acid concentrate jug size in Liters + DD_INSTIT_MIN_ACID_ALARM_LIMIT_PCT, ///< Index for Min acid alarm limit in percent. + DD_INSTIT_MIN_BICARB_ALARM_LIMIT_PCT, ///< Index for Min bicarbonate alarm limit in percent. + DD_INSTIT_POST_TREAT_DRAIN_OPTION, ///< Index for Dialysate Post Treatment Drain Option  + DD_INSTIT_POST_TREAT_DRY_BICARB_OPTION, ///< Index for Dry Bicarbonate Post Treatment Option  + DD_INSTIT_LAST_UPDATED_TIME, ///< Index for last updated time in epoch. + DD_INSTIT_CRC, ///< Index for CRC of the institutional record. + NUM_OF_DD_INSTIT_RECORD_TYPE ///< Total number of components in institutional record +}DD_INSTIT_REC_TYPE; -/// DG pressure sensors enumeration. -typedef enum DD_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. - CAL_DATA_BAROMETRIC_PRES_SENSOR, ///< DG calibration data barometric pressure sensor. - NUM_OF_CAL_DATA_PRES_SENSORS, ///< Number of calibration data pressure sensors. -} CAL_DATA_DD_PRES_SENSORS_T; - -/// DG flow sensors enumeration. -typedef enum DD_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_DD_FLOW_SENSORS_T; - -/// DG load cells enumeration. -typedef enum DD_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_DD_LOAD_CELLS_T; - -/// DG temperature sensors enumeration. -typedef enum DD_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_DD_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. - CAL_DATA_HEAT_DISINFECT_TEMP, ///< Heat disinfect temperature sensor. - CAL_DATA_INTERNAL_THD_TEMP, ///< Heat disinfect internal ADC temperature sensor. - CAL_DATA_BARMOTERIC_TEMP, ///< Barometric temperature sensor. - NUM_OF_CAL_DATA_TEMP_SENSORS, ///< Number of temperature sensors. -} CAL_DATA_DD_TEMP_SENSORS_T; - -/// DG pumps enumeration. -typedef enum DD_pumps -{ - CAL_DATA_CONC_PUMP_CP1_ACID = 0, ///< Concentrate pump 1. - CAL_DATA_CONC_PUMP_CP2_BICARB, ///< Concentrate pump 2. - NUM_OF_CAL_DATA_DD_CONC_PUMPS ///< Number of DG concentrate pumps. -} CAL_DATA_DD_PUMPS_T; - -/// DG reservoirs enumeration. -typedef enum DD_reservoirs -{ - CAL_DATA_RSRVR_1 = 0, ///< Reservoir 1. - CAL_DATA_RSRVR_2, ///< Reservoir 2. - NUM_OF_CAL_DATA_RSRVRS ///< Number of reservoirs. -} CAL_DATA_DD_RESERVOIRS_T; - -/// DG acid concentrate enumeration. -typedef enum DD_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_DD_ACID_CONCENTRATES_T; - -/// DG bicarb concentrate enumeration. -typedef enum DD_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_DD_BICARB_CONCENTRATES_T; - -/// DG fans enumeration. -typedef enum DD_fans -{ - CAL_DATA_INLET_FAN_1 = 0, ///< Inlet fan 1. - CAL_DATA_INLET_FAN_2, ///< Inlet fan 2. - CAL_DATA_INLET_FAN_3, ///< Inlet fan 3. - CAL_DATA_OUTLET_FAN_1, ///< Outlet fan 1. - CAL_DATA_OUTLET_FAN_2, ///< Outlet fan 2. - CAL_DATA_OUTLET_FAN_3, ///< Outlet fan 3. - NUM_OF_CAL_DATA_FANS ///< Number of fans. -} CAL_DATA_DD_FANS_T; - -/// DG scheduled runs enumeration. +/// DD scheduled runs enumeration. typedef enum DD_scheduled_runs { - RUN_FLUSH = 0, ///< Flush run. - RUN_HEAT_DISINFECT, ///< Heat disinfect run. - RUN_CHEMICAL_DISINFECT, ///< Chemical disinfect run. - NUM_OF_DD_SCHEDULED_RUNS ///< Number of DG scheduled runs. + RUN_FLUSH = 0, ///< Flush run. + RUN_HEAT_DISINFECT, ///< Heat disinfect run. + NUM_OF_DD_SCHEDULED_RUNS ///< Number of DD scheduled runs. } SCHEDULED_DD_RUNS_T; -/// DG usage info items +/// DD usage info items typedef enum DD_usage_items { - USAGE_INFO_RO_GEN_WATER = 0, ///< Usage info RO generated water. - USAGE_INFO_BASIC_FLUSH, ///< Usage info basic flush. - USAGE_INFO_CHEM_DIS_START, ///< Usage info chemcial disinfect start. - USAGE_INFO_CHEM_DIS, ///< Usage info chemical disinfect complete. - USAGE_INFO_CHEM_FLUSH, ///< Usage info chemical flush complete. - USAGE_INFO_HEAT_DIS, ///< Usage info heat disinfect complete. - USAGE_INFO_FILTER_FLUSH, ///< Usage info filter flush complete. - USAGE_INFO_HEAT_DIS_ACTIVE_COOL, ///< Usage info heat disinfect active cool complete. - NUM_OF_USAGE_INFO_ITEMS ///< Number of usage info items. + USAGE_INFO_RO_GEN_WATER = 0, ///< Usage info RO generated water. + USAGE_INFO_BASIC_FLUSH, ///< Usage info basic flush. + USAGE_INFO_HEAT_DIS, ///< Usage info heat disinfect complete. + USAGE_INFO_FILTER_FLUSH, ///< Usage info filter flush complete. + USAGE_INFO_HEAT_DIS_ACTIVE_COOL, ///< Usage info heat disinfect active cool complete. + NUM_OF_USAGE_INFO_ITEMS ///< Number of usage info items. } DD_USAGE_INFO_ITEMS_T; -/// DG fill conductivity tests -typedef enum DD_conductivity_ops -{ - FILL_COND_NORMAL_OP = 0, ///< Fill conductivity normal operation. - FILL_COND_ACID_TEST, ///< Fill conductivity acid test. - FILL_COND_BICARB_TEST, ///< Fill conductivity bicarb test. - NUM_OF_FILL_COND_TEST ///< Number of fill conductivity test. -} DD_FILL_COND_OPS_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. + 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 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. -} DD_COND_SENSOR_TEMP_COMP_CAL_PAYLOAD_T; - -/// DG concentrate pumps calibration record -typedef struct -{ - POLYNOMIAL_CAL_PAYLOAD_T concentratePumps[ NUM_OF_CAL_DATA_DD_CONC_PUMPS ]; ///< DG concentrate pumps calibration data. -} DD_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. -} DD_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. -} DD_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. - POLYNOMIAL_CAL_PAYLOAD_T reservedSpace[ PRES_SENSORS_RESERVED_SPACE_COUNT ]; ///< Reserved space for future pressure sensors. + POLYNOMIAL_CAL_PAYLOAD_T pressureSensors[ NUM_OF_PRESSURE_SENSORS ]; ///< Pressure sensors to calibrate. } DD_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. - POLYNOMIAL_CAL_PAYLOAD_T reservedSpace[ FLOW_SENSROS_RESERVED_SPACE_COUNT ]; ///< Reserved space for future flow sensors. -} DD_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. -} DD_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. - POLYNOMIAL_CAL_PAYLOAD_T reservedSpace[ TEMP_SENSORS_RESERVED_SPACE_COUNT ]; ///< Reserved space for future temperature sensors. + POLYNOMIAL_CAL_PAYLOAD_T tempSensors[ NUM_OF_TEMPERATURE_SENSORS ]; ///< Temperature sensors to calibrate. } DD_TEMP_SENSORS_CAL_RECORD_T; -/// Drain line volume calibration structure +/// DD concentrate pumps calibration record typedef struct { - F32 volume; ///< DG Drain line volume. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DD_DRAIN_LINE_VOLUME_T; + POLYNOMIAL_CAL_PAYLOAD_T concentratePumps[ NUM_OF_CONCENTRATE_PUMPS ]; ///< DD concentrate pumps calibration data. +} DD_CONC_PUMPS_CAL_RECORD_T; -/// DG pre RO purge volume calibration structure +/// DD D12 dialysate pump calibration structure typedef struct { - F32 pressure2FlowRatio; ///< Pressure to flow ratio. - F32 volume; ///< Volume. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DD_PRE_RO_PURGE_VOLUME_T; + F32 targetPumpSpeed; ///< Target Pump Speed + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the polynomial calibration payload. +} DD_D12_DIALYSATE_PUMP_RECORD_T; -/// DG reservoir volume calibration structure +/// DD dialysate pumps calibration record 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. -} DD_RESERVOIR_VOLUME_DATA_T; + POLYNOMIAL_CAL_PAYLOAD_T d48DialysatePump; ///< DD dialysate pump d48 calibration data. +} DD_D48_DIALYSATE_PUMP_RECORD_T; -/// DG reservoir volume record +/// DD acid concentrate typedef struct { - DD_RESERVOIR_VOLUME_DATA_T reservoir[ NUM_OF_CAL_DATA_RSRVRS ]; ///< DG reservoir volume data. -} DD_RESERVOIR_VOLUME_RECORD_T; - -/// DG generic volumes (reserved space) -typedef struct -{ - F32 volume; ///< Volume. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DD_GENERIC_VOLUME_DATA_T; - -/// DG generic volume record -typedef struct -{ - DD_GENERIC_VOLUME_DATA_T genericVolume[ GENERIC_VOL_RESERVED_SPACE_COUNT ]; ///< DG generic volume record. -}DD_GENERIC_VOLUME_RECORD_T; - -/// DG acid concentrate -typedef struct -{ - F32 acidConcMixRatio; ///< Acid concentrate mix ratio. - F32 acidFullBottleVolumeML; ///< Acid full bottle volume in milliliters. - F32 acidConductivityUSPerCM; ///< Acid conductivity in uS/cm. - F32 acidBottleTemperature; ///< Acid bottle temperature in C. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. + F32 acidConcMixRatio; ///< Acid concentrate mix ratio. + F32 acidFullBottleVolumeML; ///< Acid full bottle volume in milliliters. + F32 acidConductivityUSPerCM; ///< Acid conductivity in uS/cm. + F32 acidBottleTemperature; ///< Acid bottle temperature in C. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. } DD_ACID_CONCENTRATE_T; -/// DG bicarb concentrate +/// DD bicarb concentrate typedef struct { - F32 bicarbConcMixRatio; ///< Bicarb concentrate mix ratio. - F32 bicarbStartVolumeML; ///< Bicarb start volume. - F32 bicarbConductivityUSPerCM; ///< Bicarb conductivity in uS/cm. - F32 bicarbBottleTemperature; ///< Bicarb bottle temperature in C. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. + F32 bicarbConcMixRatio; ///< Bicarb concentrate mix ratio. + F32 bicarbStartVolumeML; ///< Bicarb start volume. + F32 bicarbConductivityUSPerCM; ///< Bicarb conductivity in uS/cm. + F32 bicarbBottleTemperature; ///< Bicarb bottle temperature in C. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC. } DD_BICARB_CONCENTRATE_T; -/// DG acid concentrates +/// DD acid concentrates typedef struct { - DD_ACID_CONCENTRATE_T acidConcentrate[ NUM_OF_CAL_DATA_ACID_CONCENTRATES ]; ///< DG acid concentrates. + DD_ACID_CONCENTRATE_T acidConcentrate[ NUM_OF_ACID_TYPE ]; ///< DD acid concentrates. } DD_ACID_CONCENTRATES_RECORD_T; -/// DG bicarb concentrates +/// DD bicarb concentrates typedef struct { - DD_BICARB_CONCENTRATE_T bicarbConcentrate[ NUM_OF_CAL_DATA_BICARB_CONCENTRATES ]; ///< DG bicarb concentrates. + DD_BICARB_CONCENTRATE_T bicarbConcentrate[ NUM_OF_BICARB_TYPE ]; ///< DD bicarb concentrates. } DD_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. -} DD_FILTER_CAL_RECORD_T; - -/// DG filters calibration data structure -typedef struct -{ - DD_FILTER_CAL_RECORD_T roFilter; ///< RO filter. - DD_FILTER_CAL_RECORD_T ultraFilter; ///< Ultra filter. - DD_FILTER_CAL_RECORD_T sedimentFilter; ///< Sediment filter. - DD_FILTER_CAL_RECORD_T carbonFilter; ///< Carbon filter. - DD_FILTER_CAL_RECORD_T carbonPolishFilter; ///< Carbon polish filter. -} DD_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. -} DD_FAN_CAL_RECORD_T; - -/// DG fans calibration data structure -typedef struct -{ - DD_FAN_CAL_RECORD_T fans[ NUM_OF_CAL_DATA_FANS ]; ///< Fans calibration record. -} DD_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. + F32 accelXOffset; ///< DD accelerometer X axis offset. + F32 accelYOffset; ///< DD accelerometer Y axis offset. + F32 accelZOffset; ///< DD accelerometer Z axis offset. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the DD accelerometer sensor. } DD_ACCEL_SENSOR_CAL_RECORD_T; -/// DG heating calibration record +/// DD blood leak calibration structure typedef struct { - F32 reservoirTempTauCPerMin; ///< Reservoir temperature Tau C/min. - F32 ultrafilterTempTauCPerMin; ///< Ultrafilter temperature Tau C/min. - U32 ultrafilterVolmL; ///< Ultrafilter volume in mL. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the reservoirs and UF record. -} DD_HEATING_CAL_RECORD_T; + U16 setPoint; ///< Blood leak sensor set point. + U32 calibrationTime; ///< Calibration time. + U16 crc; ///< CRC for the HD blood leak calibration payload. +} DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T; -/// DG acid and bicarb fill conductivity values +/// DD systems record structure typedef struct { - F32 acidConduSPerCM; ///< Acid conductivity uS/cm. - F32 bicarbConduSPerCM; ///< Bicarb conductivity uS/cm. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC for the acid/bicarb fill conductivity values. -} DD_ACID_BICARB_FILL_COND_VALUES_T; - -/// DG acid and bicarb fill conductivity record -typedef struct -{ - DD_ACID_BICARB_FILL_COND_VALUES_T fillCondValues[ NUM_OF_ACID_TYPE ][ NUM_OF_FILL_COND_TEST ]; ///< Acid and bicarb fill conductivity values. -} DD_CHEMICALS_FILL_COND_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. + BOOL isROFeatured; ///< True : RO featured. False : RO de-featured. + BOOL isROFeaturedBoostPump; ///< True : RO featured with boost pump. False : RO featured without the boost pump. + char topLevelPN[ MAX_TOP_LEVEL_PN_CHARS ]; ///< DD top level part number. + char topLevelSN[ MAX_TOP_LEVEL_SN_CHARS ]; ///< DD top level serial number. + U08 mfgLocation; ///< DD manufacturing location. + U32 mfgDate; ///< DD manufacturing date. + U16 crc; ///< CRC for the DD system record structure. } DD_SYSTEM_RECORD_T; -/// DG scheduled runs record structure +/// DD service record structure typedef struct { - U32 lastRunTime; ///< DG scheduled run last run time. - U16 crc; ///< CRC for the DG scheduled run record structure. -} DD_SCHEDULED_RUN_T; + BOOL isHDFOnlineFluid; ///< True : HDF Online Fluid feature is available, False if not. + U32 waterRecovery; ///< Low : 0, Medium : 1, High : 2. + U08 serviceLoc; ///< DD service location. + U32 lastServiceEpochDate; ///< DD last service date in epoch. + U32 serviceIntervalSeconds; ///< DD service interval in seconds. + U32 lastResetTimeEpoch; ///< Last time the record was reset in epoch. + U16 crc; ///< CRC for the DD service record structure. +} DD_SERVICE_RECORD_T; -/// DG scheduled run record structure +/// DD institutional record structure typedef struct { - DD_SCHEDULED_RUN_T ddScheduledRun[ NUM_OF_DD_SCHEDULED_RUNS ]; ///< DG scheduled run. -} DD_SCHEDULED_RUN_RECORD_T; + U32 minDialysateFlowMLPM; ///< Min dialysate flow in mL/min. + U32 maxDialysateFlowMLPM; ///< Max dialysate flow in mL/min. + F32 minDialysateTempC; ///< Min dialysate temperature in C. + F32 maxDialysateTempC; ///< Max dialysate temperature in C. + U32 minAcidConcentrate; ///< Min acid concentrate + U32 maxAcidConcentrate; ///< Max acid concentrate + U32 minBicarbCartridgeSizeG; ///< Min bicarbonate cartridge size in grams. + U32 maxBicarbCartridgeSizeG; ///< Max bicarbonate cartridge size in grams. + U32 minSodiumMEQL; ///< Min sodium in mEq/L + U32 maxSodiumMEQL; ///< Max sodium in mEq/L + U32 minBicarbonateMEQL; ///< Min bicarbonate in mEq/L + U32 maxBicarbonateMEQL; ///< Max bicarbonate in mEq/L + U32 minRORejectionRatioPCT; ///< Min RO rejection ratio in percent. + U32 disinfectionFrequency; ///< Disinfection days between cycles. + F32 disinfectionCycleTime; ///< Disinfection Cycle Time + F32 minInletWaterCondAlarmLimitUSPCM; ///< Min inlet water conductivity alarm limit in uS/cm. + F32 maxInletWaterCondAlarmLimitUSPCM; ///< Max inlet water conductivity alarm limit in uS/cm. + F32 acidConcentrateJugSizeL; ///< acid concentrate jug size in Liters + F32 minAcidAlarmLimitPCT; ///< Min acid alarm limit in percent. + F32 minBicarbAlarmLimitPCT; ///< Min bicarbonate alarm limit in percent. + U32 postTreatDrainOption; ///< Dialysate Post Treatment Drain Option  + U32 postTreatDryBicarbOption; ///< Dry Bicarbonate Post Treatment Option  + U32 lastUpdatedTime; ///< Last time when institutional setting was updated in epoch. + U16 crc; ///< CRC of the institutional record. +} DD_INSTITUTIONAL_RECORD_T; -/// DG heaters information structure +/// DD usage info structure. typedef struct { - F32 averageFillFlow; ///< Average fill flow rate. -} DD_HEATERS_RECORD_T; + F32 roWaterGenTotalL; ///< Total RO water generated in liters. (Cannot be reset) + F32 roWaterGenSinceLastServiceL; ///< RO water generated since last treatment in liters. + U32 lastBasicFlushCompleteDateEpoch; ///< Last basic flush complete date in epoch. + U32 lastHeatDisCompleteDateEpoch; ///< Last heat disinfect complete date in epoch. + U32 lastHeatActiveCoolCompleteDateEpoch; ///< Last heat disinfect active cool complete date in epoch. + U32 lastFilterFlushCompleteDateEpoch; ///< Last filter flush complete date in epoch. + U32 lastResetTimeEpoch; ///< Last time the record was reset in epoch. + U16 crc; ///< CRC for the DD usage info structure. +} DD_USAGE_INFO_RECORD_T; -#ifndef _RELEASE_ -/// DG software configurations -typedef struct -{ - U08 swConfigs[ NUM_OF_SW_CONFIGS ]; ///< Software configurations. -} DD_SW_CONFIG_RECORD_T; -#endif #pragma pack(pop) +// ********** public function prototypes ********** + void initNVRecordsDD( void ); -SELF_TEST_STATUS_T execNVDataMgmtSelfTest ( void ); +SELF_TEST_STATUS_T execNVMRecordsSelfTest( void ); +PROCESS_RECORD_SPECS_T getProcessRecord( NVM_RECORD_TYPE_T job ); void benignPolynomialCalRecord( POLYNOMIAL_CAL_PAYLOAD_T* record ); BOOL setLastDisinfectDate( DD_USAGE_INFO_ITEMS_T disinfect, U32 epochTime ); BOOL setServiceTime( void ); +U32 getMinRORejectionRatioInInstitRecordPCT( void ); +F32 getMinInletWaterConductivityLimitInstitRecordUSPCM( void ); +POLYNOMIAL_CAL_PAYLOAD_T getPressureSensorCalRecord( U08 snsrIdx ); +POLYNOMIAL_CAL_PAYLOAD_T getTemperatureSensorCalRecord( U08 snsrIdx ); +POLYNOMIAL_CAL_PAYLOAD_T getConcPumpCalRecord( U08 pumpIdx ); +DD_D12_DIALYSATE_PUMP_RECORD_T getD12PumpCalRecord( void ); +DD_D48_DIALYSATE_PUMP_RECORD_T getD48PumpCalRecord( void ); +DD_ACID_CONCENTRATE_T getAcidConcentrateCalRecord( U08 acidIdx ); +DD_BICARB_CONCENTRATE_T getBicarbConcentrateCalRecord( U08 bicarbIdx ); +DD_ACCEL_SENSOR_CAL_RECORD_T getAccelSensorCalRecord( void ); +DD_BLOOD_LEAK_SENSOR_CAL_RECORD_T getBloodLeakSensorCalRecord( void ); + +BOOL getNVMRecord( NV_DATA_T nvData, U08* bufferAddress, U32 bufferLength, + U08 numOfSnsrs2Check, ALARM_ID_T nvAlarm ); +BOOL setNVMRecord( NVM_RECORD_TYPE_T recType, U08* bufferAddress ); +BOOL setNVMCalRecord(DD_CAL_REC_TYPE calRecType, U08* bufferAddress, U08 idx); +BOOL getNVMInstitRecord( DD_INSTIT_REC_TYPE institRecType, U08 *valuePtr ); +BOOL setNVMInstitRecord(DD_INSTIT_REC_TYPE institRecType, U08 *valuePtr); +CRITICAL_DATA_TYPES_T getInstitRecDataType( DD_INSTIT_REC_TYPE institRecType ); + +void sendNVEvent( NVM_RECORD_TYPE_T recType, U32 d1, U32 d2 ); +void updateRecordCRC( NVM_RECORD_TYPE_T recType ); +void updateNVSelfTestResult( SELF_TEST_STATUS_T result ); +void updateNVSelfTestState( NVM_SELF_TEST_STATE_T state ); +void updateSelfTestReadRecordsFlag ( BOOL value ); +BOOL updateNVRecordCRC( U32 job, U16 crc ); + +/**@}*/ + #endif /* _NV_RECORDS_DD_H_ */