Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
XmppSensor.cs
1using System;
2using System.Threading.Tasks;
3using Waher.Content;
7
9{
13 public class XmppSensor : XmppContact
14 {
15 private readonly bool suportsEvents;
16
17 public XmppSensor(TreeNode Parent, XmppClient Client, string BareJid, bool SupportsEventSubscripton, bool SupportsRdp)
18 : base(Parent, Client, BareJid, SupportsRdp)
19 {
20 this.suportsEvents = SupportsEventSubscripton;
21 }
22
23 public override string TypeName
24 {
25 get { return "Sensor"; }
26 }
27
28 public override bool CanReadSensorData => true;
29 public override bool CanSubscribeToSensorData => this.suportsEvents;
30
31 public override async Task<SensorDataClientRequest> StartSensorDataMomentaryReadout()
32 {
33 XmppAccountNode XmppAccountNode = this.XmppAccountNode;
35
36 if (!(XmppAccountNode is null) && !((SensorClient = XmppAccountNode.SensorClient) is null))
38 else
39 return null;
40 }
41
42 public override async Task<SensorDataClientRequest> StartSensorDataFullReadout()
43 {
44 XmppAccountNode XmppAccountNode = this.XmppAccountNode;
46
47 if (!(XmppAccountNode is null) && !((SensorClient = XmppAccountNode.SensorClient) is null))
49 else
50 throw new NotSupportedException();
51 }
52
53 public override async Task<SensorDataSubscriptionRequest> SubscribeSensorDataMomentaryReadout(FieldSubscriptionRule[] Rules)
54 {
55 XmppAccountNode XmppAccountNode = this.XmppAccountNode;
57
58 if (!(XmppAccountNode is null) && !((SensorClient = XmppAccountNode.SensorClient) is null))
59 {
60 return await SensorClient.Subscribe(this.RosterItem.LastPresenceFullJid, FieldType.Momentary, Rules,
62 }
63 else
64 return null;
65 }
66
67 }
68}
Represents a simple XMPP sensor.
Definition: XmppSensor.cs:14
override async Task< SensorDataClientRequest > StartSensorDataMomentaryReadout()
Starts readout of momentary sensor data values.
Definition: XmppSensor.cs:31
override async Task< SensorDataSubscriptionRequest > SubscribeSensorDataMomentaryReadout(FieldSubscriptionRule[] Rules)
Starts subscription of momentary sensor data values.
Definition: XmppSensor.cs:53
override async Task< SensorDataClientRequest > StartSensorDataFullReadout()
Starts readout of all sensor data values.
Definition: XmppSensor.cs:42
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
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