Table of Contents

Class DataStorageManager

Namespace
NominalSystems.Classes
Assembly
NominalSystems.Classes.dll

The Data Storage Manager can be connected to a partitioned data storage unit and is able to configure the writing and reading of messages within the system. The manager handles the process of updating messages, connecting to the storage sources and ensurig that messages can be exported as a CSV.

public class DataStorageManager : ComponentModel<PartitionedDataStorage>
Inheritance
ComponentModel<PartitionedDataStorage>
DataStorageManager
Inherited Members
ComponentModel<PartitionedDataStorage>.Target

Constructors

DataStorageManager()

public DataStorageManager()

Fields

WritePeriod

[s] The period of time between writing of messages

[EditableVariable("s", 0, false, "", "")]
public double WritePeriod

Field Value

double

Properties

CorruptedMessages

[-] The total number of corrupted messages in the buffer

[EditableVariable("-", true, "", "")]
public int CorruptedMessages { get; }

Property Value

int

SuccessfulWrites

[-] The number of successful writes made in terms of the number of messages

[EditableVariable("-", true, "", "")]
public int SuccessfulWrites { get; }

Property Value

int

TotalMessages

[-] The total number of messages stored in the buffer

[EditableVariable("-", true, "", "")]
public int TotalMessages { get; }

Property Value

int

TotalReceived

[-] The total number of messages received in the buffer

[EditableVariable("-", true, "", "")]
public int TotalReceived { get; }

Property Value

int

Methods

DeleteAll()

Called when the messages and the references to them should all be deleted. This will remove all references to the messages in the buffer.

public void DeleteAll()

DeregisterAll()

Deregisters all messages from the tracking list and stops all messages from being saved in the storage system.

public void DeregisterAll()

DeregisterMessage(Message)

Deregisters a particular message from the list and ensures that is no longer tracked within the manager system.

public bool DeregisterMessage(Message msg)

Parameters

msg Message

The message to deregister

Returns

bool

A successful deregisteration flag

ExportMessagesToCSV(string, bool, bool)

public bool ExportMessagesToCSV(string path, bool useFormattedTime = true, bool delete = false)

Parameters

path string
useFormattedTime bool
delete bool

Returns

bool

GetNumSavedMessages(Message)

Returns the number of messages of some message stored in the data storage system of that message type from the saved buffer.

public int GetNumSavedMessages(Message msg)

Parameters

msg Message

The message to check

Returns

int

The number of messages tracked

OnUpdate(double, double)

Called each timestep during a event tick

protected override void OnUpdate(double time, double step)

Parameters

time double

current time (seconds)

step double

delta timestep (seconds)

PopSavedMessage(Type?)

Returns a single oldest message located in the buffer and is able to delete it from the list. If a type is passed in to the function, then the most recently saved message of that matching type will be returned instead. This will also delete it from the memory.

public object? PopSavedMessage(Type? type = null)

Parameters

type Type

An optional search type within the saved library of messages in the system.

Returns

object

The oldest message of some type in the saved buffer

ReadReceivedMessages<T>(ulong, ulong, bool)

Gets a list of all received messages of a particular message type and returns a list of all messages stored of that type within a time. The maximum time specefies what messages should be returned if the message time is less than the maximum time. If the maximum time is set to zero, then all messages will be returned. This is the same for the minimum timestamp.

public List<T>? ReadReceivedMessages<T>(ulong minimumTime = 0, ulong maximumTime = 0, bool delete = false) where T : Message

Parameters

minimumTime ulong

[ns] The minimum amount of time to search timed messages from.

maximumTime ulong

[ns] The maximum amount of time to search timed messages from.

delete bool

A flag for whether the messages should be deleted after being read

Returns

List<T>

A list of all messages of a particular type

Type Parameters

T

The message type to search

ReadReceivedTimestampedPayloads<T>(ulong, ulong, bool)

Returns a list of timestamped messages that are stored in the system and returns the list without actually modifying any of the data in the system. The maximum time specefies what messages should be returned if the message time is less than the maximum time. If the maximum time is set to zero, then all messages will be returned. This is the same for the minimum timestamp.

public List<TimestampedPayload<T>>? ReadReceivedTimestampedPayloads<T>(ulong minimumTime = 0, ulong maximumTime = 0, bool delete = false) where T : Message

Parameters

minimumTime ulong

[ns] The minimum amount of time to search timed messages from.

maximumTime ulong

[ns] The maximum amount of time to search timed messages from.

delete bool

A flag for whether the messages should be deleted after being read

Returns

List<TimestampedPayload<T>>

A list of all timestamped payloads of a particular type

Type Parameters

T

The message type to search

ReadSavedMessages<T>(T, bool)

Attempts to read a message from the partitioned data storage system and returns a list of all copies of that message that were stored in the system, if valid. This will handle using timed messages and ensure that only the default messages are used.

public List<T>? ReadSavedMessages<T>(T msg, bool delete = true) where T : Message

Parameters

msg T

The message reference

delete bool

A flag whether to remove those messages from the list

Returns

List<T>

A list of all messages (copies) stored, if it exists

Type Parameters

T

The message type to read

RegisterMessage(Message)

Registers a particular message to the list and is able to keep track of the data that is stored from that message. These messages will be registered such that their state will be copied to the storage system.

public bool RegisterMessage(Message msg)

Parameters

msg Message

The message to register

Returns

bool

A successful registration flag

TransmitStoredData(Transmitter, string)

Transmits stored data from a particular data storage system from the transmitter and submits all stored messages to the buffer.

public bool TransmitStoredData(Transmitter transmitter, string messageName = "")

Parameters

transmitter Transmitter

The transmitter to transmit the object on

messageName string

The message type to transmit, or all if left as none

Returns

bool

A successful upload to the transmitter

WriteMessagesToCSV(object[], string, bool)

Writes a list of timestamped messages into a CSV file of a particular path name. This works as long as the messages are timestamped messages. This static function will work with an array of obejcts and is independent of what data is saved within the instances of the storage systems.

public static bool WriteMessagesToCSV(object[] timedMessages, string path, bool useFormattedTime = true)

Parameters

timedMessages object[]

An array of timed messages

path string

The full file path to the csv file

useFormattedTime bool

A flag for using formatted time instead of nanos

Returns

bool

A success export to CSV flag

WriteReceivedData(byte[])

Called by a receiver storage model when data has been received from a transmission. This data is the raw byte that was serialized from a Timed message.

public bool WriteReceivedData(byte[] data)

Parameters

data byte[]

The raw byte data that is received.

Returns

bool

A successful storage flag

WriteReceivedObject(object)

Writes a custom object into the received buffer for storing in a database.

public bool WriteReceivedObject(object obj)

Parameters

obj object

The object to store as data

Returns

bool

A successful storage flag