Skip to main content
The Net class is the primary abstraction for interacting with hardware instruments. It provides a unified interface for controlling different types of hardware including power supplies, oscilloscopes, GPIO, ADC, DAC, and more.

Import

from lager import Net, NetType  # Convenience import

# Or import directly from pcb module
from lager import Net
from lager.pcb.constants import NetType

# For exception handling
from lager.pcb.net import InvalidNetError, SetupFunctionRequiredError

Class Methods

MethodDescription
Net.get()Create a Net instance for the specified net name and type
Net.list_saved()List all nets configured on the Lager Box
Net.list_all_from_env()List nets from environment (legacy)
Net.get_local_nets()Get all local net configurations
Net.save_local_nets()Save multiple net configurations
Net.save_local_net()Save a single net configuration
Net.delete_local_net()Delete a net configuration
Net.delete_all_local_nets()Delete all net configurations
Net.rename_local_net()Rename a net configuration
Net.filter_nets()Filter nets by name and/or role

Instance Methods

MethodDescription
enable()Enable the net and connect to hardware
disable()Disable the net and disconnect from hardware

Method Reference

Net.get(name, type, *, setup_function=None, teardown_function=None)

Create a Net instance for the specified net name and type.
# Get a power supply net
psu = Net.get('VDD', type=NetType.PowerSupply)

# Get a GPIO net
led = Net.get('LED', type=NetType.GPIO)

# Get an analog oscilloscope net
scope = Net.get('PROBE', type=NetType.Analog)
Parameters:
ParameterTypeDescription
namestrName of the net to create
typeNetTypeType of net (e.g., NetType.PowerSupply, NetType.GPIO)
setup_functioncallableOptional function called when net is enabled
teardown_functioncallableOptional function called when net is disabled
Returns: Net instance appropriate for the specified type

Net.list_saved()

List all nets configured on the Lager Box.
nets = Net.list_saved()
for net in nets:
    print(f"{net['name']}: {net['role']}")
Returns: list[dict] - List of net configurations with keys:
  • name (str) - Net name
  • role (str) - Net type/role
  • pin (int) - Hardware pin/channel number
  • instrument (str) - Associated instrument type

Net.list_all_from_env()

List nets from the LAGER_MUXES environment variable (legacy behavior).
nets = Net.list_all_from_env()
for net in nets:
    print(f"{net['name']}: {net['role']} on channel {net['channel']}")
Returns: list[dict] - List of net information

Net.save_local_net(data)

Save a net configuration to the Lager Box.
Net.save_local_net({
    'name': 'VDD',
    'role': 'power-supply',
    'pin': 1,
    'instrument': 'rigol_dp800',
    'address': '192.168.1.100'
})
Parameters:
ParameterTypeDescription
datadictNet configuration dictionary

Net.delete_local_net(name, role=None)

Delete a net configuration from the Lager Box.
# Delete by name only
Net.delete_local_net('VDD')

# Delete by name and role
Net.delete_local_net('VDD', role='power-supply')
Parameters:
ParameterTypeDescription
namestrName of net to delete
rolestrOptional role to match
Returns: bool - True if net was deleted

Net.rename_local_net(old_name, new_name)

Rename a net configuration.
Net.rename_local_net('OLD_NAME', 'NEW_NAME')
Parameters:
ParameterTypeDescription
old_namestrCurrent net name
new_namestrNew net name
Returns: bool - True if net was renamed

Net.get_local_nets()

Get all local net configurations.
nets = Net.get_local_nets()
for net in nets:
    print(f"{net['name']}: {net['role']}")
Returns: list[dict] - List of net configuration dictionaries

Net.save_local_nets(nets)

Save multiple net configurations at once.
Net.save_local_nets([
    {'name': 'VDD', 'role': 'power-supply', 'pin': 1, 'instrument': 'rigol_dp800', 'address': '192.168.1.100'},
    {'name': 'GND', 'role': 'power-supply', 'pin': 2, 'instrument': 'rigol_dp800', 'address': '192.168.1.100'}
])
Parameters:
ParameterTypeDescription
netslist[dict]List of net configuration dictionaries

Net.delete_all_local_nets()

Delete all net configurations from the Lager Box.
Net.delete_all_local_nets()
Returns: bool - True if nets were deleted

Net.filter_nets(all_nets, name, role=None)

Filter a list of nets by name and optionally by role.
all_nets = Net.get_local_nets()

