nspyre.instrument.manager

Module Contents

Classes

InstrumentManager

For consolidating connections to multiple instrument gateways.

InstrumentManagerDevice

Wrapper for a device residing in an InstrumentManager.

class nspyre.instrument.manager.InstrumentManager(*register_gateway_args, register_gateway=True, auto_device_discovery=True, **register_gateway_kwargs)

For consolidating connections to multiple instrument gateways. If only connecting to a single InstrumentGateway, you can simply pass the arguments and keyword arguments that you’d normally pass to the gateway here. The InstrumentManager returns an InstrumentManagerDevice when a device attribute is accessed, e.g.:

from nspyre import InstrumentManager

with InstrumentManager() as mgr:
    # let's assume "dev1" was created on the instrument server as an
    # instance of "MyDriver"

    # d is an InstrumentManagerDevice object
    d = mgr.dev1
    # run the get_something() method of dev1 and print its return value
    print(d.get_something())
    print(isinstance(mgr.dev1, MyDriver)) # False
    print(isinstance(mgr.dev1, InstrumentManagerDevice)) # True
Parameters:
  • register_gateway_args – See arguments for register_gateway().

  • register_gateway (bool) – if True, call register_gateway().

  • auto_device_discovery (bool) – if True, when an attribute of the manager is accessed, but the device hasn’t been registered yet with the manager using register_device(), the device will be automatically registered.

  • register_gateway_kwargs – See keyword arguments for register_gateway().

register_gateway(*gateway_args, default_exclude=False, exclude=None, name_mapping=None, **gateway_kwargs)

Create and connect to an ~nspyre.instrument.gateway.InstrumentGateway, associate it with this InstrumentManager, and add all of its devices to this InstrumentManager.

Parameters:
register_device(dev, name=None)

Add a device to the InstrumentManager.

Parameters:
disconnect()

Disconnect from all InstrumentGateway.

class nspyre.instrument.manager.InstrumentManagerDevice(name, manager)

Wrapper for a device residing in an InstrumentManager. Performs similar a function as an InstrumentGatewayDevice. See those docs for details.

Parameters: