File: core_messages.py

package info (click to toggle)
python-rpcq 3.11.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 300 kB
  • sloc: python: 1,525; makefile: 3
file content (1173 lines) | stat: -rw-r--r-- 31,481 bytes parent folder | download
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
#!/usr/bin/env python

"""
WARNING: This file is auto-generated, do not edit by hand. See README.md.
"""

import sys

from warnings import warn
from rpcq._base import Message
from typing import Any, List, Dict, Optional

if sys.version_info < (3, 7):
    from rpcq.external.dataclasses import dataclass, field, InitVar
else:
    from dataclasses import dataclass, field, InitVar

from rpcq.messages import *

@dataclass(eq=False, repr=False)
class Frame(Message):
    """
    A frame encapsulates any rotating frame
      relative to which control or readout waveforms may be defined.
    """

    direction: str
    """'rx' or 'tx'"""

    sample_rate: float
    """The sample rate [Hz] of the associated AWG/ADC"""

    frequency: float
    """The frame frequency [Hz]"""


@dataclass(eq=False, repr=False)
class Resources(Message):
    """
    The resources required by a job
    """

    qubits: List[str] = field(default_factory=list)
    """A list of qubits blocked/required by a job."""

    frames: Dict[str, Frame] = field(default_factory=dict)
    """RF/UHF frames by label."""

    frames_to_controls: Dict[str, str] = field(default_factory=dict)
    """Mapping of frames to control channels by labels."""


@dataclass(eq=False, repr=False)
class AbstractWaveform(Message):
    """
    A waveform envelope defined for a specific frame. This abstract class is made concrete by either a `Waveform` or a templated waveform such as `GaussianWaveform`
    """

    frame: str
    """The label of the associated tx-frame."""


@dataclass(eq=False, repr=False)
class Waveform(AbstractWaveform):
    """
    A waveform envelope defined by specific IQ values for a specific frame.
    """

    iqs: List[float] = field(default_factory=list)
    """The raw waveform envelope samples, alternating I and Q values."""


@dataclass(eq=False, repr=False)
class TemplateWaveform(AbstractWaveform):
    """
    A waveform envelope defined for a specific frame. A templated waveform is defined by a parameterized pulseshape rather than explicit IQ values. The message specification does not enforce that the duration is implementable on the hardware.
    """

    duration: float
    """Length of the pulse in seconds"""

    scale: float = 1.e+0
    """Scale to apply to waveform envelope"""

    phase: float = 0.0e+0
    """Phase [units of tau=2pi] to rotate the complex waveform envelope."""

    detuning: float = 0.0e+0
    """Modulation to apply to the waveform in Hz"""


@dataclass(eq=False, repr=False)
class GaussianWaveform(TemplateWaveform):
    """
    A Gaussian shaped waveform envelope defined for a specific frame.
    """

    fwhm: Optional[float] = None
    """Full Width Half Max shape paramter in seconds"""

    t0: Optional[float] = None
    """Center time coordinate of the shape in seconds. Defaults to mid-point of pulse."""


@dataclass(eq=False, repr=False)
class DragGaussianWaveform(TemplateWaveform):
    """
    A DRAG Gaussian shaped waveform envelope defined for a specific frame.
    """

    fwhm: Optional[float] = None
    """Full Width Half Max shape paramter in seconds"""

    t0: Optional[float] = None
    """Center time coordinate of the shape in seconds. Defaults to mid-point of pulse."""

    anh: float = -2.1e+8
    """Anharmonicity of the qubit, f01-f12 in (Hz)"""

    alpha: float = 0.0e+0
    """Dimensionless DRAG parameter"""


@dataclass(eq=False, repr=False)
class HermiteGaussianWaveform(TemplateWaveform):
    """
    Hermite-Gaussian shaped pulse. Reference: Effects of arbitrary laser
      or NMR pulse shapes on population inversion and coherence Warren S. Warren.
      81, (1984); doi: 10.1063/1.447644
    """

    fwhm: Optional[float] = None
    """Full Width Half Max shape paramter in seconds"""

    t0: float = 0.0e+0
    """Center time coordinate of the shape in seconds. Defaults to mid-point of pulse."""

    anh: float = -2.1e+8
    """Anharmonicity of the qubit, f01-f12 in Hz"""

    alpha: float = 0.0e+0
    """Dimensionless DRAG parameter"""

    second_order_hrm_coeff: float = 9.56e-1
    """Second order coefficient (see paper)"""


