Object Component Manager

This module implements an abstract component manager for simple object components.

class ObjectComponentManager(component, logger, communication_state_callback, component_state_callback)

An abstract component manager for a component that is an object in this process.

The base component manager is a very general class that allows for management of remote components to which communication may need to be established and maintained. In cases where the component is simply an object running in the same process as its component manager (for example, a simple simulator), such complexity is not needed. This class eliminates that complexity, providing a basic framework for these simple component managers.

__init__(component, logger, communication_state_callback, component_state_callback)

Initialise a new instance.

Parameters:
  • component (ObjectComponent) – the component managed by this component manager

  • logger (Logger) – a logger for this object to use

  • communication_state_callback (Callable[[CommunicationStatus], None]) – callback to be called when the status of the communications channel between the component manager and its component changes

  • component_state_callback (Callable[..., None]) – callback to be called when the component state changes.

off(task_callback=None)

Turn the component off.

Parameters:

task_callback (Optional[Callable]) – Update task state, defaults to None

Return type:

tuple[TaskStatus, str]

Returns:

a taskstatus and message.

on(task_callback=None)

Turn the component on.

Parameters:

task_callback (Optional[Callable]) – Update task state, defaults to None

Return type:

tuple[TaskStatus, str]

Returns:

a taskstatus and message

reset(task_callback=None)

Reset the component.

Parameters:

task_callback (Optional[Callable]) – Update task state, defaults to None

Return type:

tuple[TaskStatus, str]

Returns:

a taskstatus and message

simulate_communication_failure(fail_communicate)

Simulate (or stop simulating) a failure to communicate with the component.

Parameters:

fail_communicate (bool) – whether the connection to the component is failing

Return type:

None

standby(task_callback=None)

Put the component into low-power standby mode.

Parameters:

task_callback (Optional[Callable]) – Update task state, defaults to None

Return type:

tuple[TaskStatus, str]

Returns:

a taskstatus and message

start_communicating()

Establish communication with the component, then start monitoring.

Raises:

ConnectionError – if the attempt to establish communication with the channel fails.

Return type:

None

stop_communicating()

Cease monitoring the component, and break off all communication with it.

Return type:

None