j5 package


Module contents

j5 Robotics API.

class j5.BoardGroup(backend_class: Type[U])[source]

Bases: typing.Generic

A group of boards that can be accessed.


The Backend that this group uses for Boards.


Get an unordered list of boards in this group.

classmethod get_board_group(_: Type[T], backend: Type[U]) → j5.boards.board_group.BoardGroup[~T, ~U][T, U][source]

Get the board group with the given types.

Whilst the first parameter value is not actually used in the function, we need it for typing purposes. This is similar to how a ProxyType works in Haskell.

make_safe() → None[source]

Make all of the boards safe.

singular() → T[source]

If there is only a single board in the group, return that board.

update_boards() → None[source]

Update the boards in this group to see if new boards have been added.

class j5.BaseRobot[source]

Bases: object

A base robot.

make_safe() → None[source]

Make this robot safe.

class j5.Environment(name: str)[source]

Bases: object

A collection of backends that can work together.

A number of Backends that we wish to use in a grouping, such as those that all work together in hardware can be added to this group. We can then pass Environments to a Robot object, so that the Robot object can call different methods based on where it is being used.

e.g Hardware Environment

We have n boards of n different types. They are all physical hardware. We create an Environment containing the Backends to control the physical hardware for our boards.

It is later realised that we want to test code without the physical hardware. We can add Console backends to an environment, and instantiate our Robot object with that environment, so that the console is manipulated rather than the hardware.

This allows for a high degree of code reuse and ensures API compatibility in different situations.

get_backend(board: Type[Board]) → Type[j5.backends.backend.Backend][source]

Get the backend for a board.

get_board_group(board: Type[BoardT]) → j5.boards.board_group.BoardGroup[~BoardT, j5.backends.backend.Backend][BoardT, j5.backends.backend.Backend][source]

Get a board group for the given board type.

merge(other: j5.backends.environment.Environment) → None[source]

Merge in the board-backend mappings from another environment.

This allows vendors to predefine Environments and API authors can then merge several vendor environments to get the one that they need for their API.

This method will fail if any board is defined in both environments,
as it is unclear which one has the correct mapping.
register_backend(backend: Type[j5.backends.backend.Backend]) → None[source]

Register a new backend with this environment.


The boards that are supported by this environment.