@dataclass(eq=False, repr=False)
class ErfSquareWaveform(TemplateWaveform):
    """
    Pulse with a flat top and rounded shoulders given by error functions
    """

    risetime: float = 1.e-9
    """The width of the rise and fall sections in seconds."""

    pad_left: float = 0.0e+0
    """Length of zero-amplitude padding before the pulse in seconds."""

    pad_right: float = 0.0e+0
    """Length of zero-amplitude padding after the pulse in seconds."""


@dataclass(eq=False, repr=False)
class FlatWaveform(TemplateWaveform):
    """
    Flat pulse.
    """

    iq: List[float] = field(default_factory=list)
    """Individual IQ point to hold constant"""


@dataclass(eq=False, repr=False)
class AbstractKernel(Message):
    """
    An integration kernel defined for a specific frame. This abstract class is made concrete by either a `FilterKernel` or `TemplateKernel`
    """

    frame: str
    """The label of the associated rx-frame."""


@dataclass(eq=False, repr=False)
class FilterKernel(AbstractKernel):
    """
    A filter kernel to produce scalar readout features from acquired readout waveforms.
    """

    iqs: List[float] = field(default_factory=list)
    """The raw kernel coefficients, alternating real and imaginary parts."""

    bias: float = 0.0e+0
    """The kernel is offset by this real value. Can be used to ensure the decision threshold lies at 0.0."""


@dataclass(eq=False, repr=False)
class TemplateKernel(AbstractKernel):
    """
    An integration kernel defined for a specific frame.
    """

    duration: float
    """Length of the boxcar kernel in seconds"""

    bias: float = 0.0e+0
    """The kernel is offset by this real value. Can be used to ensure the decision threshold lies at 0.0."""

    scale: float = 1.e+0
    """Scale to apply to boxcar kernel"""

    phase: float = 0.0e+0
    """Phase [units of tau=2pi] to rotate the kernel by."""

    detuning: float = 0.0e+0
    """Modulation to apply to the filter kernel in Hz"""


@dataclass(eq=False, repr=False)
class FlatKernel(TemplateKernel):
    """
    An unnormalized flat or boxcar integration kernel.
    """


@dataclass(eq=False, repr=False)
class BoxcarAveragerKernel(TemplateKernel):
    """
    A normalized flat or boxcar integration kernel.
    """


@dataclass(eq=False, repr=False)
class FilterNode(Message):
    """
    A node in the filter pipeline.
    """

    module: str
    """Absolute python module import path in which the filter
          class is defined."""

    filter_type: str
    """The type (class name) of the filter."""

    source: str
    """Filter node label of the input to this node."""

    publish: bool
    """If True, return the output of this node with the job
          results (and publish a stream for it)."""

    params: Dict[str, float] = field(default_factory=dict)
    """Additional filter parameters."""


@dataclass(eq=False, repr=False)
class DataAxis(Message):
    """
    A data axis allows to label element(s) of a stream.
    """

    name: str
    """Label for the axis, e.g., 'time' or 'shot_index'."""

    points: List[float] = field(default_factory=list)
    """The sequence of values along the axis."""


@dataclass(eq=False, repr=False)
class Receiver(Message):
    """
    The receiver settings generated by the low-level
      translator.
    """

    instrument: str
    """The instrument name"""

    channel: str
    """The instrument channel (label)"""

    stream: str
    """Name of the associated (raw) output stream that
          should be published."""

    publish: bool
    """Whether to publish the raw output stream."""

    data_axes: List[DataAxis] = field(default_factory=list)
    """Ordered list of DataAxis objects that together
          uniquely label each element in the stream."""


@dataclass(eq=False, repr=False)
class ParameterExpression(Message):
    """
    A parametric expression.
    """

    operator: str
    """The operator '+', '-', '*'. The operands can be
          constant floating point numbers or strings referencing a dynamic
          program parameter or a ParameterAref to index into an array or
          itself a ParameterExpression."""

    a: Any
    """The first operand"""

    b: Any
    """The second operand"""


@dataclass(eq=False, repr=False)
class Instruction(Message):
    """
    An instruction superclass.
    """

    time: float
    """The time at which the instruction is emitted [in seconds]."""


