@@ -61,6 +61,43 @@ use tracing::*;
61
61
62
62
mod events;
63
63
64
+ #[ derive( Debug , Clone ) ]
65
+ pub struct SetSigGenArbitraryProperties {
66
+ pub offset_voltage : i32 , /* microvolts */
67
+ pub pk_to_pk : u32 , /* microvolts */
68
+ pub start_delta_phase : u32 ,
69
+ pub stop_delta_phase : u32 ,
70
+ pub delta_phase_increment : u32 ,
71
+ pub dwell_count : u32 ,
72
+ pub arbitrary_waveform : Vec < i16 > ,
73
+ pub sweep_type : PicoSweepType ,
74
+ pub extra_operations : PicoExtraOperations ,
75
+ pub sweeps_shots : SweepShotCount ,
76
+ pub trig_type : PicoSigGenTrigType ,
77
+ pub trig_source : PicoSigGenTrigSource ,
78
+ pub ext_in_threshold : i16 ,
79
+ }
80
+
81
+ impl Default for SetSigGenArbitraryProperties {
82
+ fn default ( ) -> Self {
83
+ SetSigGenArbitraryProperties {
84
+ offset_voltage : 0 ,
85
+ pk_to_pk : 200_000 ,
86
+ start_delta_phase : 0 ,
87
+ stop_delta_phase : 0 ,
88
+ delta_phase_increment : 0 ,
89
+ dwell_count : 1 ,
90
+ arbitrary_waveform : vec ! [ 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 ] ,
91
+ sweep_type : PicoSweepType :: Up ,
92
+ extra_operations : PicoExtraOperations :: Off ,
93
+ sweeps_shots : SweepShotCount :: None ,
94
+ trig_type : PicoSigGenTrigType :: Rising ,
95
+ trig_source : PicoSigGenTrigSource :: None ,
96
+ ext_in_threshold : 0 ,
97
+ }
98
+ }
99
+ }
100
+
64
101
#[ cfg_attr( feature = "serde" , derive( serde:: Serialize ) ) ]
65
102
#[ derive( Debug , Clone , Copy ) ]
66
103
enum Target {
@@ -556,7 +593,7 @@ impl PicoStreamingDevice {
556
593
pub fn sig_gen_software_control (
557
594
& self ,
558
595
state : i16 ,
559
- ) {
596
+ ) -> PicoResult < ( ) > {
560
597
let current_state = self . current_state . write ( ) ;
561
598
let handle = match current_state. clone ( ) {
562
599
State :: Closed => {
@@ -574,7 +611,7 @@ impl PicoStreamingDevice {
574
611
handle
575
612
} ,
576
613
} ;
577
- self . device . driver . sig_gen_software_control ( handle, state) . unwrap ( ) ;
614
+ self . device . driver . sig_gen_software_control ( handle, state)
578
615
}
579
616
580
617
#[ tracing:: instrument( skip( self ) , level = "trace" ) ]
@@ -631,18 +668,11 @@ impl PicoStreamingDevice {
631
668
}
632
669
633
670
#[ tracing:: instrument( skip( self ) , level = "trace" ) ]
634
- pub fn set_sig_gen_arbitrary ( & self ) {
635
- // Start an AWG function -
636
- let offset_voltage: i32 = 0 ;
637
- let pk_to_pk: u32 = 200_000 ;
638
- let start_delta_phase: u32 = 0 ;
639
- let stop_delta_phase: u32 = 0 ;
640
- let delta_phase_increment: u32 = 0 ;
641
- let dwell_count: u32 = 1 ;
642
- let arbitrary_waveform = vec ! [ 1 , 1 , 1 , 1 , 0 , 0 , 0 , 0 ] ;
643
- let sweeps_shots: SweepShotCount = SweepShotCount :: None ;
644
- let ext_in_threshold: i16 = 0 ;
645
-
671
+ pub fn set_sig_gen_arbitrary (
672
+ & self ,
673
+ props : SetSigGenArbitraryProperties ,
674
+ ) -> PicoResult < ( ) > {
675
+ // Start an AWG function
646
676
let current_state = self . current_state . write ( ) ;
647
677
let handle = match current_state. clone ( ) {
648
678
State :: Closed => {
@@ -663,21 +693,21 @@ impl PicoStreamingDevice {
663
693
664
694
self . device . driver . set_sig_gen_arbitrary (
665
695
handle,
666
- offset_voltage,
667
- pk_to_pk,
668
- start_delta_phase,
669
- stop_delta_phase,
670
- delta_phase_increment,
671
- dwell_count,
672
- & arbitrary_waveform,
673
- PicoSweepType :: Up ,
674
- PicoExtraOperations :: Off ,
696
+ props . offset_voltage ,
697
+ props . pk_to_pk ,
698
+ props . start_delta_phase ,
699
+ props . stop_delta_phase ,
700
+ props . delta_phase_increment ,
701
+ props . dwell_count ,
702
+ & props . arbitrary_waveform ,
703
+ props . sweep_type ,
704
+ props . extra_operations ,
675
705
PicoIndexMode :: Single ,
676
- sweeps_shots,
677
- PicoSigGenTrigType :: Rising ,
678
- PicoSigGenTrigSource :: None ,
679
- ext_in_threshold,
680
- ) . unwrap ( ) ;
706
+ props . sweeps_shots ,
707
+ props . trig_type ,
708
+ props . trig_source ,
709
+ props . ext_in_threshold ,
710
+ )
681
711
}
682
712
}
683
713
0 commit comments