Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DiscoverableTopicNode.cs
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(
44 Child is DiscoverableTopicNode ||
45 Child is MqttNcapTopicNode);
46 }
47
53 public override Grade Supports(MqttTopicRepresentation Topic)
54 {
55 if ((Topic.CurrentParentTopic?.Node is RootTopic ||
58 {
59 return Grade.Ok;
60 }
61 else
62 return Grade.NotAtAll;
63 }
64
70 public override async Task<IMqttTopicNode> CreateNew(MqttTopicRepresentation Topic)
71 {
72 return new DiscoverableTopicNode()
73 {
75 LocalTopic = Topic.CurrentSegment
76 };
77 }
78
83 public override async Task<IMqttData> GetDefaultDataObject()
84 {
85 MqttTopic Topic = await this.GetTopic();
86 if (Topic is null)
87 return null;
88
89 return new MessageData(Topic, null, null, 0);
90 }
91
98 public bool ResponseReceived(MqttTopic Topic, Ieee1451_0.Messages.Message Message)
99 {
100 if (Topic.Data is MessageData Data)
101 return Data.DataReported(Message);
102 else
103 {
104 Topic.SetData(new MessageData(Topic, Message, null, null, 0));
105 return false;
106 }
107 }
108
112 public override Task<IEnumerable<ICommand>> Commands => this.GetCommands();
113
117 private async Task<IEnumerable<ICommand>> GetCommands()
118 {
119 List<ICommand> Commands = new List<ICommand>();
120 Commands.AddRange(await base.Commands);
121
122 Commands.Add(new DiscoverNcapsTopic(await this.GetBroker(), this));
123
124 return Commands.ToArray();
125 }
126
127 }
128}
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