Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
ClockDiff.cs
1using System;
2using System.Text;
3using System.Threading.Tasks;
5
7{
12 {
16 public ClockDiff()
17 : base()
18 {
19 }
20
24 public override string Name => "ClockDiff";
25
33 public override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, ResponseCallbackHandler ResponseCallback)
34 {
36 await XmppServerModule.SendErrorMessage("No synchronization client available.", string.Empty, ResponseCallback);
37 else
38 {
40 await Gateway.SynchronizationClient.MeasureClockDifferenceAsync(Arguments[0]);
41
42 if (e.Ok)
43 {
44 StringBuilder sb = new StringBuilder();
45 TimeSpan ClockDiff = TimeSpan.FromSeconds(e.ClockDifference100Ns * 1e-7);
46
47 sb.Append("Difference: ");
48 sb.Append(ClockDiff.ToString());
49 sb.Append(", Latency: ");
50 sb.Append((e.Latency100Ns * 1e-7).ToString("F3"));
51 sb.Append(" s");
52
53 await ResponseCallback(sb.ToString(), string.Empty);
54 }
55 else
56 {
57 await XmppServerModule.SendErrorMessage(string.IsNullOrEmpty(e.ErrorText) ? "Unable to measure clock difference." : e.ErrorText,
58 string.Empty, ResponseCallback);
59 }
60 }
61 }
62
66 public override string ParameterName => "SOURCE";
67
71 public override string[] HelpParagraphs => new string[] { "Measures the difference in clocks, as well as network latency, between the broker and the `SOURCE`." };
72 }
73}
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:126
static SynchronizationClient SynchronizationClient
XMPP Synchronization Client.
Definition: Gateway.cs:3251
bool Ok
If the response is an OK result response (true), or an error response (false).
Event arguments containing the response of a clock synchronization request.
long Latency100Ns
Measured network latency in one direction, in units of 100 ns.
long ClockDifference100Ns
Measured clock difference between source clock and client clock, in units of 100 ns....
An administrative command taking one parameter.
Measures the difference between the internal clock and a specified clock source.
Definition: ClockDiff.cs:12
override string[] HelpParagraphs
Markdown description of syntax.
Definition: ClockDiff.cs:71
ClockDiff()
Measures the difference between the internal clock and a specified clock source.
Definition: ClockDiff.cs:16
override async Task Execute(ChatState State, string[] Arguments, string OrgMessage, ResponseCallbackHandler ResponseCallback)
Executes the command.
Definition: ClockDiff.cs:33
override string ParameterName
Name of parameter.
Definition: ClockDiff.cs:66
Service Module hosting the XMPP broker and its components.
delegate Task< string > ResponseCallbackHandler(string Markdown, string MessageId)
Delegate for response callback handler methods.