Thing Presence
What is Thing Presence?
To address the broad landscape of devices that connect to the ThingWorx platform, the concept of "connected" has changed from "currently bound using a websocket" to "connection normalcy", which is referred to as Thing Presence. Thing Presence indicates when the connection of a Thing is "normal", based on the expected behavior of the device. ThingWorx AlwaysOn devices (running a ThingWorx Edge SDK-based application or the ThingWorx WebSocket-based Edge MicroServer) bind websockets and, if not configured to be offline for a period of time, are always available to receive messages from the ThingWorx platform. Axeda eMessage Agent devices, on the other hand, poll the platform periodically ("ping") and can receive messages from the platform only when connected and bound. Both of these main types of devices are supported by Thing Presence.
Thing Presence is comparable across categories of devices and supported by all ThingWorx interfaces. For example, a service organization might want to create a dashboard that indicates all devices that are available for service calls or all devices that are unexpectedly offline. Thing Presence is used by the ThingWorx SCM Extension to determine if a device is connected "normally" (by checking a property called isReporting) so that a package may be selected for and deployed to a device.
It is important to understand that Thing Presence does not attempt to diagnose the overall condition of a device. Thing Presence is presented as a singular boolean property, which enables ThingWorx to provide a unified experience across the wide variety of assets that it can serve.
How It Works
In the most general sense, any device that is defined as a RemoteThing has the following new attributes
Type
Name
Description
Property
isReporting
Identifies whether or not a device is determined to be available for "normal" communications based on the applied "Reporting Strategy".
Property
reportingLastChange
Identifies when the isReporting value was last changed.
Property
reportingLastEvaluation
Identifies when the last evaluation for isReporting occurred.
Configuration
reportingStrategy
A Thing that defines the algorithm for determining if a device is reporting.
Service
EvaluateReporting
Evaluates if a device is reporting and sets the isReporting property accordingly.
Service
SetReportingStrategy
Sets the strategy used for evaluating if a device is reporting.
Service
GetReportingStrategy
Obtains the strategy currently used for evaluating if a device is reporting.
The exact algorithm for determining if a device is reporting is dependent on the specific ReportingStrategy Thing. However, the general process is as follows
1. The EvaluateReporting service is triggered by some event
2. EvaluateReporting subsequently calls the ReportingAlgorithm service on the strategy Thing
3. The ReportingAlgorithm returns a boolean, based on the specific algorithm
4. The isReporting property is set based on the results of the ReportingAlgorithm service.
The EvaluateReporting Service
The EvaluateReporting service takes the following parameters:
eventName — The name of the event that has caused this reporting state re-evaluation
eventTime — The time that the event occurred.
source — The name of the Thing that generated the event.
sourceProperty — The source property of the event.
eventData — The data of the event.
All parameters of EvaluateReporting() are passed directly to ReportingStrategy.ReportingAlgorithm()
When executed during a Thing bind or unbind, the eventName is BindingEvent and the eventData contains a single row with a single value under the isBound key whose value indicates whether the Thing has just been bound or unbound (true for bound, false for unbound).
If a problem occurs during this service (including in the ReportingAlgorithm), the Thing is updated to "not reporting", and a message placed in the ApplicationLog.