spinnman.messages.eieio.data_messages package¶
Submodules¶
spinnman.messages.eieio.data_messages.abstract_data_element module¶
-
class
spinnman.messages.eieio.data_messages.abstract_data_element.
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 ( spinnman.messages.eieio.eieio_type.EIEIOType
) – The type of the message being writtenReturns: A bytestring for the element Return type: str Raises: SpinnmanInvalidParameterException – If the type is incompatible with the element
-
spinnman.messages.eieio.data_messages.eieio_data_header module¶
-
class
spinnman.messages.eieio.data_messages.eieio_data_header.
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 (
spinnman.spinnman.messages.eieio.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 (
spinnman.messages.eieio.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
¶ Get a bytestring of the header
Returns: The header as a bytestring Return type: str
-
count
¶
-
eieio_type
¶
-
static
from_bytestring
(data, offset)[source]¶ Read an eieio data header from a bytestring
Parameters: - data (str) – The bytestring to be read
- offset (int) – The offset at which the data starts
Returns: an EIEIO header
Return type:
-
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 (
spinnman.spinnman.messages.eieio.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
- eieio_type (
-
is_time
¶
-
payload_base
¶
-
prefix
¶
-
prefix_type
¶
-
size
¶
-
tag
¶
- eieio_type (
spinnman.messages.eieio.data_messages.eieio_data_message module¶
-
class
spinnman.messages.eieio.data_messages.eieio_data_message.
EIEIODataMessage
(eieio_header, data=None, offset=0)[source]¶ Bases:
spinnman.messages.eieio.eieio_message.AbstractEIEIOMessage
An EIEIO Data message
Parameters: - eieio_header (
spinnman.messages.eieio.data_messages.EIEIODataHeader
) – The header of the message - data (str) – 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 (
spinnman.messages.eieio.data_messages.AbstractDataElement
) – The element to be addedRaises: - SpinnmanInvalidParameterException – If the element is not compatible with the header
- SpinnmanInvalidPacketException – If the message was created to read data
-
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
¶
-
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 – The EIEIOType of the message
- count – The number of items in the message
- data – The data in the message
- offset – The offset in the data where the actual data starts
- key_prefix – The prefix of the keys
- payload_prefix – The prefix of the payload
- timestamp – The timestamp of the packet
- prefix_type – The type of the key prefix if 16-bits
-
eieio_header
¶
-
get_min_packet_length
()[source]¶ Get the minimum length of a message instance in bytes
Return type: int
-
is_next_element
¶ Determine if there is another element to be read
Returns: True if the message was created with data, and there are more elements 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 (
spinnman.spinnman.messages.eieio.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 – True if there is a timestamp, False otherwise
Returns: The minimum size of the packet in bytes
Return type: int
- eieio_type (
-
n_elements
¶ The number of elements in the packet
-
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: spinnman.messages.eieio.data_messages.AbstractDataElement
-
size
¶ The size of the packet with the current contents
- eieio_header (
spinnman.messages.eieio.data_messages.key_data_element module¶
-
class
spinnman.messages.eieio.data_messages.key_data_element.
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 ( spinnman.messages.eieio.eieio_type.EIEIOType
) – The type of the message being writtenReturns: A bytestring for the element Return type: str Raises: SpinnmanInvalidParameterException – If the type is incompatible with the element
-
key
¶
-
spinnman.messages.eieio.data_messages.key_payload_data_element module¶
-
class
spinnman.messages.eieio.data_messages.key_payload_data_element.
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 ( spinnman.messages.eieio.eieio_type.EIEIOType
) – The type of the message being writtenReturns: A bytestring for the element Return type: str Raises: SpinnmanInvalidParameterException – If the type is incompatible with the element
-
key
¶
-
payload
¶
-
payload_is_timestamp
¶
-
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 ( spinnman.messages.eieio.eieio_type.EIEIOType
) – The type of the message being writtenReturns: A bytestring for the element Return type: str 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 (
spinnman.spinnman.messages.eieio.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 (
spinnman.messages.eieio.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
¶ Get a bytestring of the header
Returns: The header as a bytestring Return type: str
-
count
¶
-
eieio_type
¶
-
static
from_bytestring
(data, offset)[source]¶ Read an eieio data header from a bytestring
Parameters: - data (str) – The bytestring to be read
- offset (int) – The offset at which the data starts
Returns: an EIEIO header
Return type:
-
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 (
spinnman.spinnman.messages.eieio.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
- eieio_type (
-
is_time
¶
-
payload_base
¶
-
prefix
¶
-
prefix_type
¶
-
size
¶
-
tag
¶
- eieio_type (
-
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 (
spinnman.messages.eieio.data_messages.EIEIODataHeader
) – The header of the message - data (str) – 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 (
spinnman.messages.eieio.data_messages.AbstractDataElement
) – The element to be addedRaises: - SpinnmanInvalidParameterException – If the element is not compatible with the header
- SpinnmanInvalidPacketException – If the message was created to read data
-
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
¶
-
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 – The EIEIOType of the message
- count – The number of items in the message
- data – The data in the message
- offset – The offset in the data where the actual data starts
- key_prefix – The prefix of the keys
- payload_prefix – The prefix of the payload
- timestamp – The timestamp of the packet
- prefix_type – The type of the key prefix if 16-bits
-
eieio_header
¶
-
get_min_packet_length
()[source]¶ Get the minimum length of a message instance in bytes
Return type: int
-
is_next_element
¶ Determine if there is another element to be read
Returns: True if the message was created with data, and there are more elements 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 (
spinnman.spinnman.messages.eieio.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 – True if there is a timestamp, False otherwise
Returns: The minimum size of the packet in bytes
Return type: int
- eieio_type (
-
n_elements
¶ The number of elements in the packet
-
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: spinnman.messages.eieio.data_messages.AbstractDataElement
-
size
¶ The size of the packet with the current contents
- eieio_header (
-
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 ( spinnman.messages.eieio.eieio_type.EIEIOType
) – The type of the message being writtenReturns: A bytestring for the element Return type: str 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 ( spinnman.messages.eieio.eieio_type.EIEIOType
) – The type of the message being writtenReturns: A bytestring for the element Return type: str Raises: SpinnmanInvalidParameterException – If the type is incompatible with the element
-
key
¶
-
payload
¶
-
payload_is_timestamp
¶
-