Module: system_messaging¶
Defines
- 
MAX_MESSAGE_SIZE¶ 
- 
struct 
MessageHeaderData¶ - #include <system_messaging.h>
This struct holds all the key information for a message it’s kind of like an key to a message
Public Members
- 
char 
MessageName[MAX_MESSAGE_SIZE]¶ 
- 
char 
messageStruct[MAX_MESSAGE_SIZE]¶ Fix the max length of a message name
- 
uint64_t 
UpdateCounter¶ Fix the max length of message struct names
- 
uint32_t 
CurrentReadBuffer¶ Number of times this message has been updated
- 
uint32_t 
MaxNumberBuffers¶ current buffer to read the message from
- 
uint64_t 
MaxMessageSize¶ Max buffers this message will have
- 
uint64_t 
CurrentReadSize¶ Maximum allowable message size in bytes
- 
uint64_t 
CurrentReadTime¶ Current size available for reading
- 
uint64_t 
StartingOffset¶ [ns] Current time of last read
- 
int64_t 
previousPublisher¶ Starting offset in the storage buffer
 - 
char 
 
- 
struct 
SingleMessageHeader¶ - #include <system_messaging.h>
This header has more concise information and is stored physically with the message data.
 
- 
struct 
AllowAccessData¶ - #include <system_messaging.h>
Used to store permissions info for messages.
 
- 
struct 
MessageExchangeData¶ - #include <system_messaging.h>
Not sure yet how this is different than AllowAccessData
Public Members
- 
std::set<std::pair<long int, long int>> 
exchangeList¶ 
 - 
std::set<std::pair<long int, long int>> 
 
- 
struct 
MessageStorageContainer¶ - #include <system_messaging.h>
Basically the container for a single process buffer
Public Members
- 
std::string 
bufferName¶ 
- 
BlankStorage 
messageStorage¶ (-) Name of this process buffer for application access
- 
std::vector<AllowAccessData> 
pubData¶ (-) The storage buffer associated with this process
- 
std::vector<AllowAccessData> 
subData¶ (-) Entry of publishers for each message ID
- 
std::vector<MessageExchangeData> 
exchangeData¶ (-) Entry of subscribers for each message ID
 - 
std::string 
 
- 
struct 
MessageIdentData¶ - #include <system_messaging.h>
another header/key to a message
 
- 
class 
SystemMessaging¶ Public Functions
- 
int64_t 
AttachStorageBucket(std::string bufferName = "")¶ returns a pointer to the sim instance of SystemMessaging
- Return
 int64_t bufferCount
- Parameters
 std::string: bufferName
- 
void 
SetNumMessages(int64_t MessageCount)¶ adds a new buffer to the messaging system
This method records the current number of messages in the messageStorage space
- Return
 void
- Parameters
 int64_t: MessageCount
- 
int64_t 
GetMessageCount(int32_t bufferSelect = -1)¶ updates message count in buffer header
This method gets the number of messages in the selected or requested buffer
- Return
 int64_t CurrentMessageCount
- Parameters
 int32_t: bufferSelect
- 
void 
ClearMessageBuffer()¶ gets the number of messages in buffer bufferSelect
This method sets all bits in messageSpace for the current buffer to 0
- Return
 void
- 
uint64_t 
GetCurrentSize()¶ sets current buffer to zeros
This method returns total size of message buffer in bytes including:
a int64_t for num msgs
a MessageHeaderData Struct for each message
(the size of a message + a single message header) * the number of buffers for that message
- Return
 void
- 
int64_t 
CreateNewMessage(std::string MessageName, uint64_t MaxSize, uint64_t NumMessageBuffers = 2, std::string messageStruct = "", int64_t moduleID = -1)¶ returns size of current buffer
This method creates a new message within the currently selected buffer.
- Return
 uint64_t (GetMessageCount - 1), the assigned message ID
- Parameters
 std::string: MessageName The name of the messageuint64_t: MaxSize The size of the messageuint64_t: NumMessageBuffers The number of buffers to create for the messagestd::string: messageStruct The name of the structint64_t: moduleID The id of the requesting module
- 
bool 
WriteMessage(int64_t MessageID, uint64_t ClockTimeNanos, uint64_t MsgSize, void *MsgPayload, int64_t moduleID = -1)¶ This method writes data to an already-created message if the requester has the right to
- Return
 bool whether or not the message was written
- Parameters
 in64_t: MessageID The message to write touint64_t: ClockTimeNanos The time to say the message was written in ns since sim startuint64_t: MsgSize Size of the messagevoid*: MsgPayload The data in the messageint64_t: moduleID The requester ID
- 
bool 
ReadMessage(int64_t MessageID, SingleMessageHeader *DataHeader, uint64_t MaxBytes, void *MsgPayload, int64_t moduleID = -1, uint64_t CurrentOffset = 0)¶ This method reads a message. A warning is thrown if the requester isn’t supposed to be reading this message.
- Return
 bool Whether the message was read successfully or not
- Parameters
 int64_t: MessageID ID of the message to readSingleMessageHeader*: DataHeader Message header pointer to put message header data intouint64_t: MaxBytes The maximum number of bytes to read into MsgPayloadvoid*: MsgPayload A pointer to memory to toss the message data intoint64_t: moduleID The module requesting a readuint64_t: CurrentOffset
- 
MessageHeaderData *
FindMsgHeader(int64_t MessageID, int32_t bufferSelect = -1)¶ This method returns the MessageHeaderData for a MessageID in the bufferSelect buffer
- Return
 MessageHeaderdata* MsgHdr The data requested
- Parameters
 int64_t: MessageID The message to query for the headerint32_t: bufferSelect The buffer to query for the message
