Index: dialin/dg/drain_pump.py =================================================================== diff -u -r9bc00e997e91dab8b404aa877b02ae3d4100d417 -r783b4a4b4a44ac1ce5518701e893d6f434116b02 --- dialin/dg/drain_pump.py (.../drain_pump.py) (revision 9bc00e997e91dab8b404aa877b02ae3d4100d417) +++ dialin/dg/drain_pump.py (.../drain_pump.py) (revision 783b4a4b4a44ac1ce5518701e893d6f434116b02) @@ -32,6 +32,12 @@ DRAIN_PUMP_OPEN_LOOP_STATE = 2 +@unique +class DrainPumpRPMFeedBackSensors(DialinEnum): + DRAIN_PUMP_HALL_SNSR_FB = 0 + DRAIN_PUMP_MAXON_SNSR_FB = 1 + + class DGDrainPump(AbstractSubSystem): """ Dialysate Generator (DG) Dialin API sub-class for drain pump related commands. @@ -56,7 +62,8 @@ self.target_drain_pump_rpm = 0 self.dac_value = 0 self.drain_pump_state = 0 - self.current_drain_pump_rpm = 0 + self.current_drain_pump_rpm = {DrainPumpRPMFeedBackSensors.DRAIN_PUMP_HALL_SNSR_FB.name: 0, + DrainPumpRPMFeedBackSensors.DRAIN_PUMP_MAXON_SNSR_FB.name: 0} self.target_drain_pump_outlet_flow_lpm = 0.0 self.drain_pump_current_A = 0.0 self.drain_pump_direction = 0 @@ -86,16 +93,18 @@ """ return self.drain_pump_state - def get_drain_pump_current_rpm(self): + def get_drain_pump_current_rpm(self, sensor: int): """ Gets the drain pump current RPM + @param sensor (int) the sensor to read its data @return: Drain pump current RPM """ - return self.current_drain_pump_rpm + return self.current_drain_pump_rpm[DrainPumpRPMFeedBackSensors(sensor).name] - @publish(["dg_drain_pump_timestamp","target_drain_pump_rpm", "dac_value", "drain_pump_state", "current_drain_pump_rpm", - "drain_pump_current_A", "drain_pump_direction", "target_drain_pump_outlet_flow_lpm"]) + @publish(["dg_drain_pump_timestamp", "target_drain_pump_rpm", "dac_value", "drain_pump_state", + "drain_pump_current_A", "drain_pump_direction", "target_drain_pump_outlet_flow_lpm", + "current_drain_pump_rpm"]) def _handler_drain_pump_sync(self, message, timestamp=0.0): """ Handles published drain pump data messages. Drain pump data are captured @@ -110,14 +119,18 @@ message['message'][MsgFieldPositions.START_POS_FIELD_2:MsgFieldPositions.END_POS_FIELD_2]))[0] self.drain_pump_state = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_3:MsgFieldPositions.END_POS_FIELD_3]))[0] - self.current_drain_pump_rpm = struct.unpack('i', bytearray( + self.current_drain_pump_rpm[DrainPumpRPMFeedBackSensors.DRAIN_PUMP_HALL_SNSR_FB.name] = \ + struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_4:MsgFieldPositions.END_POS_FIELD_4]))[0] self.target_drain_pump_outlet_flow_lpm = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_5:MsgFieldPositions.END_POS_FIELD_5]))[0] self.drain_pump_current_A = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_6:MsgFieldPositions.END_POS_FIELD_6]))[0] self.drain_pump_direction = struct.unpack('i', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_7:MsgFieldPositions.END_POS_FIELD_7]))[0] + self.current_drain_pump_rpm[DrainPumpRPMFeedBackSensors.DRAIN_PUMP_MAXON_SNSR_FB.name] = \ + struct.unpack('i', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_8:MsgFieldPositions.END_POS_FIELD_8]))[0] self.dg_drain_pump_timestamp = timestamp def cmd_drain_pump_set_outlet_target_flow_lpm(self, flow: float) -> int: @@ -186,27 +199,29 @@ self.logger.debug("Timeout!!!!") return False - def cmd_drain_pump_measured_rpm_override(self, rpm: int, reset: int = NO_RESET) -> int: + def cmd_drain_pump_measured_rpm_override(self, sensor: int, rpm: int, reset: int = NO_RESET) -> int: """ Constructs and sends the drain pump measured RPM override command. Constraints: Must be logged into DG. Given RPM must be within 300 <= RPM <= 3000 + @param sensor: (int) the sensor (hall sensor or maxon sensor) @param rpm: (int) rpm to override with @param reset: (int) 1 to reset a previous override, 0 to override @return: 1 if successful, zero otherwise """ rst = integer_to_bytearray(reset) r = integer_to_bytearray(rpm) - payload = rst + r + index = integer_to_bytearray(sensor) + payload = rst + r + index message = DenaliMessage.build_message(channel_id=DenaliChannels.dialin_to_dg_ch_id, message_id=MsgIds.MSG_ID_DG_DRAIN_PUMP_MEASURED_RPM_OVERRIDE.value, payload=payload) - self.logger.debug("Override drain pump measured RPM") + self.logger.debug("Setting sensor {} to {} C".format(sensor, rpm)) # Send message received_message = self.can_interface.send(message) Index: dialin/dg/voltages.py =================================================================== diff -u -r9bc00e997e91dab8b404aa877b02ae3d4100d417 -r783b4a4b4a44ac1ce5518701e893d6f434116b02 --- dialin/dg/voltages.py (.../voltages.py) (revision 9bc00e997e91dab8b404aa877b02ae3d4100d417) +++ dialin/dg/voltages.py (.../voltages.py) (revision 783b4a4b4a44ac1ce5518701e893d6f434116b02) @@ -45,15 +45,16 @@ MONITORED_LINE_FPGA_AUX_VCC_V = 13 # FPGA auxiliary voltage (3V) MONITORED_LINE_FPGA_VPVN_V = 14 # FPGA VPVN voltage (1V) MONITORED_LINE_PS_GATE_DRIVER_V = 15 # P/S gate driver (5V) + MONITORED_LINE_NON_ISOLATED_24_V_MAIN = 16 # 24 V non-isolate voltage # NOTE: This enum has been commented out because two enums cannot have the same value but the firmware has # MONITORED_LINE_PS_GATE_DRIVER_V and MONITORED_LINE_LAST_RANGE_CHECKED_LINE with the same number so for clarity it # is kept here # MONITORED_LINE_LAST_RANGE_CHECKED_LINE = MONITORED_LINE_PS_GATE_DRIVER_V # Monitored last range - MONITORED_LINE_24V_POWER_PRIM_HTR_V = 16 # Power primary heater voltage (24V) - MONITORED_LINE_24V_GND_MAIN_PRIM_HTR_V = 17 # Main primary heater ground voltage - MONITORED_LINE_24V_GND_SMALL_PRIM_HTR_V = 18 # Small primary heater voltage (24V) - MONITORED_LINE_24V_GND_TRIM_HTR_V = 19 # Trimmer heater voltage (24V) - NUM_OF_MONITORED_LINES = 20 # Number of monitored voltages + MONITORED_LINE_24V_POWER_PRIM_HTR_V = 17 # Power primary heater voltage (24V) + MONITORED_LINE_24V_GND_MAIN_PRIM_HTR_V = 18 # Main primary heater ground voltage + MONITORED_LINE_24V_GND_SMALL_PRIM_HTR_V = 19 # Small primary heater voltage (24V) + MONITORED_LINE_24V_GND_TRIM_HTR_V = 20 # Trimmer heater voltage (24V) + NUM_OF_MONITORED_LINES = 21 # Number of monitored voltages class DGVoltages(AbstractSubSystem): @@ -139,6 +140,8 @@ message['message'][MsgFieldPositions.START_POS_FIELD_19:MsgFieldPositions.END_POS_FIELD_19])) vpvn = struct.unpack('f', bytearray( message['message'][MsgFieldPositions.START_POS_FIELD_20:MsgFieldPositions.END_POS_FIELD_20])) + v24_non_iso = struct.unpack('f', bytearray( + message['message'][MsgFieldPositions.START_POS_FIELD_21:MsgFieldPositions.END_POS_FIELD_21])) self.monitored_voltages[DGMonitoredVoltages.MONITORED_LINE_1V_FPGA.value] = v1[0] self.monitored_voltages[DGMonitoredVoltages.MONITORED_LINE_1_2V_PROC.value] = v12[0] @@ -160,6 +163,7 @@ self.monitored_voltages[DGMonitoredVoltages.MONITORED_LINE_FPGA_VCC_V.value] = int_vcc[0] self.monitored_voltages[DGMonitoredVoltages.MONITORED_LINE_FPGA_AUX_VCC_V.value] = aux_vcc[0] self.monitored_voltages[DGMonitoredVoltages.MONITORED_LINE_FPGA_VPVN_V.value] = vpvn[0] + self.monitored_voltages[DGMonitoredVoltages.MONITORED_LINE_NON_ISOLATED_24_V_MAIN.value] = v24_non_iso[0] self.dg_voltages_timestamp = timestamp def cmd_monitored_voltage_override(self, signal: int = 0, volts: float = 0.0, reset: int = NO_RESET) -> int: Index: tests/dg_nvm_scripts.py =================================================================== diff -u -r821d2c94ccc6542a7733a9453e59b751bfd0ef75 -r783b4a4b4a44ac1ce5518701e893d6f434116b02 --- tests/dg_nvm_scripts.py (.../dg_nvm_scripts.py) (revision 821d2c94ccc6542a7733a9453e59b751bfd0ef75) +++ tests/dg_nvm_scripts.py (.../dg_nvm_scripts.py) (revision 783b4a4b4a44ac1ce5518701e893d6f434116b02) @@ -32,7 +32,7 @@ # Use cmd_set_dg_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 - dg.sw_configs.cmd_update_dg_sw_config_record('/home/fw/projects/DG_NV_Records/2023-03-04-DG-SW-CONFIGS-Record.xlsx') + dg.sw_configs.cmd_update_dg_sw_config_record('/home/fw/projects/DG_NV_Records/2023-04-17-DG-SW-CONFIGS-Record.xlsx') # Use this function to reset the configuration records to all be 0 #dg.sw_configs.cmd_reset_dg_sw_config_record() @@ -112,13 +112,13 @@ if dg.cmd_log_in_to_dg(): - #run_sw_configs_commands() + run_sw_configs_commands() #run_calibration_commands() #run_system_commands() - run_usage_info_commands() + #run_usage_info_commands() #run_service_commands() Index: tests/dg_tests.py =================================================================== diff -u -r821d2c94ccc6542a7733a9453e59b751bfd0ef75 -r783b4a4b4a44ac1ce5518701e893d6f434116b02 --- tests/dg_tests.py (.../dg_tests.py) (revision 821d2c94ccc6542a7733a9453e59b751bfd0ef75) +++ tests/dg_tests.py (.../dg_tests.py) (revision 783b4a4b4a44ac1ce5518701e893d6f434116b02) @@ -23,7 +23,7 @@ from dialin.common.dg_defs import DGChemicalDisinfectStates, DGChemDisinfectUIStates from dialin.common.dg_defs import DGChemDisinfectFlushStates, DGChemDisinfectFlushUIStates from dialin.dg.chemical_disinfect import ChemCancellationModes -from dialin.dg.drain_pump import DrainPumpStates +from dialin.dg.drain_pump import DrainPumpStates, DrainPumpRPMFeedBackSensors from dialin.dg.thermistors import ThermistorsNames from dialin.dg.temperatures import DGTemperaturesNames from dialin.dg.dialysate_generator import DGOperationModes @@ -208,12 +208,14 @@ def get_drain_states_info(): info = ('Drain, {}, DAC, {}, Tgt_RPM, {}, Curr_RPM, {}, PRd, {:5.3f}, PDr, {:5.3f}, Baro, {:5.3f}, ' - 'Drain_curr_A, {:5.3f}, Drain_dir, {}, Target_flow_lpm, {:5.3f}, ' + 'Drain_curr_A, {:5.3f}, Drain_dir, {}, Target_flow_lpm, {:5.3f}, Maxon_rpm, {}, ' .format(DrainPumpStates(dg.drain_pump.drain_pump_state).name, dg.drain_pump.dac_value, - dg.drain_pump.target_drain_pump_rpm, dg.drain_pump.current_drain_pump_rpm, + dg.drain_pump.target_drain_pump_rpm, + dg.drain_pump.current_drain_pump_rpm[DrainPumpRPMFeedBackSensors.DRAIN_PUMP_HALL_SNSR_FB.name], dg.pressures.drain_pump_inlet_pressure, dg.pressures.drain_pump_outlet_pressure, dg.pressures.barometric_pressure, dg.drain_pump.drain_pump_current_A, - dg.drain_pump.drain_pump_direction, dg.drain_pump.target_drain_pump_outlet_flow_lpm)) + dg.drain_pump.drain_pump_direction, dg.drain_pump.target_drain_pump_outlet_flow_lpm, + dg.drain_pump.current_drain_pump_rpm[DrainPumpRPMFeedBackSensors.DRAIN_PUMP_MAXON_SNSR_FB.name])) return info @@ -384,6 +386,13 @@ return info +def get_dg_voltages_info(): + info = ('DG_24, {:5.3f}, DG_24_non-iso, {:5.3f}, '. + format(dg.voltages.monitored_voltages[DGMonitoredVoltages.MONITORED_LINE_24V_MAIN.value], + dg.voltages.monitored_voltages[DGMonitoredVoltages.MONITORED_LINE_NON_ISOLATED_24_V_MAIN.value])) + return info + + def run_dg(): counter = 1 timer = 0.1 @@ -513,8 +522,8 @@ f = open(address, "w") #dg.heaters.cmd_heaters_broadcast_interval_override(50) #sleep(1) - #dg.hd_proxy.cmd_start_stop_dg_heat_disinfect() - dg.hd_proxy.cmd_start_stop_dg_heat_disinfect_active_cool() + dg.hd_proxy.cmd_start_stop_dg_heat_disinfect() + #dg.hd_proxy.cmd_start_stop_dg_heat_disinfect_active_cool() try: while True: @@ -663,7 +672,7 @@ hd.cmd_log_in_to_hd() sleep(1) - #run_heat_disinfect() + run_heat_disinfect() #run_flush_mode() @@ -697,10 +706,10 @@ #hd.cmd_hd_software_reset_request() - hd.ui.cmd_set_ro_only_mode_status(1) + #hd.ui.cmd_set_ro_only_mode_status(1) - while True: - print(dg.dialysate_fill.ro_only_mode_status) - sleep(1) + #while True: + # print(get_dg_voltages_info()) + # sleep(1)