From 32511244a326d016cab447c943a87e24d1f128d3 Mon Sep 17 00:00:00 2001 From: Lane Meier Date: Wed, 11 Dec 2024 16:39:37 -0500 Subject: [PATCH 1/2] makes thorlabs_tsp01 temperature sensor heads optional per configuration --- .../services/thorlabs_tsp01/thorlabs_tsp01.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/catkit2/services/thorlabs_tsp01/thorlabs_tsp01.py b/catkit2/services/thorlabs_tsp01/thorlabs_tsp01.py index 31b91567f..7d710419e 100644 --- a/catkit2/services/thorlabs_tsp01/thorlabs_tsp01.py +++ b/catkit2/services/thorlabs_tsp01/thorlabs_tsp01.py @@ -16,10 +16,12 @@ def __init__(self): self.serial_number = self.config['serial_number'] self.num_averaging = self.config.get('averaging', 1) self.interval = self.config.get('interval', 10) + self.read_out_header_1 = self.config.get('read_out_header_1', True) + self.read_out_header_2 = self.config.get('read_out_header_2', True) self.temperature_internal = self.make_data_stream('temperature_internal', 'float64', [1], 20) - self.temperature_header_1 = self.make_data_stream('temperature_header_1', 'float64', [1], 20) - self.temperature_header_2 = self.make_data_stream('temperature_header_2', 'float64', [1], 20) + self.temperature_header_1 = self.make_data_stream('temperature_header_1', 'float64', [1], 20) if self.read_out_header_1 else None + self.temperature_header_2 = self.make_data_stream('temperature_header_2', 'float64', [1], 20) if self.read_out_header_2 else None self.humidity_internal = self.make_data_stream('humidity_internal', 'float64', [1], 20) def main(self): @@ -28,11 +30,13 @@ def main(self): temperature = self.get_temperature(1) self.temperature_internal.submit_data(np.array([temperature])) - temperature = self.get_temperature(2) - self.temperature_header_1.submit_data(np.array([temperature])) + if self.read_out_header_1: + temperature = self.get_temperature(2) + self.temperature_header_1.submit_data(np.array([temperature])) - temperature = self.get_temperature(3) - self.temperature_header_2.submit_data(np.array([temperature])) + if self.read_out_header_2: + temperature = self.get_temperature(3) + self.temperature_header_2.submit_data(np.array([temperature])) humidity = self.get_humidity() self.humidity_internal.submit_data(np.array([humidity])) From 928c2929a38ea49339b3dbe484df36f7fa767fe4 Mon Sep 17 00:00:00 2001 From: Lane Meier Date: Wed, 11 Dec 2024 19:28:20 -0500 Subject: [PATCH 2/2] removed thorlabs_tsp01 ternary operators --- catkit2/services/thorlabs_tsp01/thorlabs_tsp01.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/catkit2/services/thorlabs_tsp01/thorlabs_tsp01.py b/catkit2/services/thorlabs_tsp01/thorlabs_tsp01.py index 7d710419e..2680d1822 100644 --- a/catkit2/services/thorlabs_tsp01/thorlabs_tsp01.py +++ b/catkit2/services/thorlabs_tsp01/thorlabs_tsp01.py @@ -20,8 +20,13 @@ def __init__(self): self.read_out_header_2 = self.config.get('read_out_header_2', True) self.temperature_internal = self.make_data_stream('temperature_internal', 'float64', [1], 20) - self.temperature_header_1 = self.make_data_stream('temperature_header_1', 'float64', [1], 20) if self.read_out_header_1 else None - self.temperature_header_2 = self.make_data_stream('temperature_header_2', 'float64', [1], 20) if self.read_out_header_2 else None + + if self.read_out_header_1: + self.temperature_header_1 = self.make_data_stream('temperature_header_1', 'float64', [1], 20) + + if self.read_out_header_2: + self.temperature_header_2 = self.make_data_stream('temperature_header_2', 'float64', [1], 20) + self.humidity_internal = self.make_data_stream('humidity_internal', 'float64', [1], 20) def main(self):