From 07897bf914ca07f894c98f2c2edbfe782ccec107 Mon Sep 17 00:00:00 2001 From: Rodriguez Date: Tue, 14 Nov 2023 15:57:30 +0100 Subject: [PATCH] up --- .../korad/ka3005/itf_korad_ka3005p_ammeter.py | 10 ----- .../ka3005/itf_korad_ka3005p_voltmeter.py | 10 ----- .../devices/panduza/fake_bps/itf_ammeter.py | 9 ----- .../devices/panduza/fake_bps/itf_voltmeter.py | 11 ----- .../devices/tenma/t722710/dev_t722710.py | 15 ++++++- .../tenma/t722710/itf_tenma_722710_ammeter.py | 40 +++++++++++++++++++ ..._722710_bpc.py => itf_tenma_722710_bpc.py} | 16 -------- .../t722710/itf_tenma_722710_voltmeter.py | 40 +++++++++++++++++++ .../panduza_platform/meta_drivers/ammeter.py | 10 +---- platform/panduza_platform/meta_drivers/bpc.py | 12 +----- .../meta_drivers/voltmeter.py | 10 +---- 11 files changed, 97 insertions(+), 86 deletions(-) create mode 100644 platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_ammeter.py rename platform/panduza_platform/devices/tenma/t722710/{drv_tenma_722710_bpc.py => itf_tenma_722710_bpc.py} (90%) create mode 100644 platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_voltmeter.py diff --git a/platform/panduza_platform/devices/korad/ka3005/itf_korad_ka3005p_ammeter.py b/platform/panduza_platform/devices/korad/ka3005/itf_korad_ka3005p_ammeter.py index 01b517f..0e98012 100644 --- a/platform/panduza_platform/devices/korad/ka3005/itf_korad_ka3005p_ammeter.py +++ b/platform/panduza_platform/devices/korad/ka3005/itf_korad_ka3005p_ammeter.py @@ -6,16 +6,6 @@ COMMAND_TIME_LOCK=0.1 class InterfaceKoradKa3005pAmmeter(MetaDriverAmmeter): - # ============================================================================= - # FROM MetaDriverAmmeter - - def _PZA_DRV_AMMETER_config(self): - """ - """ - return { - "name": "korad.ka3005p.ammeter", - "description": "Power Supply KA3005P from Korad" - } # --- diff --git a/platform/panduza_platform/devices/korad/ka3005/itf_korad_ka3005p_voltmeter.py b/platform/panduza_platform/devices/korad/ka3005/itf_korad_ka3005p_voltmeter.py index 60c3732..c299a58 100644 --- a/platform/panduza_platform/devices/korad/ka3005/itf_korad_ka3005p_voltmeter.py +++ b/platform/panduza_platform/devices/korad/ka3005/itf_korad_ka3005p_voltmeter.py @@ -6,16 +6,6 @@ COMMAND_TIME_LOCK=0.1 class InterfaceKoradKa3005pVoltmeter(MetaDriverVoltmeter): - # ============================================================================= - # FROM MetaDriverVoltmeter - - def _PZA_DRV_VOLTMETER_config(self): - """ - """ - return { - "name": "korad.ka3005p.voltmeter", - "description": "Power Supply KA3005P from Korad" - } # --- diff --git a/platform/panduza_platform/devices/panduza/fake_bps/itf_ammeter.py b/platform/panduza_platform/devices/panduza/fake_bps/itf_ammeter.py index 03c6ff6..8ff133f 100644 --- a/platform/panduza_platform/devices/panduza/fake_bps/itf_ammeter.py +++ b/platform/panduza_platform/devices/panduza/fake_bps/itf_ammeter.py @@ -6,15 +6,6 @@ class InterfacePanduzaFakeAmmeter(MetaDriverAmmeter): """Fake Ammeter driver """ - # ============================================================================= - # FROM MetaDriverAmmeter - - def _PZA_DRV_AMMETER_config(self): - return { - "name": "panduza.fake.ammeter", - "description": "Virtual AMMETER" - } - # --- async def _PZA_DRV_loop_init(self): diff --git a/platform/panduza_platform/devices/panduza/fake_bps/itf_voltmeter.py b/platform/panduza_platform/devices/panduza/fake_bps/itf_voltmeter.py index 616bc8d..8ba0368 100644 --- a/platform/panduza_platform/devices/panduza/fake_bps/itf_voltmeter.py +++ b/platform/panduza_platform/devices/panduza/fake_bps/itf_voltmeter.py @@ -6,17 +6,6 @@ class InterfacePanduzaFakeVoltmeter(MetaDriverVoltmeter): """Fake Voltmeter driver """ - # ============================================================================= - # FROM MetaDriverVoltmeter - - def _PZA_DRV_VOLTMETER_config(self): - """ - """ - return { - "name": "panduza.fake.voltmeter", - "description": "Virtual VOLTMETER" - } - # --- async def _PZA_DRV_loop_init(self): diff --git a/platform/panduza_platform/devices/tenma/t722710/dev_t722710.py b/platform/panduza_platform/devices/tenma/t722710/dev_t722710.py index fe92638..1b0dad2 100644 --- a/platform/panduza_platform/devices/tenma/t722710/dev_t722710.py +++ b/platform/panduza_platform/devices/tenma/t722710/dev_t722710.py @@ -7,7 +7,9 @@ from connectors.udev_tty import HuntUsbDevs from connectors.serial_tty import ConnectorSerialTty -from .drv_tenma_722710_bpc import InterfaceTenma722710Bpc +from .itf_tenma_722710_bpc import InterfaceTenma722710Bpc +from .itf_tenma_722710_ammeter import InterfaceTenma722710Ammeter +from .itf_tenma_722710_voltmeter import InterfaceTenma722710Voltmeter USBID_VENDOR="0416" USBID_MODEL="5011" @@ -21,7 +23,7 @@ def _PZA_DEV_config(self): """ """ return { - "family": "bps", + "family": "BPS", "model": "72-2710", "manufacturer": "Tenma", "settings_props": [ @@ -99,4 +101,13 @@ async def _PZA_DEV_mount_interfaces(self): self.mount_interface( InterfaceTenma722710Bpc(name=f":channel_0:_ctrl", settings=settings) ) + self.mount_interface( + InterfaceTenma722710Ammeter(name=f":channel_0:_am", settings=settings) + ) + self.mount_interface( + InterfaceTenma722710Voltmeter(name=f":channel_0:_vm", settings=settings) + ) + + + diff --git a/platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_ammeter.py b/platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_ammeter.py new file mode 100644 index 0000000..88b0f73 --- /dev/null +++ b/platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_ammeter.py @@ -0,0 +1,40 @@ +from hamcrest import assert_that, has_key, instance_of +import asyncio +from meta_drivers.ammeter import MetaDriverAmmeter +from connectors.serial_tty import ConnectorSerialTty + +COMMAND_TIME_LOCK=0.1 + +class InterfaceTenma722710Ammeter(MetaDriverAmmeter): + + # --- + + def __init__(self, name=None, settings={}) -> None: + """Constructor + """ + self.settings = settings + super().__init__(name=name) + + # --- + + async def _PZA_DRV_loop_init(self): + """Driver initialization + """ + + # Get the Serial Connector + self.serial_connector = await ConnectorSerialTty.Get(**self.settings) + + # + self.channel = 1 + + # Call meta class BPC ini + await super()._PZA_DRV_loop_init() + + # --- + + async def _PZA_DRV_AMMETER_read_measure_value(self): + current = await self.serial_connector.write_and_read_until(f"IOUT{self.channel}?\n", time_lock_s=COMMAND_TIME_LOCK) + return float(current) + + # --- + diff --git a/platform/panduza_platform/devices/tenma/t722710/drv_tenma_722710_bpc.py b/platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_bpc.py similarity index 90% rename from platform/panduza_platform/devices/tenma/t722710/drv_tenma_722710_bpc.py rename to platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_bpc.py index 6245a8e..f2f9d1c 100644 --- a/platform/panduza_platform/devices/tenma/t722710/drv_tenma_722710_bpc.py +++ b/platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_bpc.py @@ -30,21 +30,6 @@ def __init__(self, name=None, settings={}) -> None: # --- - # ============================================================================= - # FROM MetaDriverBpc - - # --- - - def _PZA_DRV_BPC_config(self): - """ - """ - return { - "name": "tenma.722710.bpc", - "description": "Power Supply 72-2710 from Tenma" - } - - # --- - async def _PZA_DRV_loop_init(self): """Driver initialization """ @@ -66,7 +51,6 @@ async def _PZA_DRV_loop_init(self): async def _PZA_DRV_BPC_read_enable_value(self): # Send "STATUS?" to get back the output state - statusBytes = await self.serial_connector.write_and_read_until("STATUS?\n", time_lock_s=COMMAND_TIME_LOCK) self.log.debug(f"{statusBytes.strip()}") diff --git a/platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_voltmeter.py b/platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_voltmeter.py new file mode 100644 index 0000000..ed41a43 --- /dev/null +++ b/platform/panduza_platform/devices/tenma/t722710/itf_tenma_722710_voltmeter.py @@ -0,0 +1,40 @@ +from hamcrest import assert_that, has_key, instance_of +from meta_drivers.voltmeter import MetaDriverVoltmeter +from connectors.serial_tty import ConnectorSerialTty + + +COMMAND_TIME_LOCK=0.1 + +class InterfaceTenma722710Voltmeter(MetaDriverVoltmeter): + + # --- + + def __init__(self, name=None, settings={}) -> None: + """Constructor + """ + self.settings = settings + super().__init__(name=name) + + # --- + + async def _PZA_DRV_loop_init(self): + """Driver initialization + """ + + # Get the Serial Connector + self.serial_connector = await ConnectorSerialTty.Get(**self.settings) + + # + self.channel = 1 + + # Call meta class BPC ini + await super()._PZA_DRV_loop_init() + + # --- + + async def _PZA_DRV_VOLTMETER_read_measure_value(self): + voltage = await self.serial_connector.write_and_read_until(f"VOUT{self.channel}?\n", time_lock_s=COMMAND_TIME_LOCK) + return float(voltage) + + # --- + diff --git a/platform/panduza_platform/meta_drivers/ammeter.py b/platform/panduza_platform/meta_drivers/ammeter.py index 75c37b0..5230ce6 100644 --- a/platform/panduza_platform/meta_drivers/ammeter.py +++ b/platform/panduza_platform/meta_drivers/ammeter.py @@ -21,7 +21,7 @@ def _PZA_DRV_config(self): "version": "0.0" } } - return ChainMap(base, self._PZA_DRV_AMMETER_config()) + return base # --- @@ -59,14 +59,6 @@ async def _PZA_DRV_cmds_set(self, payload): # --- - @abc.abstractmethod - def _PZA_DRV_AMMETER_config(self): - """Driver base configuration - """ - pass - - # --- - async def _PZA_DRV_AMMETER_read_measure_value(self): """ """ diff --git a/platform/panduza_platform/meta_drivers/bpc.py b/platform/panduza_platform/meta_drivers/bpc.py index 1a0c706..bb75d82 100644 --- a/platform/panduza_platform/meta_drivers/bpc.py +++ b/platform/panduza_platform/meta_drivers/bpc.py @@ -20,21 +20,13 @@ def _PZA_DRV_config(self): "version": "0.0" } } - return ChainMap(base, self._PZA_DRV_BPC_config()) - + return base + # ============================================================================= # TO OVERRIDE IN DRIVER # --- - @abc.abstractmethod - def _PZA_DRV_BPC_config(self): - """Driver base configuration - """ - pass - - # --- - async def _PZA_DRV_BPC_read_enable_value(self): """Must get the state value on the BPC and return it """ diff --git a/platform/panduza_platform/meta_drivers/voltmeter.py b/platform/panduza_platform/meta_drivers/voltmeter.py index b214d77..b427c70 100644 --- a/platform/panduza_platform/meta_drivers/voltmeter.py +++ b/platform/panduza_platform/meta_drivers/voltmeter.py @@ -21,7 +21,7 @@ def _PZA_DRV_config(self): "version": "0.0" } } - return ChainMap(base, self._PZA_DRV_VOLTMETER_config()) + return base # --- @@ -59,14 +59,6 @@ async def _PZA_DRV_cmds_set(self, payload): # --- - @abc.abstractmethod - def _PZA_DRV_VOLTMETER_config(self): - """Driver base configuration - """ - pass - - # --- - async def _PZA_DRV_VOLTMETER_read_measure_value(self): """ """