@dataclass(eq=False, repr=False)
class DebugMessage(Instruction):
    """
    Instructs the target to emit a specified debug message.
    """

    frame: str
    """The frame label that owns this debug message."""

    message: int
    """The 2-byte wide debug message to emit."""


@dataclass(eq=False, repr=False)
class Pulse(Instruction):
    """
    Instruction to play a pulse with some (modified) waveform
      envelope at a specific time on a specific frame.
    """

    frame: str
    """The tx-frame label on which the pulse is played."""

    waveform: str
    """The waveform label"""

    scale: Optional[float] = 1.e+0
    """Dimensionless (re-)scaling factor which is applied to
          the envelope."""

    phase: float = 0.0e+0
    """Static phase angle [units of tau=2pi] by which the
          envelope quadratures are rotated."""

    detuning: float = 0.0e+0
    """Detuning [Hz] with which the pulse envelope should be
          modulated relative to the frame frequency."""


@dataclass(eq=False, repr=False)
class FlatPulse(Instruction):
    """
    Instruction to play a pulse with a constant amplitude
      (except for phase modulation) at a specific time on a specific frame.
    """

    frame: str
    """The tx-frame label on which the pulse is played."""

    iq: List[float]
    """The I and Q value of the constant pulse."""

    duration: float
    """The duration of the pulse in [seconds], should be a
          multiple of the associated tx-frame's inverse sample rate."""

    phase: float = 0.0e+0
    """Static phase angle [units of tau=2pi] by which the
          envelope quadratures are rotated."""

    detuning: float = 0.0e+0
    """Detuning [Hz] with which the pulse envelope should be
          modulated relative to the frame frequency."""

    scale: Optional[float] = 1.e+0
    """Dimensionless (re-)scaling factor which is applied to
          the envelope."""


@dataclass(eq=False, repr=False)
class SetPhase(Instruction):
    """
    Set the phase of a frame to an absolute value at a specific
      time.
    """

    frame: str
    """The frame label for which to set the phase."""

    phase: float = 0.0e+0
    """Phase angle [units of tau=2pi] to update the frame phase
          to."""


@dataclass(eq=False, repr=False)
class ShiftPhase(Instruction):
    """
    Shift the phase of a frame by a relative value at a
      specific time.
    """

    frame: str
    """The frame label for which to set the phase."""

    delta: Any = None
    """Phase angle [units of tau=2pi] by which to shift the
          frame phase.  Can be a numerical value, a ParameterExpression or a
          ParameterAref."""


@dataclass(eq=False, repr=False)
class SwapPhases(Instruction):
    """
    Swap the phases of two tx-frames at a specific time.
    """

    frame_a: str
    """The first frame's label."""

    frame_b: str
    """The second frame's label."""


@dataclass(eq=False, repr=False)
class SetFrequency(Instruction):
    """
    Set the frequency of a tx-frame to a specific value at a
      specific time.
    """

    frame: str
    """The frame label for which to set the frequency."""

    frequency: float = 0.0e+0
    """The frequency [Hz] to set the frame frequency to."""


@dataclass(eq=False, repr=False)
class ShiftFrequency(Instruction):
    """
    Shift the frequency of a tx-frame by a specific amount at a
      specific time.
    """

    frame: str
    """The frame label for which to set the frequency."""

    delta: float = 0.0e+0
    """Frequency shift (new-old) [Hz] to apply to the frame
          frequency."""


@dataclass(eq=False, repr=False)
class SetScale(Instruction):
    """
    Set the scale of a tx-frame to a value at a specific time.
    """

    frame: str
    """The frame label for which to set the scale."""

    scale: float = 1.e+0
    """Scale (unitless) to apply to waveforms generated on the frame."""


@dataclass(eq=False, repr=False)
class Capture(Instruction):
    """
    Specify an acquisition on an rx-frame as well as the
      filters to apply.
    """

    frame: str
    """The rx-frame label on which to trigger the acquisition."""

    duration: float
    """The duration of the acquisition in [seconds]"""

    filters: List[str] = field(default_factory=list)
    """An ordered list of labels of filter kernels to apply to
          the captured waveform."""

    send_to_host: bool = True
    """Transmit the readout bit back to Lodgepole.
          (Unnecessary for fully calibrated active reset captures)."""

    phase: float = 0.0e+0
    """Static phase angle [units of tau=2pi] by which the
          envelope quadratures are rotated."""

    detuning: float = 0.0e+0
    """Detuning [Hz] with which the pulse envelope should be
          modulated relative to the frame frequency."""


