libmuscle.mpp_message module

class libmuscle.mpp_message.ClosePort[source]

Bases: object

Sentinel value to send when closing a port.

Sending an object of this class on a port/conduit conveys to the receiver the message that no further messages will be sent on this port during the simulation.

All information is carried by the type, this has no attributes.

class libmuscle.mpp_message.ExtTypeId(value)[source]

Bases: enum.IntEnum

MessagePack extension type ids.

MessagePack lets you define your own types as an extension to the built-in ones. These are distinguished by a number from 0 to 127. This class is our registry of extension type ids.

CLOSE_PORT = 0
GRID_BOOL = 6
GRID_FLOAT32 = 4
GRID_FLOAT64 = 5
GRID_INT32 = 2
GRID_INT64 = 3
SETTINGS = 1
class libmuscle.mpp_message.MPPMessage(sender: ymmsl.identity.Reference, receiver: ymmsl.identity.Reference, port_length: Optional[int], timestamp: float, next_timestamp: Optional[float], settings_overlay: ymmsl.settings.Settings, data: Any)[source]

Bases: object

A MUSCLE Communication Protocol message.

Messages carry the identity of their sender and receiver, so that they can be routed by a MUSCLE Transport Overlay when we get to multi-site running in the future.

Create an MPPMessage.

Senders and receivers are refered to by a Reference, which contains Instance[InstanceNumber].Port[Slot].

The port_length field is only used if two vector ports are connected together. In that case the number of slots is not determined by the number of instances, and must be set by the sender and then communicated to the receiver in this additional field in all messages sent on the port.

Parameters
  • sender – The sending endpoint.

  • receiver – The receiving endpoint.

  • port_length – Length of the slot, where applicable.

  • settings_overlay – The serialised overlay settings.

  • data – The serialised contents of the message.

encoded() bytes[source]

Encode the message and return as a bytes buffer.

static from_bytes(message: bytes) libmuscle.mpp_message.MPPMessage[source]

Create an MPP Message from an encoded buffer.

Parameters

message – MessagePack encoded message data.