Index: dialin/common/dg_defs.py =================================================================== diff -u -r4d916d8daba73702a58aee58041a9c3cc089a48e -re0221f00fe32642b76d4a03c61e3f5ce2da2c881 --- dialin/common/dg_defs.py (.../dg_defs.py) (revision 4d916d8daba73702a58aee58041a9c3cc089a48e) +++ dialin/common/dg_defs.py (.../dg_defs.py) (revision e0221f00fe32642b76d4a03c61e3f5ce2da2c881) @@ -66,12 +66,14 @@ DG_FAULT_STATE_START = 0 NUM_OF_DG_FAULT_STATES = 1 + @unique class DGSoloStates(DialinEnum): DG_SOLO_STANDBY_STATE_START = 0, DG_SOLO_IDLE_STATE = 1, NUM_OF_DG_SOLO_STANDBY_STATES = 2 + @unique class DGStandByModeStates(DialinEnum): DG_STANDBY_MODE_STATE_START = 0 # Start standby mode state @@ -81,13 +83,15 @@ DG_STANDBY_MODE_STATE_SAMPLE_WATER = 4 # Sample water state NUM_OF_DG_STANDBY_MODE_STATES = 5 # Number of standby mode states + @unique class DGGenIdleModeStates(DialinEnum): DG_GEN_IDLE_MODE_STATE_START = 0 DG_GEN_IDLE_MODE_STATE_FLUSH_WATER = 1 DG_GEN_IDLE_MODE_STATE_HANDLE_BAD_FILL = 2 NUM_OF_DG_GEN_IDLE_MODE_STATES = 3 + @unique class DGGenIdleModeBadFillSubStates(DialinEnum): DG_HANDLE_BAD_FILL_STATE_START = 0 @@ -98,6 +102,7 @@ DG_HANDLE_BAD_FILL_STATE_CLEAR_ALARM = 5 NUM_OF_DG_HANDLE_BAD_FILL_STATES = 6 + @unique class DGFillModeStates(DialinEnum): DG_FILL_MODE_STATE_START = 0 # Start fill mode state Index: dialin/dg/pressures.py =================================================================== diff -u -r3a70bfb451b74106348c064c34f19934aadd9119 -re0221f00fe32642b76d4a03c61e3f5ce2da2c881 --- dialin/dg/pressures.py (.../pressures.py) (revision 3a70bfb451b74106348c064c34f19934aadd9119) +++ dialin/dg/pressures.py (.../pressures.py) (revision e0221f00fe32642b76d4a03c61e3f5ce2da2c881) @@ -14,12 +14,13 @@ # ############################################################################ import struct +from enum import unique from logging import Logger from .constants import NO_RESET from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import DenaliMessage, DenaliChannels -from ..utils.base import AbstractSubSystem, publish +from ..utils.base import AbstractSubSystem, publish, DialinEnum from ..utils.checks import check_broadcast_interval_override_ms from ..utils.conversions import integer_to_bytearray, float_to_bytearray Index: dialin/dg/sw_configs.py =================================================================== diff -u -r88b4967ce6b9ac816ac21b26326450de4b540887 -re0221f00fe32642b76d4a03c61e3f5ce2da2c881 --- dialin/dg/sw_configs.py (.../sw_configs.py) (revision 88b4967ce6b9ac816ac21b26326450de4b540887) +++ dialin/dg/sw_configs.py (.../sw_configs.py) (revision e0221f00fe32642b76d4a03c61e3f5ce2da2c881) @@ -32,12 +32,27 @@ class DGSWConfigs(DialinEnum): # NOTE: NUM_OF enum has been removed because it should be a part of the software configuration # structure since the members of this class is for looped to create the dictionary automatically - SW_CONFIG_DISABLE_HEATERS_MONITOR = 0 - SW_CONFIG_THD_USING_TRO_CONNECTOR = 1 + SW_CONFIG_DISABLE_HEATERS_AND_TEMPS = 0 + SW_CONFIG_DISABLE_ACCELS = 1 SW_CONFIG_DISABLE_CAL_CHECK = 2 - SW_CONFIG_ALARMS_DEBUG = 3 - SW_CONFIG_DISABLE_RO_PUMP_MONITOR = 4 - SW_CONFIG_DISABLE_RO_RATIO_CHECK = 5 + SW_CONFIG_DISABLE_HEATERS_MONITOR = 3 + SW_CONFIG_DISBALE_DRAIN_PUMP_MONITOR = 4 + SW_CONFIG_DISABLE_RO_PUMP_MONITOR = 5 + SW_CONFIG_DISABLE_RO_RATIO_CHECK = 6 + SW_CONFIG_DISABLE_COND_SENSOR_CHECK = 7 + SW_CONFIG_DISBALE_WATER_QAULITY_CHECK = 8 + SW_CONFIG_DISBALE_FLOW_LOAD_CELL_CHECK_IN_FILL = 9 + SW_CONFIG_DISABLE_HEATERS_EFFICIENCY = 10 + SW_CONFIG_DISBALE_DISINFECT_CONDUCTIVITY_CHECK = 11 + SW_CONFIG_DISABLE_CAPS_MONITOR = 12 + SW_CONFIG_DISBALE_UV_REACTORS = 13 + SW_CONFIG_DISABLE_ACID_ALARMS = 14 + SW_CONFIG_DISABLE_BICARB_ALARMS = 15 + SW_CONFIG_DISABLE_EMPTY_BOTTLES_ALARM = 16 + SW_CONFIG_DISABLE_BICARB_CONDUCTIVITY_TEST = 17 + SW_CONFIG_DISABLE_ACID_CONDUCTIVITY_TEST = 18 + SW_CONFIG_DISABLE_DIALYSATE_CHECK = 19 + SW_CONFIG_DISABLE_MIXING_IN_FILL = 20 class DGSoftwareConfigs(AbstractSubSystem): Index: dialin/hd/post_treatment.py =================================================================== diff -u -r8c1ae1a592e02562ad9bded9ea2bd199fa80f4bf -re0221f00fe32642b76d4a03c61e3f5ce2da2c881 --- dialin/hd/post_treatment.py (.../post_treatment.py) (revision 8c1ae1a592e02562ad9bded9ea2bd199fa80f4bf) +++ dialin/hd/post_treatment.py (.../post_treatment.py) (revision e0221f00fe32642b76d4a03c61e3f5ce2da2c881) @@ -14,13 +14,25 @@ # ############################################################################ import struct +from enum import unique from logging import Logger from ..common.msg_defs import MsgIds, MsgFieldPositions from ..protocols.CAN import DenaliChannels -from ..utils.base import AbstractSubSystem, publish +from ..utils.base import AbstractSubSystem, publish, DialinEnum from ..utils.conversions import bytearray_to_integer + +@unique +class HDPostTreatmentDrainStates(DialinEnum): + + DRAIN_RESERVOIR_SWITCH_STATE = 0 + DRAIN_RESERVOIR_START_DRAIN_STATE = 1 + DRAIN_RESERVOIR_DRAIN_STATE = 2 + DRAIN_RESERVOIR_COMPLETE_STATE = 3 + NUM_OF_DRAIN_STATES = 4 + + class HDPostTreatment(AbstractSubSystem): """ Hemodialysis Delivery (HD) Dialin API sub-class for post treatment related commands. @@ -41,14 +53,15 @@ self._handler_post_treatment_sub_mode_sync) self.post_treatment_sub_mode = 0 + self.post_treatment_drain_state = 0 def get_post_treatment_sub_mode(self) -> int: """ @return: (int) post treatment submode """ return self.post_treatment_sub_mode - @publish(["post_treatment_sub_mode"]) + @publish(["post_treatment_sub_mode", "post_treatment_drain_state"]) def _handler_post_treatment_sub_mode_sync(self, message): """ Handles published post treatment sub mode data messages. Sub mode data is also captured for reference. @@ -58,7 +71,14 @@ @return: none """ - payload = message['message'] - index = MsgFieldPositions.START_POS_FIELD_1.value - self.post_treatment_sub_mode, index = bytearray_to_integer(payload,index,False) + #payload = message['message'] + #index = MsgFieldPositions.START_POS_FIELD_1.value + #print(index) + #self.post_treatment_sub_mode, index = bytearray_to_integer(payload, index, False) + #print(index) + #self.post_treatment_drain_state, index = bytearray_to_integer(payload, index, False) + self.post_treatment_sub_mode = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_1:MsgFieldPositions.END_POS_FIELD_1]))[0] + self.post_treatment_drain_state = struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] \ No newline at end of file Index: dialin/utils/conversions.py =================================================================== diff -u -r3a70bfb451b74106348c064c34f19934aadd9119 -re0221f00fe32642b76d4a03c61e3f5ce2da2c881 --- dialin/utils/conversions.py (.../conversions.py) (revision 3a70bfb451b74106348c064c34f19934aadd9119) +++ dialin/utils/conversions.py (.../conversions.py) (revision e0221f00fe32642b76d4a03c61e3f5ce2da2c881) @@ -159,7 +159,7 @@ @param signed: (bool) convert to signed or unsigned value @return: pair of the [value and incremented index by the length. """ - length = 4 # for a integer + length = 4 # for an integer value = bytearray_to_value("i" if signed else "I", buffer[index:index + length]) return value, index + length Index: tests/dg_tests.py =================================================================== diff -u -r919fc382f49f1d88cab6cc89207d75064245fea7 -re0221f00fe32642b76d4a03c61e3f5ce2da2c881 --- tests/dg_tests.py (.../dg_tests.py) (revision 919fc382f49f1d88cab6cc89207d75064245fea7) +++ tests/dg_tests.py (.../dg_tests.py) (revision e0221f00fe32642b76d4a03c61e3f5ce2da2c881) @@ -28,14 +28,16 @@ from dialin.hd.temperatures import HDTemperaturesNames from dialin.dg.concentrate_pumps import DGConcentratePumpsStates from dialin.dg.uv_reactors import ReactorsNames -from dialin.common.hd_defs import HDOpModes, HDOpSubModes, PreTreatmentWetSelfTesStates +from dialin.common.hd_defs import HDOpModes, HDOpSubModes, PreTreatmentWetSelfTesStates, PostTreatmentStates +from dialin.hd.post_treatment import HDPostTreatmentDrainStates from dialin.common.dg_defs import DGEventList from dialin.common.hd_defs import HDEventList from dialin.hd.reservoirs import HDReservoirStates from dialin.dg.reservoirs import DGReservoirsNames from dialin.common.dg_defs import DGGenIdleModeBadFillSubStates from dialin.common.alarm_defs import AlarmList from dialin.dg.fans import DGFansNames +from dialin.dg.pressures import DGPressures from dialin.dg.conductivity_sensors import ConductivitySensorsEnum from time import sleep from datetime import datetime @@ -72,11 +74,13 @@ def get_hd_run_info(): info = ('HD_op_mode, {}, HD_sub_mode, {}, Top_alarm, {}, Target_UF_ml, {:5.3f}, Meas_UF_ml, {:5.3f}, ' - 'Wet_test_state, {}, ' + 'Wet_test_state, {}, Post_tx_state, {}, Post_tx_drain_state, {}, ' .format(HDOpModes(hd.hd_operation_mode).name, hd.hd_operation_sub_mode, hd.alarms.alarm_top, hd.dialysate_outlet_flow.reference_dialysate_outlet_uf_volume, hd.dialysate_outlet_flow.measured_dialysate_outlet_uf_volume, - PreTreatmentWetSelfTesStates(hd.pretreatment.pre_treatment_wet_self_test_state).name)) + PreTreatmentWetSelfTesStates(hd.pretreatment.pre_treatment_wet_self_test_state).name, + PostTreatmentStates(hd.post_treatment.post_treatment_sub_mode).name, + HDPostTreatmentDrainStates(hd.post_treatment.post_treatment_drain_state).name)) return info @@ -350,6 +354,7 @@ def collect_treatment_data(): f = open("/home/fw/projects/dialin/tests/treatment_run.log", "w") + """ dg.conductivity_sensors.cmd_conductivity_sensor_override(ConductivitySensorsEnum.CD2.value, 6900.00) sleep(1) dg.conductivity_sensors.cmd_conductivity_sensor_override(ConductivitySensorsEnum.CD1.value, 12100.00) @@ -358,7 +363,9 @@ dg.dialysate_fill.cmd_used_bicarb_volume_override(3700.0) sleep(1) + counter = 1 start = False + """ try: while True: @@ -379,16 +386,23 @@ fill_info = get_dg_fill_info() idle_bad_fill = get_dg_idle_bad_fill_info() - #var = str(datetime.now()) + ', ' + hd_run + dg_run + hd_rsrvrs + dg_rsrvrs + load_cell + drain + ro + \ - # temp + heaters + conc_pumps + dg_fans + valves + blood_leak + hd_pumps + '\r' - + var = str(datetime.now()) + ', ' + hd_run + dg_run + hd_rsrvrs + dg_rsrvrs + load_cell + drain + ro + \ + temp + heaters + conc_pumps + dg_fans + valves + blood_leak + hd_pumps + fill_info + '\r' + """ var = str(datetime.now()) + ', ' + hd_run + dg_run + load_cell + drain + ro + conc_pumps + valves + \ idle_bad_fill + fill_info + '\r' - if dg.dg_operation_mode == 6 and dg.dg_operation_sub_mode == 5 and start is False: - dg.conductivity_sensors.cmd_conductivity_sensor_override(ConductivitySensorsEnum.CD2.value, 12000.00) + if dg.dg_operation_mode == 6 and dg.dg_operation_sub_mode == 4 and start is False: + #dg.conductivity_sensors.cmd_conductivity_sensor_override(ConductivitySensorsEnum.CD2.value, 12000.00) + dg.pressures.cmd_pressure_override(dg.pressures.PRESSURE_SENSOR_RO_PUMP_INLET, 14) start = True + if start is True: + counter += 1 + + if 10 < counter < 14: + dg.pressures.cmd_pressure_override(dg.pressures.PRESSURE_SENSOR_RO_PUMP_INLET, 14, reset=1) + """ print(var) f.write(var) sleep(1) Index: tests/hd_nvm_scripts.py =================================================================== diff -u -r919fc382f49f1d88cab6cc89207d75064245fea7 -re0221f00fe32642b76d4a03c61e3f5ce2da2c881 --- tests/hd_nvm_scripts.py (.../hd_nvm_scripts.py) (revision 919fc382f49f1d88cab6cc89207d75064245fea7) +++ tests/hd_nvm_scripts.py (.../hd_nvm_scripts.py) (revision e0221f00fe32642b76d4a03c61e3f5ce2da2c881) @@ -32,7 +32,7 @@ # Use cmd_update_hd_sw_config_record() set the changes back to firmware # This function requires an address for the excel report. Use the absolute address of your excel report like the # example below - hd.sw_configs.cmd_update_hd_sw_config_record('/home/fw/projects/HD_NV_Records/2022-04-03-HD-SW-CONFIGS-Record.xlsx') + hd.sw_configs.cmd_update_hd_sw_config_record('/home/fw/projects/HD_NV_Records/2022-04-17-HD-SW-CONFIGS-Record.xlsx') # Use this function to reset the configuration records to all be 0 # hd.sw_configs.cmd_reset_hd_sw_config_record()