Engine handler#

Module implementing the handler for the standard Bluesky engine.

final class redsun.engine.bluesky.handler.BlueskyHandler(config, virtual_bus, module_bus, during_task)#

Bluesky handler class.

Parameters:
  • config (RedSunSessionInfo) – Configuration options for the RedSun session.

  • virtual_bus (VirtualBus) – Reference to the virtual bus.

  • module_bus (VirtualBus) – Reference to the module bus.

  • during_task (DuringTask) – The DuringTask object. For more information, see EngineHandler.

property engine: RunEngine#

Execution engine instance.

execute(controller, name)#

Execute a plan.

Parameters:
  • controller (str) – The name of the controller.

  • name (str) – The name of the plan.

Return type:

None

halt()#

Halt the current plan.

Return type:

None

load_model(name, model)#

Load a model into the handler and make it available to the rest of the application.

This method can be used to dynamically load a model. The request for adding a model should be initiated by the plugin manager.

Parameters:
  • name (str) – Model identifier.

  • model (ModelProtocol) – Model to be loaded.

Return type:

None

property models: dict[str, ModelProtocol]#

Model dictionary.

property plans: dict[str, dict[str, partial[MsgGenerator[Any]]]]#

Plans dictionary.

register_plan(controller, name, plan)#

Register a workflow with the handler.

Parameters:
  • controller (str) – The name of the controller.

  • name (str) – The name of the plan.

  • plan (partial[MsgGenerator[Any]]) – The plan to register.

Return type:

None

shutdown()#

Invoke “stop” method on the run engine.

“stop” marks it as successfull.

Return type:

None

subscribe(func, name='all')#

Subscribe a callback function to the engine notifications.

The callback has signature func(name, document):

  • name is the type of document the callback should receive;
    • "all": all documents;

    • "start": start documents;

    • "descriptor": descriptor documents;

    • "event": event documents;

    • "stop": stop documents.

  • document is the document received from the engine (a dictionary).

Parameters:
  • func (Callable[[EventName, dict[str, Any]], None]) – Function to be called when the event occurs.

  • name (Optional[EventName]) – Event type. Defaults to "all".

Returns:

token – Subscription token. It can be used to unsubscribe the callback.

Return type:

int

Notes

See also unsubscribe().

unsubscribe(token)#

Unregister a callback function its integer ID.

Parameters:

token (int) – Subscription token.

Return type:

None

Notes

See also unsubscribe().