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]¶
- Fix the max length of a message name 
 - 
char messageStruct[MAX_MESSAGE_SIZE]¶
- Fix the max length of message struct names 
 - 
uint64_t UpdateCounter¶
- Number of times this message has been updated 
 - 
uint32_t CurrentReadBuffer¶
- current buffer to read the message from 
 - 
uint32_t MaxNumberBuffers¶
- Max buffers this message will have 
 - 
uint64_t MaxMessageSize¶
- Maximum allowable message size in bytes 
 - 
uint64_t CurrentReadSize¶
- Current size available for reading 
 - 
uint64_t CurrentReadTime¶
- [ns] Current time of last read 
 - 
uint64_t StartingOffset¶
- Starting offset in the storage buffer 
 - 
int64_t previousPublisher¶
- (-) The module who last published the message 
 
- 
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¶
- (-) history of write/read pairs for message 
 
- 
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¶
- (-) Name of this process buffer for application access 
 - 
BlankStorage messageStorage¶
- (-) The storage buffer associated with this process 
 - 
std::vector<AllowAccessData> pubData¶
- (-) Entry of publishers for each message ID 
 - 
std::vector<AllowAccessData> subData¶
- (-) Entry of subscribers for each message ID 
 - 
std::vector<MessageExchangeData> exchangeData¶
- [-] List of write/read pairs 
 
- 
std::string 
- 
struct MessageIdentData¶
- #include <system_messaging.h>another header/key to a message 
- 
class SystemMessaging¶
- #include <system_messaging.h>system messaging class Public Functions - 
int64_t AttachStorageBucket(std::string bufferName = "")¶
- returns a pointer to the sim instance of SystemMessaging - Attach Storeage to Bucket - Return
- int64_t bufferCount 
- Parameters
- 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
- 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
- CurrentMessageCount 
- Parameters
- 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
- MessageName: The name of the message
- MaxSize: The size of the message
- NumMessageBuffers: The number of buffers to create for the message
- messageStruct: The name of the struct
- 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
- MessageID: The message to write to
- ClockTimeNanos: The time to say the message was written in ns since sim start
- MsgSize: Size of the message
- MsgPayload: The data in the message
- 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
- MessageID: ID of the message to read
- DataHeader: Message header pointer to put message header data into
- MaxBytes: The maximum number of bytes to read into MsgPayload
- MsgPayload: A pointer to memory to toss the message data into
- moduleID: The module requesting a read
- 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
- MessageID: The message to query for the header
- 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
- 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
- MessageID: The message to query for the name
- 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
- MessageName: The name to query for the ID
- 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
- messageName: name of the message to sub to
- messageSize: size in bytes of message
- 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
- 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
- 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
- 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
- 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
- messageID: the ID of the message to write to
- 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
- messageID: The message to get read rights to
- 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 reading
- maxMsgBytes: The maximum number of bytes for a given message type
- CurrentOffset: The message count that we want to ready out
- DataHeader: The message header that we are writing out to
- maxReadBytes: The maximum number of read bytes
- OutputBuffer: 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¶
- data buffer vector 
 - 
MessageStorageContainer *messageStorage¶
- this is a pointer to the currently selected message buffer above 
 - 
uint64_t WriteFails¶
- the number of times we tried to write invalidly 
 - 
uint64_t ReadFails¶
- the number of times we tried to read invalidly 
 - 
uint64_t CreateFails¶
- the number of times we tried to create invalidly 
 - 
int64_t nextModuleID¶
- the next module ID to give out when a module comes online 
 Private Static Attributes - 
SystemMessaging *TheInstance= NULL¶
- instance of system messaging - This constructor for TheInstance just sets it NULL 
 
- 
int64_t