/************************************************************************** * * 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 NVDataMgmtHDRecords.h * * @author (last) Dara Navaei * @date (last) 20-Jul-2021 * * @author (original) Dara Navaei * @date (original) 13-Feb-2021 * ***************************************************************************/ #ifndef FWCOMMON_NVDATAMGMTHDRECORDS_H_ #define FWCOMMON_NVDATAMGMTHDRECORDS_H_ #include "Common.h" /** * @defgroup NVDataMgmt NVDataMgmt * @brief Non-volatile HD 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. /// HD available NV data to get typedef enum hd_nv_commands { GET_CAL_BLOOD_LEAK_SENSOR = 0, ///< Get blood leak sensor calibration data. GET_CAL_TEMPERATURE_SESNORS, ///< Get temperature sensors calibration data. NUM_OF_NV_HD_DATA ///< Number of non-volatile data. } NV_DATA_T; /// HD pumps enumeration. typedef enum hd_pumps { CAL_DATA_BLOOD_PUMP = 0, ///< Blood pump. CAL_DATA_DIALYSATE_PUMP_IN, ///< Inlet dialysate pump. CAL_DATA_DIALYSATE_PUMP_OUT, ///< Outlet dialysate pump. NUM_OF_CAL_DATA_HD_PUMPS ///< Number of HD pumps. } CAL_DATA_HD_PUMPS_T; /// HD valves enumeration. typedef enum hd_valves { CAL_DATA_BLOOD_VENOUS_VALVE = 0, ///< Blood venous valve. CAL_DATA_BLOOD_ARTERIAL_VALVE, ///< Blood arterial valve. CAL_DATA_DIALYZER_INLET_VALVE, ///< Dialyzer inlet valve. CAL_DATA_DIALYZER_OUTLET_VALVE, ///< Dialyzer outlet valve. NUM_OF_CAL_DATA_HD_VALVES ///< Number of HD valves. } CAL_DATA_HD_VALVES_T; /// HD occlusion sensor enumeration. typedef enum hd_occlusion_sensors { CAL_DATA_BLOOD_PUMP_OCCLUSION_SENSOR = 0, ///< Blood pump occlusion sensor. CAL_DATA_DIALYSATE_INLET_PUMP_OCCLUSION_SENSOR, ///< Dialysate inlet occlusion sensor. CAL_DATA_DIALYSATE_OUTLET_PUMP_OCCLUSION_SENSOR, ///< Dialysate outlet occlusion sensor. NUM_OF_CAL_DATA_OCCLUSION_SENSORS, ///< Number of occlusion sensors. } CAL_DATA_HD_OCCLUSION_SENSORS_T; /// HD flow sensors enumeration. typedef enum hd_flow_sensors { CAL_DATA_HD_BLOOD_FLOW_SENSOR = 0, ///< Blood flow sensor. CAL_DATA_HD_DIALYSATE_FLOW_SENSOR, ///< Dialyzer flow sensor. NUM_OF_CAL_DATA_HD_FLOW_SENSORS, ///< Number of HD flow sensors. } CAL_DATA_HD_FLOW_SENSORS_T; /// HD pressure sensors enumeration. typedef enum hd_pressure_sensors { CAL_DATA_ARTERIAL_PRESSURE_SENSOR = 0, ///< Arterial pressure sensor. CAL_DATA_VENOUS_PRESSURE_SENSOR, ///< Venous pressure sensor. NUM_OF_CAL_DATA_HD_PRESSURE_SESNSORS, ///< Number of HD pressure sensors. } CAL_DATA_HD_PRESSURE_SENSORS_T; /// HD temperature sensors enumeration. typedef enum hd_temperature_sensors { CAL_DATA_HD_BOARD_TEMP_SENSOR_1 = 0, ///< Board temperature sensor 1. CAL_DATA_HD_BOARD_TEMP_SENSOR_2, ///< Board temperature sensor 2. CAL_DATA_HD_BOARD_TEMP_SENSOR_3, ///< Board temperature sensor 3. CAL_DATA_HD_POWER_SUPPLY_TEMP_SENSOR, ///< Power supply temperature sensor. NUM_OF_CAL_DATA_HD_TEMP_SENSORS, ///< Number of HD temperature sensors. } CAL_DATA_HD_TEMEPERATURE_SENSORS_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; /// HD pump calibration structure typedef struct { F32 pwm2Speed; ///< PWM to speed. F32 speed2Flow; ///< Speed to flow. F32 minCurrentLimit; ///< Minimum current limit. F32 maxCurrentLimit; ///< Maximum current limit. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC for the HD pumps calibration payload. } HD_PUMP_CAL_PAYLOAD_T; /// HD valve calibration structure typedef struct { F32 counts2Position; ///< Counts to position scalar. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC for the HD valves calibration payload. } HD_VALVE_CAL_PAYLOAD_T; /// HD blood pumps calibration record typedef struct { HD_PUMP_CAL_PAYLOAD_T hdPumps[ NUM_OF_CAL_DATA_HD_PUMPS ]; ///< HD pumps calibration data. } HD_PUMPS_CAL_RECORD_T; /// HD valves calibration record typedef struct { HD_VALVE_CAL_PAYLOAD_T hdvalves[ NUM_OF_CAL_DATA_HD_VALVES ]; ///< HD valves calibration data. } HD_VALVES_CAL_RECORD_T; /// HD occlusion sensors calibration record typedef struct { POLYNOMIAL_CAL_PAYLOAD_T hdOcclusionSensors[ NUM_OF_CAL_DATA_OCCLUSION_SENSORS ]; ///< HD occlusion sensors calibration data. } HD_OCCLUSION_SENSORS_CAL_RECORD_T; /// HD flow sensors calibration record typedef struct { POLYNOMIAL_CAL_PAYLOAD_T hdFlowSensors[ NUM_OF_CAL_DATA_HD_FLOW_SENSORS ]; ///< HD flow sensors calibration data. } HD_FLOW_SENSORS_CAL_RECORD_T; /// HD pressure sensors calibration record typedef struct { POLYNOMIAL_CAL_PAYLOAD_T hdPressureSensors[ NUM_OF_CAL_DATA_HD_PRESSURE_SESNSORS ]; ///< HD pressure sensors calibration data. } HD_PRESSURE_SENSORS_CAL_RECORD_T; /// HD temperature sensors calibration record typedef struct { POLYNOMIAL_CAL_PAYLOAD_T hdTemperatureSensors[ NUM_OF_CAL_DATA_HD_TEMP_SENSORS ]; ///< HD temperature sensors calibration data. } HD_TEMP_SENSORS_CAL_RECORD_T; /// HD heparin force sensor calibration record typedef struct { POLYNOMIAL_CAL_PAYLOAD_T hdHeparinForceSensor; ///< HD heparin force sensor calibration data. } HD_HEPARIN_FORCE_SENSOR_CAL_RECORD_T; /// HD accelerometer sensor calibration record typedef struct { F32 accelXOffset; ///< HD accelerometer X axis offset. F32 accelYOffset; ///< HD accelerometer Y axis offset. F32 accelZOffset; ///< HD accelerometer Z axis offset. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC for the HD accelerometer sensor. } HD_ACCELEROMETER_SENSOR_CAL_RECORD_T; /// HD blood leak calibration structure typedef struct { U16 setPoint; ///< Blood leak sensor set point. U32 calibrationTime; ///< Calibration time. U16 crc; ///< CRC for the HD blood leak calibration payload. } HD_BLOOD_LEAK_SENSOR_CAL_RECORD_T; /// HD systems record structure typedef struct { char topLevelPN[ MAX_TOP_LEVEL_PN_CHARS ]; ///< HD top level part number. char topLevelSN[ MAX_TOP_LEVEL_SN_CHARS ]; ///< HD top level serial number. U08 mfgLocation; ///< HD manufacturing location. U32 mfgDate; ///< HD manufacturing date. U16 crc; ///< CRC for the HD system record structure. } HD_SYSTEM_RECORD_T; /// HD service record structure typedef struct { U08 serviceLoc; ///< HD service location. U32 lastServiceEpochDate; ///< HD last service date in epoch. U32 serviceIntervalSeconds; ///< HD service interval in seconds. U16 crc; ///< CRC for the HD service record structure. } HD_SERVICE_RECORD_T; /// HD usage info structure. typedef struct { U32 treatmentTime; ///< Treatment time. U16 crc; ///< CRC for the HD usage info structure. } HD_USAGE_INFO_RECORD_T; #pragma pack(pop) /**@}*/ #endif