Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DiscoverNcapsRoot.cs
1using System.Text;
2using System.Threading.Tasks;
10
12{
17 {
18 private readonly MqttBrokerNode brokerNode;
19
25 {
26 this.brokerNode = BrokerNode;
27 }
28
32 [Page(1, "IEEE 1451")]
33 [Header(21, "Topic:", 100)]
34 [ToolTip(22, "Search for NCAPs on this topic.")]
35 [Required]
36 public string Topic { get; set; }
37
41 public string CommandID => "DiscoverNcaps";
42
46 public CommandType Type => CommandType.Parametrized;
47
51 public string SortCategory => "IEEE1451.1.6";
52
56 public string SortKey => "1";
57
62 public Task<string> GetNameAsync(Language Language)
63 {
64 return Language.GetStringAsync(typeof(RootTopic), 20, "Discover NCAPs...");
65 }
66
71 public Task<string> GetConfirmationStringAsync(Language Language) => Task.FromResult<string>(null);
72
77 public Task<string> GetFailureStringAsync(Language Language) => Task.FromResult<string>(null);
78
83 public Task<string> GetSuccessStringAsync(Language Language) => Task.FromResult<string>(null);
84
90 public Task<bool> CanExecuteAsync(RequestOrigin Caller) => Task.FromResult(true);
91
98
103 public ICommand Copy()
104 {
105 return new DiscoverNcapsRoot(this.brokerNode)
106 {
107 Topic = this.Topic
108 };
109 }
110
114 public async Task ExecuteCommandAsync()
115 {
116 StringBuilder ToSniffer = this.brokerNode.HasSniffers ? new StringBuilder() : null;
117 byte[] Request = DiscoveryMessage.SerializeRequest(ToSniffer);
118 MqttBroker Broker = await this.brokerNode.GetBroker();
119
120 if (!(ToSniffer is null))
121 await this.brokerNode.Information(ToSniffer.ToString());
122
123 await Broker.Publish(this.Topic, MqttQualityOfService.AtLeastOnce, false, Request);
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
static byte[] SerializeRequest(StringBuilder SnifferOutput)
Serializes an NCAP Discovery request.
Requests Ncaps to identify themselves.
DiscoverNcapsRoot(MqttBrokerNode BrokerNode)
Requests Ncaps to identify themselves.
ICommand Copy()
Creates a copy of the command object.
string Topic
Search for NCAPs on this topic.
Task< bool > CanExecuteAsync(RequestOrigin Caller)
If the command can be executed by the caller.
string SortCategory
Sort Category, if available.
async Task ExecuteCommandAsync()
Executes the command.
Task< string > GetSuccessStringAsync(Language Language)
Gets a success string, if any, of the command. If no specific success string is available,...
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.
Task StartQueryExecutionAsync(Query Query, Language Language)
Starts the execution of a query.
Task< string > GetFailureStringAsync(Language Language)
Gets a failure string, if any, of the command. If no specific failure string is available,...
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.
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