Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DiscoverNcapsTopic.cs
1using System.Text;
2using System.Threading.Tasks;
9
11{
16 {
17 private readonly MqttBrokerNode brokerNode;
18 private readonly MqttTopicNode topicNode;
19
25 public DiscoverNcapsTopic(MqttBrokerNode BrokerNode, MqttTopicNode TopicNode)
26 {
27 this.brokerNode = BrokerNode;
28 this.topicNode = TopicNode;
29 }
30
34 public string CommandID => "DiscoverNcaps";
35
39 public CommandType Type => CommandType.Simple;
40
44 public string SortCategory => "IEEE1451.1.6";
45
49 public string SortKey => "1";
50
55 public Task<string> GetNameAsync(Language Language)
56 {
57 return Language.GetStringAsync(typeof(RootTopic), 24, "Discover NCAPs");
58 }
59
64 public Task<string> GetConfirmationStringAsync(Language Language) => Task.FromResult<string>(null);
65
70 public Task<string> GetFailureStringAsync(Language Language) => Task.FromResult<string>(null);
71
76 public Task<string> GetSuccessStringAsync(Language Language) => Task.FromResult<string>(null);
77
83 public Task<bool> CanExecuteAsync(RequestOrigin Caller) => Task.FromResult(true);
84
91
96 public ICommand Copy()
97 {
98 return new DiscoverNcapsTopic(this.brokerNode, this.topicNode);
99 }
100
104 public async Task ExecuteCommandAsync()
105 {
106 StringBuilder ToSniffer = this.brokerNode.HasSniffers ? new StringBuilder() : null;
107 byte[] Request = DiscoveryMessage.SerializeRequest(ToSniffer);
108 MqttBroker Broker = await this.brokerNode.GetBroker();
109
110 if (!(ToSniffer is null))
111 await this.brokerNode.Information(ToSniffer.ToString());
112
113 await Broker.Publish(await this.topicNode.GetFullTopic(), MqttQualityOfService.AtLeastOnce, false, Request);
114 }
115 }
116}
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
static byte[] SerializeRequest(StringBuilder SnifferOutput)
Serializes an NCAP Discovery request.
Task< string > GetFailureStringAsync(Language Language)
Gets a failure string, if any, of the command. If no specific failure string is available,...
Task< bool > CanExecuteAsync(RequestOrigin Caller)
If the command can be executed by the caller.
DiscoverNcapsTopic(MqttBrokerNode BrokerNode, MqttTopicNode TopicNode)
Requests Ncaps to identify themselves.
Task< string > GetConfirmationStringAsync(Language Language)
Gets a confirmation string, if any, of the command. If no confirmation is necessary,...
Task< string > GetNameAsync(Language Language)
Gets the name of data source.
ICommand Copy()
Creates a copy of the command object.
Task< string > GetSuccessStringAsync(Language Language)
Gets a success string, if any, of the command. If no specific success string is available,...
Task StartQueryExecutionAsync(Query Query, Language Language)
Starts the execution of a query.
IEEE 1451.1.6 root topic node
Definition: RootTopic.cs:13
MQTT Broker connection object.
Definition: MqttBroker.cs:17
Task Publish(string Topic, MqttQualityOfService QoS, bool Retain, byte[] Data)
Publishes binary data to a topic.
Definition: MqttBroker.cs:147
Node representing a connection to an MQTT broker.
A Metering node representing an MQTT topic
Class handling the reception of data from a query.
Definition: Query.cs:12
Tokens available in request.
Definition: RequestOrigin.cs:9
Interface for commands.
Definition: ICommand.cs:32
MqttQualityOfService
MQTT Quality of Service level.
CommandType
Command type.
Definition: ICommand.cs:11