@dataclass(eq=False, repr=False)
class MNIOConnection(Message):
    """
    Description of one side of an MNIO connection between two Tsunamis.
    """

    port: int
    """The physical Tsunami MNIO port, indexed from 0, 
          where this connection originates."""

    destination: str
    """The Tsunami where this connection terminates."""


@dataclass(eq=False, repr=False)
class Program(Message):
    """
    The dynamic aspects (waveforms, readout kernels, scheduled
  instructions and parameters) of a job.
    """

    waveforms: Dict[str, AbstractWaveform] = field(default_factory=dict)
    """The waveforms appearing in the program by waveform
          label."""

    filters: Dict[str, AbstractKernel] = field(default_factory=dict)
    """The readout filter kernels appearing in the program by
          feature label."""

    scheduled_instructions: List[Instruction] = field(default_factory=list)
    """The ordered sequence of scheduled instruction objects."""

    parameters: Dict[str, ParameterSpec] = field(default_factory=dict)
    """A mapping of dynamic parameter names to their type
          specification."""


@dataclass(eq=False, repr=False)
class ScheduleIRJob(Message):
    """
    The unit of work to be executed.
    """

    num_shots: int
    """How many repetitions the job should be executed for."""

    resources: Resources
    """The resources required by the job."""

    program: Program
    """The actual program to be executed."""

    operating_point: Dict[str, Dict] = field(default_factory=dict)
    """Operating points or static instrument channel settings
          (mapping control_name (instrument name) -> instrument channel settings
          (instrument settings) dictionary)."""

    filter_pipeline: Dict[str, FilterNode] = field(default_factory=dict)
    """The filter pipeline. Mapping of node labels to
          FilterNode's."""

    job_id: InitVar[Optional[str]] = None
    """A unique ID to help the submitter track the job."""

    def _extend_by_deprecated_fields(self, d):
        super()._extend_by_deprecated_fields(d)

    def __post_init__(self, job_id):
        if job_id is not None:
            warn('job_id is deprecated; please don\'t set it anymore')


@dataclass(eq=False, repr=False)
class RackMeta(Message):
    """
    Meta information about a rack configuration.
    """

    rack_id: Optional[str] = None
    """A unique identifier for the rack."""

    rack_version: Optional[int] = None
    """A version of the rack configuration."""

    schema_version: int = 0
    """A version of the rack configuration."""


@dataclass(eq=False, repr=False)
class QPU(Message):
    """
    Configuration info for the QPU
    """

    chip_label: str
    """The fabrication label for the QPU chip."""

    qubits: List[str] = field(default_factory=list)
    """A list of qubits labels."""

    controls: Dict[str, List] = field(default_factory=dict)
    """A mapping of control labels to tuples (instrument
          label, channel label)."""

    controls_by_qubit: Dict[str, List] = field(default_factory=dict)
    """A map of qubit label to list of controls that should be
          considered blocked when the qubit is part of a job execution."""


@dataclass(eq=False, repr=False)
class Instrument(Message):
    """
    Instrument settings.
    """

    address: str
    """The full address of a QPU."""

    module: str
    """Full python import path for the module that includes
          the instrument driver."""

    instrument_type: str
    """Instrument type (driver class name)."""

    mnio_connections: Dict[str, MNIOConnection] = field(default_factory=dict)
    """MNIO network connections between Tsunami instruments"""

    channels: Dict[str, Any] = field(default_factory=dict)
    """Mapping of channel labels to channel settings"""

    virtual: bool = False
    """Whether the instrument is virtual."""

    setup: Dict[str, Any] = field(default_factory=dict)
    """Any additional information used by the instrument for
          one-time-setup"""


@dataclass(eq=False, repr=False)
class DeployedRack(Message):
    """
    The rack configuration for lodgepole.
    """

    rack_meta: RackMeta
    """Meta information about the deployed rack."""

    qpu: QPU
    """Information about the QPU."""

    instruments: Dict[str, Instrument] = field(default_factory=dict)
    """Mapping of instrument name to instrument settings."""


