1 # Copyright (C) 2011 W. Trevor King <wking@drexel.edu>
3 # This file is part of pypiezo.
5 # pypiezo is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation, either version 3 of the License, or (at your
8 # option) any later version.
10 # pypiezo is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with pypiezo. If not, see <http://www.gnu.org/licenses/>.
18 """Construct example piezo configurations to simplify testing
20 These methods make it easier to write tests in packages that depend on
24 from .base import get_axis_name as _get_axis_name
25 from .config import AxisConfig as _AxisConfig
26 from .config import InputChannelConfig as _InputChannelConfig
27 from .config import OutputChannelConfig as _OutputChannelConfig
28 from .config import PiezoConfig as _PiezoConfig
31 def get_piezo_config(storage=None):
32 """Return a default PiezoConfig instance.
34 >>> p = get_piezo_config()
50 conversion-coefficients: 0, 1
52 inverse-conversion-coefficients: 0, 1
53 inverse-conversion-origin: 0
67 conversion-coefficients: 0, 1
69 inverse-conversion-coefficients: 0, 1
70 inverse-conversion-origin: 0
80 conversion-coefficients: 0, 1
82 inverse-conversion-coefficients: 0, 1
83 inverse-conversion-origin: 0
91 conversion-coefficients: 0, 1
93 inverse-conversion-coefficients: 0, 1
94 inverse-conversion-origin: 0
95 >>> _get_axis_name(p['axes'][0])
97 >>> d = p.select_config('inputs', 'deflection')
101 piezo_config = _PiezoConfig(storage=storage)
102 piezo_config['name'] = 'test piezo'
103 piezo_config['axes'] = []
104 for i,name in enumerate(['x', 'z']):
106 axis['channel'] = _OutputChannelConfig()
107 axis['channel']['name'] = name
108 axis['channel']['channel'] = i
109 axis['channel']['maxdata'] = 100
110 axis['channel']['conversion-coefficients'] = (0,1)
111 axis['channel']['conversion-origin'] = 0
112 axis['channel']['inverse-conversion-coefficients'] = (0,1)
113 axis['channel']['inverse-conversion-origin'] = 0
114 piezo_config['axes'].append(axis)
115 piezo_config['inputs'] = []
116 for i,name in enumerate(['deflection', 'temperature']):
117 channel = _InputChannelConfig()
118 channel = _OutputChannelConfig()
119 channel['name'] = name
120 channel['channel'] = i
121 channel['maxdata'] = 100
122 channel['conversion-coefficients'] = (0,1)
123 channel['conversion-origin'] = 0
124 channel['inverse-conversion-coefficients'] = (0,1)
125 channel['inverse-conversion-origin'] = 0
126 piezo_config['inputs'].append(channel)