Source code for src.instruments.controllers.ctrl_heliox

"""A class for monitoring and controlling the Heliox.
"""
from time import sleep
from src.core.instrument import Controller

UPDATE_DELAY = 0.5
INSTRUMENT = 'Heliox'

[docs]class HelioxController(Controller): """A tool for monitoring the Heliox status and manually controlling it.""" def __init__(self, experiment, heliox): """Instantiate a Heliox monitor.""" super(HelioxController, self).__init__() self.setDaemon(True) self._expt = experiment self._heliox = heliox self._continue = True self._running = False self._data = {} self._commands = []
[docs] def run(self): """Start updating the monitor and listening for commands.""" self._running = True while self._continue: self._data = {'field': self._heliox.directGetField(), 'setpoint': self._heliox.getFieldSetpoint(), 'ramp_rate': self._heliox.getFieldRampRate(), 'pid': self._heliox.getPID(), 'temperatures': self._heliox.directGetTemperatures(), 'auto_temp': self._heliox.getTemperature()} for command in self._commands: command.execute(data=self._data) sleep(UPDATE_DELAY) self._running = False
[docs] def abort(self): """Stop the monitor.""" self._continue = False self._commands = []
[docs] def setUpdateCommands(self, commands): """Set the commands to execute each time the monitor updates. All of the parameters of which the monitor keeps track will be substituted into the commands as keyword arguments every time there is an update. The keys are as follows: - 'field' - 'setpoint' - 'ramp_rate' - 'pid' - 'temperatures' Parameters ---------- commands : list of Command A list of `Command` objects which will be executed each time the monitor object updates. """ self._commands = commands
[docs] def clearUpdateCommands(self): """Remove all update commands.""" self._commands = []
[docs] def setField(self, field): """Set the magnetic field. Parameters ---------- field : float The desired magnetic field in Tesla. """ self._heliox.setField(field, 'proceed')
[docs] def setFieldRampRate(self, rampRate): """Set the magnetic field ramp rate. Parameters ---------- rampRate : float The desired magnetic field ramp rate. """ self._heliox.setFieldRampRate(rampRate)
[docs] def setPID(self, newP, newI, newD): """Set the PID values for the temperature controller. Parameters ---------- newP : float The proportional band in Kelvin, to a resolution of 0.001 K. newI : float The integral action time in minutes. Values between 0 and 140 minutes (inclusive), in steps of 0.1 minutes, are accepted. newD : float The derivative action time in minutes. The allowed range is 0 to 273 minutes. The default is 0.0. """ self._heliox.setPID(newP, newI, newD)
[docs] def setTemperatureSorb(self, temperature): """Set the sorb temperature. Parameters ---------- temperature : float The desired sorb temperature in Kelvin. """ self._heliox.setTemperatureSorb(temperature)
[docs] def setTemperatureSampleLow(self, temperature): """Set the sample-low temperature. Parameters ---------- temperature : float The desired sample-low temperature in Kelvin. """ self._heliox.setTemperatureSampleLow(temperature)
[docs] def setTemperatureSampleHigh(self, temperature): """Set the sample-high temperature. Parameters ---------- temperature : float The desired sample-high temperature in Kelvin. """ self._heliox.setTemperatureSampleHigh(temperature)
[docs] def setTemperature(self, temperature): """Set the sample temperature using the automatic algorithm. Parameters ---------- temperature : float The desired sample temperature in Kelvin. """ self._heliox.setTemperature(temperature)
@classmethod
[docs] def getInstrumentClassName(cls): """Return the instrument class managed by this controller.""" return 'Heliox'
@classmethod
[docs] def isSingleton(cls): """Return whether at most one instance of the controller may exist. Returns ------- bool Whether only zero or one instance of the controller may exist. """ return True