newest version of okasanas drivers

This commit is contained in:
l_samenv
2023-05-17 16:56:49 +02:00
parent 1407514458
commit db94def694
3 changed files with 313 additions and 33 deletions

View File

@ -18,6 +18,60 @@
# Module authors:
# Oksana Shliakhtun <oksana.shliakhtun@psi.ch>
# *****************************************************************************
""" RUFS Command: Description of Bits
====== ======================================================== ==============================================
Value Description
====== ======================================================== ==============================================
V1
B6: warning, rtd1 (internal temp. sensor) is shorted
B0 --> 1
B7: warning, rtd1 is open
B1 --> 2
V2
B0: error, HTC (high temperature cutout) fault B2 --> 4
B1: error, high RA (refrigeration) temperature fault B3 --> 8
V3 B4 --> 16
B0: warning, low level in the bath
B5 --> 32
B1: warning, low temperature
B6 --> 64
B2: warning, high temperature
B7 --> 128
B3: error, low level in the bath
B4: error, low temperature fault
B5: error, high temperature fault
B6: error, low temperature fixed* fault
B7: error, high temperature fixed** fault
V4
B3: idle, circulator** is running
B5: error, circulator** fault
V5
B0: error, pump speed fault
B1: error, motor overloaded
B2: error, high pressure cutout
B3: idle, maximum cooling
B4: idle, cooling
B5: idle, maximum heating
B6: idle, heating
====== ======================================================== ==============================================
"""
from frappy.core import StringIO, Parameter, Readable, HasIO, \
Drivable, FloatRange, IDLE, ERROR, WARN, BoolType
@ -34,57 +88,64 @@ class SensorA10(HasIO, Readable):
value = Parameter('internal temperature', unit='degC')
def get_par(self, cmd):
"""
All the reading commands starts with 'R', in the source code all the commands are written without 'R' (except
'RUFS').The result of a reading command is a value in the format '20C', without spaces.
:param cmd: any hardware command
:return: 'R'+cmd
"""
new_cmd = 'R' + cmd
reply = self.communicate(new_cmd)
if any(unit.isalpha() for unit in reply):
reply = ''.join(unit for unit in reply if not unit.isalpha())
return float(reply)
# def set_par(self, cmd, arg):
# new_cmd = 'S' + cmd.format(arg=arg)
# return self.communicate(new_cmd)
# # return self.get_par(cmd)
def read_value(self):
"""
Reading internal temperature sensor value.
"""
return self.get_par('T')
def read_status(self):
result_str = self.communicate('RUFS')
result_str = self.communicate('RUFS') # read unit fault status
values_str = result_str.strip().split()
values_int = [int(val) for val in values_str]
v1, v2, v3, v4, v5 = values_int[:5]
v1, v2, v3, v4, v5 = values_int #[:5]
status_messages = [
(ERROR, 'high tempr. cutout fault', v2, 0),
(ERROR, 'high RA tempr. fault', v2, 1),
(ERROR, 'high temperature fixed fault', v3, 7),
(ERROR, 'low temperature fixed fault', v3, 6),
(ERROR, 'high temperature fault', v3, 5),
(ERROR, 'low temperature fault', v3, 4),
(ERROR, 'low level fault', v3, 3),
(ERROR, 'circulator fault', v4, 5),
(ERROR, 'high press. cutout', v5, 2),
(ERROR, 'motor overloaded', v5, 1),
(ERROR, 'pump speed fault', v5, 0),
(WARN, 'open internal sensor', v1, 7),
(WARN, 'shorted internal sensor', v1, 6),
(WARN, 'high temperature warn', v3, 2),
(WARN, 'low temperature warn', v3, 1),
(WARN, 'low level warn', v3, 0),
(IDLE, 'max. heating', v5, 5),
(IDLE, 'heating', v5, 6),
(IDLE, 'cooling', v5, 4),
(IDLE, 'max cooling', v5, 3),
(IDLE, '', v4, 3),
(ERROR, 'high tempr. cutout fault', 2, 0),
(ERROR, 'high RA tempr. fault', 2, 1),
(ERROR, 'high temperature fixed fault', 3, 7),
(ERROR, 'low temperature fixed fault', 3, 6),
(ERROR, 'high temperature fault', 3, 5),
(ERROR, 'low temperature fault', 3, 4),
(ERROR, 'low level fault', 3, 3),
(ERROR, 'circulator fault', 4, 5),
(ERROR, 'high press. cutout', 5, 2),
(ERROR, 'motor overloaded', 5, 1),
(ERROR, 'pump speed fault', 5, 0),
(WARN, 'open internal sensor', 1, 7),
(WARN, 'shorted internal sensor', 1, 6),
(WARN, 'high temperature warn', 3, 2),
(WARN, 'low temperature warn', 3, 1),
(WARN, 'low level warn', 3, 0),
(IDLE, 'max. heating', 5, 5),
(IDLE, 'heating', 5, 6),
(IDLE, 'cooling', 5, 4),
(IDLE, 'max cooling', 5, 3),
(IDLE, '', 4, 3),
]
for status_type, status_msg, vi,bit in status_messages:
if vi & (1 << bit):
for status_type, status_msg, vi, bit in status_messages:
if values_int[vi-1] & (1 << bit):
print(status_type, status_msg, vi, bit)
return status_type, status_msg
return WARN, 'circulation off'
return WARN, 'circulation off'
class TemperatureLoopA10(HasConvergence, SensorA10, Drivable):
class TemperatureLoopA10(SensorA10, Drivable):
value = Parameter('temperature', unit='degC')
target = Parameter('setpoint/target', datatype=FloatRange, unit='degC', default=0)
circ_on = Parameter('is circulation running', BoolType(), readonly=False, default=False)
@ -108,9 +169,12 @@ class TemperatureLoopA10(HasConvergence, SensorA10, Drivable):
return self.get_par('S')
def write_target(self, target):
"""
:param target: here, it serves as an equivalent to a setpoint.
"""
self.write_circ_on('1')
self.communicate(f'SS {target}')
self.start_state()
# self.start_state()
return target
## heat PID