Skip to content

Commit

Permalink
try to restore hm30t behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguez committed Nov 9, 2023
1 parent d435d1e commit b741e4a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
11 changes: 7 additions & 4 deletions platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ async def _PZA_DEV_mount_interfaces(self):
"""
"""

# "usb_vendor": USBID_VENDOR,
# "usb_model": USBID_MODEL
modbus_settings = {
"usb_vendor": USBID_VENDOR,
"usb_model": USBID_MODEL,
"serial_baudrate": 9600
}

self.mount_interface(
InterfaceHanmatekHm310tBpc(name=f":channel_0:_ctrl")
InterfaceHanmatekHm310tBpc(name=f":channel_0:_ctrl", modbus_settings=modbus_settings)
)
self.mount_interface(
InterfaceHanmatekHM310tAmmeter(name=f":channel_0:_am")
InterfaceHanmatekHM310tAmmeter(name=f":channel_0:_am", modbus_settings=modbus_settings)
)

Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,22 @@ class InterfaceHanmatekHM310tAmmeter(MetaDriverAmmeter):
"""
"""

def _PZA_DRV_AMMETER_config(self):
return {
"name": "hanmatek.hm310t.ammeter",
"description": "Ampermeter for HM310T channel"
}
# ---

def __init__(self, name=None, modbus_settings={}) -> None:
"""Constructor
"""
self.modbus_settings = modbus_settings
super().__init__(name=name)

# ---

async def _PZA_DRV_loop_init(self):
"""Driver initialization
"""

# Checks
assert_that(self.settings, has_key("usb_vendor"))
assert_that(self.settings, has_key("usb_model"))
assert_that(self.settings, has_key("serial_baudrate"))

# Get the gate
self.modbus = await ConnectorModbusClientSerial.Get(**self.settings)
self.modbus = await ConnectorModbusClientSerial.Get(**self.modbus_settings)

#
self.modbus_unit = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,27 @@ class InterfaceHanmatekHm310tBpc(MetaDriverBpc):
""" Driver to manage the HM310T power supply
"""

# =============================================================================
# FROM MetaDriverBpc

# ---

def _PZA_DRV_BPC_config(self):
def __init__(self, name=None, modbus_settings={}) -> None:
"""Constructor
"""
"""
return {
"name": "hanmatek.hm310t.bpc",
"description": "Power Supply HM310T from Hanmatek"
}
self.modbus_settings = modbus_settings
super().__init__(name=name)

# ---

# =============================================================================
# FROM MetaDriverBpc

# ---

async def _PZA_DRV_loop_init(self):
"""Driver initialization
"""

# Checks
assert_that(self.settings, has_key("usb_vendor"))
assert_that(self.settings, has_key("usb_model"))
assert_that(self.settings, has_key("serial_baudrate"))

# Get the gate
self.modbus = await ConnectorModbusClientSerial.Get(**self.settings)
self.modbus = await ConnectorModbusClientSerial.Get(**self.modbus_settings)

#
self.modbus_unit = 1
Expand Down

0 comments on commit b741e4a

Please sign in to comment.