[WIP] fi furnace improvements
- still under development Change-Id: I5fc22f041fb136b549016f510f06ea703122bee5
This commit is contained in:
@@ -19,9 +19,9 @@
|
||||
|
||||
"""interlocks for furnace"""
|
||||
|
||||
import time
|
||||
from frappy.core import Module, Writable, Attached, Parameter, FloatRange, Readable,\
|
||||
BoolType, ERROR, IDLE
|
||||
from frappy.errors import ImpossibleError
|
||||
from frappy.mixins import HasControlledBy
|
||||
from frappy_psi.picontrol import PImixin
|
||||
from frappy_psi.convergence import HasConvergence
|
||||
@@ -30,15 +30,19 @@ import frappy_psi.tdkpower as tdkpower
|
||||
import frappy_psi.bkpower as bkpower
|
||||
|
||||
|
||||
class Interlocks(Module):
|
||||
input = Attached(Readable, 'the input module')
|
||||
vacuum = Attached(Readable, 'the vacuum pressure')
|
||||
wall_T = Attached(Readable, 'the wall temperature')
|
||||
htr_T = Attached(Readable, 'the heater temperature')
|
||||
class Interlocks(Writable):
|
||||
value = Parameter('interlock o.k.', BoolType(), default=True)
|
||||
target = Parameter('set to true to confirm', BoolType(), readonly=False)
|
||||
input = Attached(Readable, 'the input module', mandatory=False) # TODO: remove
|
||||
vacuum = Attached(Readable, 'the vacuum pressure', mandatory=False)
|
||||
wall_T = Attached(Readable, 'the wall temperature', mandatory=False)
|
||||
htr_T = Attached(Readable, 'the heater temperature', mandatory=False)
|
||||
main_T = Attached(Readable, 'the main temperature')
|
||||
extra_T = Attached(Readable, 'the extra temperature')
|
||||
control = Attached(Module, 'the control module')
|
||||
relais = Attached(Writable, 'the interlock relais')
|
||||
htr = Attached(Module, 'the heater module', mandatory=False)
|
||||
relais = Attached(Writable, 'the interlock relais', mandatory=False)
|
||||
flowswitch = Attached(Readable, 'the flow switch', mandatory=False)
|
||||
wall_limit = Parameter('maximum wall temperature', FloatRange(0, unit='degC'),
|
||||
default = 50, readonly = False)
|
||||
vacuum_limit = Parameter('maximum vacuum pressure', FloatRange(0, unit='mbar'),
|
||||
@@ -46,9 +50,12 @@ class Interlocks(Module):
|
||||
htr_T_limit = Parameter('maximum htr temperature', FloatRange(0, unit='degC'),
|
||||
default = 530, readonly = False)
|
||||
main_T_limit = Parameter('maximum main temperature', FloatRange(0, unit='degC'),
|
||||
default = 530, readonly = False)
|
||||
default = 530, readonly = False)
|
||||
extra_T_limit = Parameter('maximum extra temperature', FloatRange(0, unit='degC'),
|
||||
default = 530, readonly = False)
|
||||
default = 530, readonly = False)
|
||||
|
||||
_off_reason = None # reason triggering interlock
|
||||
_conditions = '' # summary of reasons why locked now
|
||||
|
||||
def initModule(self):
|
||||
super().initModule()
|
||||
@@ -60,25 +67,50 @@ class Interlocks(Module):
|
||||
(self.vacuum, 'vacuum_limit'),
|
||||
]
|
||||
|
||||
def doPoll(self):
|
||||
# TODO: check channels are valid
|
||||
super().doPoll()
|
||||
newstatus = None
|
||||
if self.input.status[0] >= ERROR:
|
||||
newstatus = self.input.status
|
||||
else:
|
||||
for sensor, limitname in self._sensor_checks:
|
||||
if sensor.value > getattr(self, limitname):
|
||||
newstatus = f'above {sensor.name} limit'
|
||||
break
|
||||
if sensor.status[0] >= ERROR:
|
||||
newstatus = f'error at {sensor.name}: {sensor.status[1]}'
|
||||
return
|
||||
self.control.status = newstatus
|
||||
def write_target(self, value):
|
||||
if value:
|
||||
self.read_status()
|
||||
if self._conditions:
|
||||
raise ImpossibleError('not ready to start')
|
||||
self._off_reason = None
|
||||
self.value = True
|
||||
elif self.value:
|
||||
self.switch_off()
|
||||
self._off_reason = 'switched off'
|
||||
self.value = False
|
||||
self.read_status()
|
||||
|
||||
def switch_off(self):
|
||||
if self.value:
|
||||
self._off_reason = self._conditions
|
||||
self.value = False
|
||||
if self.control.control_active:
|
||||
self.log.error('switch control off %r', self.control.status)
|
||||
self.control.write_control_active(False)
|
||||
self.relais.write_target(False)
|
||||
self.control.write_control_active(False)
|
||||
self.control.status = ERROR, self._conditions
|
||||
if self.htr and self.htr.target:
|
||||
self.htr.write_target(0)
|
||||
if self.relais and (self.relais.value or self.relais.target):
|
||||
self.relais.write_target(False)
|
||||
|
||||
def read_status(self):
|
||||
conditions = []
|
||||
if self.flowswitch and self.flowswitch.value == 0:
|
||||
conditions.append('no cooling water')
|
||||
for sensor, limitname in self._sensor_checks:
|
||||
if sensor is None:
|
||||
continue
|
||||
if sensor.value > getattr(self, limitname):
|
||||
conditions.append(f'above {sensor.name} limit')
|
||||
if sensor.status[0] >= ERROR:
|
||||
conditions.append(f'error at {sensor.name}: {sensor.status[1]}')
|
||||
break
|
||||
self._conditions = ', '.join(conditions)
|
||||
if conditions and (self.control.control_active or self.htr.target):
|
||||
self.switch_off()
|
||||
if self.value:
|
||||
return IDLE, '; '.join(conditions)
|
||||
return ERROR, self._off_reason
|
||||
|
||||
|
||||
class PI(HasConvergence, PImixin):
|
||||
@@ -111,3 +143,4 @@ class PKRgauge(LogVoltageInput):
|
||||
rawrange = (1.82, 8.6)
|
||||
valuerange = (5e-9, 1000)
|
||||
extendedrange = (0.5, 9.5)
|
||||
value = Parameter(unit='mbar')
|
||||
|
||||
Reference in New Issue
Block a user