nspyre.extras

Submodules

Package Contents

Classes

Subsystem

Generalized experimental subsystem that allows for management of dependencies between subsystems for boot sequencing.

class nspyre.extras.Subsystem(name, pre_dep_boot=None, post_dep_boot=None, default_boot_timeout=10, default_boot_inserv=None, default_boot_add_args=None, default_boot_add_kwargs=None, pre_dep_shutdown=None, post_dep_shutdown=None, dependencies=None)

Generalized experimental subsystem that allows for management of dependencies between subsystems for boot sequencing.

Parameters:
  • name (str) – Subsystem name.

  • pre_dep_boot (Optional[Callable]) – Function to run before booting any dependency subsystems. It should take 1 argument, which is the subsystem object.

  • post_dep_boot (Optional[Callable]) – Function to run to boot the subsystem after booting any dependency subsystems. It should take 1 argument, which is the subsystem object. If None, default_boot() will be used.

  • default_boot_timeout (float) – Time to wait (s) for the driver to initialize in default_boot().

  • default_boot_inserv (Optional[Union[nspyre.instrument.server.InstrumentServer, nspyre.instrument.gateway.InstrumentGateway]]) – InstrumentServer (or a connected InstrumentGateway) to add the driver to in default_boot().

  • default_boot_add_args (Optional[list]) – Arguments to pass to the InstrumentServer add() method to create the driver in default_boot().

  • default_boot_add_kwargs (Optional[Dict]) – Keyword arguments to pass to the InstrumentServer add() method to create the driver in default_boot().

  • pre_dep_shutdown (Optional[Callable]) – Function to run once shutdown is requested, but before shutting down any dependencies. It should take 1 argument, which is the subsystem object. If None, default_shutdown() will be used.

  • post_dep_shutdown (Optional[Callable]) – Function to run after shutting down any dependencies. It should take 1 argument, which is the subsystem object.

  • dependencies (Optional[list]) – List of Subsystem objects this subsystem depends on. They will be booted (in order) before this subsystem, and shutdown (in reverse order) after this subsystem shuts down.

default_boot()

Tries to add the driver to the InstrumentServer in a loop, until default_boot_timeout has elapsed.

default_shutdown()

Remove the driver from the InstrumentServer.

boot(boot_dependencies=True)
Parameters:

boot_dependencies (bool) – if True, boot all dependencies before booting this subsystem.

shutdown(shutdown_dependencies=True)

Shutdown the subsystem.

Parameters:

shutdown_dependencies (bool) – if True, shutdown all dependencies after shutting down