From e0d8c1eeb73add7e3d08860dff9c7a150eed8af0 Mon Sep 17 00:00:00 2001
From: su530201 <olivier.kaufmann@umons.ac.be>
Date: Wed, 11 Oct 2023 21:58:58 +0200
Subject: [PATCH] Fixes a bug in _adc_gain_auto in mb_2024

---
 ohmpi/hardware_components/mb_2023_0_X.py | 2 +-
 ohmpi/hardware_components/mb_2024_0_2.py | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/ohmpi/hardware_components/mb_2023_0_X.py b/ohmpi/hardware_components/mb_2023_0_X.py
index bd98758b..5216c77a 100644
--- a/ohmpi/hardware_components/mb_2023_0_X.py
+++ b/ohmpi/hardware_components/mb_2023_0_X.py
@@ -258,7 +258,7 @@ class Rx(RxAbstract):
         self.exec_logger.event(f'{self.model}\trx_adc_auto_gain\tbegin\t{datetime.datetime.utcnow()}')
         gain = _ads_1115_gain_auto(AnalogIn(self._ads_voltage, ads.P0, ads.P1))
         self.exec_logger.debug(f'Setting RX ADC gain automatically to {gain}')
-        self.gain = gain
+        self._adc_gain = gain
         self.exec_logger.event(f'{self.model}\trx_adc_auto_gain\tend\t{datetime.datetime.utcnow()}')
 
     def gain_auto(self):
diff --git a/ohmpi/hardware_components/mb_2024_0_2.py b/ohmpi/hardware_components/mb_2024_0_2.py
index 801b143e..940f9c84 100644
--- a/ohmpi/hardware_components/mb_2024_0_2.py
+++ b/ohmpi/hardware_components/mb_2024_0_2.py
@@ -153,7 +153,7 @@ class Rx(Rx_mb_2023):
         self.exec_logger.event(f'{self.model}\trx_adc_auto_gain\tbegin\t{datetime.datetime.utcnow()}')
         gain = _ads_1115_gain_auto(AnalogIn(self._ads_voltage, ads.P0))
         self.exec_logger.debug(f'Setting RX ADC gain automatically to {gain}')
-        self.gain = gain
+        self._adc_gain = gain
         self.exec_logger.event(f'{self.model}\trx_adc_auto_gain\tend\t{datetime.datetime.utcnow()}')
 
     def _dg411_gain_auto(self):
@@ -161,6 +161,7 @@ class Rx(Rx_mb_2023):
             self._dg411_gain = 1.
         else:
             self._dg411_gain = 1/2
+        self.exec_logger.debug(f'Setting RX DG411 gain automatically to {self._dg411_gain}')
 
     @property
     def gain(self):
@@ -179,6 +180,7 @@ class Rx(Rx_mb_2023):
 
     def gain_auto(self):
         self._dg411_gain_auto()
+        self.exec_logger.debug(f'Setting RX gain automatically to {self.gain}')
 
     @property
     def voltage(self):
-- 
GitLab