########################################################################### # # Copyright (c) 2021-2024 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 dd_defs.py # # @author (last) Dara Navaei # @date (last) 08-Feb-2024 # @author (original) Peter Lucia # @date (original) 22-Jun-2021 # ############################################################################ from enum import unique from ..utils.base import DialinEnum @unique class DDOpModes(DialinEnum): MODE_FAUL = 0 # Fault Mode MODE_SERV = 1 # Service Mode MODE_INIT = 2 # Initialization & POST Mode MODE_STAN = 3 # Standby Mode MODE_PREG = 4 # Pre-generate Dialysate Mode MODE_GEND = 5 # Generate Dialysate Mode MODE_POSG = 6 # Post-generate Dialysate Mode MODE_HEAT = 7 # Heat Mode MODE_HCOL = 8 # Cooling Mode MODE_ROPS = 9 # RO Permeate Sample Mode MODE_NLEG = 10 # Non-legal Mode - an illegitimate mode transition has occurred NUM_OF_DD_MODES = 11 # Number of Modes for the DD @unique class DDInitStates(DialinEnum): DD_POST_STATE_START = 0 # Post Generate Dialysate Start State DD_POST_STATE_FW_COMPATIBILITY = 1 # Firmware Compatibility State DD_POST_STATE_FW_INTEGRITY = 2 # Firmware Integrity State DD_POST_STATE_FPGA = 3 # FPGA State DD_POST_STATE_NVDATAMGMT = 4 # Non-volatile Data Management State DD_POST_STATE_TEMPERATURE_SENSORS = 5 # Temperature Sensors State DD_POST_STATE_PRESSURES = 6 # Pressure Sensors State DD_POST_STATE_DIALYSATE_PUMPS = 7 # Dialysate Pumps State DD_POST_STATE_CONCENTRATE_PUMPS = 8 # Concentrate Pumps State DD_POST_STATE_CONDUCTIVITY_SENSORS = 9 # Conductivity Sensors State DD_POST_STATE_WATCHDOG = 10 # Watchdog State DD_POST_STATE_SAFETY_SHUTDOWN = 11 # Safety Shutdown State DD_POST_STATE_COMPLETED = 12 # Post Generate Dialysate Completed State DD_POST_STATE_FAILED = 13 # Post Generate Dialysate Fail State NUM_OF_DD_POST_STATES = 14 # Number of Post Generate Dialysate States @unique class DDFaultStates(DialinEnum): DD_FAULT_STATE_START = 0 # DD fault start state DD_FAULT_DEENERGIZED_STATE = 1 # DD fault de-energized state DD_FAULT_ENERGIZED_STATE_ = 2 # DD fault energized state NUM_OF_DD_FAULT_STATES = 3 # Number of fault mode states @unique class DDFaultNVDataStates(DialinEnum): DD_FAULT_STATE_START = 0 # DD fault start state DD_FAULT_STATE_RUN_NV_POSTS = 1 # DD fault run RTC and NV data management post DD_FAULT_STATE_COMPLETE = 2 # DD fault complete NUM_OF_DD_FAULT_NVDATA_STATES = 3 # Number of fault mode NV Data management states @unique class DDStandByModeStates(DialinEnum): DD_STANDBY_MODE_STATE_IDLE = 0 # Idle standby mode state DD_STANDBY_MODE_STATE_PAUSE = 1 # Pause state NUM_OF_DD_STANDBY_MODE_STATES = 2 # Number of standby mode states @unique class DDPreGenDialysateStates(DialinEnum): DD_PRE_GEN_DIALYSATE_HYD_CHAMBER_FILL_CHECK = 0, # DD Pre-Gen Dialysate hyrochamber fill check DD_PRE_GEN_WET_SELF_TEST = 1 # DD Pre-Gen Wet Self Test DD_PRE_GEN_DIALYSATE_WAIT_FOR_GEND = 2 # DD Pre-Gen Dialysate Wait for Gen Dialysate state transition NUM_OF_DD_PRE_GEN_DIALYSATE_STATES = 3 # Number of Pre-Gen Dialysate mode states @unique class DDGenDialysateModeStates(DialinEnum): DD_GEND_STATE_START = 0 # Gen dialysate start state DD_GEND_DIALYSATE_BYPASS_STATE = 1 # Gen dialysate - Bypass dialysate state DD_GEND_DIALYSATE_DELIVERY_STATE = 2 # Gen dialysate - deliver dialysate state DD_GEND_ISOLATED_UF_STATE = 3 # Gen dialysate - Isolated ultrafiltration state DD_GEND_SPENT_CHAMBER_FILL_STATE = 4 # Gen dialysate - spent chamber fill state DD_GEND_BICARB_CHAMBER_FILL_STATE = 5 # Gen dialysate - bicarb chamber fill state DD_GEND_DIALYSATE_DELIVERY_PAUSE = 6 # Gen dialysate - dialysate delivery pause state NUM_OF_DD_GEND_MODE_STATES = 7 # Number of gen dialysate states @unique class DDPostGenDialysateState(DialinEnum): DD_POST_GEN_DIALYSATE_STATE_START = 0 # DD Post-Gen Dialysate state start DD_POST_GEN_DIALYSATE_STATE_COMPLETE = 1 # DD Post-Gen Dialysate complete state NUM_OF_DD_POST_GEN_DIALYSATE_STATES = 2 # Number of Post-Gen Dialysate mode states @unique class DDEventList(DialinEnum): DD_EVENT_STARTUP = 0 # DD startup event DD_EVENT_OP_MODE_CHANGE = 1 # DD Op mode change event DD_EVENT_SUB_MODE_CHANGE = 2 # DD Op sub-mode change event DD_EVENT_OPERATION_STATUS = 3 # DD operation status event DD_EVENT_D6_LEVL_CHANGE = 4 # DD floater level change event DD_EVENT_D63_LEVL_CHANGE = 5 # DD bicarb level change event DD_EVENT_D46_LEVL_CHANGE = 6 # DD spent dialysate air seperation level change event DD_EVENT_TD_COMMUNICATION_LOSS = 7 # DD TD communication loss DD_EVENT_TEMPERATURE_DRIFT = 8 # DD dialysate temperature drift DD_EVENT_BLOOD_LEAK_ZEROING_REQUEST = 9 # DD blood leak zeroing request DD_EVENT_BLOOD_LEAK_ZEROING_REQUIRED = 10 # DD blood leak zeroing required DD_EVENT_BLOOD_LEAK_NUM_OF_SET_POINT_CHECK_FAILURES = 11 # DD blood leak number of setpoint check failures DD_EVENT_BLOOD_LEAK_SELF_TEST_RESULT = 12 # DD blood leak self test result NUM_OF_DD_EVENT_IDS = 13 # Total number of DD events @unique class DDEventDataType(DialinEnum): EVENT_DATA_TYPE_NONE = 0 # No Event Data Type EVENT_DATA_TYPE_U32 = 1 # Unsigned 32bit Event Data Type EVENT_DATA_TYPE_S32 = 2 # Signed 32bit Event Data Type EVENT_DATA_TYPE_F32 = 3 # Float 32bit Event Data Type EVENT_DATA_TYPE_BOOL = 4 # Boolean Event Data Type NUM_OF_EVENT_DATA_TYPES = 5 # Number of Event Data Types @unique class DDServiceModesStates(DialinEnum): DD_SERVICE_STATE_START = 0 # Start service mode state NUM_OF_DD_SERVICE_STATES = 1 # Number of service mode states @unique class DDBalancingChamberStates(DialinEnum): BAL_CHAMBER_STATE_START = 0, # Initial state of balancing chamber BAL_CHAMBER_STATE1_FILL_START = 1 # Balancing chamber state 1 fill start state BAL_CHAMBER_STATE1_BICARB_ACID_DOSING_CNTRL = 2 # Balancing Chamber state 1 Bicarb and acid dosing control state BAL_CHAMBER_STATE1_FILL_END = 3 # Balancing Chamber state 1 fill end state BAL_CHAMBER_STATE2_FILL_START = 4 # Balancing chamber state 2 fill start state BAL_CHAMBER_STATE2_BICARB_ACID_DOSING_CNTRL = 5 # Balancing Chamber state 2 Bicarb and acid dosing control state BAL_CHAMBER_STATE2_FILL_END = 6 # Balancing Chamber state 2 fill end state NUM_OF_BAL_CHAMBER_EXEC_STATES = 7 # Number of balancing chamber states @unique class DDBalancingChamberSwitchStates(DialinEnum): BAL_CHAMBER_SW_STATE1 = 0 # Balancing chamber switching state 1 (V2,V5 and V3, V8 open, rest closed) BAL_CHAMBER_SW_STATE2 = 1 # Balancing chamber switching state 2 ( V1,V6 and V4, V7 open, rest closed) NUM_OF_BAL_CHAMBER_SW = 2 # Number of balancing chamber states @unique class DDBloodLeakStates(DialinEnum): """ DD blood leak embedded mode state machine states """ BLOOD_LEAK_WAIT_FOR_POST_STATE = 0 BLOOD_LEAK_CHECK_SET_POINT_STATE = 1 BLOOD_LEAK_INIT_STATE = 2 BLOOD_LEAK_CHECK_ZERO_AND_SELF_TEST_STATE = 3 BLOOD_LEAK_VERIFY_INTENSITY_AFTER_ZEROING_STATE = 4 BLOOD_LEAK_NORMAL_STATE = 5 BLOOD_LEAK_RECOVER_BLOOD_DETECT_STATE = 6 NUM_OF_BLOOD_LEAK_STATES = 7 @unique class DDConcentratePumpsEnum(DialinEnum): D11_CP1_ACID = 0 # Acid Concentrate Pump D10_CP2_BICARB = 1 # Bicarbonate Concentrate Pump D76_UF = 2 # Ultrafiltration Concentrate Pump NUM_OF_CONCENTRATE_PUMPS = 3 # Number of Concentrate Pumps @unique class DDConcentratePumpsStates(DialinEnum): CONCENTRATE_PUMP_OFF_STATE = 0 # Concentrate Pump Off State CONCENTRATE_PUMP_RAMP_TO_TARGET_SPEED_STATE = 1 # Ramp to Target Speed Concentrate Pump State CONCENTRATE_PUMP_CONTROL_TARGET_SPEED_STATE = 2 # Control Target Speed Concentrate Pump State NUM_OF_CONCENTRATE_PUMP_STATES = 3 # Number of Concentrate Pump States @unique class DDConcentratePumpAttributesEnum(DialinEnum): CURRENT_STATE = 0 # Current State Concentrate Pump Attribute CURRENT_SET_SPEED = 1 # Current Set Speed Concentrate Pump Attribute MEASURED_SPEED = 2 # Measured Speed Concentrate Pump Attribute TARGET_SPEED = 3 # Target Speed Concentrate Pump Attribute PULSE_US = 4 # Hall Sensor Pulse Width (in micro seconds) Concentrate Pump Attribute TARGET_REV_COUNT = 5 # Target Revolutions Concentrate Pump Attribute MEASURED_REV_COUNT = 6 # Measured Revolutions Concentrate Pump Attribute PARKED = 7 # Parked Concentrate Pump Attribute PARK_FAULT = 8 # Park Fault Concentrate Pump Attribute NUM_OF_D10_D11_CONCENTRATE_PUMP_ATTRIBUTES = 9 # Number of Acid (D11) and Bicarbonate (D10) Concentrate Pump Attributes @unique class DDConductivitySensorsEnum(DialinEnum): D17_COND = 0 # Closed Loop Control of Dosing for D74 Conductivity Sensor D27_COND = 1 # Closed Loop Control of Dosing for D29 Conductivity Sensor D29_COND = 2 # Water, Bicarbonate, and Acid Collective Conductivity Sensor D43_COND = 3 # Self Test Conductivity Sensor (not used for dialysate conductivity) D74_COND = 4 # Water and Bicarbonate Collective Conductivity Sensor NUM_OF_CONDUCTIVITY_SENSORS = 5 # Number of Conductivity Sensors @unique class DDDialysatePumpsEnum(DialinEnum): D12_PUMP = 0 # Fresh Dialysate Pump D48_PUMP = 1 # Spent Dialysate Pump NUM_OF_DIALYSATE_PUMPS = 2 # Number of Dialysate Pumps @unique class DDDialysatePumpAttributesEnum(DialinEnum): TARGET_RPM = 0 # Target RPM Dialysate Pump Attribute MEASURED_SPEED = 1 # Measured Speed Dialysate Pump Attribute CURRENT_SPEED = 2 # Current Speed Dialysate Pump Attribute STATE = 3 # State to command Dialysate Pump Attribute TARGET_PRESSURE = 4 # Target Pressure Dialysate Pump Attribute MEASURED_PRESSURE = 5 # Measured Pressure Dialysate Pump Attribute MEASURED_CURRENT = 6 # Measured Current Dialysate Pump Attribute CONTROL = 7 # Pump Run/Stop Control Pump Attribute DIRECTION_ERROR_COUNT = 8 # Direction Error Count Dialysate Pump Attribute MEASURED_DIRECTION = 9 # Measured Direction Dialysate Pump Attribute NUM_OF_DIALYSATE_PUMP_ATTRIBUTES = 10 # Number of Dialysate Pump Attributes @unique class DDDialysatePumpsStates(DialinEnum): DIALYSATE_PUMP_OFF_STATE = 0 # Dialysate Pump Off State DIALYSATE_PUMP_RAMP_UP_STATE = 1 # Dialysate Pump Ramp Up State DIALYSATE_PUMP_CONTROL_TO_TARGET_STATE = 2 # Dialysate Pump Control to Target State NUM_OF_DIALYSATE_PUMP_STATES = 3 # Number of Dialysate Pump States @unique class DDHeatersStartStop(DialinEnum): STOP = 0 START = 1 @unique class DDHeatersState(DialinEnum): DD_HEAT_DISINFECT_STATE_START = 0 # Heat disinfect, start mode state DD_HEAT_DISINFECT_STATE_COMPLETE = 1 # Heat disinfect, complete state NUM_OF_DD_HEAT_DISINFECT_STATES = 2 # Number of heat disinfect mode states @unique class DDHeatersExecState(DialinEnum): HEATER_EXEC_STATE_OFF = 0 # Heater Execution Off State HEATER_EXEC_STATE_RAMP_TO_TARGET = 1 # Heater Execution Ramp to Target State HEATER_EXEC_STATE_CONTROL_TO_TARGET = 2 # Heater Execution Control to Target State HEATER_EXEC_STATE_CONTROL_TO_DISINFECT_TARGET = 3 # Heater Execution Control to Disinfection State NUM_OF_HEATERS_EXEC_STATE = 4 @unique class DDHeatersNames(DialinEnum): D5_HEAT = 0 # Primary heater D45_HEAT = 1 # Trimmer heater NUM_OF_DD_HEATERS = 2 # Number of Heaters @unique class DDHeatersAttributesEnum(DialinEnum): HEAT_DUTY_CYCLE = 0 # Heat Duty Cycle Attribute for Heaters HEAT_TARGET_TEMP = 1 # Target Temperature Attribute for Heaters HEAT_STATE = 2 # State to command Attribute for Heaters DUTY_CYCLE_COUNT = 3 # Duty Cycle Count Attribute for Heaters PWM_PERIOD = 4 # Pulse Width Modulation Attribute for Heaters ADJUSTED_TARGET_TEMP = 5 # Adjusted Target Temperature Attribute for Heaters TARGET_TEMP_TD = 6 # Target Temperature Attribute for Heaters NUM_OF_DD_HEATER_ATTRIBUTES = 7 # Number of Heater Attributes @unique class DDHeatersCoolingStates(DialinEnum): NUM_OF_DD_HEAT_COOL_STATES = 0 # TODO: populate with heater cooling states @unique class DDLevelSensorEnum(DialinEnum): D6_LEVEL = 0 # floater switch low, medium and high status D63_LEVEL = 1 # bicarb level low or high status D46_LEVEL = 2 # Spent dialysate air separation chamber level low or high status NUM_OF_LEVELS = 3 # Number of Level Sensors @unique class DDPistonPumpsEnum(DialinEnum): ACID = 0 # Acid piston pump BICARB = 1 # Bicarbonate piston pump UF = 2 # Ultrafiltration piston pump NUM_OF_PISTON_PUMPS = 3 # Number of piston pumps @unique class DDPistonPumpAttributesEnum(DialinEnum): CONTROL_STATE = 0 # Control State for the Piston Pumps SW_COUNTER = 1 # Software counter attribute for the Piston Pumps CYCLE_COUNTER = 2 # Cycle Counter for the Piston Pumps NUM_OF_PISTON_PUMP_ATTRIBUTES = 3 # Number of Piston Pump Attributes @unique class DDPressureNames(DialinEnum): # Pressure Sensor IDs D9_PRES = 0 # Hydraulics outlet pressure (PHo/Pn) D66_PRES = 1 # Dry Bicarb pressure (PDB/PCb) D51_PRES = 2 # Spent Dialysate pressure (PDs) D18_PRES = 3 # Fresh Dialysate pressure (PDf) D41_PRES = 4 # Transmembrane pressure (Ptm) NUM_OF_PRESSURE_SENSORS = 5 # Number of pressure sensors COND_SENSOR_INDEX_OFFSET = 6 # Conductivity Sensor Index Offset for the Temperature Readings PRES_SENSOR_INDEX_OFFSET = 15 # Pressure Sensors Offset for Temperature Readings @unique class DDROPermeateStates(DialinEnum): NUM_OF_RO_PERMEATE_STATES = 0 # TODO: populate with RO Permeate states @unique class DDTemperaturesNames(DialinEnum): D1_TEMP = 0 # Heat exchanger Inlet temperature sensor D78_TEMP = 1 # Heat exchanger Outlet temperature sensor D4_TEMP = 2 # Hydraulics primary heater temperature sensor D50_TEMP = 3 # Trimmer heater temperature sensor BRD_TEMP = 4 # Barometric temperature sensor BARO_TEMP = 5 # DD board temperature sensor ( thermistor ) D16_TEMP = 6 # D16 Conductivity sensor temperature value D28_TEMP = 7 # D28 Conductivity sensor temperature value D30_TEMP = 8 # D30 Conductivity sensor temperature value D44_TEMP = 9 # D44 Conductivity sensor temperature value D75_TEMP = 10 # D75 Conductivity sensor temperature value D4_AVG_TEMP = 11 # D4 Filtered value D50_AVG_TEMP = 12 # D50 Filtered value D28_AVG_TEMP = 13 # D28 Filtered value D30_AVG_TEMP = 14 # D30 Filtered value D9_TEMP = 15 # D9 Pressure sensor temperature value D66_TEMP = 16 # D66 Pressure sensor temperature value D51_TEMP = 17 # D51 Pressure sensor temperature value D18_TEMP = 18 # D18 Pressure sensor temperature value D41_TEMP = 19 # D41 Pressure sensor temperature value NUM_OF_TEMP_SENSORS = 20 # Number of Temperature Sensors @unique class DDValveStates(DialinEnum): VALVE_STATE_CLOSED = 0 # Valve Closed State VALVE_STATE_OPEN = 1 # Valve Open State @unique class DDValveNames(DialinEnum): D14_VALV = 0 # Valve Hydraulics Outlet (D14) D52_VALV = 1 # Valve Thermal Disinfect (D52) D8_VALV = 2 # Valve Hydraulics Bypass (D8) D54_VALV = 3 # Valve Rinse Port (D54) D53_VALV = 4 # Valve Drain (D53) D34_VALV = 5 # Valve Dialyzer Bypass (D34) D64_VALV = 6 # Valve Purge 1 (D64) D31_VALV = 7 # Valve Pressure Test (D31) D65_VALV = 8 # Valve DryBcarb Inlet (D65) D35_VALV = 9 # Valve Dialyzer Inlet (D35) D40_VALV = 10 # Valve Dialyzer Outlet (D40) D47_VALV = 11 # Valve Dialysate Out Purge 2 (D47) D3_VALV = 12 # Valve Hydraulics Inlet (D3) D80_VALV = 13 # Valve Dry Bicarb (D80) D81_VALV = 14 # Valve De-scaler (D81) RSRVD_SPACE1 = 15 # This space has been reserved D23_VALV = 16 # Balancing chamber Valve 1 (D23) D19_VALV = 17 # Balancing chamber Valve 2 (D19) D25_VALV = 18 # Balancing chamber Valve 3 (D25) D21_VALV = 19 # Balancing chamber Valve 4 (D21) D24_VALV = 20 # Balancing chamber Valve 5 (D24) D20_VALV = 21 # Balancing chamber Valve 6 (D20) D26_VALV = 22 # Balancing chamber Valve 7 (D26) D22_VALV = 23 # Balancing chamber Valve 8 (D22) D79_PMP_VALV = 24 # D79 pump mapped to spare valve 0 SPARE1_VALV = 25 # Spare Valve 1 SPARE2_VALV = 26 # Spare Valve 2 SPARE3_VALV = 27 # Spare Valve 3 SPARE4_VALV = 28 # Spare Valve 4 SPARE5_VALV = 29 # Spare Valve 5 SPARE6_VALV = 30 # Spare Valve 6 SPARE7_VALV = 31 # Spare Valve 7 M4_VALV = 32 # First IO valve (M4) M12_VALV = 33 # Last IO valve IO valve (M12) P11_VALV = 34 # First FP Valve (P11) P33_VALV = 35 # Valve (P33) P34_VALV = 36 # Valve (P34) P37_VALV = 37 # Valve (P37) P39_VALV = 38 # Valve (P39) P6_VALV = 39 # Last FP Valve (P6) NUM_OF_DD_VALVES = 40 # Number of Valves for the DD @unique class DDNotLegalStates(DialinEnum): NUM_OF_NOT_LEGAL_STATES = 0 # TODO: populate with Not Legal states @unique class DDMonitoredVoltages(DialinEnum): MONITORED_LINE_1_2V = 0 # Processor voltage (1.2V) MONITORED_LINE_3_3V = 1 # Logic voltage (3.3V) MONITORED_LINE_5V_LOGIC = 2 # Logic voltage (5V) MONITORED_LINE_24V_1 = 3 # Actuators voltage (24V) MONITORED_LINE_24V_2 = 4 # Actuators regen voltage (24V) MONITORED_LINE_FPGA_VCC_V = 5 # FPGA Vcc (3V) MONITORED_LINE_FPGA_AUX_V = 6 # FPGA Vaux (3V) MONITORED_LINE_FPGA_PVN_V = 7 # FPGA Vpvn (1V) NUM_OF_MONITORED_VOLTAGE_LINES = 8 # Number of TD operation modes