Skip to content

Commit b4d501c

Browse files
committed
add SetSigGenArbitraryProperties
1 parent d381c30 commit b4d501c

File tree

2 files changed

+59
-28
lines changed

2 files changed

+59
-28
lines changed

driver/src/ps2000a.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ impl PicoDriver for PS2000ADriver {
345345
trigger_source: PicoSigGenTrigSource,
346346
ext_in_threshold: i16,
347347
) -> PicoResult<()> {
348+
tracing::trace!(sweeps = sweeps_shots.to_sweeps(), shots = sweeps_shots.to_shots());
348349
PicoStatus::from(unsafe {
349350
self.bindings.ps2000aSetSigGenBuiltInV2(
350351
handle,

streaming/src/lib.rs

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,43 @@ use tracing::*;
6161

6262
mod events;
6363

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+
64101
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
65102
#[derive(Debug, Clone, Copy)]
66103
enum Target {
@@ -556,7 +593,7 @@ impl PicoStreamingDevice {
556593
pub fn sig_gen_software_control(
557594
&self,
558595
state: i16,
559-
) {
596+
) -> PicoResult<()> {
560597
let current_state = self.current_state.write();
561598
let handle = match current_state.clone() {
562599
State::Closed => {
@@ -574,7 +611,7 @@ impl PicoStreamingDevice {
574611
handle
575612
},
576613
};
577-
self.device.driver.sig_gen_software_control(handle, state).unwrap();
614+
self.device.driver.sig_gen_software_control(handle, state)
578615
}
579616

580617
#[tracing::instrument(skip(self), level = "trace")]
@@ -631,18 +668,11 @@ impl PicoStreamingDevice {
631668
}
632669

633670
#[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
646676
let current_state = self.current_state.write();
647677
let handle = match current_state.clone() {
648678
State::Closed => {
@@ -663,21 +693,21 @@ impl PicoStreamingDevice {
663693

664694
self.device.driver.set_sig_gen_arbitrary(
665695
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,
675705
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+
)
681711
}
682712
}
683713

0 commit comments

Comments
 (0)