Skip to content

eewBackbone

robin-cachy edited this page Jun 10, 2026 · 2 revisions

eewBackbone

core/eewBackbone.json is the vendor-neutral SCPI command database used by all scripts and the GUI. core/eewBackbone.py loads it and exposes three functions used everywhere.


API

from eewBackbone import classify, get_command, resolve_command

family = classify(idn_string)          # → resolved family dict, or None
steps  = get_command(family, "apply",  # → [(action, scpi_string), ...]
                     func="SIN", freq=1000, amp=1.0, offset=0)

classify(idn)

Matches an *IDN? response against all family patterns lists (case-insensitive substring match). Returns the fully resolved family dict (with inheritance applied), or None if no match.

get_command(family, operation, **kwargs)

Returns a list of (action, scpi_string) tuples for the given operation. action is one of "write", "query", or "raw_query". Raises KeyError if the operation is not defined for this family.

resolve_command(cmd, **kwargs)

Low-level: resolves a single command spec (string, list, or dict) into steps.


Family structure

{
  "id":       "keysight_edu33211a",
  "vendor":   "Keysight",
  "series":   "EDU33211A / EDU33212A Waveform Generator",
  "type":     "awg",
  "patterns": ["EDU33211A", "EDU33212A"],
  "commands": {
    "reset":          ["*RST", "*CLS"],
    "apply":          "SOUR{ch}:APPL:{func} {freq},{amp},{offset}",
    "set_frequency":  { "write": "SOUR{ch}:FREQ {freq}", "query": "SOUR{ch}:FREQ?" },
    "output_on":      "OUTP{ch} ON",
    "output_off":     "OUTP{ch} OFF"
  }
}
Field Description
id Unique identifier, used as family_id in workbench files
vendor Display name
series Human-readable model description
type scope, psu, awg, dmm, load, or smu
patterns Substrings to match in the *IDN? response (case-insensitive)
commands Map of operation name → command spec

Command spec formats

Format Meaning
"CMD {ch}" Single write
["CMD1", "CMD2"] Sequential writes
{"write": "CMD {v}", "query": "CMD?"} Settable + readable
{"query": "CMD?"} Read-only
{"raw_query": "CMD?"} Binary read via read_raw() (e.g. screenshots)

Placeholders

Placeholder Meaning
{ch} Channel number (1-indexed)
{value} Generic numeric value
{freq} Frequency in Hz
{amp} Amplitude
{offset} DC offset in V
{unit} Amplitude unit: VPP, VRMS, DBM
{func} Waveform function: SIN, SQU, RAMP, PULS, NOIS, DC
{coupling} AC, DC, GND
{slope} POS, NEG, EITH
{voltage} Voltage value
{current} Current value

Inheritance

Derived families declare "inherits": "parent_id" and optionally "overrides":

{
  "id":       "keysight_33500b",
  "vendor":   "Keysight",
  "series":   "33500B / 33600A Series",
  "type":     "awg",
  "inherits": "keysight_edu33211a",
  "patterns": ["33509B", "33510B", "33511B", "33512B", "33521B", "33522B"],
  "overrides": {
    "set_burst_mode": "BURS:MODE {value}"
  }
}
  • A key in overrides that matches a parent command replaces it
  • A key set to null removes the parent command (marks it unsupported)
  • A key not in the parent adds a new command

classify() always returns a fully merged family — callers never need to walk the inheritance chain.


Adding a new instrument

  1. Open core/eewBackbone.json
  2. Add an entry to the "families" array:
    • Set a unique id (e.g. "rigol_dp711")
    • Set type, vendor, series, patterns
    • Add commands — or use "inherits" + "overrides" if it's a variant of an existing family
  3. No code changes needed — classify() picks it up automatically on next load

Check your IDN string first:

python3 -c "
import pyvisa
rm = pyvisa.ResourceManager('@py')
r  = rm.open_resource('USB0::...')
print(r.query('*IDN?'))
"

The patterns list should contain one or more substrings that appear in the IDN response and are specific enough not to match unrelated instruments.


Current coverage

Type Families Vendors include
Oscilloscope 25 Keysight, Rigol, Rohde & Schwarz, Tektronix, Siglent, Hantek, OWON, GW Instek
AWG / FGen 15 Keysight, Agilent, Rigol, Siglent, GW Instek, Tektronix
Power supply 15 Keysight, Rigol, Siglent, Korad, BK Precision, AIM-TTI
DMM 9 Keysight, Rigol, Fluke, Siglent
SMU 3 Keithley, AIM-TTI
Electronic load 2 Rigol, BK Precision

69 families total across 15 vendors.

Clone this wiki locally