REDAC Hybrid Controller Abstraction

class pybrid.redac.controller.Controller

Abstraction of the REDAC hybrid controller.

The hybrid controller is an interface to all relevant functions to configure and control the REDAC. It also collects all Run instances started with it.

The controller object also holds references to the underlying protocol and transport objects and manages them.

computer: REDAC

Representation of the current configuration of the analog computer.

devices: dict[pybrid.redac.entities.Path, pybrid.redac.protocol.protocol.Protocol]

Dictionary of all managed devices identified by their unique entity path. TODO: Remove in favor of protocols below.

async get_computer() REDAC

Retrieve the current hardware configuration of the REDAC.

classmethod get_run_implementation() Type[Run]

Returns the specific Run implementation used by the REDAC.

async hack(cmd: str, data: Any) Any

Send the passed data as a ‘hack’ request, only used during development. It allows to pass and receive arbitrary data to and from the hybrid controller.

async handle_run_data(msg: RunDataMessage, path: Path)

A handler for incoming RunDataMessage messages.

async handle_run_state_change(msg: RunStateChangeMessage, protocol: Protocol)

A handler for incoming RunStateChangeMessage messages.

protocols: dict[pybrid.redac.protocol.protocol.Protocol, set[pybrid.redac.entities.Path]]

Dictionary of protocol connections mapped to entity paths they manage

async reset(keep_calibration: bool = True, sync: bool = True)

Reset the hybrid controller and the analog computer to its initial configuration.

Parameters:
  • keep_calibration – Whether to keep the calibration.

  • sync – Whether to write the reset values to the hardware.

Returns:

None

runs: dict[uuid.UUID, pybrid.redac.run.Run]

List of all runs started by this controller.

async set_computer(computer: REDAC)

Change the configuration of all carrier boards and sub-entities on the REDAC.

Parameters:

computer – The REDAC object containing the configuration to be set.

Returns:

None

async set_config(entity: Entity)

Change the configuration of a singe entity.

Parameters:

entity – The entity to change.

Returns:

None

async start_and_await_run(run: Optional[Run] = None, timeout=5) Run

A convenience function which starts a run, blocks until it is completed and returns it.

Parameters:
  • run – The Run to be started, including its configuration. If None, a new run is created.

  • timeout – Timeout

Returns:

The completed Run.

async start_run(run: Optional[Run] = None, entities: Optional[Iterable[Path]] = None) DistributedRunState

Start a run (computation) on the REDAC.

Parameters:

run – The Run to be started, including its configuration. If None, a new run is created.

Returns:

An asyncio.Future which can be awaited and will return the run object once it is done.