spinn_front_end_common.utilities.connections package

Module contents

class spinn_front_end_common.utilities.connections.LiveEventConnection(live_packet_gather_label: str | None, receive_labels: Iterable[str] | None = None, send_labels: Iterable[str] | None = None, local_host: str | None = None, local_port: int | None = 19999)

Bases: DatabaseConnection

A connection for receiving and sending live events from and to SpiNNaker.

Note

This class is intended to be potentially usable from another process than the one that the simulator is present in.

Parameters:
  • live_packet_gather_label (str) – The label of the vertex to which received events are being sent. If None, no receive labels may be specified.

  • receive_labels (iterable(str)) – Labels of vertices from which live events will be received.

  • send_labels (iterable(str)) – Labels of vertices to which live events will be sent

  • local_host (str) – Optional specification of the local hostname or IP address of the interface to listen on

  • local_port (int) – Optional specification of the local port to listen on. Must match the port that the toolchain will send the notification on (19999 by default)

add_init_callback(label: str, init_callback: Callable[[str, int, float, float], None])[source]

Add a callback to be called to initialise a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • init_callback (callable(str, int, float, float) -> None) – A function to be called to initialise the vertex. This should take as parameters the label of the vertex, the number of neurons in the population, the run time of the simulation in milliseconds, and the simulation timestep in milliseconds

add_pause_stop_callback(label: str, pause_stop_callback: Callable[[str, LiveEventConnection], None])[source]

Add a callback for the pause and stop state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • pause_stop_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the pause or stop message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

add_receive_callback(label: str, live_event_callback: Callable[[str, int, List[int]], None], translate_key: bool = True)[source]

Add a callback for the reception of time events from a vertex.

These are typically used to receive keys or atoms ids that spiked.

Note

Previously this method was also used to add no time callback I.e. the once that take as parameters the label of the vertex, an int atom ID or key, and an int payload which may be None. For those use add_receive_no_time_callback now

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • live_event_callback (callable(str, int, list(int)) -> None) – A function to be called when events are received. This should take as parameters the label of the vertex, the simulation timestep when the event occurred, and an array-like of atom IDs or keys.

  • translate_key (bool) – True if the key is to be converted to an atom ID, False if the key should stay a key

add_receive_label(label: str)[source]
add_receive_no_time_callback(label: str, live_event_callback: Callable[[str, int, int | None], None], translate_key: bool = True)[source]

Add a callback for the reception of live events from a vertex.

Parameters:
  • label (str) – The label of the vertex to be notified about. Must be one of the vertices listed in the constructor

  • live_event_callback (callable(str, int, int or None) -> None) – A function to be called when events are received. This should take as parameters the label of the vertex, an int atom ID or key, and an int payload which may be None

add_send_label(label: str)[source]
add_start_callback(label: str, start_callback: Callable[[str, LiveEventConnection], None])[source]

Add a callback for the start of the simulation.

Parameters:
  • start_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events

  • label (str) – the label of the function to be sent

add_start_resume_callback(label: str, start_resume_callback: Callable[[str, LiveEventConnection], None])[source]

Add a callback for the start and resume state of the simulation.

Parameters:
  • label (str) – the label of the function to be sent

  • start_resume_callback (callable(str, LiveEventConnection) -> None) – A function to be called when the start or resume message has been received. This function should take the label of the referenced vertex, and an instance of this class, which can be used to send events.

close() None[source]

Closes the connection.

send_eieio_message(message: AbstractEIEIOMessage, label: str)[source]

Send an EIEIO message (using one-way the live input) to the vertex with the given label.

Parameters:
  • message (AbstractEIEIOMessage) – The EIEIO message to send

  • label (str) – The label of the receiver machine vertex

send_event(label: str, atom_id: int, send_full_keys: bool = False)[source]

Send an event from a single atom.

Parameters:
  • label (str) – The label of the vertex from which the event will originate

  • atom_id (int) – The ID of the atom sending the event

  • send_full_keys (bool) – Determines whether to send full 32-bit keys, getting the key for each atom from the database, or whether to send 16-bit atom IDs directly

send_event_with_payload(label: str, atom_id: int, payload: int)[source]

Send an event with a payload from a single atom.

Parameters:
  • label (str) – The label of the vertex from which the event will originate

  • atom_id (int) – The ID of the atom sending the event

  • payload (int) – The payload to send

send_events(label: str, atom_ids: List[int], send_full_keys: bool = False)[source]

Send a number of events.

Parameters:
  • label (str) – The label of the vertex from which the events will originate

  • atom_ids (list(int)) – array-like of atom IDs sending events

  • send_full_keys (bool) – Determines whether to send full 32-bit keys, getting the key for each atom from the database, or whether to send 16-bit atom IDs directly

send_events_with_payloads(label: str, atom_ids_and_payloads: List[Tuple[int, int]])[source]

Send a number of events with payloads.

Parameters:
  • label (str) – The label of the vertex from which the events will originate

  • atom_ids_and_payloads (list(tuple(int,int))) – array-like of tuples of atom IDs sending events with their payloads