Module: dataStorageUnitBase
Executive Summary
DataStorageUnitBase is a base class that is used generate a standard interface and list of features for modules that store simulated onboard data. This class is used by other modules as a parent class and cannot be instantiated by itself. All Basilisk data storage modules based on this DataStorageUnitBase inherit the following common properties:
Writes out a DataStorageStatusMsgPayload containing the sum of the current stored data (in bits), the storage capacity (bits), the current net data rate (in baud), an array of char array containing the names of the stored data (ex. Instrument 1, Instrument 2), and an array of integers containing the stored data associated with each type (bits).
Allows for multiple DataNodeUsageMsgPayload corresponding to individual Module: dataNodeBase instances to be subscribed to using the
addDataNodeToModel(msg)
method.Iterates through attached DataNodeUsageMsgPayload instances, integrates the data for each data node, and adds it to its respective entry using
integrateDataStatus()
method, which may be overwritten in child classes.Loops through the vector of storedData to sum the total amount of data contained within the storage unit.
Add or remove data from specified partitions using
setDataBuffer()
method.
Core functionality is wrapped in the integrateDataStatus
protected virtual void method, which computes the amount of data stored in a storage unit on a module basis. This base class automatically implements a partitioned storage unit (different data buffers for each device). See Module: simpleStorageUnit for an example of how this functionality can be overwritten.
Protected methods prepended with custom
are intended for module developers to override with additional, module-specific functionality.
For more information on how to set up and use classes derived from this module, see the simple data system example: scenarioDataDemo
Module Assumptions and Limitations
The base class makes no specific data storage device related assumptions.
Message Connection Descriptions
The following table lists all the module input and output messages. The module msg connection is set by the user from python. The msg type contains a link to the message structure definition, while the description provides information on what this message is used for.
Msg Variable Name |
Msg Type |
Description |
---|---|---|
nodeDataUseInMsgs |
Vector of data node usage input messages. Subscribed to using |
|
storageUnitDataOutMsg |
Output message. Describes storage unit capacity, storage level, net data rate, and contents. |
User Guide
The user can connect to the output message using
storageUnitDataOutMsg
in Python.The input message (data nodes) are provided by calling the method
addDataNodeToModel()
-
struct dataInstance
- #include <dataStorageUnitBase.h>
Struct for instances of data stored in a buffer. Includes names and amounts.
-
class DataStorageUnitBase : public SysModel
- #include <dataStorageUnitBase.h>
on-board data handling base class
Public Functions
-
DataStorageUnitBase()
This method initializes some basic parameters for the module.
- Returns:
void
-
~DataStorageUnitBase()
Destructor.
- Returns:
void
-
void Reset(uint64_t CurrentSimNanos)
This method is used to reset the module.
- Parameters:
CurrentSimNanos –
- Returns:
void
-
void addDataNodeToModel(Message<DataNodeUsageMsgPayload> *tmpNodeMsg)
Adds dataNode to the storageUnit.
Adds a simDataNodeMsg name to be iterated over. Called in Python.
- Parameters:
tmpNodeMsg –
- Returns:
void
-
void UpdateState(uint64_t CurrentSimNanos)
Reads messages, adds new data to the storage unit, and writes out the storage unit status
- Parameters:
CurrentSimNanos – The current simulation time in nanoseconds
- Returns:
void
-
void setDataBuffer(std::string partitionName, int64_t data)
Adds/removes the data from the partitionName partition once.
Adds a specific amount of data to the storedData vector once
- Parameters:
partitionName – //Name of the partition to add data to
data – //Amount of data to add to the partition
- Returns:
void
Public Members
-
std::vector<ReadFunctor<DataNodeUsageMsgPayload>> nodeDataUseInMsgs
Vector of data node input message names.
-
Message<DataStorageStatusMsgPayload> storageUnitDataOutMsg
Vector of message names to be written out by the storage unit.
-
int64_t storageCapacity
Storage capacity of the storage unit.
-
BSKLogger bskLogger
logging variable
Protected Functions
-
void writeMessages(uint64_t CurrentClock)
Loops through the storedData vector and assigns values to output message.
- Parameters:
CurrentClock – The current time used for time-stamping the message
- Returns:
void
-
bool readMessages()
This method is used to read the incoming data supply/outgoing data messages and store them for future use.
- Returns:
void
-
virtual void integrateDataStatus(double currentTime)
Integrates the dataStatus over all of the dataNodes.
Loops through all of the input messages, integrates the baud rates, and adds the new data to the storedData vector
- Parameters:
currentTime –
- Returns:
void
-
virtual void customReset(uint64_t CurrentClock)
Custom Reset method, similar to customSelfInit.
Custom Reset() method. This allows a child class to add additional functionality to the Reset() method
- Returns:
void
-
virtual void customWriteMessages(uint64_t CurrentClock)
custom Write method, similar to customSelfInit.
custom Write method, similar to customSelfInit.
- Returns:
void
-
virtual bool customReadMessages()
Custom read method, similar to customSelfInit; returns true by default.
Custom read method, similar to customSelfInit; returns true by default.
- Returns:
void
-
int messageInStoredData(DataNodeUsageMsgPayload *tmpNodeMsg)
Returns index of the dataName if it’s already in storedData.
Checks to see if a data node is in the storedData vector or not, returns the index.
- Parameters:
tmpNodeMsg –
- Returns:
index
-
int64_t sumAllData()
Sums all of the data in the storedData vector.
Sums all of the data in the storedData vector
- Returns:
double
Protected Attributes
-
DataStorageStatusMsgPayload storageStatusMsg
class variable
-
std::vector<DataNodeUsageMsgPayload> nodeBaudMsgs
class variable
-
int64_t storedDataSum
[bits] Stored data in bits.
-
std::vector<dataInstance> storedData
Vector of data. Represents the makeup of the data buffer.
-
double previousTime
Previous time used for integration.
-
double currentTimestep
[s] Timestep duration in seconds.
-
double netBaud
Net baud rate at a given time step.
-
DataStorageUnitBase()