-
Notifications
You must be signed in to change notification settings - Fork 11
/
MeasFiltersViews.enaml
311 lines (294 loc) · 9.94 KB
/
MeasFiltersViews.enaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
from enaml.widgets.api import Window, Label, Field, Form, Container, GroupBox, ComboBox, \
CheckBox, PushButton, SpinBox, RadioButton
from enaml.stdlib.fields import FloatField, IntField
from enaml.core.api import Conditional, Looper
from enaml.layout.api import hbox, vbox, spacer
from widgets import EnumComboBox
from DictManagerView import DictManagerView
import MeasFilters
from numpy import pi
enamldef RawStreamForm(GroupBox):
attr myFilter
attr filterLib
title := '{} ({})'.format(myFilter.label, myFilter.__class__.__name__)
hug_width = 'medium'
Form:
Label:
text = "Data source"
Field:
text := myFilter.dataSource
tool_tip = myFilter.get_member('dataSource').metadata['desc']
Label:
text = "Channel"
Field:
text := myFilter.channel
tool_tip = myFilter.get_member('channel').metadata['desc']
Label:
text = 'Records File'
Field:
text := myFilter.recordsFilePath
tool_tip = myFilter.get_member('recordsFilePath').metadata['desc']
Label:
text = "Save records"
CheckBox:
checked := myFilter.saveRecords
tool_tip = myFilter.get_member('saveRecords').metadata['desc']
Label:
text = "Plot scope"
CheckBox:
checked := myFilter.plotScope
Label:
text = "Plot mode"
EnumComboBox:
obj := myFilter
enumName = 'plotMode'
enamldef DigitalDemodForm(GroupBox):
attr myFilter
attr filterLib
title := '{} ({})'.format(myFilter.label, myFilter.__class__.__name__)
hug_width = 'medium'
Form:
Label:
text = 'I.F. Freq (MHz)'
FloatField:
value << myFilter.IFfreq/1e6
value :: myFilter.IFfreq = value*1e6
tool_tip = myFilter.get_member('IFfreq').metadata['desc']
Label:
text = 'Bandwidth (MHz)'
FloatField:
value << myFilter.bandwidth/1e6
value :: myFilter.bandwidth = value*1e6
tool_tip = myFilter.get_member('bandwidth').metadata['desc']
Label:
text = 'Sampling Rate (MS/s)'
FloatField:
value << myFilter.samplingRate/1e6
value :: myFilter.samplingRate = value*1e6
tool_tip = myFilter.get_member('samplingRate').metadata['desc']
Label:
text = "First Stage Decimation"
IntField:
value := myFilter.decimFactor1
tool_tip = myFilter.get_member('decimFactor1').metadata['desc']
Label:
text = "Second Stage Decimation"
IntField:
value := myFilter.decimFactor2
tool_tip = myFilter.get_member('decimFactor2').metadata['desc']
Label:
text = "Third Stage Decimation"
IntField:
value := myFilter.decimFactor3
tool_tip = myFilter.get_member('decimFactor3').metadata['desc']
Label:
text = "Phase (deg.)"
FloatField:
value << (180/pi)*myFilter.phase
value :: myFilter.phase = (pi/180)*value
Label:
text = "Data source"
Field:
text := myFilter.dataSource
Label:
text = "Plot scope"
CheckBox:
checked := myFilter.plotScope
Label:
text = "Plot mode"
EnumComboBox:
obj := myFilter
enumName = 'plotMode'
Label:
text = 'Records File'
Field:
text := myFilter.recordsFilePath
tool_tip = myFilter.get_member('recordsFilePath').metadata['desc']
Label:
text = "Save records"
CheckBox:
checked := myFilter.saveRecords
tool_tip = myFilter.get_member('saveRecords').metadata['desc']
enamldef KernelIntegrationForm(GroupBox):
attr myFilter
attr filterLib
title := '{} ({})'.format(myFilter.label, myFilter.__class__.__name__)
Form:
Label:
text = "Data source"
Field:
text := myFilter.dataSource
Label:
text = 'Arbitrary kernel'
Field:
text := myFilter.kernel
tool_tip = myFilter.get_member('kernel').metadata["desc"]
Label:
text = 'Simple kernel'
GroupBox:
Form:
Label:
text = 'Box car start'
IntField:
value := myFilter.boxCarStart
Label:
text = 'Box car stop'
IntField:
value := myFilter.boxCarStop
Label:
text = 'IF frequency (MHz)'
FloatField:
value << myFilter.IFfreq / 1e6
value :: myFilter.IFfreq = value * 1e6
Label:
text = 'Sampling rate (MS/s)'
FloatField:
value << myFilter.samplingRate / 1e6
value :: myFilter.samplingRate = value * 1e6
Label:
text = ''
Container:
constraints = [hbox(rb1, rb2, spacer)]
RadioButton: rb1:
text = 'arbitrary'
checked << not myFilter.simpleKernel
RadioButton: rb2:
text = 'simple'
checked := myFilter.simpleKernel
Label:
text = 'Bias'
FloatField:
value := myFilter.bias
tool_tip = myFilter.get_member('bias').metadata["desc"]
Label:
text = "Plot scope"
CheckBox:
checked := myFilter.plotScope
Label:
text = "Plot mode"
EnumComboBox:
obj := myFilter
enumName = 'plotMode'
def filterLooperGetIndex(items, myFilter, loop_index):
if loop_index < len(myFilter.filters) and \
myFilter.filters[loop_index].label in items:
return items.index(myFilter.filters[loop_index].label)
else:
return -1
enamldef CorrelatorView(GroupBox):
attr myFilter
attr filterLib
title := '{} ({})'.format(myFilter.label, myFilter.__class__.__name__)
Form:
Label:
text = 'Num. Channels'
SpinBox: numFiltersBox:
minimum = 2
value = len(myFilter.filters) if myFilter.filters and (len(myFilter.filters) > 0) else 2
Looper: filterLooper:
iterable << range(numFiltersBox.value)
iterable ::
if len(myFilter.filters) > len(iterable):
myFilter.filters = myFilter.filters[:numFiltersBox.value]
elif len(myFilter.filters) < len(iterable):
myFilter.filters += [None]
Form:
Label:
text = 'Filter {}:'.format(loop_index+1)
ComboBox:
items << list(filterLib.filterDict.keys())
index << filterLooperGetIndex(items, myFilter, loop_index)
index ::
myFilter.filters[loop_index] = filterLib.filterDict[selected_item]
Label:
text = "Plot mode"
EnumComboBox:
obj := myFilter
enumName = 'plotMode'
Label:
text = "Plot scope"
CheckBox:
checked := myFilter.plotScope
enamldef StateComparatorView(GroupBox):
attr myFilter
attr filterLib
title := '{} ({})'.format(myFilter.label, myFilter.__class__.__name__)
Form:
Label:
text = "Data source"
Field:
text := myFilter.dataSource
Label:
text = 'Threshold'
FloatField:
value := myFilter.threshold
Label:
text = 'Integration time (samples)'
IntField:
value := myFilter.integrationTime
tool_tip = myFilter.get_member('integrationTime').metadata['desc']
Label:
text = "Plot mode"
EnumComboBox:
obj := myFilter
enumName = 'plotMode'
enamldef StreamSelectorView(GroupBox):
attr myFilter
attr filterLib
title := '{} ({})'.format(myFilter.label, myFilter.__class__.__name__)
Form:
Label:
text = "Data source"
Field:
text := myFilter.dataSource
Label:
text = 'Stream'
Field:
text := myFilter.stream
Label:
text = "Plot scope"
CheckBox:
checked := myFilter.plotScope
Label:
text = "Plot mode"
EnumComboBox:
obj := myFilter
enumName = 'plotMode'
Label:
text = 'Saved'
CheckBox:
checked := myFilter.saved
Label:
text = 'Records File'
Field:
text := myFilter.recordsFilePath
tool_tip = myFilter.get_member('recordsFilePath').metadata['desc']
Label:
text = "Save records"
CheckBox:
checked := myFilter.saveRecords
tool_tip = myFilter.get_member('saveRecords').metadata['desc']
#Dummy empty view
enamldef EmptyMeasFilterForm(Container):
attr myFilter
attr filterLib
#Map filters to views
filterViewMap = {type(None): EmptyMeasFilterForm,
MeasFilters.RawStream: RawStreamForm,
MeasFilters.DigitalDemod: DigitalDemodForm,
MeasFilters.KernelIntegration: KernelIntegrationForm,
MeasFilters.Correlator: CorrelatorView,
MeasFilters.StateComparator: StateComparatorView,
MeasFilters.StreamSelector: StreamSelectorView}
enamldef MeasFilterManager(Container): measFilterManager:
attr filterLib
DictManagerView:
dictManager = filterLib.filterManager
modelName = 'myFilter'
viewMap = filterViewMap
viewkwargs = {'filterLib':filterLib}
enamldef MeasFilterManagerWindow(Window): measFilterManagerTest:
attr filterLib
title = 'Filter Manager'
MeasFilterManager:
filterLib := measFilterManagerTest.filterLib