Network#

class pyaseba.network.Network(address: str = '0.0.0.0', port: int = 33333, advertised_name: str = 'pyaseba')#

Aseba network hosting pyaseba.network.Node nodes. Clients can connect to the dashel target "tcp:address=<address>;port=<port>".

Parameters:
  • address – The IP address to connect to this network.

  • port – The port to connect to this network.

  • advertised_name – The name used for auto-discovery.

Examples

The typical life-cycle of an Aseba network starts by creating it,

>>> network = Network()

adding one or more nodes

>>> network.add_node(...)

and then letting it spin

>>> network.spin(time_step=0.1, duration=10)

In case we need to spin it in different thread, we can start

>>> network.start(time_step=0.1, duration=10)

and possibly stop it later

>>> network.stop()
add_node(self, node: Node) None#

Adds a node to the network.

Parameters:

node – the node.

property address#

The IP address (readonly).

property port#

The port (readonly).

spin(self, time_step: float, duration: float = -1) None#

Spins the network for some time. During spinning, it dispatches messages to nodes, it runs the nodes Aseba virtual machine, and it regularly call pyaseba.network.Node.tick().

Parameters:
  • time_step – the period in seconds between calling pyaseba.network.Node.tick()

  • duration – the duration in seconds. If negative, it will keep spinning indefinitely.

spin_async(self, time_step: float, duration: float = -1) Awaitable[None]#

Spins the network for some time in a background thread. During spinning, it dispatches messages to nodes, it runs the nodes Aseba virtual machine, and it regularly call pyaseba.network.Node.tick().

Parameters:
  • time_step – the period in seconds between calling pyaseba.network.Node.tick()

  • duration – the duration in seconds. If negative, it will keep spinning indefinitely.

start(self, time_step: float, duration: float = -1) None#

Starts spinning inside a background thread.

Parameters:
  • time_step – the period in seconds between calling pyaseba.network.Node.tick()

  • duration – the duration in seconds. If negative, it will keep spinning indefinitely.

stop(self) None#

Stops spinning (only relevant if already spinning inside a background thread).