>>> config['temperature'] = pyafm.config.TemperatureConfig()
>>> config['temperature']['name'] = 'test temperature'
- >>> afm = AFM(config=config, devices=devices)
+ >>> afm = AFM(config=config)
+ >>> afm.load_from_config(devices=devices)
>>> afm.setup_config()
>>> afm.get_temperature() # doctest: +SKIP
test temperature
<HDF5 dataset "units": shape (), type "|S7">
Celsius
- >>> afm2 = pyafm.storage.load_afm(filename=filename, devices=devices)
+ >>> afm2 = pyafm.storage.load_afm(filename=filename)
+ >>> afm2.load_from_config(devices=devices)
>>> afm2.get_temperature() # doctest: +SKIP
297.37
>>> os.remove(filename)
"""
- def __init__(self, config, piezo=None, stepper=None, temperature=None,
- devices=None):
+ def __init__(self, config, piezo=None, stepper=None, temperature=None):
self.config = config
self.piezo = piezo
self.stepper = stepper
self.temperature = temperature
- self.load_from_config(devices=devices)
def load_from_config(self, devices):
c = self.config # reduce verbosity
if self.piezo is None and c['piezo']:
- self.piezo = _AFMPiezo(config=c['piezo'], devices=devices)
+ self.piezo = _AFMPiezo(config=c['piezo'])
+ self.piezo.load_from_config(devices=devices)
if self.stepper is None and c['stepper']:
- self.stepper = _Stepper(config=c['stepper'], devices=devices)
+ self.stepper = _Stepper(config=c['stepper'])
+ self.stepper.load_from_config(devices=devices)
if self.temperature is None and c['temperature']:
self.temperature = _Temperature(config=c['temperature'])
+ self.temperature.load_from_config()
def setup_config(self):
if self.piezo:
>>> config['channels'] = [1, 2, 3, 4]
>>> config['name'] = 'test port'
- >>> port = DigitalPort(config=config, devices=devices)
+ >>> port = DigitalPort(config=config)
+ >>> port.load_from_config(devices=devices)
>>> port.write_bitfield(13)
>>> port.write([1, 0, 1, 0])
>>> port.write_bitfield(0)
>>> for device in devices:
... device.close()
"""
- def __init__(self, config, devices=None):
+ def __init__(self, config):
self.config = config
self.subdevice = None
- self.load_from_config(devices=devices)
def load_from_config(self, devices):
c = self.config # reduce verbosity
>>> config['port']['name'] = 'stepper port'
>>> config['name'] = 'test stepper'
- >>> s = Stepper(config=config, devices=devices)
+ >>> s = Stepper(config=config)
+ >>> s.load_from_config(devices=devices)
>>> s.position
0
>>> s.single_step(1)
>>> for device in devices:
... device.close()
"""
- def __init__(self, config, devices=None):
+ def __init__(self, config):
self.config = config
self.port = None
- self.load_from_config(devices=devices)
c = self.config # reduce verbosity
super(Stepper, self).__init__(
write=self.port.write_bitfield, full_step=c['full-step'],
def load_from_config(self, devices):
c = self.config # reduce verbosity
if self.port is None:
- self.port = _DigitalPort(config=c['port'], devices=devices)
+ self.port = _DigitalPort(config=c['port'])
+ self.port.load_from_config(devices=devices)
self._write = self.port.write_bitfield
self.full_step = c['full-step']
self.logic = c['logic']
storage = _HDF5_Storage(filename=filename, group=group)
storage.save(config=afm.config)
-def load_afm(filename=None, group=None, devices=None):
+def load_afm(filename=None, group=None):
if filename is None:
filename = DEFAULT_FILENAME
if group is None:
config.load()
_LOG.debug(
'constructing AFM from configuration:\n{}'.format(config.dump()))
- return AFM(config=config, devices=devices)
+ return = AFM(config=config)
>>> config = TemperatureConfig()
>>> t = Temperature(config=config)
+ >>> t.load_from_config()
>>> t.get_temperature() # doctest: +SKIP
297.37
>>> t.cleanup()
_LOG.debug('setup temperature monitor')
self.config = config
self.backend = backend
- self.load_from_config()
def load_from_config(self):
c = self.config # reduce verbosity