From 8137cc3b303363c1ee4a36387c12790dd6d3a72d Mon Sep 17 00:00:00 2001 From: su530201 <olivier.kaufmann@umons.ac.be> Date: Fri, 22 Sep 2023 22:22:27 +0200 Subject: [PATCH] Modifies the way a controller is used by defining several connections and adding an io to components --- dev/test_2_mux_2024.py | 2 +- dev/test_3_mux_2024.py | 2 +- dev/test_4_mux_2024.py | 2 +- dev/test_mux_2024.py | 2 +- dev/test_mux_2024_2_roles_AB.py | 2 +- ohmpi/hardware_components/raspberry_pi_i2c.py | 22 ----------- .../raspberry_pi_modbus.py | 38 ------------------- 7 files changed, 5 insertions(+), 65 deletions(-) delete mode 100644 ohmpi/hardware_components/raspberry_pi_i2c.py delete mode 100644 ohmpi/hardware_components/raspberry_pi_modbus.py diff --git a/dev/test_2_mux_2024.py b/dev/test_2_mux_2024.py index eb7a95fe..9451657a 100644 --- a/dev/test_2_mux_2024.py +++ b/dev/test_2_mux_2024.py @@ -4,7 +4,7 @@ from ohmpi.plots import plot_exec_log import logging change_config('../configs/config_mb_2023_2_mux_2024.py', verbose=False) from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG -from ohmpi.hardware_components import raspberry_pi_i2c as ctl_module +from ohmpi.hardware_components import raspberry_pi as ctl_module # from ohmpi.config import HARDWARE_CONFIG stand_alone_mux = False diff --git a/dev/test_3_mux_2024.py b/dev/test_3_mux_2024.py index 21e6496c..a6430ec5 100644 --- a/dev/test_3_mux_2024.py +++ b/dev/test_3_mux_2024.py @@ -4,7 +4,7 @@ from ohmpi.plots import plot_exec_log import logging change_config('../configs/config_mb_2023_3_mux_2024.py', verbose=False) from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG -from ohmpi.hardware_components import raspberry_pi_i2c as ctl_module +from ohmpi.hardware_components import raspberry_pi as ctl_module from ohmpi.config import HARDWARE_CONFIG stand_alone_mux = False diff --git a/dev/test_4_mux_2024.py b/dev/test_4_mux_2024.py index 39489871..98f93e89 100644 --- a/dev/test_4_mux_2024.py +++ b/dev/test_4_mux_2024.py @@ -4,7 +4,7 @@ from ohmpi.plots import plot_exec_log import logging change_config('../configs/config_mb_2023_4_mux_2024.py', verbose=False) from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG -from ohmpi.hardware_components import raspberry_pi_i2c as ctl_module +from ohmpi.hardware_components import raspberry_pi as ctl_module from ohmpi.config import HARDWARE_CONFIG stand_alone_mux = False diff --git a/dev/test_mux_2024.py b/dev/test_mux_2024.py index 0d57749c..93fb74ea 100644 --- a/dev/test_mux_2024.py +++ b/dev/test_mux_2024.py @@ -3,7 +3,7 @@ from ohmpi.utils import change_config import logging change_config('../configs/config_mb_2023_mux_2024.py', verbose=False) from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG -from ohmpi.hardware_components import raspberry_pi_i2c as ctl_module +from ohmpi.hardware_components import raspberry_pi as ctl_module # from ohmpi.config import HARDWARE_CONFIG stand_alone_mux = False # Testing hardware component alone diff --git a/dev/test_mux_2024_2_roles_AB.py b/dev/test_mux_2024_2_roles_AB.py index b4548b64..d946fe5c 100644 --- a/dev/test_mux_2024_2_roles_AB.py +++ b/dev/test_mux_2024_2_roles_AB.py @@ -3,7 +3,7 @@ from ohmpi.utils import change_config import logging change_config('../configs/config_mb_2023_mux_2024_2_roles_AB.py', verbose=False) from ohmpi.hardware_components.mux_2024_rev_0_0 import Mux, MUX_CONFIG -from ohmpi.hardware_components import raspberry_pi_i2c as ctl_module +from ohmpi.hardware_components import raspberry_pi as ctl_module # from ohmpi.config import HARDWARE_CONFIG stand_alone_mux = True # Testing hardware component alone diff --git a/ohmpi/hardware_components/raspberry_pi_i2c.py b/ohmpi/hardware_components/raspberry_pi_i2c.py deleted file mode 100644 index f2e8632a..00000000 --- a/ohmpi/hardware_components/raspberry_pi_i2c.py +++ /dev/null @@ -1,22 +0,0 @@ -from ohmpi.hardware_components import CtlAbstract -import board # noqa -import busio # noqa -import os -from ohmpi.utils import get_platform -from gpiozero import CPUTemperature # noqa - - -class Ctl(CtlAbstract): - def __init__(self, **kwargs): - kwargs.update({'board_name': os.path.basename(__file__).rstrip('.py')}) - super().__init__(**kwargs) - self.bus = busio.I2C(board.SCL, board.SDA) # noqa - platform, on_pi = get_platform() - assert on_pi - self.board_name = platform - self._cpu_temp_available = True - self.max_cpu_temp = 85. # °C - - @property - def _cpu_temp(self): - return CPUTemperature().temperature \ No newline at end of file diff --git a/ohmpi/hardware_components/raspberry_pi_modbus.py b/ohmpi/hardware_components/raspberry_pi_modbus.py deleted file mode 100644 index b6e4fb0e..00000000 --- a/ohmpi/hardware_components/raspberry_pi_modbus.py +++ /dev/null @@ -1,38 +0,0 @@ -from ohmpi.hardware_components import CtlAbstract -from ohmpi.config import HARDWARE_CONFIG -import board # noqa -import busio # noqa -import os -from ohmpi.utils import get_platform -from gpiozero import CPUTemperature # noqa -import minimalmodbus # noqa - - -class Ctl(CtlAbstract): - def __init__(self, **kwargs): - kwargs.update({'board_name': os.path.basename(__file__).rstrip('.py')}) - baudrate = kwargs.pop('baudrate', 9600) - bitesize = kwargs.pop('bitesize', 8) - timeout = kwargs.pop('timeout', 1) - debug = kwargs.pop('debug', False) - parity = kwargs.pop('parity', 'N') - mode = kwargs.pop('mode', minimalmodbus.MODE_RTU) - port = kwargs.pop('port', '/dev/ttyUSB0') - slave_address = kwargs.pop('slave_address', 1) - super().__init__(**kwargs) - self.bus = minimalmodbus.Instrument(port=port, slaveaddress=slave_address) # port name, address (decimal) - self.bus.serial.baudrate = baudrate # Baud rate 9600 as listed in doc - self.bus.serial.bytesize = bitesize # - self.bus.serial.timeout = timeout # greater than 0.5 for it to work - self.bus.debug = debug # - self.bus.serial.parity = parity # No parity - self.bus.mode = mode # RTU mode - platform, on_pi = get_platform() - assert on_pi - self.board_name = platform - self._cpu_temp_available = True - self.max_cpu_temp = 85. # °C - - @property - def _cpu_temp(self): - return CPUTemperature().temperature -- GitLab