Module: sim_model¶
Typedefs
-
typedef enum varAccessType
VarAccessType
¶
-
class
SimModel
¶ - #include <sim_model.h>
The top-level container for an entire simulation.
Public Functions
-
SimModel
()¶ The SimModel constructor.
This Constructor is used to initialize the top-level sim model.
-
void
selfInitSimulation
()¶ Method to initialize all added Tasks.
This method goes through all of the processes in the simulation, all of the tasks within each process, and all of the models within each task and self-inits them.
- Return
void
-
void
crossInitSimulation
()¶ Method to initialize all added Tasks.
This method goes through all of the processes in the simulation, all of the tasks within each process, and all of the models within each task and cross-inits them.
- Return
void
-
void
resetInitSimulation
()¶ Method to reset all added tasks.
This method goes through all of the processes in the simulation, all of the tasks within each process, and all of the models within each task and resets them.
- Return
void
-
void
StepUntilStop
(uint64_t SimStopTime, int64_t stopPri)¶ Step simulation until stop time uint64_t reached.
This method steps the simulation until the specified stop time and stop priority have been reached.
- Return
void
- Parameters
uint64_t
: SimStopTime Nanoseconds to step the simulation forint64_t
: stopPri The priority level below which the sim won’t go
-
void
SingleStepProcesses
(int64_t stopPri = -1)¶ Step only the next Task in the simulation.
This method steps all of the processes forward to the current time. It also increments the internal simulation time appropriately as the simulation processes are triggered
- Return
void
- Parameters
int64_t
: stopPri The priority level below which the sim won’t go
-
void
PrintSimulatedMessageData
()¶ Print out all messages that have been created.
This method exists to provide the python layer with a handle to call to print out the internal message stats.
- Return
void
-
void
addNewProcess
(SysProcess *newProc)¶ This method allows the user to attach a process to the simulation for execution. Note that the priority level of the process determines what order it gets called in: higher priorities are called before lower priorities. If priorities are the same, the proc added first goes first.
- Return
void
- Parameters
SysProcess
: *newProc the new process to be added
-
uint64_t
IsMsgCreated
(std::string MessageName)¶ This method exists to provide a hook into the messaging system for obtaining message data that was written in the simulation.
- Return
uint64_t Message Write time that we got
- Parameters
MessageName
: String name for the message we are queryingMaxSize
: Maximum size of the message that we can pullMessageData
: A shapeshifting buffer that we can chunk data intoLatestOffset
: An offset from the latest message to pull (default as zero)
-
uint64_t
GetWriteData
(std::string MessageName, uint64_t MaxSize, void *MessageData, VarAccessType logType = messageBuffer, uint64_t LatestOffset = 0)¶ Grab a particular MessageName with MaxSize limited.
This method exists to provide a hook into the messaging system for obtaining message data that was written in the simulation.
- Return
uint64_t Message Write time that we got
- Parameters
MessageName
: String name for the message we are queryingMaxSize
: Maximum size of the message that we can pullMessageData
: A shapeshifting buffer that we can chunk data intoLatestOffset
: An offset from the latest message to pull (default as zero)
-
void
ResetSimulation
()¶ Reset simulation back to zero.
This method is used to reset a simulation to time 0. It sets all process and tasks back to the initial call times. It clears all message logs. However, it does not clear all message buffers and does not reset individual models.
- Return
void
-
void
WriteMessageData
(std::string MessageName, uint64_t MessageSize, uint64_t ClockTime, void *MessageData)¶ Write in a single message.
This method exists to provide a hook into the messaging system for writing message data into existing messages
- Return
void
- Parameters
std::string
: MessageName Name for the message we are writinguint64_t
: MessageSize Size in bytes of the message we’re trying to writeuint64_t
: ClockTime The time that we are writing the message in nanosecondsvoid
: *MessageData A shapeshifting buffer that we can chunk data into
-
void
CreateNewMessage
(std::string processName, std::string MessageName, uint64_t MessageSize, uint64_t NumBuffers = 2, std::string messageStruct = "")¶ Create a new message for use.
This method exists to provide a hook into the messaging system for creating messages for use by the simulation.
- Return
void
- Parameters
std::string
: processName Name of process that we create the message instd::string
: MessageName Name for the message we are creatinguint64_t
: MessageSize Size in bytes of the message we want to makeuint64_t
: NumBuffers The count of message buffers to createstd::string
: messageStruct A name for the message struct type
-
void
logThisMessage
(std::string messageName, uint64_t messagePeriod = 0)¶ This method functions as a pass-through to the message logging structure when adding messages to log. The main point is to serve as an API at the main simulation level without having to hook in the message logger somewhere else.
- Return
void
- Parameters
std::string
: messageName The name of the message that we want to loguint64_t
: messagePeriod The minimum time between messages to allow in ns
-
int64_t
getNumMessages
()¶ Get number of messages in simulation.
This method gets the current number of messages that have been created in the simulation.
- Return
uint64_t The number of messages that have been created
-
std::string
getMessageName
(int64_t messageID)¶ Get name for specified message ID.
This method finds the name associated with the message ID that is passed in.
- Return
std::string messageName The message name for the ID
- Parameters
uint64_t
: messageID The message id that we wish to find the name for
-
MessageIdentData
getMessageID
(std::string messageName)¶ Get the ID associated with message name.
This method finds the ID associated with the message name and returns it to the caller. Mostly used to make sure a message is valid. If it’s not, you’ll just get -1, not a warning or failure.
- Return
int64_t messageID ID of the message associated with messageName
- Parameters
std::string
: messageName The name of the message that you want the ID for
-
void
populateMessageHeader
(std::string messageName, MessageHeaderData *headerOut)¶ Get header data associated with msg.
This method obtains the header information associated with a given message. Note the copy out to the incoming message. The assumption is that this method is called from the python level where the storage for headerOut is created. This way we don’t connect a pointer to the internal message at the python level
- Return
void
- Parameters
std::string
: messageName The name of the message we want to pull header information forMessageHeaderData*
: headerOut The output header information we extract from the simulation
-
std::set<std::string>
getUniqueMessageNames
()¶ This method gets the list of unique message names present in the simulation so that the user can see what messages have been created with no duplicates
- Return
std::set<std::string> set of strings that constitute the unique names
-
std::set<std::pair<long int, long int>>
getMessageExchangeData
(std::string messageName, std::set<unsigned long> procList = std::set<unsigned long>())¶ This method returns all of the read/write pairs for the entire simulation for a given message. That allows us to capture and analyze our data flow in a very clean manner.
- Return
std::set<std::pair> returnPairs Write/Read pairs for the entire simulation run
- Parameters
std::string
: messageName The name of the message to find pairs forstd::set<unsigned
: long> procList procs to check for read/write pairs
-
void
terminateSimulation
()¶ This method clears all messages. Note that once you do this, the simulation object itself is really dead.
- Return
void
Public Members
-
std::vector<SysProcess*>
processList
¶ List of processes we’ve created
-
std::string
SimulationName
¶ Identifier for Sim
-
uint64_t
CurrentNanos
¶ [ns] Current sim time
-
uint64_t
NextTaskTime
¶ [ns] time for the next Task
-
int64_t
nextProcPriority
¶ [-] Priority level for the next process
-
messageLogger
messageLogs
¶ Message log data
-