Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Uuid.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
8
10{
14 public class Uuid : TedsRecord
15 {
19 public Uuid()
20 : base()
21 {
22 }
23
28 public Uuid(byte[] Uuid)
29 : base(1, 4, Uuid)
30 {
31 if (Uuid is null || Uuid.Length != 16)
32 throw new ArgumentException("Invalid UUID", nameof(Uuid));
33
34 this.Identity = Uuid;
35 }
36
40 public byte[] Identity { get; set; }
41
47 public override Grade Supports(ClassTypePair RecordTypeId)
48 {
49 return RecordTypeId.Class == 1 && RecordTypeId.Type == 4 ? Grade.Perfect : Grade.NotAtAll;
50 }
51
59 public override TedsRecord Parse(ClassTypePair RecordTypeId, Binary RawValue, ParsingState State)
60 {
61 return new Uuid()
62 {
63 Class = RecordTypeId.Class,
64 Type = RecordTypeId.Type,
65 RawValue = RawValue.Body,
66 Identity = RawValue.NextUInt8Array(nameof(this.Identity), 16)
67 };
68 }
69
77 public override void AddFields(ThingReference Thing, DateTime Timestamp, List<Field> Fields, Teds Teds)
78 {
79 Fields.Add(new StringField(Thing, Timestamp, "IEEE 1451 UUID",
80 Hashes.BinaryToString(this.Identity, true), FieldType.Identity,
81 FieldQoS.AutomaticReadout));
82 }
83
88 public override void AppendDetails(StringBuilder SnifferOutput)
89 {
90 SnifferOutput.Append("UUID=");
91 SnifferOutput.AppendLine(Hashes.BinaryToString(this.Identity, true));
92 }
93 }
94}
Contains methods for simple hash calculations.
Definition: Hashes.cs:59
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
Definition: Hashes.cs:65
TEDS Universal unique identifier (§6.4.2.2)
Definition: Uuid.cs:15
override Grade Supports(ClassTypePair RecordTypeId)
How well the class supports a specific TEDS field type.
Definition: Uuid.cs:47
override TedsRecord Parse(ClassTypePair RecordTypeId, Binary RawValue, ParsingState State)
Parses a TEDS record.
Definition: Uuid.cs:59
Uuid(byte[] Uuid)
TEDS Universal unique identifier (§6.4.2.2)
Definition: Uuid.cs:28
override void AppendDetails(StringBuilder SnifferOutput)
Appends record details to sniffer output.
Definition: Uuid.cs:88
override void AddFields(ThingReference Thing, DateTime Timestamp, List< Field > Fields, Teds Teds)
Adds fields to a collection of fields.
Definition: Uuid.cs:77
Uuid()
TEDS Universal unique identifier (§6.4.2.2)
Definition: Uuid.cs:19
Represents one record in a TEDS
Definition: TedsRecord.cs:16
byte Class
This field identifies the TEDS being accessed. The value is the TEDS access code found in Table 72.
Definition: TedsRecord.cs:42
Represents a string value.
Definition: StringField.cs:10
Contains a reference to a thing
Grade
Grade enumeration
Definition: Grade.cs:7
FieldQoS
Field Quality of Service flags
Definition: FieldQoS.cs:10
FieldType
Field Type flags
Definition: FieldType.cs:10