Table of Contents

Class ReceiverMessageWriterModel

Namespace
NominalSystems.Classes
Assembly
NominalSystems.Classes.dll

[Nominal] This implements a model on the receiver that can be connected to a partitioned storage system and is able to write the received messages to the storage.


[UniverseParent(typeof(Receiver))]
public class ReceiverMessageWriterModel : UniverseModel
Inheritance
ReceiverMessageWriterModel

Constructors

ReceiverMessageWriterModel()

Default constructor

protected ReceiverMessageWriterModel()

Fields

In_EpochMsg

An optional epoch message that can be used to store the epoch data within the data.

public EpochMessage? In_EpochMsg

Field Value

EpochMessage

Key

A key to look for mapping the received messages

public string Key

Field Value

string

KeyFilters

A filter of keys that are allowed to be stored in the system. Any data that is not in this list will be ignored. If the list is empty, all data will be stored by the receiver model.

[Hidden]
public List<string> KeyFilters

Field Value

List<string>

PointerData

A object storing the data for the pointers for the purpose of serialization when the data is saved.

[Hidden]
public JObject PointerData

Field Value

JObject

Storage

A reference to the partitioned data storage system that is attached to this model.

public PartitionedDataStorage? Storage

Field Value

PartitionedDataStorage

Properties

NumReceived

The number of received message pointers that have been stored in the system.

[Unit(UnitType.NONE)]
public int NumReceived { get; }

Property Value

int

Methods

AddFilter(string)

Adds a message type filter to the receiver model. This will ensure that only the message, with the specified key, can be filtered out.

public void AddFilter(string key = "")

Parameters

key string

The key to use for the filter

AddMessageFilter(Type, string)

Adds a message type filter to the receiver model. This will ensure that only the message, with the specified key, can be filtered out.

public void AddMessageFilter(Type type, string key = "")

Parameters

type Type

The message type to be filtered

key string

The optional key to use for the filter

AddMessageFilter<T>(string)

Adds a message type filter to the receiver model. This will ensure that only the message, with the specified key, can be filtered out.

public void AddMessageFilter<T>(string key = "") where T : Message

Parameters

key string

The optional key to use for the filter

Type Parameters

T

The message type to filter by

Export(string, bool, bool)

Exports all the data that has been saved to the data storage system. This will save the data to a CSV file in the directory that is passed in. The data can also be formatted to a DateTime format and the data can be deleted after it has been exported.

public void Export(string directory, bool formatTime = false, bool delete = false)

Parameters

directory string

The directory to save the data to

formatTime bool

A flag whether to use a datetime format

delete bool

A flag whether to delete the data after being written

OnCreate()

Called when the object is created from the controller and has been attached to the parent object. By this point, it has been registered to the simulation and will run after the constructor.

protected override void OnCreate()

OnLoad(double)

Called after all of the data has been loaded from a save state on this object. This enables any post-load operations to be performed and extra data to be loaded from the metadata.

protected override void OnLoad(double time)

Parameters

time double

[s] The current clock time of the simulation

OnSave()

Called before the object is saved into the save state. This ensures that any additional metadata can be saved on the object before it is automatically serialized.

protected override void OnSave()

OnUpdate(double, double)

Called when the object should update from the simulation tick. This will take in a time and a step, where the time is the time of the clock before updating the object.

protected override void OnUpdate(double time, double step)

Parameters

time double

[s] Current time of the simulation before the update

step double

[s] The time-step to update during this tick

ReadClosestMessage(Message, double, string)

Reads the message data that is associated with the closest value to some time that is passed in. This will look into the messages that are received and will find the closest time to the time that is passed in. This will then update the data in the message.

public bool ReadClosestMessage(Message msg, double time, string key = "")

Parameters

msg Message

The message to write the data into

time double

[s] The time to fetch the closest value from, which is in transmission time

key string

The key to fetch the data from

Returns

bool

A successful write

ReadLatestJSON(string, bool)

Reads the latest value of the JSON data received from the data storage system. This will fetch the data and return it as a JSON object. This will be able to specify a key to fetch the data from. If deleting, this will remove the data from the storage system.

public JToken? ReadLatestJSON(string key = "", bool delete = false)

Parameters

key string

The key to fetch the data from

delete bool

A flag whether to delete the data in the storage

Returns

JToken

The JSON data that was received

ReadLatestMessage(Message, string, bool)

Reads the latest value of the message received from the data storage system. This will write the data into the message reference that is passed in and will be able to fetch the data from some key. If deleting, this will remove the data from the storage system.

public bool ReadLatestMessage(Message msg, string key = "", bool delete = false)

Parameters

msg Message

The message reference to write the data in

key string

The key to fetch the data from

delete bool

A flag whether to delete the data in the storage

Returns

bool

A successful write to the message