Thing Events
Events are interesting or critical property states that the Thing publishes to subscribers. Events are initiators to kick off some functionality in a subscription, which is basically a triggered service. Within a service definition, if you double click the event, the script necessary to fire the event will be stubbed out in the service for you. Triggers are well-defined changes of state (for example, Motor is overheating) of an asset or system (a Thing). Triggers often require an action to respond to the change (for example, Display warning light to show that the tractor is overheating). Complex predictions from analytical algorithms can fire events and allow the application developer to react to those events with business logic.
Business logic and actions in a ThingWorx application are driven by events. An event can be as simple as a new data value from a machine to more complex events from many data points and their dependencies. For example, ThingWorx Analytics real-time scoring predicts a failure and fires an event to the IoT run-time engine so you can take action. Events can be fired through API requests from a user in an application, or a device can fire its own events based on local data analysis or diagnostic routines.
An event must have a subscriber. To initiate a subscription, the subscriber is sent a data packet.
ThingWorx provides standard events and related data packets as defined by Data Shapes. The most common type of event is a data change related to a Thing property. When you define a property, there are many configuration aspects. For example, using DataChangeEvent, you can set an event to fire when there is new data for a property, only if the data has changed, only if the data evaluates true or false, or only if the new value changed beyond a defined threshold. All data change events send a data packet with the same predefined Data Shape.
You can create custom events in your model. For example, you may have a machine that runs diagnostic checks. When the diagnostic check determines that the machine needs to be calibrated, you can create a custom calibration alert for that class of equipment (usually at the Thing Shape or Thing Template level). In the definition, you can create a Data Shape that contains the data from the machine that needs to take action. You can configure the machine agent to fire that event through the ThingWorx API when the condition is detected. In the subscription, you can implement business logic to respond to the event. You can also fire events through the standard ThingWorx REST API, so that mashups and custom applications can trigger events through ThingWorx Analytics.
DynamicSubscriptionInvalidated Event
From ThingWorx 9.4 and later, a new event is added DynamicSubscriptionInvalidated. This event occurs on a Thing when other dynamic subscription created by it are deleted. The dynamic subscriptions may get deleted because the thing is stopped or restarted, properties may be deleted or the thing itself may be deleted.
This event is primarily used by mashups when the Automatically update values when available checkbox is selected.
This allows the mashup to alert operator that updates will no longer be provided from ThingWorx Platform when a thing has changed (for example, an update to thing property).
Using ThingWorx Analytics to Trigger Events
ThingWorx Analytics can examine data and recognize anomalous behaviors, or it can be trained by historical data. ThingWorx Analytics can use real-time data from ThingWorx to predict outcomes. A basic example is predictive analytics. You can train the analytics engine for a class of equipment based on historical data, including failure information. You can send run-time data from individual Things to the analytics engine. If the analytics engine detects a pattern that led to a past failure, it can fire an event to that Thing and allow you to take an action through a subscription. That action can be to create a service ticket or send a notification to the service department. Alerts or subscriptions to custom events allow you to link a specific action and business logic to near real-time events.
Was this helpful?