From 7eb0d38f1657174e48a7dbfcccde6004d2a4a887 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Thu, 1 Jun 2023 12:15:48 +0200
Subject: [PATCH] Adds option in ohmpi_card_3_15 to create a ctl if ctl config
 is passed as a dict

---
 ohmpi/hardware_components/abstract_hardware_components.py | 2 +-
 ohmpi/hardware_components/ohmpi_card_3_15.py              | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ohmpi/hardware_components/abstract_hardware_components.py b/ohmpi/hardware_components/abstract_hardware_components.py
index 603e2f0c..c670948c 100644
--- a/ohmpi/hardware_components/abstract_hardware_components.py
+++ b/ohmpi/hardware_components/abstract_hardware_components.py
@@ -9,7 +9,7 @@ from threading import Barrier
 class CtlAbstract(ABC):
     def __init__(self, **kwargs):
         self.board_name = kwargs.pop('board_name', 'unknown CTL hardware')
-        self.bus = None # TODO: allow for several buses
+        self.bus = None  # TODO: allow for several buses
         self.exec_logger = kwargs.pop('exec_logger', None)
         if self.exec_logger is None:
             self.exec_logger = create_stdout_logger('exec_ctl')
diff --git a/ohmpi/hardware_components/ohmpi_card_3_15.py b/ohmpi/hardware_components/ohmpi_card_3_15.py
index 63630605..a09cf278 100644
--- a/ohmpi/hardware_components/ohmpi_card_3_15.py
+++ b/ohmpi/hardware_components/ohmpi_card_3_15.py
@@ -82,6 +82,8 @@ class Tx(TxAbstract):
         self.current_adjustable = False
         if self.ctl is None:
             self.ctl = ctl_module.Ctl()
+        elif self.ctl is isinstance(dict):
+            self.ctl = ctl_module.Ctl(dict)
 
         # I2C connexion to MCP23008, for current injection
         self.mcp_board = MCP23008(self.ctl.bus, address=TX_CONFIG['mcp_board_address'])
@@ -204,6 +206,8 @@ class Rx(RxAbstract):
         super().__init__(**kwargs)
         if self.ctl is None:
             self.ctl = ctl_module.Ctl()
+        elif self.ctl is isinstance(dict):
+            self.ctl = ctl_module.Ctl(dict)
 
         # ADS1115 for voltage measurement (MN)
         self._ads_voltage_address = 0x49
-- 
GitLab