Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Teds.cs
1using System.Collections.Generic;
2using System;
7
9{
13 public class Teds
14 {
21 {
22 this.ChannelInfo = ChannelInfo;
23 this.Records = Records;
24 this.FieldName = null;
25 this.FieldUnit = null;
26 this.Unit = string.Empty;
27
28 foreach (TedsRecord Record in Records)
29 {
30 if (Record is TEDS.FieldTypes.TransducerChannelTeds.PhysicalUnits TedsUnits)
31 {
32 PhysicalUnits Units = TedsUnits.Units;
33
34 this.FieldUnit = Units.TryCreateUnit();
35 if (!(this.FieldUnit is null))
36 {
37 this.Unit = this.FieldUnit.ToString();
38 if (Script.Units.Unit.TryGetCategory(this.FieldUnit, out IUnitCategory Category))
39 this.FieldName = Category.Name;
40 }
41 }
42 }
43
44 }
45
49 public TedsRecord[] Records { get; }
50
55
59 public string FieldName { get; }
60
64 public Unit FieldUnit { get; }
65
69 public string Unit { get; }
70
77 public Field[] GetFields(ThingReference Thing, DateTime Timestamp)
78 {
79 List<Field> Fields = new List<Field>();
80 this.AddFields(Thing, Timestamp, Fields);
81 return Fields.ToArray();
82 }
83
90 public virtual void AddFields(ThingReference Thing, DateTime Timestamp, List<Field> Fields)
91 {
92 Fields.Add(new StringField(Thing, Timestamp, "Application ID",
93 Hashes.BinaryToString(this.ChannelInfo.ApplicationId),
94 FieldType.Identity, FieldQoS.AutomaticReadout));
95
96 Fields.Add(new StringField(Thing, Timestamp, "NCAP ID",
97 Hashes.BinaryToString(this.ChannelInfo.NcapId),
98 FieldType.Identity, FieldQoS.AutomaticReadout));
99
100 Fields.Add(new StringField(Thing, Timestamp, "TIM ID",
101 Hashes.BinaryToString(this.ChannelInfo.TimId),
102 FieldType.Identity, FieldQoS.AutomaticReadout));
103
104 Fields.Add(new Int32Field(Thing, Timestamp, "Channel ID", this.ChannelInfo.ChannelId,
105 FieldType.Identity, FieldQoS.AutomaticReadout));
106
107 foreach (TedsRecord Record in this.Records)
108 Record.AddFields(Thing, Timestamp, Fields, this);
109 }
110 }
111}
Represents a unit.
Definition: Unit.cs:15
override string ToString()
Definition: Unit.cs:517
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
Field[] GetFields(ThingReference Thing, DateTime Timestamp)
Gets the information in the record, as an array of fields.
Definition: Teds.cs:77
string FieldName
Field name of value, if found, otherwise null.
Definition: Teds.cs:59
Unit FieldUnit
Field unit of value, if found, otherwise null.
Definition: Teds.cs:64
virtual void AddFields(ThingReference Thing, DateTime Timestamp, List< Field > Fields)
Adds fields to a collection of fields.
Definition: Teds.cs:90
Teds(ChannelAddress ChannelInfo, TedsRecord[] Records)
IEEE 1451.0 TEDS
Definition: Teds.cs:20
ChannelAddress ChannelInfo
Address information.
Definition: Teds.cs:54
TedsRecord[] Records
TLV records available in TEDS
Definition: Teds.cs:49
Represents one record in a TEDS
Definition: TedsRecord.cs:16
virtual void AddFields(ThingReference Thing, DateTime Timestamp, List< Field > Fields, Teds Teds)
Adds fields to a collection of fields.
Definition: TedsRecord.cs:102
Base class for all sensor data fields.
Definition: Field.cs:20
Represents a 32-bit integer value.
Definition: Int32Field.cs:10
Represents a string value.
Definition: StringField.cs:10
Contains a reference to a thing
Interface for a category of units.
Definition: IUnitCategory.cs:7
FieldQoS
Field Quality of Service flags
Definition: FieldQoS.cs:10
FieldType
Field Type flags
Definition: FieldType.cs:10
Unit TryCreateUnit()
Tries to create a unit from the description available in the object.