From 189806e84ea0e278c0008acc2649ac4dd0aa213d Mon Sep 17 00:00:00 2001
From: awatlet <arnaud.watlet@umons.ac.be>
Date: Tue, 26 Sep 2023 15:45:41 +0200
Subject: [PATCH] Updates mux handling in hardware system

---
 ohmpi/hardware_system.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ohmpi/hardware_system.py b/ohmpi/hardware_system.py
index b8114cdf..cdbacbfd 100644
--- a/ohmpi/hardware_system.py
+++ b/ohmpi/hardware_system.py
@@ -103,13 +103,13 @@ class OhmPiHardware:
             mux_config.update({'exec_logger': self.exec_logger, 'data_logger': self.data_logger,
                                'soh_logger': self.soh_logger})
             mux_config.update(**HARDWARE_CONFIG['mux']['boards'][mux_id])
-            mux_config.update({'ctl': self.ctl})
+            ctl = mux_config.pop({'ctl': self.ctl})
             mux_module = importlib.import_module(f'ohmpi.hardware_components.{mux_config["model"]}')
-            # if isinstance(ctl, dict): ### TODO: is this needed?
-            #     mux_ctl_module = importlib.import_module(f'ohmpi.hardware_components.{mux_config["ctl"]["model"]}')
-            #     ctl = mux_ctl_module.Ctl(**self.ctl)
+            if isinstance(ctl, dict): ### TODO: is this needed?
+                mux_ctl_module = importlib.import_module(f'ohmpi.hardware_components.{mux_config["ctl"]["model"]}')
+                ctl = mux_ctl_module.Ctl(**self.ctl)
             assert issubclass(type(mux_config['ctl']), CtlAbstract)
-            io = mux_config.pop('io', self.ctl.connections[mux_config.pop('connection', 'i2c')])
+            io = mux_config.pop('io', ctl.connections[mux_config.pop('connection', 'i2c')])
             mux_config.update({'io': io})
             mux_config['id'] = mux_id
 
-- 
GitLab