1 # Copyright (C) 2011-2012 W. Trevor King <wking@tremily.us>
3 # This file is part of pyafm.
5 # pyafm is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free Software
7 # Foundation, either version 3 of the License, or (at your option) any later
10 # pyafm is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # pyafm. If not, see <http://www.gnu.org/licenses/>.
19 import h5config.config as _config
20 import h5config.tools as _h5config_tools
21 import pycomedi.constant as _constant
22 import pypiezo.config as _pypiezo_config
25 class PackageConfig (_h5config_tools.PackageConfig):
26 "Configure `pyafm` module operation"
27 settings = _h5config_tools.PackageConfig.settings + [
28 _config.BooleanSetting(
30 help='Plot pyafm actions using `matplotlib`.',
35 class _TemperatureUnit (object):
39 class Celsius (_TemperatureUnit):
43 class Kelvin (_TemperatureUnit):
47 class TemperatureConfig (_config.Config):
48 "Configure a temperature monitor"
52 help='Monitor name (so the user will know what is measured).',
54 _config.ChoiceSetting(
56 help='Units of raw temperature measurements.',
62 _config.IntegerSetting(
64 help='MTCA controller ID.',
68 help="Serial port you're using to connect to the controller.",
69 default='/dev/ttyS0'),
70 _config.IntegerSetting(
72 help="Baud rate for which you've configured your controller.",
74 _config.IntegerSetting(
76 help="Maxium current (in amps) output by the controller.",
81 class DigitalPortConfig (_config.Config):
82 "Configure a digital input/output port."
86 help="Port name (so the user will know what it's used for).",
90 help='Comedi device.',
91 default='/dev/comedi0'),
92 _config.IntegerSetting(
94 help='Comedi subdevice index. -1 for automatic detection.',
96 _config.ChoiceSetting(
97 name='subdevice-type',
98 help='Comedi subdevice type for autodetection.',
99 choices=[(x.name, x) for x in _constant.SUBDEVICE_TYPE],
100 default=_constant.SUBDEVICE_TYPE.dio),
101 _config.IntegerListSetting(
103 help='Subdevice channels to control by index.',
105 _config.ChoiceSetting(
107 help='Port direction.',
108 choices=[(x.name, x) for x in _constant.IO_DIRECTION]),
112 class StepperConfig (_config.Config):
113 "Configure a stepper motor."
117 help="Motor name (so the user will know what it's used for).",
119 _config.BooleanSetting(
121 help='Place the stepper in full-step mode (vs. half-step)',
123 _config.BooleanSetting(
125 help='Place the stepper in active-high mode (vs. active-low)',
127 _config.FloatSetting(
129 help=('Time delay between steps in seconds, in case the motor '
130 'response is slower that the digital output driver.'),
132 _config.FloatSetting(
134 help= 'Approximate step size in meters.' ,
136 _config.IntegerSetting(
138 help= 'Generous estimate of the backlash length in half-steps.',
140 _config.ConfigSetting(
142 help=('Configure the digital port used to communicate with the '
144 config_class=DigitalPortConfig,
149 class AFMConfig (_config.Config):
150 "Configure an Atomic Force Microscope (AFM)."
154 help="AFM name (so the user will know what it's used for).",
158 help=("Name of the piezo axis controlling distance from the "
161 _config.ConfigSetting(
163 help='Configure the underlying piezo (fine adjustment).',
164 config_class=_pypiezo_config.PiezoConfig,
166 _config.ConfigSetting(
168 help='Configure the underlying stepper motor (coarse adjustment).',
169 config_class=StepperConfig,
171 _config.ConfigSetting(
173 help='Configure the underlying temperature sensor.',
174 config_class=TemperatureConfig,
176 _config.FloatSetting(
177 name='fallback-temperature',
178 help=('Temperature in Kelvin to use if no temperature sensor is '
181 _config.FloatSetting(
183 help=('Approximate distance in meters to move away to get "far" '
184 'from the surface. For possible stepper adjustments while '
185 'initially locating the surface.'),