@dataclass(eq=False, repr=False)
class AWGChannel(Message):
    """
    Configuration of a single RF channel.
    """

    sample_rate: float
    """The sampling rate [Hz] of the associated DAC/ADC
          component."""

    direction: str
    """'rx' or 'tx'"""

    lo_frequency: Optional[float] = None
    """The local oscillator frequency [Hz] of the channel."""

    gain: Optional[float] = None
    """If there is an amplifier, the amplifier gain [dB]."""

    delay: float = 0.0e+0
    """Delay [seconds] to account for inter-channel skew."""


@dataclass(eq=False, repr=False)
class QFDChannel(Message):
    """
    Configuration for a single QFD Channel.
    """

    channel_index: int
    """The channel index on the QFD, zero indexed from the
          lowest channel, as installed in the box."""

    direction: Optional[str] = "tx"
    """The QFD is a device that transmits pulses."""

    nco_frequency: Optional[float] = 0.0e+0
    """The DAC NCO frequency [Hz]."""

    gain: Optional[float] = 0.0e+0
    """The output gain on the DAC in [dB]. Note that this
          should be in the range -45dB to 0dB and is rounded to the
          nearest 3dB step."""

    delay: float = 0.0e+0
    """Delay [seconds] to account for inter-channel skew."""

    flux_current: Optional[float] = None
    """Flux current [Amps]."""

    relay_closed: Optional[bool] = None
    """Set the state of the Flux relay.
          True  - Relay closed, allows flux current to flow.
          False - Relay open, no flux current can flow."""


@dataclass(eq=False, repr=False)
class QGSChannel(Message):
    """
    Configuration for a single QGS Channel.
    """

    direction: Optional[str] = "tx"
    """The QGS is a device that transmits pulses."""

    nco_frequency: Optional[float] = 2.e+9
    """The DAC NCO frequency [Hz]."""

    gain: Optional[float] = 0.0e+0
    """The output gain on the DAC in [dB]. Note that this
          should be in the range -45dB to 0dB and is rounded to the
          nearest 3dB step."""

    channel_index: Optional[int] = 0
    """The channel index on the QGS, zero indexed from the lowest channel,
        as installed in the box."""

    delay: float = 0.0e+0
    """Delay [seconds] to account for inter-channel skew."""


@dataclass(eq=False, repr=False)
class QRTChannel(Message):
    """
    Configuration for a single QRT Channel.
    """

    direction: Optional[str] = "tx"
    """The QRT is a device that transmits readout pulses."""

    nco_frequency: Optional[float] = 1.25e+9
    """The DAC NCO frequency [Hz]."""

    gain: Optional[float] = 0.0e+0
    """The output gain on the DAC in [dB]. Note that this should be in the range
       -45dB to 0dB and is rounded to the nearest 3dB step."""

    channel_index: Optional[int] = 0
    """The channel index on the QRT, zero indexed from the lowest channel,
        as installed in the box."""

    delay: float = 0.0e+0
    """Delay [seconds] to account for inter-channel skew."""


@dataclass(eq=False, repr=False)
class QRRChannel(Message):
    """
    Configuration for a single QRR Channel.
    """

    channel_index: int
    """The channel index on the QRR, zero indexed from the lowest channel,
        as installed in the box."""

    direction: Optional[str] = "rx"
    """The QRR is a device that receives readout pulses."""

    nco_frequency: Optional[float] = 0.0e+0
    """The ADC NCO frequency [Hz]."""

    gain: Optional[float] = 0.0e+0
    """The input gain on the ADC in [dB]. Note that this should be in the range
       -45dB to 0dB and is rounded to the nearest 3dB step."""

    delay: float = 0.0e+0
    """Delay [seconds] to account for inter-channel skew."""


@dataclass(eq=False, repr=False)
class CWChannel(Message):
    """
    Configuration for a single CW Generator Channel.
    """

    channel_index: int = 0
    """The zero-indexed channel of the generator's output."""

    rf_output_frequency: Optional[int] = 1000000000
    """The CW generator's output frequency [Hz]."""

    rf_output_power: Optional[float] = 0.0e+0
    """The power of CW generator's output [dBm]."""

    rf_output_enabled: Optional[bool] = True
    """The state (on/off) of CW generator's output."""