# Find all nets named 'VDD'
vdd_nets = Net.filter_nets(all_nets, 'VDD')

# Find 'VDD' with specific role
psu_nets = Net.filter_nets(all_nets, 'VDD', role='power-supply')
Parameters:
ParameterTypeDescription
all_netslist[dict]List of nets to search
namestrNet name to match
rolestrOptional role to match
Returns: list[dict] - Matching nets

enable()

Enable the net and connect to hardware.
scope = Net.get('PROBE', type=NetType.Analog)
scope.enable()  # Connect to oscilloscope
Behavior by net type:
  • Analog: Connects to multiplexer and enables oscilloscope channel
  • Logic: Enables logic analyzer channel
  • Battery: Enables battery simulation output
  • PowerSupply: Enables power supply output
  • ELoad: Enables electronic load

disable(teardown=True)

Disable the net and disconnect from hardware.
scope.disable()  # Disconnect and run teardown
scope.disable(teardown=False)  # Disconnect without teardown
Parameters:
ParameterTypeDefaultDescription
teardownboolTrueWhether to call teardown function

NetType Enum

Available net types:
NetTypeRole StringDescription
NetType.AnaloganalogOscilloscope analog input
NetType.LogiclogicLogic analyzer input
NetType.WaveformwaveformWaveform generator
NetType.BatterybatteryBattery simulator
NetType.PowerSupplypower-supplyPower supply
NetType.ELoadeloadElectronic load
NetType.GPIOgpioDigital I/O
NetType.ADCadcAnalog-to-digital converter
NetType.DACdacDigital-to-analog converter
NetType.ThermocouplethermocoupleTemperature sensor
NetType.WattMeterwatt-meterPower meter
NetType.UARTuartSerial communication
NetType.DebugdebugDebug probe
NetType.ArmarmRobotic arm
NetType.UsbusbUSB device
NetType.RotationrotationRotary encoder
NetType.WifiwifiWiFi module
NetType.ActuateactuateActuator control
NetType.PowerSupply2Qpower-supply-2qTwo-quadrant power supply (solar simulation)

Properties

name

Get the net name.
print(net.name)  # 'VDD'

type

Get the net type.
print(net.type)  # NetType.PowerSupply

Examples

List and Use Nets

from lager import Net, NetType

# List all available nets
nets = Net.list_saved()
print("Available nets:")
for net in nets:
    print(f"  {net['name']}: {net['role']}")

# Get and use a specific net
psu = Net.get('VDD', type=NetType.PowerSupply)
psu.set_voltage(3.3)
psu.enable()

Simple Nets (GPIO, ADC, DAC)

from lager import Net, NetType

# GPIO - no enable/disable needed
button = Net.get('BUTTON', type=NetType.GPIO)
state = button.input()

led = Net.get('LED', type=NetType.GPIO)
led.output(1)

# ADC - no enable/disable needed
sensor = Net.get('SENSOR', type=NetType.ADC)
voltage = sensor.input()

# DAC - no enable/disable needed
vref = Net.get('VREF', type=NetType.DAC)
vref.output(2.5)

Complex Nets (Power, Scope)

from lager import Net, NetType

# Power supply - requires enable/disable
psu = Net.get('VDD', type=NetType.PowerSupply)
psu.set_voltage(3.3)
psu.set_current(0.5)
psu.enable()
# ... use the power supply ...
psu.disable()

# Oscilloscope - requires enable/disable
scope = Net.get('PROBE', type=NetType.Analog)
scope.enable()
freq = scope.measurement.frequency()
scope.disable()

Manage Net Configuration

from lager import Net

# Save a new net
Net.save_local_net({
    'name': 'NEW_PSU',
    'role': 'power-supply',
    'pin': 2,
    'instrument': 'rigol_dp800',
    'address': '192.168.1.100'
})

# Rename a net
Net.rename_local_net('NEW_PSU', 'MAIN_POWER')

# Delete a net
Net.delete_local_net('MAIN_POWER')

Notes

  • Simple nets (GPIO, ADC, DAC, Thermocouple) work directly without enable()/disable() calls
  • Complex nets (Analog, Logic, PowerSupply, Battery, ELoad) require enable() before use
  • Always call disable() when finished with complex nets to properly release hardware
  • Net names must match those configured on the Lager Box
  • Use Net.list_saved() to see all available nets