spinnman.messages.eieio.data_messages package

Module contents

class spinnman.messages.eieio.data_messages.AbstractDataElement[source]

Bases: object

A marker interface for possible data elements in the EIEIO data packet.

get_bytestring(eieio_type)[source]

Get a bytestring for the given type

Parameters:eieio_type (EIEIOType) – The type of the message being written
Returns:A bytestring for the element
Return type:bytes
Raises:SpinnmanInvalidParameterException – If the type is incompatible with the element
class spinnman.messages.eieio.data_messages.EIEIODataHeader(eieio_type, tag=0, prefix=None, prefix_type=<EIEIOPrefix.LOWER_HALF_WORD: 0>, payload_base=None, is_time=False, count=0)[source]

Bases: object

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
bytestring

The bytestring of the header.

Return type:bytes
count
eieio_type
static from_bytestring(data, offset)[source]

Read an eieio data header from a bytestring.

Parameters:
  • data (bytes) – The bytestring to be read
  • offset (int) – The offset at which the data starts
Returns:

an EIEIO header

Return type:

EIEIODataHeader

static get_header_size(eieio_type, is_prefix=False, is_payload_base=False)[source]

Get the size of a header with the given parameters.

Parameters:
  • eieio_type (EIEIOType) – the type of message
  • is_prefix (bool) – True if there is a prefix, False otherwise
  • is_payload_base (bool) – True if there is a payload base, False otherwise
Returns:

The size of the header in bytes

Return type:

int

increment_count()[source]
is_time
payload_base
prefix
prefix_type
reset_count()[source]
size
tag
class spinnman.messages.eieio.data_messages.EIEIODataMessage(eieio_header, data=None, offset=0)[source]

Bases: spinnman.messages.eieio.eieio_message.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)[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:
add_key(key)[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, payload)[source]

Adds a key and payload to the packet.

Parameters:
  • key (int) – The key to add
  • payload (int) – The payload to add
Raises:

SpinnmanInvalidParameterException – If the key or payload is too big for the format, or the format doesn’t expect a payload

bytestring

The bytes of the message.

Return type:bytes
static create(eieio_type, count=0, data=None, offset=0, key_prefix=None, payload_prefix=None, timestamp=None, prefix_type=<EIEIOPrefix.LOWER_HALF_WORD: 0>)[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
eieio_header

The header of the message.

Return type:EIEIODataHeader
get_min_packet_length()[source]

Get the minimum length of a message instance in bytes.

Return type:int
is_next_element

Whether there is another element to be read.

Return type:bool
max_n_elements

The maximum number of elements that can fit in the packet.

Return type:int
static min_packet_length(eieio_type, is_prefix=False, is_payload_base=False, is_timestamp=False)[source]

The minimum length of a message with the given header, in bytes.

Parameters:
  • eieio_type (EIEIOType) – the type of message
  • is_prefix (bool) – True if there is a prefix, False otherwise
  • is_payload_base (bool) – True if there is a payload base, False otherwise
  • is_timestamp (bool) – True if there is a timestamp, False otherwise
Returns:

The minimum size of the packet in bytes

Return type:

int

n_elements

The number of elements in the packet.

Return type:int
next_element

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:AbstractDataElement
size

The size of the packet with the current contents.

Return type:int
class spinnman.messages.eieio.data_messages.KeyDataElement(key)[source]

Bases: spinnman.messages.eieio.data_messages.abstract_data_element.AbstractDataElement

A data element that contains just a key.

get_bytestring(eieio_type)[source]

Get a bytestring for the given type

Parameters:eieio_type (EIEIOType) – The type of the message being written
Returns:A bytestring for the element
Return type:bytes
Raises:SpinnmanInvalidParameterException – If the type is incompatible with the element
key
class spinnman.messages.eieio.data_messages.KeyPayloadDataElement(key, payload, payload_is_timestamp=False)[source]

Bases: spinnman.messages.eieio.data_messages.abstract_data_element.AbstractDataElement

A data element that contains a key and a payload.

get_bytestring(eieio_type)[source]

Get a bytestring for the given type

Parameters:eieio_type (EIEIOType) – The type of the message being written
Returns:A bytestring for the element
Return type:bytes
Raises:SpinnmanInvalidParameterException – If the type is incompatible with the element
key
payload
payload_is_timestamp