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"
30 class _TemperatureUnit (object):
34 class Celsius (_TemperatureUnit):
38 class Kelvin (_TemperatureUnit):
42 class TemperatureConfig (_config.Config):
43 "Configure a temperature monitor"
47 help='Monitor name (so the user will know what is measured).',
49 _config.ChoiceSetting(
51 help='Units of raw temperature measurements.',
57 _config.IntegerSetting(
59 help='MTCA controller ID.',
63 help="Serial port you're using to connect to the controller.",
64 default='/dev/ttyS0'),
65 _config.IntegerSetting(
67 help="Baud rate for which you've configured your controller.",
69 _config.IntegerSetting(
71 help="Maxium current (in amps) output by the controller.",
76 class DigitalPortConfig (_config.Config):
77 "Configure a digital input/output port."
81 help="Port name (so the user will know what it's used for).",
85 help='Comedi device.',
86 default='/dev/comedi0'),
87 _config.IntegerSetting(
89 help='Comedi subdevice index. -1 for automatic detection.',
91 _config.ChoiceSetting(
92 name='subdevice-type',
93 help='Comedi subdevice type for autodetection.',
94 choices=[(x.name, x) for x in _constant.SUBDEVICE_TYPE],
95 default=_constant.SUBDEVICE_TYPE.dio),
96 _config.IntegerListSetting(
98 help='Subdevice channels to control by index.',
100 _config.ChoiceSetting(
102 help='Port direction.',
103 choices=[(x.name, x) for x in _constant.IO_DIRECTION]),
107 class StepperConfig (_config.Config):
108 "Configure a stepper motor."
112 help="Motor name (so the user will know what it's used for).",
114 _config.BooleanSetting(
116 help='Place the stepper in full-step mode (vs. half-step)',
118 _config.BooleanSetting(
120 help='Place the stepper in active-high mode (vs. active-low)',
122 _config.FloatSetting(
124 help=('Time delay between steps in seconds, in case the motor '
125 'response is slower that the digital output driver.'),
127 _config.FloatSetting(
129 help= 'Approximate step size in meters.' ,
131 _config.IntegerSetting(
133 help= 'Generous estimate of the backlash length in half-steps.',
135 _config.ConfigSetting(
137 help=('Configure the digital port used to communicate with the '
139 config_class=DigitalPortConfig,
144 class AFMConfig (_config.Config):
145 "Configure an Atomic Force Microscope (AFM)."
149 help="AFM name (so the user will know what it's used for).",
153 help=("Name of the piezo axis controlling distance from the "
156 _config.ConfigSetting(
158 help='Configure the underlying piezo (fine adjustment).',
159 config_class=_pypiezo_config.PiezoConfig,
161 _config.ConfigSetting(
163 help='Configure the underlying stepper motor (coarse adjustment).',
164 config_class=StepperConfig,
166 _config.ConfigSetting(
168 help='Configure the underlying temperature sensor.',
169 config_class=TemperatureConfig,
171 _config.FloatSetting(
172 name='fallback-temperature',
173 help=('Temperature in Kelvin to use if no temperature sensor is '
176 _config.FloatSetting(
178 help=('Approximate distance in meters to move away to get "far" '
179 'from the surface. For possible stepper adjustments while '
180 'initially locating the surface.'),