CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::DataMessageHeader Struct Reference

The current (version 10) DataMessage wire/shared-memory header. More...

#include <DataMessage.h>

Collaboration diagram for cmlabs::DataMessageHeader:
[legend]

Public Member Functions

std::string toJSON (std::map< uint16, std::string > *subtypes=NULL, std::map< uint16, std::string > *subcontexts=NULL, std::map< uint32, std::string > *compNames=NULL)
 Render the header fields as a JSON object (header only, no user entries).
std::string toXML (std::map< uint16, std::string > *subtypes=NULL, std::map< uint16, std::string > *subcontexts=NULL, std::map< uint32, std::string > *compNames=NULL)
 Render the header fields as an XML fragment (header only, no user entries).

Public Attributes

uint32 size
 Total size of the whole message block in bytes (header + all entries).
uint32 cid
 Object id, always DATAMESSAGEID for a valid current-format message; used by isValid().
uint16 cver
 Message format version (CURRENTDATAMESSAGEVERSION).
uint16 cenc
 Encoding flags (reserved for compression/encryption of the payload).
uint64 memid
 Shared-memory id assigned when the message is stored in a memory map.
uint64 time
 Creation time in microseconds since epoch (see PsyTime).
uint64 sendtime
 Time the message was posted/sent, in microseconds.
uint64 recvtime
 Time the message was received by the current component, in microseconds.
uint16 origin
 NodeID of the node the message originated on.
uint16 destination
 NodeID of the target node (0 = local/any).
uint64 ttl
 Time-to-live in microseconds; 0 means deliver-and-forget (not retained in memory).
uint16 priority
 Scheduling priority; higher values are processed first by whiteboards and modules.
uint8 policy
 Delivery policy flags, e.g.
uint32 from
 Component id of the sender.
uint32 to
 Component id of the addressee; 0 for publish/subscribe distribution.
PsyType type
 Hierarchical message type (e.g.
uint32 tag
 User tag id for temporal/semantic grouping of related messages.
uint16 status
 User/application status code.
uint64 reference
 Reference id linking this message to another (e.g.
uint64 serial
 Serial number, e.g.
PsyContext contextchange
 Context switch this message announces (NOCONTEXT if none).
uint32 userSize
 Total size in bytes of all user entries currently in use.
uint32 userCount
 Number of user entries currently in use.
uint32 cyclecputime
 CPU time spent processing the triggering message in this cycle, in microseconds (profiling).
uint32 cyclewalltime
 Wall-clock time spent in this cycle, in microseconds (profiling).
uint32 chaincputime
 Accumulated CPU time across the whole causal message chain, in microseconds.
uint32 chainwalltime
 Accumulated wall time across the whole causal message chain, in microseconds.
uint32 chaincount
 Number of messages in the causal chain leading to (and including) this one.
uint32 systemid
 Id of the Psyclone system instance that sent the message.

Detailed Description

The current (version 10) DataMessage wire/shared-memory header.

This struct is the first thing in every DataMessage memory block; the user entries follow immediately after it. It is written verbatim into shared memory and onto the network, so its size, alignment and field order form a binary contract between all nodes and all recorded data.

Warning
Never reorder, remove or resize fields. To extend the format, append fields, bump CURRENTDATAMESSAGEVERSION, change DATAMESSAGEID, and provide a converter (as was done for DataMessageHeader_Old, version < 10).

Field provenance conventions used in the trailing comments:

  • "auto": maintained by the messaging core itself
  • "api": set by the PsyAPI/runtime while routing
  • "spec": copied from the posting TriggerSpec/PostSpec
  • "user": freely settable by user code

Definition at line 188 of file DataMessage.h.

Member Function Documentation

◆ toJSON()

std::string cmlabs::DataMessageHeader::toJSON ( std::map< uint16, std::string > * subtypes = NULL,
std::map< uint16, std::string > * subcontexts = NULL,
std::map< uint32, std::string > * compNames = NULL )

Render the header fields as a JSON object (header only, no user entries).

Parameters
subtypesoptional map translating type level ids to readable names
subcontextsoptional map translating context level ids to readable names
compNamesoptional map translating component ids to readable names
Returns
JSON string

Definition at line 53 of file DataMessage.cpp.

References chaincount, chaincputime, chainwalltime, cid, contextchange, cyclecputime, cyclewalltime, DATAMESSAGEID, destination, from, memid, origin, policy, cmlabs::PrintTimeString(), priority, recvtime, reference, sendtime, serial, size, status, cmlabs::utils::StringFormat(), tag, time, to, ttl, type, userCount, and userSize.

◆ toXML()

std::string cmlabs::DataMessageHeader::toXML ( std::map< uint16, std::string > * subtypes = NULL,
std::map< uint16, std::string > * subcontexts = NULL,
std::map< uint32, std::string > * compNames = NULL )

Render the header fields as an XML fragment (header only, no user entries).

Parameters
subtypesoptional map translating type level ids to readable names
subcontextsoptional map translating context level ids to readable names
compNamesoptional map translating component ids to readable names
Returns
XML string

Definition at line 101 of file DataMessage.cpp.

References chaincount, chaincputime, chainwalltime, cid, contextchange, cyclecputime, cyclewalltime, DATAMESSAGEID, destination, from, memid, origin, policy, cmlabs::PrintTimeString(), priority, recvtime, reference, sendtime, serial, size, status, cmlabs::utils::StringFormat(), tag, time, to, ttl, type, userCount, and userSize.

Member Data Documentation

◆ cenc

uint16 cmlabs::DataMessageHeader::cenc

Encoding flags (reserved for compression/encryption of the payload).

auto

Definition at line 192 of file DataMessage.h.

◆ chaincount

uint32 cmlabs::DataMessageHeader::chaincount

Number of messages in the causal chain leading to (and including) this one.

Definition at line 221 of file DataMessage.h.

Referenced by toJSON(), toXML(), and cmlabs::PsyAPI::waitForNewMessage().

◆ chaincputime

uint32 cmlabs::DataMessageHeader::chaincputime

Accumulated CPU time across the whole causal message chain, in microseconds.

Definition at line 219 of file DataMessage.h.

Referenced by cmlabs::Internal_StatsLog(), toJSON(), toXML(), and cmlabs::PsyAPI::waitForNewMessage().

◆ chainwalltime

uint32 cmlabs::DataMessageHeader::chainwalltime

Accumulated wall time across the whole causal message chain, in microseconds.

Definition at line 220 of file DataMessage.h.

Referenced by cmlabs::Internal_StatsLog(), toJSON(), toXML(), and cmlabs::PsyAPI::waitForNewMessage().

◆ cid

uint32 cmlabs::DataMessageHeader::cid

Object id, always DATAMESSAGEID for a valid current-format message; used by isValid().

auto

Definition at line 190 of file DataMessage.h.

Referenced by cmlabs::DataMessage::ConvertDataFromOlderMessageFormat(), cmlabs::DataMessage::copyUserEntriesFromMessage(), toJSON(), and toXML().

◆ contextchange

PsyContext cmlabs::DataMessageHeader::contextchange

Context switch this message announces (NOCONTEXT if none).

api/user

Definition at line 212 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ cver

uint16 cmlabs::DataMessageHeader::cver

Message format version (CURRENTDATAMESSAGEVERSION).

auto

Definition at line 191 of file DataMessage.h.

Referenced by cmlabs::DataMessage::ConvertDataFromOlderMessageFormat().

◆ cyclecputime

uint32 cmlabs::DataMessageHeader::cyclecputime

CPU time spent processing the triggering message in this cycle, in microseconds (profiling).

Definition at line 217 of file DataMessage.h.

Referenced by cmlabs::Internal_StatsLog(), toJSON(), and toXML().

◆ cyclewalltime

uint32 cmlabs::DataMessageHeader::cyclewalltime

Wall-clock time spent in this cycle, in microseconds (profiling).

Definition at line 218 of file DataMessage.h.

Referenced by cmlabs::Internal_StatsLog(), toJSON(), and toXML().

◆ destination

uint16 cmlabs::DataMessageHeader::destination

NodeID of the target node (0 = local/any).

api

Definition at line 198 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ from

uint32 cmlabs::DataMessageHeader::from

Component id of the sender.

user

Definition at line 204 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ memid

uint64 cmlabs::DataMessageHeader::memid

Shared-memory id assigned when the message is stored in a memory map.

auto

Definition at line 193 of file DataMessage.h.

Referenced by cmlabs::PsySpace::postMessage(), toJSON(), and toXML().

◆ origin

uint16 cmlabs::DataMessageHeader::origin

NodeID of the node the message originated on.

api

Definition at line 197 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ policy

uint8 cmlabs::DataMessageHeader::policy

Delivery policy flags, e.g.

MESSAGE_NON_GUARANTEED. spec

Definition at line 202 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ priority

uint16 cmlabs::DataMessageHeader::priority

Scheduling priority; higher values are processed first by whiteboards and modules.

spec

Definition at line 201 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ recvtime

uint64 cmlabs::DataMessageHeader::recvtime

Time the message was received by the current component, in microseconds.

api

Definition at line 196 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ reference

uint64 cmlabs::DataMessageHeader::reference

Reference id linking this message to another (e.g.

request/reply correlation). api

Definition at line 210 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ sendtime

uint64 cmlabs::DataMessageHeader::sendtime

Time the message was posted/sent, in microseconds.

api

Definition at line 195 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ serial

uint64 cmlabs::DataMessageHeader::serial

Serial number, e.g.

sequence position in a recording. api/user

Definition at line 211 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ size

◆ status

uint16 cmlabs::DataMessageHeader::status

User/application status code.

api/user

Definition at line 209 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ systemid

uint32 cmlabs::DataMessageHeader::systemid

Id of the Psyclone system instance that sent the message.

Definition at line 223 of file DataMessage.h.

◆ tag

uint32 cmlabs::DataMessageHeader::tag

User tag id for temporal/semantic grouping of related messages.

api/user

Definition at line 208 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ time

uint64 cmlabs::DataMessageHeader::time

Creation time in microseconds since epoch (see PsyTime).

auto

Definition at line 194 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ to

uint32 cmlabs::DataMessageHeader::to

Component id of the addressee; 0 for publish/subscribe distribution.

user

Definition at line 205 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ ttl

uint64 cmlabs::DataMessageHeader::ttl

Time-to-live in microseconds; 0 means deliver-and-forget (not retained in memory).

spec

Definition at line 200 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ type

PsyType cmlabs::DataMessageHeader::type

Hierarchical message type (e.g.

"2.201.3") used for subscription matching. api/user

Definition at line 207 of file DataMessage.h.

Referenced by toJSON(), and toXML().

◆ userCount

uint32 cmlabs::DataMessageHeader::userCount

◆ userSize

uint32 cmlabs::DataMessageHeader::userSize

Total size in bytes of all user entries currently in use.

Definition at line 214 of file DataMessage.h.

Referenced by cmlabs::DataMessage::fillInDraftUserDataFrom(), toJSON(), and toXML().


The documentation for this struct was generated from the following files: