Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
TedsRecord.cs
1using System;
2using System.Collections.Generic;
3using System.Text;
9
11{
15 public class TedsRecord : IFieldType
16 {
20 public TedsRecord()
21 {
22 }
23
31 public TedsRecord(byte Class, byte Type, byte[] Raw)
32 {
33 this.Class = Class;
34 this.Type = Type;
35 this.RawValue = Raw;
36 }
37
42 public byte Class { get; set; }
43
47 public byte Type { get; set; }
48
52 public byte[] RawValue { get; set; }
53
61 public virtual TedsRecord Parse(ClassTypePair RecordTypeId, Binary RawValue, ParsingState State)
62 {
63 return new TedsRecord()
64 {
65 Class = RecordTypeId.Class,
66 Type = RecordTypeId.Type,
67 RawValue = RawValue.Body
68 };
69 }
70
76 public virtual Grade Supports(ClassTypePair RecordTypeId)
77 {
78 return Grade.Barely;
79 }
80
88 public Field[] GetFields(ThingReference Thing, DateTime Timestamp, Teds Teds)
89 {
90 List<Field> Fields = new List<Field>();
91 this.AddFields(Thing, Timestamp, Fields, Teds);
92 return Fields.ToArray();
93 }
94
102 public virtual void AddFields(ThingReference Thing, DateTime Timestamp, List<Field> Fields, Teds Teds)
103 {
104 Fields.Add(new StringField(Thing, Timestamp,
105 this.Class.ToString("X2") + " " + this.Type.ToString("X2") + ", Raw",
106 Convert.ToBase64String(this.RawValue), FieldType.Identity,
107 FieldQoS.AutomaticReadout));
108 }
109
113 public override string ToString()
114 {
115 return Convert.ToBase64String(this.RawValue);
116 }
117
122 public void Append(StringBuilder SnifferOutput)
123 {
124 SnifferOutput.Append("Class ");
125 SnifferOutput.Append(this.Class.ToString());
126 SnifferOutput.Append(", Type ");
127 SnifferOutput.Append(this.Type.ToString());
128 SnifferOutput.Append(", ");
129 this.AppendDetails(SnifferOutput);
130 }
131
136 public virtual void AppendDetails(StringBuilder SnifferOutput)
137 {
138 SnifferOutput.AppendLine(Hashes.BinaryToString(this.RawValue, true));
139 }
140 }
141}
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
Represents one record in a TEDS
Definition: TedsRecord.cs:16
TedsRecord(byte Class, byte Type, byte[] Raw)
Represents one record in a TEDS
Definition: TedsRecord.cs:31
virtual TedsRecord Parse(ClassTypePair RecordTypeId, Binary RawValue, ParsingState State)
Parses a TEDS record.
Definition: TedsRecord.cs:61
virtual void AddFields(ThingReference Thing, DateTime Timestamp, List< Field > Fields, Teds Teds)
Adds fields to a collection of fields.
Definition: TedsRecord.cs:102
virtual Grade Supports(ClassTypePair RecordTypeId)
How well the class supports a specific TEDS field type.
Definition: TedsRecord.cs:76
TedsRecord()
Represents one record in a TEDS
Definition: TedsRecord.cs:20
Field[] GetFields(ThingReference Thing, DateTime Timestamp, Teds Teds)
Gets the information in the record, as an array of fields.
Definition: TedsRecord.cs:88
override string ToString()
Object.ToString()
Definition: TedsRecord.cs:113
virtual void AppendDetails(StringBuilder SnifferOutput)
Appends record details to sniffer output.
Definition: TedsRecord.cs:136
void Append(StringBuilder SnifferOutput)
Appends record to sniffer output.
Definition: TedsRecord.cs:122
byte Class
This field identifies the TEDS being accessed. The value is the TEDS access code found in Table 72.
Definition: TedsRecord.cs:42
Base class for all sensor data fields.
Definition: Field.cs:20
Represents a string value.
Definition: StringField.cs:10
Contains a reference to a thing
Basic interface for TEDS field types.
Definition: IFieldType.cs:14
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