frappy/frappy_psi/furnace.py
Markus Zolliker d681507f94 frappy_psi.furnace: special classes PTXgauge and PRtransmitter
move some initialization from cfg file to source code
+ make 'out of calibrated range' and 'sensor break' more generic

Change-Id: I3e92100fdb9c983f82665de9d8e063609cd7af5a
2025-04-23 08:28:08 +02:00

114 lines
4.3 KiB
Python

# *****************************************************************************
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Module authors:
# Markus Zolliker <markus.zolliker@psi.ch>
# *****************************************************************************
"""interlocks for furnace"""
import time
from frappy.core import Module, Writable, Attached, Parameter, FloatRange, Readable,\
BoolType, ERROR, IDLE
from frappy.mixins import HasControlledBy
from frappy_psi.picontrol import PImixin
from frappy_psi.convergence import HasConvergence
from frappy_psi.ionopimax import CurrentInput, LogVoltageInput
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')
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')
wall_limit = Parameter('maximum wall temperature', FloatRange(0, unit='degC'),
default = 50, readonly = False)
vacuum_limit = Parameter('maximum vacuum pressure', FloatRange(0, unit='mbar'),
default = 0.1, readonly = False)
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)
extra_T_limit = Parameter('maximum extra temperature', FloatRange(0, unit='degC'),
default = 530, readonly = False)
def initModule(self):
super().initModule()
self._sensor_checks = [
(self.wall_T, 'wall_limit'),
(self.main_T, 'main_T_limit'),
(self.extra_T, 'extra_T_limit'),
(self.htr_T, 'htr_T_limit'),
(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
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)
class PI(HasConvergence, PImixin):
input_module = Attached(Readable, 'the input module')
relais = Attached(Writable, 'the interlock relais', mandatory=False)
def read_value(self):
return self.input.value
def write_target(self, value):
super().write_target(value)
if self.relais:
self.relais.write_target(1)
class TdkOutput(HasControlledBy, tdkpower.Output):
pass
class BkOutput(HasControlledBy, bkpower.Output):
pass
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)