Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DiscoverableTopicNode.cs
1using System.Collections.Generic;
2using System.Threading.Tasks;
7
9{
14 {
19 {
20 }
21
25 public override Task<string> GetTypeNameAsync(Language Language)
26 {
27 return Language.GetStringAsync(typeof(RootTopic), 23, "IEEE 1451.1.6 Topic Node");
28 }
29
33 public override Task<bool> AcceptsParentAsync(INode Parent)
34 {
35 return Task.FromResult(Parent is DiscoverableTopicNode || Parent is RootTopic);
36 }
37
41 public override Task<bool> AcceptsChildAsync(INode Child)
42 {
43 return Task.FromResult(Child is DiscoverableTopicNode || Child is MqttNcapTopicNode);
44 }
45
51 public override Grade Supports(MqttTopicRepresentation Topic)
52 {
53 if ((Topic.CurrentParentTopic?.Node is RootTopic ||
56 {
57 return Grade.Ok;
58 }
59 else
60 return Grade.NotAtAll;
61 }
62
68 public override async Task<IMqttTopicNode> CreateNew(MqttTopicRepresentation Topic)
69 {
70 return new DiscoverableTopicNode()
71 {
73 LocalTopic = Topic.CurrentSegment
74 };
75 }
76
81 public override async Task<IMqttData> GetDefaultDataObject()
82 {
83 MqttTopic Topic = await this.GetTopic();
84 if (Topic is null)
85 return null;
86
87 return new MessageData(Topic, null, null, 0);
88 }
89
96 public bool ResponseReceived(MqttTopic Topic, Ieee1451_0.Messages.Message Message)
97 {
98 if (Topic.Data is MessageData Data)
99 return Data.DataReported(Message);
100 else
101 {
102 Topic.SetData(new MessageData(Topic, Message, null, null, 0));
103 return false;
104 }
105 }
106
110 public override Task<IEnumerable<ICommand>> Commands => this.GetCommands();
111
115 private async Task<IEnumerable<ICommand>> GetCommands()
116 {
117 List<ICommand> Commands = new List<ICommand>();
118 Commands.AddRange(await base.Commands);
119
120 Commands.Add(new DiscoverNcapsTopic(await this.GetBroker(), this));
121
122 return Commands.ToArray();
123 }
124
125 }
126}
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
MQTT Topic node that publishes discovery commands in accordance with IEEE 1451.0.
override Grade Supports(MqttTopicRepresentation Topic)
How well the topic node supports an MQTT topic
DiscoverableTopicNode()
MQTT Topic node that publishes discovery commands in accordance with IEEE 1451.0.
override async Task< IMqttTopicNode > CreateNew(MqttTopicRepresentation Topic)
Creates a new node of the same type.
override Task< bool > AcceptsChildAsync(INode Child)
If the node accepts a given child.
override Task< bool > AcceptsParentAsync(INode Parent)
If the node accepts a given parent.
override Task< string > GetTypeNameAsync(Language Language)
Diaplayable type name for node.
override async Task< IMqttData > GetDefaultDataObject()
Gets the default data object, if any.
override Task< IEnumerable< ICommand > > Commands
Available command objects. If no commands are available, null is returned.
bool ResponseReceived(MqttTopic Topic, Ieee1451_0.Messages.Message Message)
A response message has been received.
Encapsulates messages from an IEEE1451.1.6 device.
Definition: MessageData.cs:44
Topic node representing an IEEE 1451.0 NCAP.
IEEE 1451.1.6 root topic node
Definition: RootTopic.cs:13
static async Task< string > GetUniqueNodeId(string NodeId)
Gets a Node ID, based on NodeId that is not already available in the database.
MQTT Topic information.
Definition: MqttTopic.cs:19
IMqttTopicNode Node
Reference to the MQTT Topic Node
Definition: MqttTopic.cs:51
IMqttData Data
Current parsed data.
Definition: MqttTopic.cs:71
A Metering node representing an MQTT topic
async Task< MqttBrokerNode > GetBroker()
TODO
async Task< MqttTopic > GetTopic()
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