frappy/frappy_psi/furnace.py
Markus Zolliker 8bc0671f73 fs furnace: move PI with relais to frappy_psi/furnace.py
Change-Id: Ia8bec296035b3ae23a698f041fe8be39d925d996
2024-06-12 11:25:22 +02:00

64 lines
2.5 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 furnance"""
import time
from frappy.core import Module, Writable, Attached, Parameter, FloatRange, Readable,\
BoolType, ERROR, IDLE
from frappy_psi.picontrol import PImixin
class Interlocks(Module):
input = Attached(Readable, 'the input module')
vacuum = Attached (Readable, 'the vacuum pressure')
wall_T = Attached (Readable, 'the wall 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)
def doPoll(self):
super().doPoll()
if self.input.status[0] >= ERROR:
self.control.status = self.input.status
elif self.vacuum.value > self.vacuum_limit:
self.control.status = ERROR, 'bad vacuum'
elif self.wall_T.value > self.wall_limit:
self.control.status = ERROR, 'wall overheat'
else:
return
self.control.write_control_active(False)
self.relais.write_target(False)
class PI(PImixin, Writable):
input = 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)