diff --git a/platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py b/platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py index 5b1a763..ac487dc 100644 --- a/platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py +++ b/platform/panduza_platform/devices/hanmatek/hm310t/dev_hm310t.py @@ -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) ) diff --git a/platform/panduza_platform/devices/hanmatek/hm310t/itf_hanmatek_hm310t_ammeter.py b/platform/panduza_platform/devices/hanmatek/hm310t/itf_hanmatek_hm310t_ammeter.py index 72f1f64..d4a0c96 100644 --- a/platform/panduza_platform/devices/hanmatek/hm310t/itf_hanmatek_hm310t_ammeter.py +++ b/platform/panduza_platform/devices/hanmatek/hm310t/itf_hanmatek_hm310t_ammeter.py @@ -6,11 +6,13 @@ 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) # --- @@ -18,13 +20,8 @@ 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 diff --git a/platform/panduza_platform/devices/hanmatek/hm310t/itf_hanmatek_hm310t_bpc.py b/platform/panduza_platform/devices/hanmatek/hm310t/itf_hanmatek_hm310t_bpc.py index 69faba0..0f5c3e7 100644 --- a/platform/panduza_platform/devices/hanmatek/hm310t/itf_hanmatek_hm310t_bpc.py +++ b/platform/panduza_platform/devices/hanmatek/hm310t/itf_hanmatek_hm310t_bpc.py @@ -16,18 +16,18 @@ 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 # --- @@ -35,13 +35,8 @@ 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