fs: improve and fix implementation
+ introduce WrapControlledBy and fix HasControlledBy this in a new module before mercury/triton have been fixed
This commit is contained in:
@@ -20,9 +20,9 @@
|
||||
"""interlocks for furnace"""
|
||||
|
||||
from frappy.core import Module, Writable, Attached, Parameter, FloatRange, Readable,\
|
||||
BoolType, ERROR, IDLE
|
||||
BoolType, ERROR, IDLE, Command
|
||||
from frappy.errors import ImpossibleError
|
||||
from frappy.mixins import HasControlledBy
|
||||
from frappy.ctrlby import WrapControlledBy
|
||||
from frappy_psi.picontrol import PImixin
|
||||
from frappy_psi.convergence import HasConvergence
|
||||
from frappy_psi.ionopimax import CurrentInput, LogVoltageInput
|
||||
@@ -86,12 +86,12 @@ class Interlocks(Writable):
|
||||
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.control.status = ERROR, self._conditions
|
||||
self.control.write_control_active(False)
|
||||
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)
|
||||
if self.relais.value or self.relais.target:
|
||||
self.log.warning('switch off relais %r %r', self.relais.value, self.relais.target)
|
||||
self.relais.write_target(False)
|
||||
|
||||
def read_status(self):
|
||||
conditions = []
|
||||
@@ -112,35 +112,46 @@ class Interlocks(Writable):
|
||||
return IDLE, '; '.join(conditions)
|
||||
return ERROR, self._off_reason
|
||||
|
||||
@Command
|
||||
def reset(self):
|
||||
"""reset interlock after error
|
||||
|
||||
class PI(HasConvergence, PImixin):
|
||||
will fail if error conditions still apply
|
||||
"""
|
||||
self.write_target(1)
|
||||
|
||||
|
||||
class PI(HasConvergence, PImixin, Writable):
|
||||
input_module = Attached(Readable, 'the input module')
|
||||
relais = Attached(Writable, 'the interlock relais', mandatory=False)
|
||||
|
||||
def read_value(self):
|
||||
return self.input.value
|
||||
return self.input_module.value
|
||||
|
||||
def write_target(self, value):
|
||||
super().write_target(value)
|
||||
def read_status(self):
|
||||
return self.input_module.status
|
||||
|
||||
def set_target(self, value):
|
||||
super().set_target(value)
|
||||
if self.relais:
|
||||
if not self.relais.value or not self.relais.target:
|
||||
self.log.warning('switch on relais %r %r', self.relais.value, self.relais.target)
|
||||
self.relais.write_target(1)
|
||||
|
||||
|
||||
class TdkOutput(HasControlledBy, tdkpower.Output):
|
||||
class PIctrl(WrapControlledBy, PI):
|
||||
pass
|
||||
|
||||
|
||||
class BkOutput(HasControlledBy, bkpower.Output):
|
||||
pass
|
||||
class PI2(PI):
|
||||
maxovershoot = Parameter('max. overshoot', FloatRange(0, 100, unit='%'), readonly=False, default=20)
|
||||
|
||||
def doPoll(self):
|
||||
self.output_max = self.target * (1 + 0.01 * self.maxovershoot)
|
||||
self.output_min = self.target * (1 - 0.01 * self.maxovershoot)
|
||||
super().doPoll()
|
||||
|
||||
class PRtransmitter(CurrentInput):
|
||||
rawrange = (0.004, 0.02)
|
||||
extendedrange = (0.0036, 0.021)
|
||||
|
||||
|
||||
class PKRgauge(LogVoltageInput):
|
||||
rawrange = (1.82, 8.6)
|
||||
valuerange = (5e-9, 1000)
|
||||
extendedrange = (0.5, 9.5)
|
||||
value = Parameter(unit='mbar')
|
||||
def write_target(self, target):
|
||||
if not self.control_active:
|
||||
self.output_module.write_target(target)
|
||||
super().write_target(target)
|
||||
|
||||
Reference in New Issue
Block a user