@dataclass(eq=False, repr=False)
class QDOSlowFluxChannel(Message):
    """
    Configuration for a single QDO Slow Flux Channel.
    """

    channel_index: int
    """The channel index on the QDO, zero indexed from the
          lowest channel, as installed in the box. Flux index typically starts at 4."""

    flux_current: Optional[float] = None
    """Flux current [Amps]."""

    relay_closed: Optional[bool] = False
    """Set the state of the Flux relay.
          True  - Relay closed, allows flux current to flow.
          False - Relay open, no flux current can flow."""


@dataclass(eq=False, repr=False)
class QDOFastFluxChannel(Message):
    """
    Configuration for a single QDO Fast Flux Channel.
    """

    channel_index: int
    """The channel index on the QDO, zero indexed from the
          lowest channel, as installed in the box."""

    direction: Optional[str] = "tx"
    """The QDO is a device that transmits pulses."""

    delay: float = 0.0e+0
    """Delay [seconds] to account for inter-channel skew."""

    flux_current: Optional[float] = None
    """Flux current [Amps]."""


@dataclass(eq=False, repr=False)
class YokogawaGS200Channel(Message):
    """
    Configuration for a single Yokogawa GS200 Channel.
    """


@dataclass(eq=False, repr=False)
class LegacyUSRPSequencer(Message):
    """
    Configuration for a Legacy USRP Sequencer
    """

    tx_channel: Optional[str] = None
    """The label of the associated tx channel."""

    rx_channel: Optional[str] = None
    """The label of the associated rx channel."""


@dataclass(eq=False, repr=False)
class QFDSequencer(Message):
    """
    Configuration for a single QFD Sequencer.
    """

    tx_channel: str
    """The label of the associated channel."""

    sequencer_index: int
    """The sequencer index of this sequencer."""


@dataclass(eq=False, repr=False)
class QDOSequencer(Message):
    """
    Configuration for a single QDO Sequencer.
    """

    tx_channel: str
    """The label of the associated channel."""

    sequencer_index: int
    """The sequencer index of this sequencer."""


@dataclass(eq=False, repr=False)
class QFDx2Sequencer(Message):
    """
    Configuration for a single QFDx2 Sequencer.
    """

    tx_channel: str
    """The label of the associated channel."""

    sequencer_index: int
    """The sequencer index of this sequencer."""


@dataclass(eq=False, repr=False)
class QGSSequencer(Message):
    """
    Configuration for a single QGS Sequencer.
    """

    tx_channel: str
    """The label of the associated channel."""

    sequencer_index: int
    """The sequencer index of this sequencer."""


@dataclass(eq=False, repr=False)
class QGSx2Sequencer(Message):
    """
    Configuration for a single QGSx2 Sequencer.
    """

    tx_channel: str
    """The label of the associated channel."""

    sequencer_index: int
    """The sequencer index of this sequencer."""


@dataclass(eq=False, repr=False)
class QRTSequencer(Message):
    """
    Configuration for a single readout transmit (QRT) sequencer.
    """

    tx_channel: str
    """The label of the associated tx channel."""

    sequencer_index: int
    """The sequencer index (0-7) of this sequencer."""

    low_freq_range: Optional[bool] = False
    """Used to signal if this sequencer is in the low frequency configuration."""


@dataclass(eq=False, repr=False)
class QRTx2Sequencer(Message):
    """
    Configuration for a dual readout transmit (QRTx2) sequencer.
    """

    tx_channel: str
    """The label of the associated tx channel."""

    sequencer_index: int
    """The sequencer index (0-15) of this sequencer."""

    low_freq_range: Optional[bool] = False
    """Used to signal if this sequencer is in the low frequency configuration."""


@dataclass(eq=False, repr=False)
class QRRSequencer(Message):
    """
    Configuration for a single readout receive (QRR) sequencer.
    """

    rx_channel: str
    """The label of the associated rx channel."""

    sequencer_index: int
    """The sequencer index (0-15) to assign. Note that only
         sequencer 0 can return raw readout measurements."""


@dataclass(eq=False, repr=False)
class USICardSequencer(Message):
    """
    Configuration for the card which
      interfaces with the USI Target on the USRP.
    """

    tx_channel: str
    """The label of the associated channel."""


@dataclass(eq=False, repr=False)
class USITargetSequencer(Message):
    """
    Configuration for a single USITarget Sequencer.
    """

    tx_channel: str
    """The label of the associated intial tx channel."""

    rx_channel: str
    """The label of the associated initial rx channel."""

    sequencer_index: int
    """The sequencer index (0-7) to assign. Note that only
           sequencer 0 has the ability to use the NCO or capture raw readout
           streams."""


