pub const FGEN_READ_FREQUENCY: &str = ":SOUR:FREQ?";
pub const SCOPE_READ_TIMEBASE_SCALE: &str = ":TIMebase:SCALe?";
pub const SCOPE_RUN: &str = ":RUN";
pub const SCOPE_STOP: &str = ":STOP";
pub const SCOPE_SINGLE: &str = ":SINGle";
pub const SCOPE_WAVEFORM_FORMAT_ASCII: &str = ":WAVeform:FORMat ASCii";
pub const SCOPE_WAVEFORM_PREAMBLE: &str = ":WAVeform:PREamble?";
pub const SCOPE_WAVEFORM_DATA: &str = ":WAVeform:DATA?";
pub const SWITCH_OPEN_ALL: &str = ":ROUTe:OPEN:ALL";
pub const COUNTER_MEASURE_FREQUENCY: &str = ":MEASure:FREQuency?";
pub const COUNTER_MEASURE_PERIOD: &str = ":MEASure:PERiod?";
pub const COUNTER_RESET_TOTALIZE: &str = ":COUNter:CRESet";
pub const COUNTER_READ_TOTALIZE: &str = ":COUNter:DATA?";
pub const DMM_INITIATE: &str = "INIT";
pub const DMM_FETCH: &str = "FETC?";
pub const DMM_READ: &str = "READ?";
pub const DMM_SOFTWARE_TRIGGER: &str = "*TRG";
pub const PWRMETER_INITIATE: &str = "INIT";
pub const PWRMETER_FETCH: &str = "FETC?";
pub const PWRMETER_READ: &str = "READ?";
pub const PWRMETER_CONFIGURE: &str = ":CONF";
pub const SPECAN_MARKER_PEAK: &str = ":CALC:MARK:MAX";
pub const SPECAN_MARKER_X: &str = ":CALC:MARK:X?";
pub const SPECAN_MARKER_Y: &str = ":CALC:MARK:Y?";
pub const SPECAN_SINGLE_SWEEP: &str = ":INIT:IMM";
pub const SPECAN_WAIT_OPC: &str = "*OPC?";
pub const SPECAN_TRACE_DATA: &str = ":TRAC:DATA? TRACE1";
pub fn dmm_measure_voltage_dc(range: Option<f64>) -> String {
match range {
Some(r) => format!(":MEAS:VOLT:DC? {r}"),
None => ":MEAS:VOLT:DC?".into(),
}
}
pub fn dmm_measure_voltage_ac(range: Option<f64>) -> String {
match range {
Some(r) => format!(":MEAS:VOLT:AC? {r}"),
None => ":MEAS:VOLT:AC?".into(),
}
}
pub fn dmm_measure_current_dc(range: Option<f64>) -> String {
match range {
Some(r) => format!(":MEAS:CURR:DC? {r}"),
None => ":MEAS:CURR:DC?".into(),
}
}
pub fn dmm_measure_current_ac(range: Option<f64>) -> String {
match range {
Some(r) => format!(":MEAS:CURR:AC? {r}"),
None => ":MEAS:CURR:AC?".into(),
}
}
pub fn dmm_measure_resistance(range: Option<f64>) -> String {
match range {
Some(r) => format!(":MEAS:RES? {r}"),
None => ":MEAS:RES?".into(),
}
}
pub fn dmm_measure_resistance_2wire(range: Option<f64>) -> String {
match range {
Some(r) => format!(":MEAS:RES? {r}"),
None => ":MEAS:RES?".into(),
}
}
pub fn dmm_measure_resistance_4wire(range: Option<f64>) -> String {
match range {
Some(r) => format!(":MEAS:FRES? {r}"),
None => ":MEAS:FRES?".into(),
}
}
pub fn dmm_measure_temperature(range: Option<f64>) -> String {
match range {
Some(r) => format!(":MEAS:TEMP? {r}"),
None => ":MEAS:TEMP?".into(),
}
}
pub fn psu_set_voltage(channel: u32, volts: f64) -> String {
format!(":SOUR{channel}:VOLT {volts}")
}
pub fn psu_set_current_limit(channel: u32, amps: f64) -> String {
format!(":SOUR{channel}:CURR {amps}")
}
pub fn psu_output_enable(channel: u32, state: &str) -> String {
format!(":OUTP{channel} {state}")
}
pub fn psu_output_state_query(channel: u32) -> String {
format!(":OUTP{channel}?")
}
pub fn psu_read_voltage(channel: u32) -> String {
format!(":MEAS:VOLT? {channel}")
}
pub fn psu_read_current(channel: u32) -> String {
format!(":MEAS:CURR? {channel}")
}
pub fn psu_ovp_level(channel: u32, volts: f64) -> String {
format!(":SOUR{channel}:VOLT:PROT {volts}")
}
pub fn psu_ovp_enable(channel: u32, state: &str) -> String {
format!(":SOUR{channel}:VOLT:PROT:STAT {state}")
}
pub fn psu_ovp_query(channel: u32) -> String {
format!(":SOUR{channel}:VOLT:PROT:STAT?")
}
pub fn psu_sense_enable(channel: u32, state: &str) -> String {
format!(":OUTP{channel}:SENS {state}")
}
pub fn fgen_set_waveform(scpi_name: &str) -> String {
format!(":SOUR:FUNC {scpi_name}")
}
pub fn fgen_set_frequency(hz: f64) -> String {
format!(":SOUR:FREQ {hz}")
}
pub fn fgen_set_amplitude(vpp: f64) -> String {
format!(":SOUR:VOLT {vpp}")
}
pub fn fgen_set_offset(volts: f64) -> String {
format!(":SOUR:VOLT:OFFS {volts}")
}
pub fn fgen_set_duty_cycle(percent: f64) -> String {
format!(":SOUR:FUNC:SQU:DCYC {percent}")
}
pub fn fgen_set_load(ohms: f64) -> String {
format!(":OUTP:LOAD {ohms}")
}
pub fn fgen_output_enable(state: &str) -> String {
format!(":OUTP {state}")
}
pub fn fgen_burst_count(count: u32) -> String {
format!(":SOUR:BURS:NCYC {count}")
}
pub fn fgen_burst_state(state: &str) -> String {
format!(":SOUR:BURS:STAT {state}")
}
pub fn fgen_burst_trigger(source: &str) -> String {
format!(":TRIG:SOUR {source}")
}
pub fn scope_set_timebase_scale(seconds_per_div: f64) -> String {
format!(":TIMebase:SCALe {seconds_per_div}")
}
pub fn scope_set_channel_scale(channel: u32, volts_per_div: f64) -> String {
format!(":CHANnel{channel}:SCALe {volts_per_div}")
}
pub fn scope_channel_display(channel: u32, state: &str) -> String {
format!(":CHANnel{channel}:DISP {state}")
}
pub fn scope_channel_coupling(channel: u32, coupling: &str) -> String {
format!(":CHANnel{channel}:COUP {coupling}")
}
pub fn scope_trigger_source(source: &str) -> String {
format!(":TRIGger:EDGE:SOURce {source}")
}
pub fn scope_trigger_level(volts: f64) -> String {
format!(":TRIGger:EDGE:LEVel {volts}")
}
pub fn scope_trigger_slope(slope: &str) -> String {
format!(":TRIGger:EDGE:SLOPe {slope}")
}
pub fn scope_measure_vpp(channel: u32) -> String {
format!(":MEASure:VPP? CHAN{channel}")
}
pub fn scope_measure_frequency(channel: u32) -> String {
format!(":MEASure:FREQuency? CHAN{channel}")
}
pub fn scope_set_waveform_source(channel: u32) -> String {
format!(":WAVeform:SOURce CHAN{channel}")
}
pub fn switch_close_route(ch1: u32, ch2: u32) -> String {
format!(":ROUTe:CLOS (@({ch1},{ch2}))")
}
pub fn switch_open_route(ch1: u32, ch2: u32) -> String {
format!(":ROUTe:OPEN (@({ch1},{ch2}))")
}
pub fn switch_is_closed(ch1: u32, ch2: u32) -> String {
format!(":ROUTe:CLOS? (@({ch1},{ch2}))")
}
pub fn counter_gate_time(seconds: f64) -> String {
format!(":SENSe:FREQuency:APERture {seconds}")
}
pub fn counter_channel_select(channel: u32) -> String {
format!(":SENSe:FUNCtion:ON \"FREQ {channel}\"")
}
pub fn pwrmeter_unit(unit: &str) -> String {
format!(":UNIT:POW {unit}")
}
pub fn pwrmeter_auto_range(state: &str) -> String {
format!(":SENS:POW:RANG:AUTO {state}")
}
pub fn pwrmeter_auto_average(state: &str) -> String {
format!(":SENS:AVER:COUN:AUTO {state}")
}
pub fn pwrmeter_correction_frequency(hz: f64) -> String {
format!(":SENS:FREQ {hz}")
}
pub fn pwrmeter_offset(db: f64) -> String {
format!(":SENS:CORR:GAIN2 {db}")
}
pub fn specan_center_frequency(hz: f64) -> String {
format!(":FREQ:CENT {hz}")
}
pub fn specan_span(hz: f64) -> String {
format!(":FREQ:SPAN {hz}")
}
pub fn specan_rbw(hz: f64) -> String {
format!(":BAND {hz}")
}
pub fn specan_vbw(hz: f64) -> String {
format!(":BAND:VID {hz}")
}
pub fn specan_ref_level(dbm: f64) -> String {
format!(":DISP:WIND:TRAC:Y:RLEV {dbm}")
}
pub fn specan_sweep_continuous(state: &str) -> String {
format!(":INIT:CONT {state}")
}
pub fn dmm_configure_voltage_dc(range: Option<f64>, resolution: Option<f64>) -> String {
match (range, resolution) {
(Some(r), Some(res)) => format!(":CONF:VOLT:DC {r},{res}"),
(Some(r), None) => format!(":CONF:VOLT:DC {r}"),
(None, Some(res)) => format!(":CONF:VOLT:DC DEF,{res}"),
(None, None) => ":CONF:VOLT:DC".into(),
}
}
pub fn dmm_configure_voltage_ac(range: Option<f64>, resolution: Option<f64>) -> String {
match (range, resolution) {
(Some(r), Some(res)) => format!(":CONF:VOLT:AC {r},{res}"),
(Some(r), None) => format!(":CONF:VOLT:AC {r}"),
(None, Some(res)) => format!(":CONF:VOLT:AC DEF,{res}"),
(None, None) => ":CONF:VOLT:AC".into(),
}
}
pub fn dmm_configure_current_dc(range: Option<f64>, resolution: Option<f64>) -> String {
match (range, resolution) {
(Some(r), Some(res)) => format!(":CONF:CURR:DC {r},{res}"),
(Some(r), None) => format!(":CONF:CURR:DC {r}"),
(None, Some(res)) => format!(":CONF:CURR:DC DEF,{res}"),
(None, None) => ":CONF:CURR:DC".into(),
}
}
pub fn dmm_configure_current_ac(range: Option<f64>, resolution: Option<f64>) -> String {
match (range, resolution) {
(Some(r), Some(res)) => format!(":CONF:CURR:AC {r},{res}"),
(Some(r), None) => format!(":CONF:CURR:AC {r}"),
(None, Some(res)) => format!(":CONF:CURR:AC DEF,{res}"),
(None, None) => ":CONF:CURR:AC".into(),
}
}
pub fn dmm_configure_resistance(range: Option<f64>, resolution: Option<f64>) -> String {
match (range, resolution) {
(Some(r), Some(res)) => format!(":CONF:RES {r},{res}"),
(Some(r), None) => format!(":CONF:RES {r}"),
(None, Some(res)) => format!(":CONF:RES DEF,{res}"),
(None, None) => ":CONF:RES".into(),
}
}
pub fn dmm_configure_resistance_4wire(range: Option<f64>, resolution: Option<f64>) -> String {
match (range, resolution) {
(Some(r), Some(res)) => format!(":CONF:FRES {r},{res}"),
(Some(r), None) => format!(":CONF:FRES {r}"),
(None, Some(res)) => format!(":CONF:FRES DEF,{res}"),
(None, None) => ":CONF:FRES".into(),
}
}