109 lines
3.5 KiB
Python
109 lines
3.5 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
# *****************************************************************************
|
|
# 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:
|
|
# Oksana Shliakhtun <oksana.shliakhtun@psi.ch>
|
|
# *****************************************************************************
|
|
|
|
from frappy.core import StringIO, Parameter, Readable, HasIO, \
|
|
Drivable, FloatRange
|
|
|
|
|
|
class ThermFishIO(StringIO):
|
|
end_of_line = '\r'
|
|
identification = [('RVER', r'.[.*')] # Firmware Version
|
|
|
|
|
|
class SensorA10(HasIO, Readable):
|
|
ClassIO = ThermFishIO
|
|
value = Parameter('internal temperature', unit='degC')
|
|
|
|
def read_value(self):
|
|
return self.communicate('RT') # return the value and the units without space
|
|
|
|
def set_par(self, cmd):
|
|
|
|
|
|
|
|
class TemperatureLoopA10(SensorSC, Drivable):
|
|
value = Parameter('temperature', unit='degC')
|
|
target = Parameter('setpoint', FloatRange, readonly=False)
|
|
p_heat = Parameter('proportional heat parameter', FloatRange(), unit='degC', readonly=False)
|
|
i_heat = Parameter('integral heat parameter', FloatRange(), readonly=False)
|
|
d_heat = Parameter('derivative heat parameter', FloatRange(), readonly=False)
|
|
p_cool = Parameter('proportional cool parameter', FloatRange(), readonly=False)
|
|
i_cool = Parameter('integral cool parameter', FloatRange(), readonly=False)
|
|
d_cool = Parameter('derivative cool parameter', FloatRange(), readonly=False)
|
|
|
|
setpoint_num = ['', 1, 2, 3, 4, 5]
|
|
|
|
def read_target(self):
|
|
return self.communicate(f'RS{self.setpoint_num}')
|
|
|
|
def write_target(self):
|
|
target = self.communicate(f'SS{self.setpoint_num} {self.target}')
|
|
return target
|
|
|
|
## heat PID
|
|
def read_p_heat(self):
|
|
p_heat = self.communicate(f'RPH')
|
|
return p_heat
|
|
|
|
def write_p_heat(self, p_heat):
|
|
self.communicate(f'SPH {p_heat}')
|
|
return self.read_p_heat()
|
|
|
|
def read_i_heat(self):
|
|
i_heat = self.communicate(f'RIH')
|
|
return i_heat
|
|
|
|
def write_i_heat(self, i_heat):
|
|
self.communicate(f'SIH {i_heat}')
|
|
return self.read_i_heat()
|
|
|
|
def read_d_heat(self):
|
|
d_heat = self.communicate(f'RDH')
|
|
return d_heat
|
|
|
|
def write_d_heat(self, d_heat):
|
|
self.communicate(f'SDH {d_heat}')
|
|
return self.read_d_heat()
|
|
|
|
## cool PID
|
|
def read_p_cool(self):
|
|
p_cool = self.communicate(f'RPC')
|
|
return p_cool
|
|
|
|
def write_p_cool(self, p_cool):
|
|
self.communicate(f'SPC {p_cool}')
|
|
return self.read_p_cool()
|
|
|
|
def read_i_cool(self):
|
|
i_cool = self.communicate(f'RIC')
|
|
return i_cool
|
|
|
|
def write_i_cool(self, i_cool):
|
|
self.communicate(f'SIC {i_cool}')
|
|
return self.read_i_cool()
|
|
|
|
def read_d_cool(self):
|
|
d_cool = self.communicate(f'RDC')
|
|
return d_cool
|
|
|
|
def write_d_cool(self, d_cool):
|
|
self.communicate(f'SDC {d_cool}')
|
|
return self.read_d_cool() |