frappy_psi.haake: make it possible to use the extra sensor only
This commit is contained in:
1 parent
41b4156401
commit
23fc0ff629
1 file changed
+60
-37
+60
-37
@@ -20,7 +20,7 @@
|
||||
import re
|
||||
import time
|
||||
from frappy.core import StringIO, HasIO, Parameter, FloatRange, BoolType, \
|
||||
EnumType, ERROR, IDLE, WARN, BUSY, Drivable, Command
|
||||
EnumType, ERROR, IDLE, WARN, BUSY, Drivable, Command, Readable
|
||||
from frappy_psi.convergence import HasConvergence
|
||||
from frappy.errors import CommunicationFailedError
|
||||
|
||||
@@ -40,13 +40,10 @@ class HaakeIO(StringIO):
|
||||
identification = [('V', r'')] # version of the software
|
||||
|
||||
|
||||
class TemperatureLoop(HasIO, HasConvergence, Drivable):
|
||||
class Temperature(HasIO, Readable):
|
||||
"""temperature sensor: only external (F2)"""
|
||||
ioClass = HaakeIO
|
||||
value = Parameter('temperature', unit='degC')
|
||||
target = Parameter('target', datatype=FloatRange(-50, 200), unit='degC', readonly=False)
|
||||
setpoint = Parameter('setpoint', datatype=FloatRange, unit='degC')
|
||||
control_active = Parameter('control on/off', BoolType, readonly=False, default=False)
|
||||
mode = Parameter('internal/external control', EnumType(int=1, ext=2), readonly=False, default=1)
|
||||
|
||||
status_messages = [
|
||||
(ERROR, 'Alarm overtemperature', 3, 1),
|
||||
@@ -73,6 +70,40 @@ class TemperatureLoop(HasIO, HasConvergence, Drivable):
|
||||
string = reply.rstrip('$')
|
||||
return [int(val) for val in string]
|
||||
|
||||
def read_value(self):
|
||||
"""
|
||||
F2 - external temperature
|
||||
:return: float temperature value
|
||||
"""
|
||||
return convert(self.communicate('F2'))
|
||||
|
||||
def read_status(self): # control_active update
|
||||
"""
|
||||
Operating status.
|
||||
:return: statu type and message
|
||||
"""
|
||||
values_str = self.get_values_status()
|
||||
for status_type, status_msg, position, value in self.status_messages:
|
||||
if values_str[position] == value: # error first
|
||||
return status_type, status_msg # error - needs to reset
|
||||
return IDLE, ''
|
||||
|
||||
@Command
|
||||
def clear_errors(self):
|
||||
""" Reset after error. Otherwise the status will not be updated"""
|
||||
if self.read_status()[0] == ERROR:
|
||||
try:
|
||||
self.communicate('ER')
|
||||
except CommunicationFailedError:
|
||||
time.sleep(2) # wait for reset to be complete
|
||||
|
||||
|
||||
class TemperatureLoop(HasConvergence, Temperature, Drivable):
|
||||
target = Parameter('target', datatype=FloatRange(-50, 200), unit='degC', readonly=False)
|
||||
mode = Parameter(default=1, export='mode')
|
||||
setpoint = Parameter('setpoint', datatype=FloatRange, unit='degC')
|
||||
control_active = Parameter('control on/off', BoolType, readonly=False, default=False)
|
||||
|
||||
def read_status(self): # control_active update
|
||||
"""
|
||||
Operating status.
|
||||
@@ -100,6 +131,29 @@ class TemperatureLoop(HasIO, HasConvergence, Drivable):
|
||||
value = self.communicate('F2')
|
||||
return convert(value)
|
||||
|
||||
def write_target(self, target):
|
||||
"""
|
||||
Selecting Celsius, setting the target
|
||||
:param target: target
|
||||
:return: target
|
||||
"""
|
||||
self.write_control_active(True)
|
||||
self.read_status()
|
||||
self.communicate('W TE C')
|
||||
self.communicate(f'W SW {target}')
|
||||
return target
|
||||
|
||||
def write_mode(self, mode):
|
||||
"""
|
||||
Switching to internal or external control
|
||||
:param mode: internal/external
|
||||
:return: selected mode
|
||||
"""
|
||||
if mode == 1:
|
||||
self.communicate('W IN')
|
||||
self.communicate('W EX')
|
||||
return mode
|
||||
|
||||
def write_control_active(self, value):
|
||||
"""
|
||||
Turning on/off the heating, pump and regulation
|
||||
@@ -125,35 +179,4 @@ class TemperatureLoop(HasIO, HasConvergence, Drivable):
|
||||
string = self.communicate('S')
|
||||
return convert(string)
|
||||
|
||||
def write_target(self, target):
|
||||
"""
|
||||
Selecting Celsius, setting the target
|
||||
:param target: target
|
||||
:return: target
|
||||
"""
|
||||
self.write_control_active(True)
|
||||
self.read_status()
|
||||
self.communicate('W TE C')
|
||||
self.communicate(f'W SW {target}')
|
||||
return target
|
||||
|
||||
def write_mode(self, mode):
|
||||
"""
|
||||
Switching to internal or external control
|
||||
:param mode: internal/external
|
||||
:return: selected mode
|
||||
"""
|
||||
if mode == 1:
|
||||
self.communicate('W IN')
|
||||
self.communicate('W EX')
|
||||
return mode
|
||||
|
||||
@Command
|
||||
def clear_errors(self):
|
||||
""" Reset after error. Otherwise the status will not be updated"""
|
||||
if self.read_status()[0] == ERROR:
|
||||
try:
|
||||
self.communicate('ER')
|
||||
except CommunicationFailedError:
|
||||
time.sleep(2) # wait for reset to be complete
|
||||
|
||||
Reference in new issue
Block a user