Table of Contents

Class PartitionedDataStorage

Namespace
NominalSystems.Classes
Assembly
NominalSystems.Classes.dll

This class can store multiple data storage nodes and is able to store larger clusters of data that can be read from and written to. This provides a virtual storage system.

public class PartitionedDataStorage : PhysicalComponent, IGroundStationAttachment
Inheritance
PartitionedDataStorage
Implements
Inherited Members

Constructors

PartitionedDataStorage()

Default constructor for the partitioned data storage.

public PartitionedDataStorage()

Fields

Cluster

A list of all the data storage nodes that exist in this partitioned data storage node.

public List<DataStorage> Cluster

Field Value

List<DataStorage>

In_ClockMsg

A reference to the clock message, if it exists, connected from the Computer onboard.

public ClockMessage? In_ClockMsg

Field Value

ClockMessage

In_ComputerStatusMsg

A reference to the connected computer status message for this data storage unit.

public ComputerStatusMessage? In_ComputerStatusMsg

Field Value

ComputerStatusMessage

Out_DataStorageMsg

A data storage message that contains the information about the on-board data storage system.

public DataStorageMessage Out_DataStorageMsg

Field Value

DataStorageMessage

Properties

ChunkSize

The number of bytes in each cluster.

[EditableVariable("B", 8, false, "", "")]
public int ChunkSize { get; set; }

Property Value

int

ClusterNum

The number of data storage nodes inside the cluster.

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

Property Value

int

MaxMemory

The number of bytes in the memory of the cluster. By default, the memory is set to 1MB.

[EditableVariable("B", 0, false, "", "")]
public int MaxMemory { get; set; }

Property Value

int

Memory

The amount of memory currently used up by the cluster.

[EditableVariable("B", true, "", "")]
public int Memory { get; }

Property Value

int

MemoryFraction

[-] Returns the fraction between 0 and 1 of the memory that is currently being allocated.

[EditableVariable("-", true, "", "")]
public double MemoryFraction { get; }

Property Value

double

Name

The name of the partitioned data storage system that can be used to identify some data.

[EditableVariable("-", false, "", "")]
public string Name { get; set; }

Property Value

string

Running

A flag for whether the storage unit is running

[EditableVariable("-", true, "", "")]
public bool Running { get; }

Property Value

bool

Methods

DeleteAll()

Deletes all memory stored on the partitioned data storage unit. This will corrupt messages which are pointing to the unit if not checking for empty messages.

public void DeleteAll()

DeleteMemory(DataPointer)

Deletes the memory occupied by some data pointer in a particular chunk.

public bool DeleteMemory(DataPointer ptr)

Parameters

ptr DataPointer

The pointer to the data to delete

Returns

bool

A successful deletion flag

GetManager()

Gets the data storage manager associated with the storage system and makes sure that is enabled.

public DataStorageManager GetManager()

Returns

DataStorageManager

The data storage manager for the system

OnBegin(double)

Called when the 'Component' is beginning

protected override void OnBegin(double time)

Parameters

time double

current time (seconds)

OnDecodeMetadata(JObject)

Called after the "Component" was loaded to handle additional metadata.

protected override void OnDecodeMetadata(JObject metadata)

Parameters

metadata JObject

OnEncodeMetadata(JObject)

Called while the "Component" is being saved to save additional metadata.

protected override JObject OnEncodeMetadata(JObject metadata)

Parameters

metadata JObject

Returns

JObject

ReadBytes(DataPointer)

Attempts to read byte data from the data storage system and returns the raw byte data back, regardless if it is successful.

public byte[] ReadBytes(DataPointer ptr)

Parameters

ptr DataPointer

The pointer to the data in the chunk.

Returns

byte[]

The data from the storage system.

ReadBytes(DataPointer, ref byte[])

Attempts to read byte data from the partitioned data storage system with the partitioned pointer. If the pointer is invalid, it will retun a false.

public bool ReadBytes(DataPointer ptr, ref byte[] data)

Parameters

ptr DataPointer

The pointer to the data in the chunk.

data byte[]

The reference data to update with the read value.

Returns

bool

A successful read operation

ReadCustom<T>(DataPointer)

Attempts to read an object from the data storage system and deserializes the byte data to the object. This method will attempt to cast the object to a specified type.

public T? ReadCustom<T>(DataPointer ptr)

Parameters

ptr DataPointer

The pointer to the data in the chunk.

Returns

T

The object stored in the data, casted into the appropriate type if the data matches.

Type Parameters

T

ReadMessage(DataPointer)

Attempts to read a message from the data storage system, by decoding and deserializing the byte data to the object. If the message does not exist or has been corrupted, then the object will be returned as a null reference. Additionally, if the pointer has a timed message, then it will decompile and get the data in the message.

public Message? ReadMessage(DataPointer ptr)

Parameters

ptr DataPointer

The pointer to the data in the chunk.

Returns

Message

The message stored in the data, if it is valid. If the object is not valid, a null reference will be returned.

ReadObject(DataPointer)

Attempts to read an object from the data storage system and deserializes the byte data to the object. If the object is invalid or the bytes failed to load, then the object will be returned as a null pointer.

public object? ReadObject(DataPointer ptr)

Parameters

ptr DataPointer

The pointer to the data in the chunk.

Returns

object

The object stored in the data, if it is valid. If the object is not valid, a null reference will be returned.

ReadTimestamped<T>(DataPointer)

Attempts to read a specific timestamped message from the current data system with some particular pointer. The timestamped payload must also accept a particular message type and it will determine the correct data to read.

public TimestampedPayload<T>? ReadTimestamped<T>(DataPointer ptr) where T : Message

Parameters

ptr DataPointer

The pointer to the data in the chunk.

Returns

TimestampedPayload<T>

The timestamped payload stored in the data, if it is valid. If the object is not valid, a null reference will be returned.

Type Parameters

T

The message type of the payload

WriteBytes(byte[])

Writes a set of binary byte data into the partitioned system and attempts to find a space where it can fit inside the clusters. If it cannot fit, then the pointer will be invalid.

public DataPointer WriteBytes(byte[] data)

Parameters

data byte[]

The binary byte data to write into the clusters

Returns

DataPointer

A pointer to the data

WriteObject(object)

Attempts to write a custom object into the data storage system by converting the object to bytes. If it cannot be serialized, then the data pointer will be invalid.

public DataPointer WriteObject(object obj)

Parameters

obj object

The object to write into the system

Returns

DataPointer

A pointer to the data