frappy_psi: fix write_on in tcs
This commit is contained in:
@@ -15,11 +15,12 @@
|
|||||||
#
|
#
|
||||||
# Module authors:
|
# Module authors:
|
||||||
# Markus Zolliker <markus.zolliker@psi.ch>
|
# Markus Zolliker <markus.zolliker@psi.ch>
|
||||||
|
# Anik Stark <anik.stark@psi.ch>
|
||||||
# *****************************************************************************
|
# *****************************************************************************
|
||||||
|
|
||||||
from frappy.core import StringIO, HasIO, Writable, Parameter, Property, FloatRange, IntRange, BoolType, \
|
from frappy.core import StringIO, HasIO, Writable, Parameter, Property, FloatRange, IntRange, BoolType, \
|
||||||
ERROR
|
ERROR
|
||||||
from frappy.errors import CommunicationFailedError
|
from frappy.errors import CommunicationFailedError, HardwareError
|
||||||
|
|
||||||
|
|
||||||
class IO(StringIO):
|
class IO(StringIO):
|
||||||
@@ -46,16 +47,17 @@ class Heater(HasIO, Writable):
|
|||||||
def write_on(self, value):
|
def write_on(self, value):
|
||||||
for _ in range(2):
|
for _ in range(2):
|
||||||
txtvalue = self.query_status()
|
txtvalue = self.query_status()
|
||||||
on_idx = (self.channel - 1) * 4 + 2 + 1
|
on_idx = (self.channel - 1) * 4 + 2
|
||||||
if txtvalue[on_idx] == str(int(value)):
|
if txtvalue[on_idx + 1] == str(int(value)):
|
||||||
break
|
break
|
||||||
txtvalue[on_idx] = str(int(value))
|
setup = ['0'] * 12
|
||||||
answer = ','.join(txtvalue)
|
setup[on_idx] = '1' # toggle
|
||||||
|
answer = ','.join(setup)
|
||||||
reply = self.communicate(f'SETUP {answer}')
|
reply = self.communicate(f'SETUP {answer}')
|
||||||
if reply != '0/t':
|
if reply != '0':
|
||||||
raise CommunicationFailedError(f'Bad reply: {reply}')
|
raise CommunicationFailedError(f'Bad reply: {reply}')
|
||||||
else:
|
else:
|
||||||
return ERROR, 'unable to turn device on/off'
|
raise HardwareError('unable to turn device on/off')
|
||||||
|
|
||||||
def write_target(self, target):
|
def write_target(self, target):
|
||||||
reply = self.communicate(f'SETDAC {self.channel} 0 {int(target * 1e6)}') # 0: autorange
|
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}
|
multipliers = {'1': 99e-6, '2': 990e-6, '3': 9900e-6, '4': 99e-3}
|
||||||
value = float(current) / 100 * float(multipliers[current_range])
|
value = float(current) / 100 * float(multipliers[current_range])
|
||||||
return value
|
return value
|
||||||
|
|
||||||
# no measured value available
|
# no measured value available
|
||||||
read_value = read_target
|
read_value = read_target
|
||||||
|
|||||||
Reference in New Issue
Block a user