frappy_psi: fix write_on in tcs

This commit is contained in:
Anik Stark
2025-10-21 16:24:16 +02:00
parent cb142c580d
commit fed7ce2197

View File

@@ -15,11 +15,12 @@
#
# Module authors:
# Markus Zolliker <markus.zolliker@psi.ch>
# Anik Stark <anik.stark@psi.ch>
# *****************************************************************************
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)):
on_idx = (self.channel - 1) * 4 + 2
if txtvalue[on_idx + 1] == str(int(value)):
break
txtvalue[on_idx] = str(int(value))
answer = ','.join(txtvalue)
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