From fed7ce21975775e8fbc136c9d8290d32c3123a62 Mon Sep 17 00:00:00 2001 From: Anik Stark Date: Tue, 21 Oct 2025 16:24:16 +0200 Subject: [PATCH] frappy_psi: fix write_on in tcs --- frappy_psi/tcs.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/frappy_psi/tcs.py b/frappy_psi/tcs.py index cda28bb5..4180146b 100644 --- a/frappy_psi/tcs.py +++ b/frappy_psi/tcs.py @@ -15,11 +15,12 @@ # # Module authors: # Markus Zolliker +# Anik Stark # ***************************************************************************** from frappy.core import StringIO, HasIO, Writable, Parameter, Property, FloatRange, IntRange, BoolType, \ ERROR -from frappy.errors import CommunicationFailedError +from frappy.errors import CommunicationFailedError, HardwareError class IO(StringIO): @@ -46,16 +47,17 @@ class Heater(HasIO, Writable): def write_on(self, value): for _ in range(2): txtvalue = self.query_status() - on_idx = (self.channel - 1) * 4 + 2 + 1 - if txtvalue[on_idx] == str(int(value)): - break - txtvalue[on_idx] = str(int(value)) - answer = ','.join(txtvalue) + on_idx = (self.channel - 1) * 4 + 2 + if txtvalue[on_idx + 1] == str(int(value)): + break + setup = ['0'] * 12 + setup[on_idx] = '1' # toggle + answer = ','.join(setup) reply = self.communicate(f'SETUP {answer}') - if reply != '0/t': + if reply != '0': raise CommunicationFailedError(f'Bad reply: {reply}') else: - return ERROR, 'unable to turn device on/off' + raise HardwareError('unable to turn device on/off') def write_target(self, target): reply = self.communicate(f'SETDAC {self.channel} 0 {int(target * 1e6)}') # 0: autorange @@ -69,6 +71,6 @@ class Heater(HasIO, Writable): multipliers = {'1': 99e-6, '2': 990e-6, '3': 9900e-6, '4': 99e-3} value = float(current) / 100 * float(multipliers[current_range]) return value - + # no measured value available read_value = read_target