Index: NVDataMgmt.h =================================================================== diff -u -r0ee608e8de70aef91f5bdf7ebfa1f1cccf2e43dd -rff5e595afd7ad79dd7693dfa598b24fdeacad95d --- NVDataMgmt.h (.../NVDataMgmt.h) (revision 0ee608e8de70aef91f5bdf7ebfa1f1cccf2e43dd) +++ NVDataMgmt.h (.../NVDataMgmt.h) (revision ff5e595afd7ad79dd7693dfa598b24fdeacad95d) @@ -21,6 +21,13 @@ #include "Common.h" #include "ConcentratePumps.h" +#ifdef _HD_ + #include "NVDataMgmtHDRecords.h" +#endif +#ifdef _DG_ + #include "NVDataMgmtDGRecords.h" +#endif + /** * @defgroup NVDataMgmt NVDataMgmt * @brief Non-volatile data management module. Handles Bank 7 of the TI processor and the @@ -32,27 +39,6 @@ // ********** 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. - -#define MAX_HW_SERIAL_NUMBER_CHARACTERS 5U ///< Max number of characters for HD serial number TODO remove -#define MAX_DATE_CHARACTERS 10U ///< Max number of characters for date TODO REMOVE - -/// Manufacturing location enumeration. -typedef enum mfg_location -{ - MFG_LOC_FACTORY = 0, ///< Manufacturing location (HD/DG). - NUM_OF_MFG_LOC ///< Number of manufacturing location. -} MFG_LOCATION_T; - -/// Service location enumeration. -typedef enum service_location -{ - SERVICE_LOC_FACTORY = 0, ///< Service location factory (HD/DG). - SERVICE_LOC_FIELD, ///< Service location field (HD/DG). - NUM_OF_SERVICE_LOC ///< Number of service location. -} SERVICE_LOCATION_T; - /// Log event enumeration. typedef enum log_event { @@ -73,111 +59,8 @@ NVDATAMGMT_READ_COMPLETE ///< Read status complete. } NVDATAMGMT_READ_STATUS_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, - NUM_OF_CAL_DATA_FLOW_SENSORS, -} CAL_DATA_DG_FLOW_SENSORS_T; - -/// DG load cells enumeration. -typedef enum dg_load_cells -{ - CAL_DATA_LOAD_CELL_A1 = 0, - CAL_DATA_LOAD_CELL_A2, - CAL_DATA_LOAD_CELL_B1, - CAL_DATA_LOAD_CELL_B2, - NUM_OF_CAL_DATA_LOAD_CELLS, -} CAL_DATA_DG_LOAD_CELLS_T; - -/// DG temperature sensors enumeration. -typedef enum dg_temperature_sensors -{ - CAL_DATA_FPGA_BOARD_TEMP = 0, - CAL_DATA_LOAD_CELL_A1_B1_TEMP, - CAL_DATA_LOAD_CELL_A2_B2_TEMP, - CAL_DATA_INTERNAL_THDO_RTD_TEMP, - CAL_DATA_INTERNAL_TDI_RTD_TEMP, - CAL_DATA_INTERNAL_COND_SENSOR_TEMP, - CAL_DATA_THERMISTOR_DG_ONBOARD_NTC_TEMP, - CAL_DATA_THERMISTOR_POWER_SUPPLY_1_TEMP, - CAL_DATA_THERMISTOR_POWER_SUPPLY_2_TEMP, - CAL_DATA_OUTLET_REDUNDANT_TEMP, - CAL_DATA_INLET_DIALYSATE_TEMP, - CAL_DATA_INLET_PRIMARY_HEATER_TEMP, - CAL_DATA_OUTLET_PRIMARY_HEATER_TEMP, - CAL_DATA_COND_SENSOR_1_TEMP, - CAL_DATA_COND_SENSOR_2_TEMP, - NUM_OF_CAL_DATA_TEMP_SENSORS, -} CAL_DATA_DG_TEMP_SENSORS_T; - -/// DG conductivity sensors enumeration. -typedef enum dg_conductivity_sensors -{ - CAL_DATA_CPI_COND_SENSOR = 0, - CAL_DATA_CPO_COND_SENSOR, - CAL_DATA_CD1_COND_SENSOR, - CAL_DATA_CD2_COND_SENSOR, - NUM_OF_CAL_DATA_COND_SENSORS, -} CAL_DATA_DG_COND_SENSORS_T; - -/// DG pumps enumeration. -typedef enum dg_pumps -{ - CAL_DATA_CONC_PUMP_1 = 0, - CAL_DATA_CONC_PUMP_2, - CAL_DATA_DRAIN_PUMP, - CAL_DATA_RO_PUMP, - NUM_OF_CAL_DATA_DG_PUMPS -} CAL_DATA_DG_PUMPS_T; - -typedef enum dg_reservoirs -{ - CAL_DATA_RSRVR_1 = 0, - CAL_DATA_RSRVR_2, - NUM_OF_CAL_DATA_RSRVRS -} CAL_DATA_DG_RESERVOIRS_T; - -typedef enum dg_acid_concentrate -{ - CAL_DATA_ACID_CONCENTRATE_1 = 0, - CAL_DATA_ACID_CONCENTRATE_2, - CAL_DATA_ACID_CONCENTRATE_3, - CAL_DATA_ACID_CONCENTRATE_4, - CAL_DATA_ACID_CONCENTRATE_5, - NUM_OF_CAL_DATA_ACID_CONCENTRATES -} CAL_DATA_DG_ACID_CONCENTRATE_T; - -typedef enum dg_bicarb_concentrate -{ - CAL_DATA_BICARB_CONCENTRATE_1 = 0, - CAL_DATA_BICARB_CONCENTRATE_2, - CAL_DATA_BICARB_CONCENTRATE_3, - CAL_DATA_BICARB_CONCENTRATE_4, - CAL_DATA_BICARB_CONCENTRATE_5, - NUM_OF_CAL_DATA_BICARB_CONCENTRATES -} CAL_DATA_DG_BICARB_CONCENTRATE_T; - -/// DG scheduled runs -typedef enum dg_scheduled_runs -{ - FLUSH = 0, - HEAT_DISINFECT, - CHEMICAL_DISINFECT, - NUM_OF_DG_SCHEDULED_RUNS -} SCHEDULED_DG_RUNS_T; - #pragma pack(push, 1) +/********************** OLD STRUCTS TODO REMOVE ******************/ /// Payload record structure for a linear calibration message. TODO remove typedef struct { @@ -186,226 +69,6 @@ } LINEAR_F32_CAL_PAYLOAD_T; // TODO remove the above structure -/// Linear calibration structure -typedef struct -{ - F32 gain; - F32 offset; - U32 calibrationTime; - U16 crc; -} LINEAR_CAL_PAYLOAD_T; - -/// DG concentrate pumps one-gain payload -typedef struct -{ - F32 stepSpeed2FlowRatio; - U32 calibrationTime; - U16 crc; -} DG_CONC_PUMPS_CAL_RECORD_T; - -/// DG drain pump two-gain payload -typedef struct -{ - F32 voltage2SpeedRatio; - F32 stepSpeed2FlowRatio; - U32 calibrationTime; - U16 crc; -} DG_DRAIN_PUMP_CAL_RECORD_T; - -/// DG RO pump calibration structure. -typedef struct -{ - F32 gain1Ratio; - F32 gain2Ratio; - F32 gain3Ratio; - U32 calibrationTime; - U16 crc; -} DG_RO_PUMP_CAL_RECORD_T; - -/// Pressure sensors calibration structure -typedef struct -{ - LINEAR_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 - LINEAR_CAL_PAYLOAD_T reservedSpace[ 6 ]; ///< Reserved space for future pressure sensors. -} DG_PRES_SENSORS_CAL_RECORD_T; - -/// Flow sensors calibration structure -typedef struct -{ - LINEAR_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 - LINEAR_CAL_PAYLOAD_T reservedSpace[ 3 ]; ///< Reserved space for future flow sensors. -} DG_FLOW_SENSORS_CAL_RECORD_T; - -/// Load cells calibration structure -typedef struct -{ - LINEAR_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 -{ - LINEAR_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 - LINEAR_CAL_PAYLOAD_T reservedSpace[ 5 ]; ///< Reserved space for future temperature sensors. -} DG_TEMP_SENSORS_CAL_RECORD_T; - -/// Conductivity sensors calibration structure -typedef struct -{ - LINEAR_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 - LINEAR_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_T; - -/// DG generic volumes (reserved space) -typedef struct -{ - F32 volume; ///< Volume. - U32 calibrationTime; ///< Calibration time. - U16 crc; ///< CRC. -} DG_GENERIC_VOLUME_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_T; - -/// DG bicarb concentrates -typedef struct -{ - DG_BICARB_CONCENTRATE_T bicarbConcentrate[ NUM_OF_CAL_DATA_BICARB_CONCENTRATES ]; ///< DG bicarb concentrates. -} DG_BICARB_CONCENTRATES_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; - -/// 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. - MFG_LOCATION_T 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 -{ - SERVICE_LOCATION_T lastServiceLoc; ///< DG service location. - U32 lastServiceDate; ///< DG service date. - U16 crc; ///< CRC for the DG last service record structure. -} DG_SERVICE_RECORD_T; - -typedef struct -{ - U32 lastRunTime; - U16 crc; -} DG_SCHEDULED_RUN_T; - -typedef struct -{ - DG_SCHEDULED_RUN_T dgScheduledRun[ NUM_OF_DG_SCHEDULED_RUNS ]; -} DG_SCHEDULED_RUN_RECORD_T; - -/********************** OLD STRUCTS TODO REMOVE ******************/ -/// Manufacturing data structure. TODO remove -typedef struct mfg_Data -{ - char SYSSerialNumber [ MAX_TOP_LEVEL_PN_CHARS ]; ///< SYS serial number. - char HWSerialNumber [ MAX_HW_SERIAL_NUMBER_CHARACTERS ]; ///< HW serial number. - char mfgDate [ MAX_DATE_CHARACTERS ]; ///< Manufacturing date. -} MFG_DATA_T; - /// Calibration data structure. typedef struct calibration_Data { @@ -421,16 +84,10 @@ char calDateBloodFlow[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of blood flow sensor char calDateDialysateFlow[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of blood flow sensor #endif - char calDateAccel[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of accelerometer + //char calDateAccel[ MAX_DATE_CHARACTERS ]; ///< Last calibration date of accelerometer } CALIBRATION_DATA_T; -/// Service dates structure. TODo remove -typedef struct service_dates -{ - char currentServiceDate [ MAX_DATE_CHARACTERS ]; ///< Current service date - char nextServiceDate [ MAX_DATE_CHARACTERS ]; ///< Next service date -} SERVICE_DATA_T; -/********************** OLD STRUCTS REMOVE ******************/ +/********************** TODO OLD STRUCT REMOVE ******************/ /// Read data status structure. typedef struct get_data @@ -451,13 +108,6 @@ F32 data4; ///< Log data 4 F32 data5; ///< Log data 5 } LOG_DATA_T; - -/// Disinfection date structure. -typedef struct -{ - char disinfectionDate [ MAX_DATE_CHARACTERS ]; ///< Disinfection Date -} DISINFECTION_DATE_T; - #pragma pack(pop) void initNVDataMgmt ( void ); @@ -482,32 +132,36 @@ BOOL getScheduledRunsRecord( void ); BOOL setScheduledRunsRecord( U32 currentMessage, U32 totalMessages, U32 length, U08 *addressPtr ); +#ifdef _DG_ DG_PRES_SENSORS_CAL_RECORD_T getDGPressureSensorsCalibrationRecord( void ); -void getDGFlowSensorsCalibrationRecord( U08* buffer ); +DG_FLOW_SENSORS_CAL_RECORD_T getDGFlowSensorsCalibrationRecord( void ); +DG_LOAD_CELLS_CAL_RECORD_T getDGLoadCellsCalibrationRecord( void ); +DG_TEMP_SENSORS_CAL_RECORD_T getDGTemperatureSensorsCalibrationRecord( void ); +DG_COND_SENSORS_CAL_RECORD_T getDGConducitivitySensorsCalibrationRecord( void ); +DG_DRAIN_LINE_VOLUME_T getDGDrainLineVolumeRecord( void ); +DG_PRE_RO_PURGE_VOLUME_T getDGPreROPurgeVolumeRecord( void ); +DG_RESERVOIR_VOLUME_RECORD_T getDGReservoirsVolumeRecord( void ); +DG_ACID_CONCENTRATES_T getDGAcidConcentratesRecord( void ); +DG_BICARB_CONCENTRATES_T getDGBicarbConcentratesRecord( void ); +DG_FILTERS_CAL_RECORD_T getDGFiltersRecord( void ); +DG_FANS_CAL_RECORD_T getDGFansRecord( void ); +DG_SYSTEM_RECORD_T getDGSystemRecord( void ); +DG_SERVICE_RECORD_T getDGServiceRecord( void ); +DG_SCHEDULED_RUN_RECORD_T getDGScheduledRunRecord( void ); +DG_RO_PUMP_CAL_RECORD_T getDGROPumpRecord( void ); +DG_DRAIN_PUMP_CAL_RECORD_T getDGDrainPumpRecord( void ); +#endif -// TODO clean up -BOOL setBootloaderFlag ( U32 flag ); -U32 getBootloaderFlag ( void ); - -BOOL setMfgData ( MFG_DATA_T data ); -BOOL getMfgData ( MFG_DATA_T* buffer ); - BOOL setCalibrationData ( CALIBRATION_DATA_T data ); //TODO remove BOOL getCalibrationData ( CALIBRATION_DATA_T* buffer ); //TODO remove -BOOL testResetCalibrationData( U32 key ); +BOOL testResetCalibrationData( U32 key ); // TODO clean up -BOOL setServiceDate ( SERVICE_DATA_T data ); -BOOL getServiceDate ( SERVICE_DATA_T* buffer ); - BOOL setTreatmentTime ( U32 hours ); U32 getTreatmentTime ( void ); BOOL setWaterConsumption ( U32 liters ); U32 getWaterConsumption ( void ); -BOOL setDisinfectionDate ( DISINFECTION_DATE_T date ); -BOOL getDisinfectionDate ( DISINFECTION_DATE_T* buffer ); - BOOL writeLogData ( LOG_DATA_T* data ); BOOL readLogData ( READ_DATA_T* buffer, U32 length );