Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguez committed Nov 14, 2023
1 parent 03a98d3 commit 07897bf
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

# ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

# ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 13 additions & 2 deletions platform/panduza_platform/devices/tenma/t722710/dev_t722710.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -21,7 +23,7 @@ def _PZA_DEV_config(self):
"""
"""
return {
"family": "bps",
"family": "BPS",
"model": "72-2710",
"manufacturer": "Tenma",
"settings_props": [
Expand Down Expand Up @@ -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)
)




Original file line number Diff line number Diff line change
@@ -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)

# ---

Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -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()}")
Expand Down
Original file line number Diff line number Diff line change
@@ -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)

# ---

10 changes: 1 addition & 9 deletions platform/panduza_platform/meta_drivers/ammeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _PZA_DRV_config(self):
"version": "0.0"
}
}
return ChainMap(base, self._PZA_DRV_AMMETER_config())
return base

# ---

Expand Down Expand Up @@ -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):
"""
"""
Expand Down
12 changes: 2 additions & 10 deletions platform/panduza_platform/meta_drivers/bpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand Down
10 changes: 1 addition & 9 deletions platform/panduza_platform/meta_drivers/voltmeter.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _PZA_DRV_config(self):
"version": "0.0"
}
}
return ChainMap(base, self._PZA_DRV_VOLTMETER_config())
return base

# ---

Expand Down Expand Up @@ -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):
"""
"""
Expand Down

0 comments on commit 07897bf

Please sign in to comment.