Add surface-matplotlib config option to pypiezo.
[pypiezo.git] / pypiezo / config.py
1 # Copyright (C) 2011-2012 W. Trevor King <wking@tremily.us>
2 #
3 # This file is part of pypiezo.
4 #
5 # pypiezo 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
8 # version.
9 #
10 # pypiezo 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.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # pypiezo.  If not, see <http://www.gnu.org/licenses/>.
16
17 "Piezo configuration"
18
19 import h5config.config as _config
20 import h5config.tools as _h5config_tools
21
22 import pycomedi.constant as _constant
23
24
25 class PackageConfig (_h5config_tools.PackageConfig):
26     "Configure `pypiezo` module operation"
27     settings = _h5config_tools.PackageConfig.settings + [
28         _config.BooleanSetting(
29             name='matplotlib',
30             help='Plot piezo motion using `matplotlib`.',
31             default=False),
32         _config.BooleanSetting(
33             name='surface-matplotlib',
34             help='Plot surface positiong fit using `matplotlib`.',
35             default=False),
36         ]
37
38
39 class ChannelConfig (_config.Config):
40     "Configure a single DAC/ADC channel"
41     settings = [
42         _config.Setting(
43             name='name',
44             help="Channel name (so the user will know what it's used for).",
45             default=None),
46         _config.Setting(
47             name='device',
48             help='Comedi device.',
49             default='/dev/comedi0'),
50         _config.IntegerSetting(
51             name='subdevice',
52             help='Comedi subdevice index.  -1 for automatic detection.',
53             default=-1),
54         _config.IntegerSetting(
55             name='channel',
56             help='Subdevice channel index.',
57             default=0),
58         _config.IntegerSetting(
59             name='maxdata',
60             help="Channel's maximum bit value."),
61         _config.IntegerSetting(
62             name='range',
63             help="Channel's selected range index.",
64             default=0),
65         _config.ChoiceSetting(
66             name='analog-reference',
67             help="Channel's selected analog reference index.",
68             choices=[(x.name, x) for x in _constant.AREF]),
69         _config.FloatListSetting(
70             name='conversion-coefficients',
71             help=('Bit to physical unit conversion coefficients starting with '
72                   'the constant coefficient.')),
73         _config.FloatSetting(
74             name='conversion-origin',
75             help=('Origin (bit offset) of bit to physical polynomial '
76                   'expansion.')),
77         _config.FloatListSetting(
78             name='inverse-conversion-coefficients',
79             help=('Physical unit to bit conversion coefficients starting with '
80                   'the constant coefficient.')),
81         _config.FloatSetting(
82             name='inverse-conversion-origin',
83             help=('Origin (physical unit offset) of physical to bit '
84                   'polynomial expansion.')),
85         ]
86
87
88 class OutputChannelConfig (ChannelConfig):
89     pass
90
91
92 class InputChannelConfig (ChannelConfig):
93     pass
94
95
96 class AxisConfig (_config.Config):
97     "Configure a single piezo axis"
98     settings = [
99         _config.FloatSetting(
100             name='gain',
101             help=(
102                 'Volts applied at piezo per volt output from the DAQ card '
103                 '(e.g. if your DAQ output is amplified before driving the '
104                 'piezo),')),
105         _config.FloatSetting(
106             name='sensitivity',
107             help='Meters of piezo deflection per volt applied to the piezo.'),
108         _config.FloatSetting(
109             name='minimum',
110             help='Set a lower limit on allowed output voltage',
111             default=None),
112         _config.FloatSetting(
113             name='maximum',
114             help='Set an upper limit on allowed output voltage',
115             default=None),
116         _config.ConfigSetting(
117             name='channel',
118             help='Configure the underlying DAC channel.',
119             config_class=OutputChannelConfig,
120             default=None),
121         _config.ConfigSetting(
122             name='monitor',
123             help='Configure the underlying (optional) ADC monitoring channel.',
124             config_class=InputChannelConfig,
125             default=None),
126         ]
127
128
129 class PiezoConfig (_config.Config):
130     "Configure a piezo experiment"
131     settings = [
132         _config.Setting(
133             name='name',
134             help="Piezo name (so the user will know what it's used for).",
135             default=None),
136         _config.ConfigListSetting(
137             name='axes',
138             help='Configure the underlying axes.',
139             config_class=AxisConfig,
140             default=None),
141         _config.ConfigListSetting(
142             name='inputs',
143             help='Configure the underlying (optional) ADC monitoring channels.',
144             config_class=InputChannelConfig,
145             default=None),
146         ]
147
148
149 class WiggleConfig (_config.Config):
150     "Configure an interference wiggle"
151     settings = [
152         _config.Setting(
153             name='axis',
154             help="Name of the axis to wiggle.",
155             default='z'),
156         _config.Setting(
157             name='input',
158             help="Name of the channel to watch.",
159             default='deflection'),
160         _config.FloatSetting(
161             name='frequency',
162             help="Frequency for a full wiggle cycle (hertz).",
163             default=2),
164         _config.IntegerSetting(
165             name='samples',
166             help='Number of samples in a full wiggle cycle.',
167             default=1024),
168         _config.IntegerSetting(
169             name='offset',
170             help='Center of the wiggle position (bits)',
171             default=None),
172         _config.IntegerSetting(
173             name='amplitude',
174             help='Amplitude of the wiggle sinusoid (bits)',
175             default=None),
176         _config.IntegerSetting(
177             name='wavelength',
178             help=('Instead of giving an explicit amplitude, you can specify '
179                   'the laser wavelength in meters.  The amplitude will then '
180                   'be set to contain about two interference cycles.'),
181             default=None),
182         ]