Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
MqttChannelTopicNode.cs
1using System.Collections.Generic;
2using System.Text;
3using System.Threading.Tasks;
9
11{
16 {
17 private string preferredUnit;
18 private int channelId;
19
24 {
25 }
26
30 [Page(1, "IEEE 1451")]
31 [Header(8, "Channel:", 300)]
32 [ToolTip(9, "Channel identifier on TIM.")]
33 [Required]
34 [Range(1, ushort.MaxValue)]
35 public int ChannelId
36 {
37 get => this.channelId;
38 set => this.channelId = value;
39 }
40
44 [Page(1, "IEEE 1451")]
45 [Header(33, "Preferred Unit:", 300)]
46 [ToolTip(36, "Preferred unit to use for transducer values.")]
47 public string PreferredUnit
48 {
49 get => this.preferredUnit;
50 set => this.preferredUnit = value;
51 }
52
56 public override string LocalId
57 {
58 get
59 {
60 if (!string.IsNullOrEmpty(this.EntityName))
61 return this.EntityName;
62 else
63 return this.NodeId;
64 }
65 }
66
70 public override Task<string> GetTypeNameAsync(Language Language)
71 {
72 return Language.GetStringAsync(typeof(Ieee1451Parser), 7, "IEEE 1451.0 Channel");
73 }
74
81 public override async Task<IEnumerable<Parameter>> GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
82 {
83 LinkedList<Parameter> Parameters = (LinkedList<Parameter>)await base.GetDisplayableParametersAsync(Language, Caller);
84
85 Parameters.AddLast(new Int32Parameter("ChannelId",
86 await Language.GetStringAsync(typeof(MqttNcapTopicNode), 10, "Channel"),
87 this.ChannelId));
88
89 Parameters.AddLast(new StringParameter("TimId",
90 await Language.GetStringAsync(typeof(MqttNcapTopicNode), 7, "TIM ID"),
91 this.TimId));
92
93 Parameters.AddLast(new StringParameter("NcapId",
94 await Language.GetStringAsync(typeof(MqttNcapTopicNode), 4, "NCAP ID"),
95 this.NcapId));
96
97 return Parameters;
98 }
99
103 public override Task<bool> AcceptsParentAsync(INode Parent)
104 {
105 return Task.FromResult(Parent is MqttTimTopicNode);
106 }
107
111 public override Task<bool> AcceptsChildAsync(INode Child)
112 {
113 return Task.FromResult(false);
114 }
115
122 {
123 if (Topic.SegmentIndex > 0 &&
124 Topic.CurrentParentTopic?.Node is MqttTimTopicNode &&
125 !(Topic.CurrentParentTopic?.Node is MqttChannelTopicNode) &&
126 int.TryParse(Topic.CurrentSegment, out _))
127 {
128 return Grade.Excellent;
129 }
130 else
131 return Grade.NotAtAll;
132 }
133
139 public override async Task<IMqttTopicNode> CreateNew(MqttTopicRepresentation Topic)
140 {
141 StringBuilder sb = new StringBuilder();
142
143 sb.Append("Channel-");
144 sb.Append(Topic.Segments[Topic.SegmentIndex - 1]);
145 sb.Append('#');
146 sb.Append(Topic.CurrentSegment);
147
148 return new MqttChannelTopicNode()
149 {
150 NodeId = await GetUniqueNodeId(sb.ToString()),
152 ChannelId = int.Parse(Topic.CurrentSegment),
153 TimId = Topic.Segments[Topic.SegmentIndex - 1],
154 NcapId = Topic.Segments[Topic.SegmentIndex - 2]
155 };
156 }
157
158 }
159}
Contains information about a language.
Definition: Language.cs:17
Task< string > GetStringAsync(Type Type, int Id, string Default)
Gets the string value of a string ID. If no such string exists, a string is created with the default ...
Definition: Language.cs:209
Topic node representing an IEEE 1451.0 Channel.
override async Task< IMqttTopicNode > CreateNew(MqttTopicRepresentation Topic)
Creates a new node of the same type.
MqttChannelTopicNode()
Topic node representing an IEEE 1451.0 Channel.
override Grade Supports(MqttTopicRepresentation Topic)
How well the topic node supports an MQTT topic
override async Task< IEnumerable< Parameter > > GetDisplayableParametersAsync(Language Language, RequestOrigin Caller)
Gets displayable parameters.
override Task< bool > AcceptsChildAsync(INode Child)
If the node accepts a given child.
override Task< string > GetTypeNameAsync(Language Language)
Diaplayable type name for node.
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a given parent.
Topic node representing an IEEE 1451.0 NCAP.
Topic node representing an IEEE 1451.0 TIM.
Static class for IEEE 1451-related parsing tasks.
static async Task< string > GetUniqueNodeId(string NodeId)
Gets a Node ID, based on NodeId that is not already available in the database.
string LocalTopic
Local Topic segment
Contains information about an MQTT topic
string CurrentSegment
Current segment being processed.
MqttTopic CurrentParentTopic
Current parent topic.
string[] Segments
Segments in topic string.
Tokens available in request.
Definition: RequestOrigin.cs:9
Interface for nodes that are published through the concentrator interface.
Definition: INode.cs:49
new INode Parent
Parent Node, or null if a root node.
Grade
Grade enumeration
Definition: Grade.cs:7