-
Notifications
You must be signed in to change notification settings - Fork 11
/
ChannelsViews.enaml
276 lines (262 loc) · 10.4 KB
/
ChannelsViews.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
from enaml.widgets.api import Window, Container, Notebook, Page, PushButton, GroupBox, Form, Label, Field, \
ComboBox
from enaml.stdlib.fields import FloatField, Field
from enaml.layout.api import hbox, vbox, spacer
from enaml.core.api import Looper, Conditional
from DictManagerView import DictManagerView
from widgets import EnumComboBox
import QGL.Channels
import QGL.PulseShapes
from types import FunctionType
psList = [f for f in QGL.PulseShapes.__dict__.values() if isinstance(f, FunctionType)]
from ExpSettingsVal import is_valid_awg_channel_name
enamldef LogicalMarkerChannelView(GroupBox): curView:
attr chan
attr channelLib
attr instrumentLib
attr physicalChannels
physicalChannels << [ch for ch in channelLib.values() if isinstance(ch, QGL.Channels.PhysicalMarkerChannel)]
title := '{} (LogicalMarker)'.format(chan.label)
Form:
Label:
text = 'Physical Chan.'
ComboBox:
items << [c.label for c in physicalChannels]
index = items.index(chan.physChan.label) if (chan.physChan and chan.physChan.label in items) else -1
index ::
chan.physChan = channelLib[selected_item]
Looper:
iterable << sorted(chan.pulseParams.keys())
Label:
text = loop_item
Conditional:
condition = isinstance(chan.pulseParams[loop_item], float) or isinstance(chan.pulseParams[loop_item], int)
FloatField:
value << float(chan.pulseParams[loop_item])
value >> chan.pulseParams[loop_item]
Conditional:
condition = isinstance(chan.pulseParams[loop_item], FunctionType)
ComboBox:
items << [f.__name__ for f in psList]
index << psList.index(chan.pulseParams[loop_item])
index ::
chan.pulseParams[loop_item] = psList[index]
enamldef PhysicalMarkerChannelView(GroupBox): curView:
attr chan
attr channelLib
attr instrumentLib
title := '{} (PhysicalMarker)'.format(chan.label)
Form:
Label:
text = 'Delay (s)'
FloatField:
value := chan.delay
Label:
text = 'Gate Buffer (s)'
FloatField:
value := chan.gateBuffer
Label:
text = 'Min Pulse Width (s)'
FloatField:
value := chan.gateMinWidth
Label:
text = 'AWG'
ComboBox:
items << instrumentLib.AWGs.displayList + instrumentLib.markedInstrs.displayList
index = items.index(chan.instrument) if chan.instrument in items else -1
index ::
chan.instrument = selected_item
chan.translator = instrumentLib[selected_item].translator
chan.samplingRate = instrumentLib[selected_item].samplingRate
enamldef PhysicalQuadratureChannelView(GroupBox): curView:
attr chan
attr channelLib
attr instrumentLib
title := '{} (PhysicalQuadrature)'.format(chan.label)
Form:
Label:
text = 'AWG'
ComboBox:
items << instrumentLib.AWGs.displayList
index = items.index(chan.instrument) if chan.instrument in items else -1
index ::
chan.instrument = selected_item
chan.translator = instrumentLib[selected_item].translator
chan.samplingRate = instrumentLib[selected_item].samplingRate
Label:
text = 'Source'
ComboBox:
items << [''] + instrumentLib.sources.displayList
index = items.index(chan.generator) if chan.generator in items else 0
index ::
chan.generator = selected_item
Label:
text = 'Delay (s)'
FloatField:
value := chan.delay
Label:
text = 'Amp. Factor'
FloatField:
value := chan.ampFactor
Label:
text = 'Phase Skew (deg.)'
FloatField:
value := chan.phaseSkew
enamldef ReceiverChannelView(GroupBox): curView:
attr chan
attr channelLib
attr instrumentLib
title := '{} (ReceiverChannel)'.format(chan.label)
Form:
Label:
text = 'Receiver'
ComboBox:
items << instrumentLib.markedInstrs.displayList
index = items.index(chan.instrument) if chan.instrument in items else -1
index ::
chan.instrument = selected_item
Label:
text = 'Channel'
Field:
text := chan.channel
enamldef LogicalQuadratureView(GroupBox): curView:
attr chan
attr channelLib
attr physicalChannels
physicalChannels << [ch for ch in channelLib.values() if isinstance(ch, QGL.Channels.PhysicalQuadratureChannel)]
attr logicalMarkerChannels
logicalMarkerChannels << [ch for ch in channelLib.values() if isinstance(ch, QGL.Channels.LogicalMarkerChannel)]
attr qubits
qubits << [ch for ch in channelLib.values() if isinstance(ch, QGL.Channels.Qubit)]
attr receivers
receivers << [ch for ch in channelLib.values() if isinstance(ch, QGL.Channels.ReceiverChannel)]
title := '{} ({})'.format(chan.label, chan.__class__.__name__)
Form:
Conditional:
condition = isinstance(chan, QGL.Channels.Measurement)
Label:
text = 'Type'
EnumComboBox:
obj := chan
enumName = 'measType'
Conditional:
condition << chan.measType == 'autodyne'
Label:
text = 'Autodyne Freq. (MHz)'
FloatField:
value << chan.autodyneFreq/1e6
value :: chan.autodyneFreq = value*1e6
tool_tip = chan.get_member('autodyneFreq').metadata["desc"]
Label:
text = 'Trigger Chan.'
ComboBox:
items << [''] + [c.label for c in logicalMarkerChannels]
index = items.index(chan.trigChan.label)
index ::
chan.trigChan = channelLib[selected_item]
Label:
text = 'Receiver Chan.'
ComboBox:
items << [c.label for c in receivers]
index = items.index(chan.receiverChan.label) if chan.receiverChan else -1
index ::
chan.receiverChan = channelLib[selected_item]
Conditional:
condition = isinstance(chan, QGL.Channels.Edge)
Label:
text = 'Source Qubit'
ComboBox:
items << [c.label for c in qubits]
index = items.index(chan.source.label) if chan.source else -1
index ::
chan.source = channelLib[selected_item]
Label:
text = 'Target Qubit'
ComboBox:
items << [c.label for c in qubits]
index = items.index(chan.target.label) if chan.target else -1
index ::
chan.target = channelLib[selected_item]
Label:
text = 'Frequency (MHz)'
FloatField:
value << chan.frequency/1e6
value :: chan.frequency = value*1e6
tool_tip = chan.get_member('frequency').metadata["desc"]
Label:
text = 'Physical Chan.'
ComboBox:
items << [c.label for c in physicalChannels]
index = items.index(chan.physChan.label) if (chan.physChan and chan.physChan.label in items) else -1
index ::
chan.physChan = channelLib[selected_item]
Label:
text = 'Gate Chan.'
ComboBox:
items << [''] + [c.label for c in logicalMarkerChannels]
index = items.index(chan.gateChan.label) if chan.gateChan else 0
index ::
chan.gateChan = channelLib[selected_item] if selected_item else ""
Looper:
iterable << sorted(chan.pulseParams.keys())
Label:
text = loop_item
Conditional:
condition = isinstance(chan.pulseParams[loop_item], float) or isinstance(chan.pulseParams[loop_item], int)
FloatField:
value << float(chan.pulseParams[loop_item])
value >> chan.pulseParams[loop_item]
Conditional:
condition = isinstance(chan.pulseParams[loop_item], FunctionType)
ComboBox:
items << [f.__name__ for f in psList]
index << psList.index(chan.pulseParams[loop_item])
index ::
chan.pulseParams[loop_item] = psList[index]
enamldef EmptyChannelView(Container):
attr chan
attr channelLib
attr instrumentLib
ChannelViewMap = {
type(None): EmptyChannelView,
QGL.Channels.Qubit: LogicalQuadratureView,
QGL.Channels.Measurement: LogicalQuadratureView,
QGL.Channels.Edge: LogicalQuadratureView,
QGL.Channels.LogicalMarkerChannel: LogicalMarkerChannelView,
QGL.Channels.PhysicalQuadratureChannel: PhysicalQuadratureChannelView,
QGL.Channels.PhysicalMarkerChannel: PhysicalMarkerChannelView,
QGL.Channels.ReceiverChannel : ReceiverChannelView
}
enamldef ChannelLibraryView(Container): channelLibCont:
attr channelLib
attr logicalChannelManager
attr physicalChannelManager
attr instrumentLib
Notebook:
tab_style = 'preferences'
Page:
title = 'Logical'
closable = False
DictManagerView:
dictManager = logicalChannelManager
modelName = 'chan'
viewMap = ChannelViewMap
viewkwargs = {'channelLib': channelLib}
Page:
title = "Physical"
closable = False
DictManagerView:
dictManager = physicalChannelManager
modelName = 'chan'
viewMap = ChannelViewMap
viewkwargs = {'instrumentLib': instrumentLib,
'channelLib': channelLib}
labelValidator = is_valid_awg_channel_name
enamldef ChannelLibraryWindow(Window): channelLibWin:
attr channelLib
attr instrumentLib
title = 'Channel Library'
Container:
ChannelLibraryView:
channelLib = channelLibWin.channelLib
instrumentLib = channelLibWin.instrumentLib