@dataclass(eq=False, repr=False)
class CWFrequencySweep(Message):
    """
    Configuration of a continuous wave frequency sweep.
    """

    start: float
    """Start frequency of the sweep, in Hz"""

    stop: float
    """Stop frequency of the sweep, in Hz"""

    num_pts: int
    """Number of frequency points to sample, cast to int."""

    source: int
    """Source port number"""

    measure: int
    """Measure port number"""


@dataclass(eq=False, repr=False)
class VNASettings(Message):
    """
    Configuration of VNA settings for a continuous wave sweep.
    """

    e_delay: float
    """Electrical delay in seconds from source to measure port"""

    phase_offset: float
    """Phase offset in degrees from measured to reported phase"""

    bandwidth: float
    """Bandwidth of the sweep, in Hz"""

    power: float
    """Source power in dBm"""

    freq_sweep: CWFrequencySweep
    """Frequency sweep settings"""

    averaging: int = 1
    """Sets the number of points to combine into an averaged
          trace"""


@dataclass(eq=False, repr=False)
class TimeBomb(Message):
    """
    Payload used to match a job with a particular execution
      target.
    """

    deadline: str
    """Deadline, specified in the format
          '%Y-%m-%dT%H:%M:%S.000Z', after which this job becomes unexecutable."""

    chip_label: str
    """Label string for the chip on which this job is meant to
          execute."""


@dataclass(eq=False, repr=False)
class MicrowaveSourceSettings(Message):
    """
    Configuration of Microwave Source settings for operating amplifiers.
    """

    frequency: float
    """Frequency setting for microwave source (Hz)."""

    power: float
    """Power setting for microwave source (dBm)."""

    output: bool
    """Output setting for microwave source. If true, the source will be turned on."""


@dataclass(eq=False, repr=False)
class ExecutorJob(Message):
    """
    Job which is sent directly to the executor
    """

    instrument_settings: Dict[str, Any]
    """Dict mapping instrument names to arbitrary instrument
          settings."""

    filter_pipeline: Dict[str, FilterNode]
    """The filter pipeline to process measured data."""

    receivers: Dict[str, Receiver]
    """Dict mapping stream names to receiver settings."""

    duration: Optional[float] = None
    """The total duration of the program execution in seconds."""

    timebomb: Optional[TimeBomb] = None
    """An optional payload used to match this job with a
          particular execution target."""


@dataclass(eq=False, repr=False)
class PatchableBinary(Message):
    """
    Tsunami binary with patching metadata for classical
      parameter modification.
    """

    base_binary: Any
    """Raw Tsunami binary object."""

    patch_table: Dict[str, PatchTarget]
    """Dictionary mapping patch names to their memory
          descriptors."""


@dataclass(eq=False, repr=False)
class ActiveReset(Message):
    """
    An active reset control sequence consisting of a repeated
      sequence of a measurement block and a feedback block conditional on the
      outcome of a specific measurement bit.  Regardless of the measurement
      outcomes the total duration of the control sequence is [attempts x
      (measurement_duration + feedback_duration)].  The total
      measurement_duration must be chosen to allow for enough time after any
      Capture commands for the measurement bit to propagate back to the gate
      cards that are actuating the feedback.
    """

    time: float
    """Time at which the ActiveReset begins in [seconds]."""

    measurement_duration: float
    """The duration of measurement block in [seconds]. The
          measurement bit is expected to have arrived on the QGS after
          this time relative to the overall start of the ActiveReset block."""

    feedback_duration: float
    """The duration of feedback block in [seconds]"""

    measurement_bit: int
    """The address of the readout bit to condition the
          feedback on.  The bit is first accessed after measurement_duration
          has elapsed."""

    attempts: int = 3
    """The number of times to repeat the active reset sequence."""

    measurement_instructions: List[Dict] = field(default_factory=list)
    """The ordered sequence of scheduled measurement
          instructions."""

    apply_feedback_when: bool = True
    """Apply the feedback when the measurement_bit equals the
          value of this flag."""

    feedback_instructions: List[Dict] = field(default_factory=list)
    """The ordered sequence of scheduled feedback instructions."""