ScopeDriverBase#
- class ScopeDriverBase[source]#
Bases:
ABCVendor scope driver contract. Concrete drivers compose a transport (typically
VisaDriver).Channels are 1-indexed analog input numbers throughout — the wrapper instrument (
InstroScope) is responsible for range-checking against the declarednum_channels.Methods
Drain the vendor's error queue; raise
RuntimeErrorif any error is pending.Close the underlying transport.
Arm a single acquisition and block until the trigger fires and the capture completes.
Fetch the most recently acquired waveform from
channel.Force a trigger event immediately, regardless of the configured conditions.
Read back the current acquisition mode.
Read back the acquisition run state (RUNNING / STOPPED).
Read back the waveforms-to-average count.
Read back input coupling on
channel.Read back the timebase (seconds/div).
Read back
channel's probe attenuation ratio.Read back the current sample rate (samples per second).
Read back the trigger status (ARMED / READY / TRIGGERED / …).
Read back
channel's vertical offset (volts).Read back
channel's vertical scale (V/div).Recall a scope setup from
name.Read a built-in measurement (VPP, VMAX, VMIN, VAVG, VRMS, …) on
channel.Open the underlying transport.
Start continuous (free-running) acquisition.
Capture a screenshot.
Save the current scope setup.
Set the acquisition mode.
Set the number of waveforms to average.
Set AC/DC input coupling on
channel.Set the timebase to
seconds_per_div.Set
channel's probe attenuation ratio (e.g. 1, 10, 100, 1000).Set the trigger threshold to
level(volts).Set the trigger sweep mode (AUTO / NORMAL).
Set the trigger edge slope (RISING / FALLING / EITHER).
Set the trigger source to analog
channel.Set the trigger type (EDGE, PULSE, …).
Set
channel's vertical offset tooffset(volts).Set
channel's vertical scale tovolts_per_div(V/div).Ensure a measurement slot exists for
measurement_type/channelbefore the scope triggers.Arm a single-shot acquisition.
Stop acquisition.
- abstractmethod open() None[source]#
Open the underlying transport. Idempotent.
Concrete drivers also perform any one-shot instrument setup here (e.g.
*CLS, remote-mode handshake).
- abstractmethod check_errors() None[source]#
Drain the vendor’s error queue; raise
RuntimeErrorif any error is pending.Used between setup commands and any blocking query — calling a data query while the scope’s error queue holds a syntax error would hang.
- abstractmethod set_vertical_scale( ) None[source]#
Set
channel’s vertical scale tovolts_per_div(V/div).Drivers may snap to the nearest hardware-supported step. Callers that need the actual applied value should
get_vertical_scale()afterward.
- abstractmethod get_vertical_scale(channel: int) float[source]#
Read back
channel’s vertical scale (V/div).
- abstractmethod set_vertical_offset(offset: float, channel: int) None[source]#
Set
channel’s vertical offset tooffset(volts).
- abstractmethod get_vertical_offset(channel: int) float[source]#
Read back
channel’s vertical offset (volts).
- abstractmethod set_probe_attenuation( ) None[source]#
Set
channel’s probe attenuation ratio (e.g. 1, 10, 100, 1000).
- abstractmethod get_probe_attenuation(channel: int) float[source]#
Read back
channel’s probe attenuation ratio.
- abstractmethod set_horizontal_scale(seconds_per_div: float) None[source]#
Set the timebase to
seconds_per_div. Applies globally to all channels.
- abstractmethod get_sample_rate() float[source]#
Read back the current sample rate (samples per second).
This is the effective hardware rate the scope is acquiring at; it depends on the timebase, memory depth, and interpolation settings.
- abstractmethod set_acquisition_mode(
- mode: AcquisitionMode,
Set the acquisition mode.
Drivers should raise
NotImplementedErrorforAcquisitionModevalues their scope doesn’t support (e.g. Keysight 1200X has no ENVELOPE mode).
- abstractmethod get_acquisition_mode() AcquisitionMode[source]#
Read back the current acquisition mode.
- abstractmethod set_average_count(count: int) None[source]#
Set the number of waveforms to average. Only takes effect in
AcquisitionMode.AVERAGE.
- abstractmethod stop() None[source]#
Stop acquisition. Leaves the captured data intact for
fetch_waveform/measure.
- abstractmethod single() None[source]#
Arm a single-shot acquisition.
Non-blocking — use
get_acquisition_stateto poll for STOPPED, or preferdigitize()which combines arming and waiting.
- abstractmethod digitize(timeout: float) None[source]#
Arm a single acquisition and block until the trigger fires and the capture completes.
Acquisition is global — all enabled channels capture simultaneously. On success the scope is left stopped with valid data ready for readout.
- Parameters:
timeout
Maximum seconds to wait for the trigger to fire.
- Raises:
TimeoutError – Trigger did not fire within
timeout. The driver clears any pending operation so the session stays usable.
- abstractmethod get_acquisition_state() AcquisitionState[source]#
Read back the acquisition run state (RUNNING / STOPPED).
- abstractmethod fetch_waveform(
- channel: int,
Fetch the most recently acquired waveform from
channel.- Returns:
WaveformDatawithtimesin nanoseconds relative to the trigger point (negative = pre-trigger) andvoltagesalready scaled through the configured probe attenuation.
- setup_measurement(
- measurement_type: ScopeMeasurementType,
- channel: int,
Ensure a measurement slot exists for
measurement_type/channelbefore the scope triggers.Required for instruments (e.g. Tektronix) that compute measurements during acquisition — the slot must be present at trigger time or the first
measure()returns stale/invalid data. Default is a no-op for instruments (e.g. Keysight 1200X) that compute on demand.
- abstractmethod measure(
- measurement_type: ScopeMeasurementType,
- channel: int,
Read a built-in measurement (VPP, VMAX, VMIN, VAVG, VRMS, …) on
channel.Returns
math.nanwhen the scope reports its invalid-measurement sentinel (no valid acquisition yet, channel off, etc.).
- abstractmethod set_trigger_source(channel: int) None[source]#
Set the trigger source to analog
channel.Drivers typically cache this value because the trigger-level SCPI on some scopes requires the source channel in the same command.
- abstractmethod set_trigger_type(
- trigger_type: TriggerType,
Set the trigger type (EDGE, PULSE, …).
- abstractmethod set_trigger_level(level: float) None[source]#
Set the trigger threshold to
level(volts). Applies to the configured trigger source.
- abstractmethod set_trigger_slope(
- slope: TriggerSlope,
Set the trigger edge slope (RISING / FALLING / EITHER).
- abstractmethod set_trigger_mode(
- mode: TriggerMode,
Set the trigger sweep mode (AUTO / NORMAL).
AUTO forces an acquisition if no trigger fires within the timeout; NORMAL waits indefinitely for a real trigger.
- abstractmethod force_trigger() None[source]#
Force a trigger event immediately, regardless of the configured conditions.
- abstractmethod get_trigger_status() TriggerStatus[source]#
Read back the trigger status (ARMED / READY / TRIGGERED / …).
- abstractmethod save_screenshot( ) bytes[source]#
Capture a screenshot.
- Parameters:
filepath
Output path. When
to_instrument=Falsethis is a host path; whenTrueit is a path on the scope’s filesystem (USB stick, internal storage).to_instrument
When
True, the scope writes the file itself and this returnsb"". WhenFalse, the image is transferred to the host, written tofilepath, and the raw bytes are returned for in-memory use.
- abstractmethod save_settings( ) bytes[source]#
Save the current scope setup. Path semantics mirror
save_screenshot().
- abstractmethod load_settings( ) None[source]#
Recall a scope setup from
name.With
from_instrument=Truethe scope reads from its own filesystem; otherwise the host readsnameand pushes the bytes to the scope. After loading, the callingInstroScopeshould invalidate its trackedScopeStateand resync if a fresh view is needed.