spinnman.messages.eieio.data_messages package¶
Module contents¶
- class spinnman.messages.eieio.data_messages.AbstractDataElement¶
Bases:
object
A marker interface for possible data elements in the EIEIO data packet.
- abstract get_bytestring(eieio_type: EIEIOType) bytes [source]¶
Get a byte-string for the given type
- Parameters:
eieio_type (EIEIOType) – The type of the message being written
- Returns:
A byte-string for the element
- Return type:
- Raises:
SpinnmanInvalidParameterException – If the type is incompatible with the element
- class spinnman.messages.eieio.data_messages.EIEIODataHeader(eieio_type: EIEIOType, tag: int = 0, prefix: int | None = None, prefix_type: EIEIOPrefix = EIEIOPrefix.LOWER_HALF_WORD, payload_base: int | None = None, is_time: bool = False, count: int = 0)¶
Bases:
object
The header part of EIEIO data.
EIEIO header for data packets.
- Parameters:
eieio_type (EIEIOType) – the type of message
tag (int) – the tag of the message (0 by default)
prefix (int or None) – the key prefix of the message or None if not prefixed
prefix_type (EIEIOPrefix) – the position of the prefix (upper or lower)
payload_base (int or None) – The base payload to be applied, or None if no base payload
is_time (bool) – True if the payloads should be taken to be timestamps, or False otherwise
count (int) – Count of the number of items in the packet
- static from_bytestring(data: bytes, offset: int) EIEIODataHeader [source]¶
Read an EIEIO data header from a byte-string.
- Parameters:
- Returns:
an EIEIO header
- Return type:
- static get_header_size(eieio_type: EIEIOType, is_prefix: bool = False, is_payload_base: bool = False) int [source]¶
Get the size of a header with the given parameters.
- property payload_base: int | None¶
Gets the payload_base value passed into the init (if applicable).
- Return type:
int or None
- property prefix: int | None¶
Gets prefix passed into the init (if applicable).
- Return type:
int or None
- property prefix_type: EIEIOPrefix¶
Gets the prefix_type passed into the init.
- Return type:
- class spinnman.messages.eieio.data_messages.EIEIODataMessage(eieio_header: EIEIODataHeader, data: bytes | None = None, offset: int = 0)¶
Bases:
AbstractEIEIOMessage
An EIEIO Data message.
- Parameters:
eieio_header (EIEIODataHeader) – The header of the message
data (bytes) – Optional data contained within the packet
offset (int) – Optional offset where the valid data starts
- add_element(element: AbstractDataElement) None [source]¶
Add an element to the message. The correct type of element must be added, depending on the header values.
- Parameters:
element (AbstractDataElement) – The element to be added
- Raises:
SpinnmanInvalidParameterException – If the element is not compatible with the header
SpinnmanInvalidPacketException – If the message was created to read data
- add_key(key: int) None [source]¶
Add a key to the packet.
- Parameters:
key (int) – The key to add
- Raises:
SpinnmanInvalidParameterException – If the key is too big for the format, or the format expects a payload
- add_key_and_payload(key: int, payload: int) None [source]¶
Adds a key and payload to the packet.
- Parameters:
- Raises:
SpinnmanInvalidParameterException – If the key or payload is too big for the format, or the format doesn’t expect a payload
- static create(eieio_type: EIEIOType, count: int = 0, data: bytes | None = None, offset: int = 0, key_prefix: int | None = None, payload_prefix: int | None = None, timestamp: int | None = None, prefix_type: EIEIOPrefix = EIEIOPrefix.LOWER_HALF_WORD) EIEIODataMessage [source]¶
Create a data message.
- Parameters:
eieio_type (EIEIOType) – The type of the message
count (int) – The number of items in the message
data (bytes) – The data in the message
offset (int) – The offset in the data where the actual data starts
key_prefix (int) – The prefix of the keys
payload_prefix (int) – The prefix of the payload
timestamp (int) – The timestamp of the packet
prefix_type (EIEIOPrefix) – The type of the key prefix if 16-bits
- property eieio_header: EIEIODataHeader¶
The header of the message.
- Return type:
- get_min_packet_length() int [source]¶
Get the minimum length of a message instance in bytes.
- Return type:
- property max_n_elements: int¶
The maximum number of elements that can fit in the packet.
- Return type:
- static min_packet_length(eieio_type: EIEIOType, is_prefix: bool = False, is_payload_base: bool = False, is_timestamp: bool = False) int [source]¶
The minimum length of a message with the given header, in bytes.
- Parameters:
- Returns:
The minimum size of the packet in bytes
- Return type:
- property next_element: AbstractDataElement | None¶
The next element to be read, or None if no more elements. The exact type of element returned depends on the packet type.
- Return type:
- class spinnman.messages.eieio.data_messages.KeyDataElement(key: int)¶
Bases:
AbstractDataElement
A data element that contains just a key.
- get_bytestring(eieio_type: EIEIOType) bytes [source]¶
Get a byte-string for the given type
- Parameters:
eieio_type (EIEIOType) – The type of the message being written
- Returns:
A byte-string for the element
- Return type:
- Raises:
SpinnmanInvalidParameterException – If the type is incompatible with the element
- class spinnman.messages.eieio.data_messages.KeyPayloadDataElement(key: int, payload: int, payload_is_timestamp: bool = False)¶
Bases:
AbstractDataElement
A data element that contains a key and a payload.
- get_bytestring(eieio_type: EIEIOType) bytes [source]¶
Get a byte-string for the given type
- Parameters:
eieio_type (EIEIOType) – The type of the message being written
- Returns:
A byte-string for the element
- Return type:
- Raises:
SpinnmanInvalidParameterException – If the type is incompatible with the element