- 
void 
PrintAllMessageData()¶ returns a MessageHeaderData
This method prints all message data from the current buffer
- Return
 void
- 
void 
PrintMessageStats(int64_t MessageID)¶ prints data for messages in current buffer
This message prints MessageHeaderData information for the requested MessageID
- Return
 void
- Parameters
 int64_t: MessageID The message to query
- 
std::string 
FindMessageName(int64_t MessageID, int32_t bufferSelect = -1)¶ prints data for a single message by ID
Finds the message name for the requested message in the selected buffer
- Return
 std::string MessageName The name of the six fingered man
- Parameters
 int64_t: MessageID The message to query for the nameint32_t: bufferSelect The buffer to query for the message
- 
int64_t 
FindMessageID(std::string MessageName, int32_t bufferSelect = -1)¶ searches only the selected buffer
This message takes a MessageName and gives a message ID
- Return
 int64_t the message ID
- Parameters
 std::string: MessageName The name to query for the IDint32_t: bufferSelect The buffer to query for the name
- 
int64_t 
subscribeToMessage(std::string messageName, uint64_t messageSize, int64_t moduleID)¶ searches only the selected buffer
This method subscribes a module to a message (but what does that mean different than read rights?)
- Return
 int64_t messageID
- Parameters
 std::string: messageName name of the message to sub touint64_t: messageSize size in bytes of messageint64_t: moduleID ID of the requesting module
- 
int64_t 
checkoutModuleID()¶ This method assigns a module ID to a new module and increments the NextModuleID counter
- Return
 uint64_t nextModuleID the newly minted module ID
- 
void 
selectMessageBuffer(int64_t bufferUse)¶ Assigns next integer module ID
This method selects which message buffer is being read from when messageStorage is referenced
- Return
 void
- Parameters
 uint64_t: bufferUse
- 
uint64_t 
getProcessCount()¶ sets a default buffer for everything to use
- 
MessageIdentData 
messagePublishSearch(std::string messageName)¶ This method checks ALL message buffers for a message with the given name
- Return
 MessageIdentData dataFound A chunk of info about the message including whether it was found or not
- Parameters
 std::string: messageName
- 
int64_t 
findMessageBuffer(std::string bufferName)¶ returns MessageIdentData if found
This method finds a buffer given a name
- Return
 MessageStorageContainer* a pointer to the buffer. Or, return -1 if not found.
- Parameters
 std::string: bufferName
- 
std::set<std::string> 
getUnpublishedMessages()¶ This method returns a list of messages that no one has access to.
- Return
 std::set<std::string> unpublishedList The list of message names that are unpublished.
- 
std::set<std::string> 
getUniqueMessageNames()¶ returns msgs no one has access rights to
This method searches across all message buffers to get unique message names in the sim
- Return
 std::set<std::string> outputNames A list of unique message names in the whole sim
- 
std::set<std::pair<long int, long int>> 
getMessageExchangeData(int64_t messageID)¶ searched across all buffers
This message gets the exchangeData for a given messageID
- Return
 std::set<std::pair<long int, long int>> exchangeList
- Parameters
 int64_t: messageID
- 
void 
clearMessaging()¶ This method clears all data from all message buffers
- Return
 void
- 
bool 
obtainWriteRights(int64_t messageID, int64_t moduleID)¶ wipes out all messages and buffers. total messaging system reset.
This message gives the requesting module write rights if the module and message are valid
- Return
 bool rightsObtained True if access was granted, else false
- Parameters
 int64_t: messageID the ID of the message to write toint64_t: moduleID The ID of the requesting module
- 
bool 
obtainReadRights(int64_t messageID, int64_t moduleID)¶ grants rights to the requesting module
this method gives the requesting module permission to read the requested message
- Return
 bool rightsObtained True if rights granted, else false
- Parameters
 int64_t: messageID The message to get read rights toint64_t: moduleID The requesting module
- 
uint64_t 
getFailureCount()¶ grants rights to the requesting module
Public Static Functions
- 
SystemMessaging *
GetInstance()¶ This gives a pointer to the messaging system to whoever asks for it.
- Return
 SystemMessaging* TheInstance
- 
void 
AccessMessageData(uint8_t *MsgBuffer, uint64_t maxMsgBytes, uint64_t CurrentOffset, SingleMessageHeader *DataHeader, uint64_t maxReadBytes, uint8_t *OutputBuffer)¶ This method is static and is added so that other classes (ex. messageLogger) that have the messaging buffer layout can easily access their own internal buffers without having to re-write the same code. Kind of overkill, but there you go.
- Return
 void
- Parameters
 MsgBuffer: The base address of the message buffer we are readingMsgBytes: The maximum number of bytes for a given message typeCurrentOffset: The message count that we want to ready outDataHeader: The message header that we are writing out toOutputBuffer: The output message buffer we are writing out to
Private Functions
- 
SystemMessaging()¶ This constructor for SystemMessaging initializes things
- 
~SystemMessaging()¶ This destructor for SystemMessaging sets the messageStorage spce to NULL.
- 
SystemMessaging(SystemMessaging const&)¶ 
- 
SystemMessaging &
operator=(SystemMessaging const&)¶ 
Private Members
- 
std::vector<MessageStorageContainer*> 
dataBuffers¶ 
- 
MessageStorageContainer *
messageStorage¶ 
- 
uint64_t 
WriteFails¶ 
- 
uint64_t 
ReadFails¶ the number of times we tried to write invalidly
- 
uint64_t 
CreateFails¶ the number of times we tried to read invalidly
- 
int64_t 
nextModuleID¶ the number of times we tried to create invalidly
Private Static Attributes
- 
SystemMessaging *
TheInstance= NULL¶ This constructor for TheInstance just sets it NULL
- 
int64_t