Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
XmppActuator.cs
1using System;
2using System.Threading.Tasks;
3using Waher.Content;
4using Waher.Events;
11
13{
18 {
19 private readonly bool isSensor;
20 private readonly bool suportsEvents;
21
22 public XmppActuator(TreeNode Parent, XmppClient Client, string BareJid, bool IsSensor, bool SupportsEventSubscripton, bool SupportsRdp)
23 : base(Parent, Client, BareJid, SupportsRdp)
24 {
25 this.isSensor = IsSensor;
26 this.suportsEvents = SupportsEventSubscripton;
27 }
28
29 public override string TypeName
30 {
31 get { return "Actuator"; }
32 }
33
34 public override bool CanReadSensorData => this.isSensor;
35 public override bool CanSubscribeToSensorData => this.suportsEvents;
36
37 public override async Task<SensorDataClientRequest> StartSensorDataMomentaryReadout()
38 {
39 if (this.isSensor)
40 {
41 XmppAccountNode XmppAccountNode = this.XmppAccountNode;
43
44 if (!(XmppAccountNode is null) && !((SensorClient = XmppAccountNode.SensorClient) is null))
46 else
47 return null;
48 }
49 else
50 throw new NotSupportedException();
51 }
52
53 public override async Task<SensorDataClientRequest> StartSensorDataFullReadout()
54 {
55 if (this.isSensor)
56 {
57 XmppAccountNode XmppAccountNode = this.XmppAccountNode;
59
60 if (!(XmppAccountNode is null) && !((SensorClient = XmppAccountNode.SensorClient) is null))
62 else
63 return null;
64 }
65 else
66 throw new NotSupportedException();
67 }
68
69 public override async Task<SensorDataSubscriptionRequest> SubscribeSensorDataMomentaryReadout(FieldSubscriptionRule[] Rules)
70 {
71 if (this.isSensor)
72 {
73 XmppAccountNode XmppAccountNode = this.XmppAccountNode;
75
76 if (!(XmppAccountNode is null) && !((SensorClient = XmppAccountNode.SensorClient) is null))
77 {
78 return await SensorClient.Subscribe(this.RosterItem.LastPresenceFullJid, FieldType.Momentary, Rules,
80 }
81 else
82 return null;
83 }
84 else
85 throw new NotSupportedException();
86 }
87
88 public override bool CanConfigure => true;
89
90 public override void Configure()
91 {
92 base.Configure();
93 }
94
95 protected override bool UseActuatorControl => true;
96
97 public override async Task GetConfigurationForm(EventHandlerAsync<DataFormEventArgs> Callback, object State)
98 {
99 XmppAccountNode XmppAccountNode = this.XmppAccountNode;
101
102 if (!(XmppAccountNode is null) && !((ControlClient = XmppAccountNode.ControlClient) is null))
103 await ControlClient.GetForm(this.RosterItem.LastPresenceFullJid, "en", Callback, State);
104 else
105 throw new NotSupportedException();
106 }
107
108 }
109}
Represents a simple XMPP actuator.
Definition: XmppActuator.cs:18
override async Task< SensorDataSubscriptionRequest > SubscribeSensorDataMomentaryReadout(FieldSubscriptionRule[] Rules)
Starts subscription of momentary sensor data values.
Definition: XmppActuator.cs:69
override async Task GetConfigurationForm(EventHandlerAsync< DataFormEventArgs > Callback, object State)
Gets the configuration form for the node.
Definition: XmppActuator.cs:97
override void Configure()
Starts configuration of the node.
Definition: XmppActuator.cs:90
override async Task< SensorDataClientRequest > StartSensorDataFullReadout()
Starts readout of all sensor data values.
Definition: XmppActuator.cs:53
override async Task< SensorDataClientRequest > StartSensorDataMomentaryReadout()
Starts readout of momentary sensor data values.
Definition: XmppActuator.cs:37
Abstract base class for tree nodes in the connection view.
Definition: TreeNode.cs:24
TreeNode Parent
Parent node. May be null if a root node.
Definition: TreeNode.cs:107
Class representing a normal XMPP account.
Represents an XMPP contact whose capabilities have not been measured.
Definition: XmppContact.cs:24
Implements an XMPP control client interface.
Task GetForm(string To, string Language, params ThingReference[] Nodes)
Gets a control form.
Maintains information about an item in the roster.
Definition: RosterItem.cs:75
string LastPresenceFullJid
Full JID of last resource sending online presence.
Definition: RosterItem.cs:343
Maintains the status of a field subscription rule.
Implements an XMPP sensor client interface.
Definition: SensorClient.cs:21
Task< SensorDataClientRequest > RequestReadout(string Destination, FieldType Types)
Requests a sensor data readout.
Task< SensorDataSubscriptionRequest > Subscribe(string Destination, FieldType Types, FieldSubscriptionRule[] Fields, bool ImmediateReadout)
Subscribes to sensor data readout.
Manages an XMPP client connection. Implements XMPP, as defined in https://tools.ietf....
Definition: XmppClient.cs:59
FieldType
Field Type flags
Definition: FieldType.cs:10
Represents a duration value, as defined by the xsd:duration data type: http://www....
Definition: Duration.cs:13
static Duration FromMinutes(int Minutes)
Creates a Duration object from a given number of minutes.
Definition: Duration.cs:579
static Duration FromSeconds(int Seconds)
Creates a Duration object from a given number of seconds.
Definition: Duration.cs:589