Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
RootTopic.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
6
8{
12 public class RootTopic : MqttTopicNode
13 {
17 public RootTopic()
18 {
19 }
20
26 public override Grade Supports(MqttTopicRepresentation Topic)
27 {
28 if (!(Topic.CurrentParentTopic is null))
29 return Grade.NotAtAll;
30
31 switch (Topic.CurrentSegment)
32 {
33 case "璑": // Unicode character representing the bytes 145, 116
34 case "1451.1.6":
35 case "_1451.1.6":
36 return Grade.Perfect;
37
38 default:
39 return Grade.NotAtAll;
40
41 }
42 }
43
49 public override async Task<IMqttTopicNode> CreateNew(MqttTopicRepresentation Topic)
50 {
51 return new RootTopic()
52 {
54 LocalTopic = Topic.CurrentSegment
55 };
56 }
57
61 public override Task<bool> AcceptsChildAsync(INode Child)
62 {
63 return Task.FromResult(Child is DiscoverableTopicNode);
64 }
65
69 public override Task<bool> AcceptsParentAsync(INode Parent)
70 {
71 return Task.FromResult(Parent is MqttBrokerNode);
72 }
73
77 public override Task<string> GetTypeNameAsync(Language Language)
78 {
79 return Language.GetStringAsync(typeof(RootTopic), 11, "IEEE 1451.1.6 Root");
80 }
81
85 public override Task<IEnumerable<ICommand>> Commands => this.GetCommands();
86
90 private async Task<IEnumerable<ICommand>> GetCommands()
91 {
92 List<ICommand> Commands = new List<ICommand>();
93 Commands.AddRange(await base.Commands);
94
95 Commands.Add(new DiscoverNcapsRoot(await this.GetBroker())
96 {
97 Topic = "_1451.1.6/D0"
98 });
99
100 return Commands.ToArray();
101 }
102
103 }
104}
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
Requests Ncaps to identify themselves.
MQTT Topic node that publishes discovery commands in accordance with IEEE 1451.0.
IEEE 1451.1.6 root topic node
Definition: RootTopic.cs:13
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a given parent.
Definition: RootTopic.cs:69
override async Task< IMqttTopicNode > CreateNew(MqttTopicRepresentation Topic)
Creates a new node of the same type.
Definition: RootTopic.cs:49
override Task< IEnumerable< ICommand > > Commands
Available command objects. If no commands are available, null is returned.
Definition: RootTopic.cs:85
override Task< bool > AcceptsChildAsync(INode Child)
If the node accepts a given child.
Definition: RootTopic.cs:61
override Grade Supports(MqttTopicRepresentation Topic)
How well the topic node supports an MQTT topic
Definition: RootTopic.cs:26
override Task< string > GetTypeNameAsync(Language Language)
Diaplayable type name for node.
Definition: RootTopic.cs:77
RootTopic()
IEEE 1451.1.6 root topic node
Definition: RootTopic.cs:17
static async Task< string > GetUniqueNodeId(string NodeId)
Gets a Node ID, based on NodeId that is not already available in the database.
Node representing a connection to an MQTT broker.
A Metering node representing an MQTT topic
async Task< MqttBrokerNode > GetBroker()
TODO
string LocalTopic
Local Topic segment
Contains information about an MQTT topic
string CurrentSegment
Current segment being processed.
MqttTopic CurrentParentTopic
Current parent topic.
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