From 8255b9c40736a1cc3ee1ba79cbddd99e4623e401 Mon Sep 17 00:00:00 2001 From: CPD Date: Mon, 10 Mar 2025 11:07:04 +0100 Subject: [PATCH] Add __str__ member --- cpdctrl/led_control_device/base.py | 4 ++++ cpdctrl/led_control_device/impl/test.py | 3 +++ cpdctrl/led_control_device/impl/thorlabs_dc2200.py | 5 ++++- cpdctrl/led_control_device/impl/thorlabs_ledd1b.py | 3 +++ cpdctrl/voltage_measurement_device/base.py | 3 +++ cpdctrl/voltage_measurement_device/impl/keithley2700.py | 2 ++ cpdctrl/voltage_measurement_device/impl/test.py | 3 +++ 7 files changed, 22 insertions(+), 1 deletion(-) diff --git a/cpdctrl/led_control_device/base.py b/cpdctrl/led_control_device/base.py index 35a3e5d..85043ef 100644 --- a/cpdctrl/led_control_device/base.py +++ b/cpdctrl/led_control_device/base.py @@ -42,4 +42,8 @@ class LedControlDevice(ABC): ------- None. """ + pass + + @abstractmethod + def __str__(self): pass \ No newline at end of file diff --git a/cpdctrl/led_control_device/impl/test.py b/cpdctrl/led_control_device/impl/test.py index 2583431..8be6770 100644 --- a/cpdctrl/led_control_device/impl/test.py +++ b/cpdctrl/led_control_device/impl/test.py @@ -12,3 +12,6 @@ class TestLedControlDevice(LedControlDevice): def set_level(self, level: int): pass + + def __str__(self): + return "Dummy Led Controller" \ No newline at end of file diff --git a/cpdctrl/led_control_device/impl/thorlabs_dc2200.py b/cpdctrl/led_control_device/impl/thorlabs_dc2200.py index 7b78678..27c943f 100644 --- a/cpdctrl/led_control_device/impl/thorlabs_dc2200.py +++ b/cpdctrl/led_control_device/impl/thorlabs_dc2200.py @@ -44,4 +44,7 @@ class DC2200(LedControlDevice): def connect_device(name): rm = pyvisa.ResourceManager() instr = rm.open_resource(name) - return DC2200(instr) \ No newline at end of file + return DC2200(instr) + + def __str__(self): + return "Thorlabs DC2200" diff --git a/cpdctrl/led_control_device/impl/thorlabs_ledd1b.py b/cpdctrl/led_control_device/impl/thorlabs_ledd1b.py index aec358b..5780de7 100644 --- a/cpdctrl/led_control_device/impl/thorlabs_ledd1b.py +++ b/cpdctrl/led_control_device/impl/thorlabs_ledd1b.py @@ -45,6 +45,9 @@ class LEDD1B(LedControlDevice): else: raise ValueError(f"LEDD1B Led controller can only set 0% or 100%") + def __str__(self): + return "Thorlabs LEDD1B" + if __name__ == '__main__': led = LEDD1B() \ No newline at end of file diff --git a/cpdctrl/voltage_measurement_device/base.py b/cpdctrl/voltage_measurement_device/base.py index e90809e..d2a8cd8 100644 --- a/cpdctrl/voltage_measurement_device/base.py +++ b/cpdctrl/voltage_measurement_device/base.py @@ -50,4 +50,7 @@ class VoltageMeasurementDevice(ABC): None. """ + pass + @abstractmethod + def __str__(self): pass \ No newline at end of file diff --git a/cpdctrl/voltage_measurement_device/impl/keithley2700.py b/cpdctrl/voltage_measurement_device/impl/keithley2700.py index 51ddbe7..ec1a6c2 100644 --- a/cpdctrl/voltage_measurement_device/impl/keithley2700.py +++ b/cpdctrl/voltage_measurement_device/impl/keithley2700.py @@ -256,3 +256,5 @@ class Keithley2700(VoltageMeasurementDevice): instr = rm.open_resource(name) return Keithley2700(instr) + def __str__(self): + return "Keithley 2700" diff --git a/cpdctrl/voltage_measurement_device/impl/test.py b/cpdctrl/voltage_measurement_device/impl/test.py index a7013d7..6ce01fd 100644 --- a/cpdctrl/voltage_measurement_device/impl/test.py +++ b/cpdctrl/voltage_measurement_device/impl/test.py @@ -52,3 +52,6 @@ class TestVoltageMeasurementDevice(VoltageMeasurementDevice): """ pass + + def __str__(self): + return "Simulated Voltage Measurement Device"