Struct DataPacket
- Namespace
- NominalSystems.Classes
- Assembly
- NominalSystems.Classes.dll
[Nominal] This struct stores information about a particular packet within a sequence of packets. This packet will contain some data in a form of raw bytes and will also have a header information including the name of the object that was decoded, the packet number and the index of the next packet. If there are no next packets, this will be recorded as an invalid index. The packet also includes a checksum that can be used to evaluate if any errors exist before the decoding is made.
public struct DataPacket
Constructors
DataPacket()
Default constructor
public DataPacket()
Fields
Checksum
The checksum specifies the number of 1s that exist within the data message and can be used to ensure the data has not been altered due to bit-flipping error models.
public int Checksum
Field Value
Data
The raw data of the packet, stored in bytes. The first byte in the data array is the first byte used for the packet.
public byte[] Data
Field Value
- byte[]
Name
The name of the object that was created to ensure that the packets of the objects line up. This is calculated using the Type.GetType().Name parameter and does not include the namespace FullName property.
public string Name
Field Value
NextPacket
The index of the next packet that is connected. If less than 0, this is the final packet of the sequence.
public int NextPacket
Field Value
PacketNumber
The current index of the packet number that is in this sequence. This must be unique within the sequence.
public int PacketNumber
Field Value
Time
[s] The time that the packet was emitted by the simulation. This will determine when the packet was created and will be used to determine the time it takes to transmit the packet.
public double Time
Field Value
Properties
Size
The size of the data that exists in the packet in number of bytes. This is calculated based on the length of the data array.
public int Size { get; }
Property Value
Methods
Deserialize(JToken?)
Deserializes the JSON object into a data packet that can be used for the telemetry system.
public static DataPacket Deserialize(JToken? json)
Parameters
json
JTokenThe JSON object to serialize
Returns
- DataPacket
The packet in its raw form
Serialize(DataPacket)
Serializes the data packet into a JSON object that can be serialized in the system.
public static JObject Serialize(DataPacket packet)
Parameters
packet
DataPacketThe packet to serialize
Returns
- JObject
The JSON object to serialize