What is a “Thing” in Thingworx Composer?
What is a “Thing”?
A Thing is defined by Thingworx as a representation of a business process in terms of properties and business logic. For example, a locomotive would be represented not in terms of static information such as dimensions, color and weight but in terms of dynamic business-relevant such as its current location, pulling capacity and maintenance status.
What Makes Things Interesting?
Things are only interesting if they have characteristics that interest us. To extend the locomotive analogy, a train that is running on time and about to reach my station is probably more interesting than one still an hour away. It is even more interesting if it is going to my destination. These characteristics are called Properties in Thingworx.
How Do Things Talk?
A train is famous for blowing it’s horn or whistle. The interest level of a train whistle’s can vary by distance or whether you are waiting for a train or standing on the tracks. But there is no indication in a whistle that indicates which train the whistle comes from or necessarily why it was blown. Things address these limitations by providing a rich system of events, alerts and subscriptions.
Events: When Things Happen To Things
A Thing Property can have an Event defined. This is a business rule where an action can be taken when a property changes in a certain way. Such as a train that is more than 5 minutes behind schedule.
Alerts: We Care When Certain Things Happens
Events can trigger a message to the next station which could display an updated arrival time on a schedule display. They can also be used (along with additional rules and location data) to calculate what speed increase is required to catch up before arriving at the next station and supress sending a late arrival message.
Subscriptions: Only Some of Us Care
Telling a system what alerts are wanted ensures that only information of interest is sent. Instead of standing by the train arrival display, commuters use an app to subscribe to updated arrival times so they can sit in the coffee shop and wait for a jingle when they have a couple minutes left to board. This requires subscribing to alerts for your train at your planned departure time.
When to use:
- Where a specific representation of an instance of an asset that combines properties, processes and business logic is needed.
- Things are also often used to provide a single instance of internal application services, such as a utility function holder.
A Thing Example
A Thing is represented by this default icon in the Composer Editor Home Menu. The most basic Thing is one based on GenericThing. This is as basic a Thing as you can define. It inherits the properties and services that are required for any Thing, much like an interface would define required properties and methods of a Class.
Extending a Thing
Things are only useful when you define specific properties, services, alerts and alarms on them. You can do this using built-in capabilities inherited from the Generic Thing.
To clearly illustrate how the these features interact to provide functionality I will show how to exercise all aspects of a Thing using only custom features:
- Create a Thing Property
- Create a Thing Service
- Create a Service Event
- Create a Thing Subscription
- Integrate a Thing into a Mashup
To add a custom property to a Thing, create a new Thing that inherits Generic Thing. Click the Properties link from the Left menu. Refer to the screen shot below. We will add a boolean property because it is a simple switch.
Subscriptions are used to respond to particular events. In this example I subscribe to an data change event on my Thing when the property value is flipped to false.
Using a Thing in a Mashup
There isn’t a “Thing Widget” that can be dragged onto a layout in Thingworx Composer. Specific aspects of a Thing can be added to a Mashup via a combination of widgets and data services. This can add up to a selective rendition of the aspects of a thing that focuses on the aspects of it that are important for a particular viewer.
Alerts can be added to each property of a Thing. They can be set to fire when a condition is met. In this case, when macProperty is false.
Alerts can be subscribed to in order to set other properties, send emails, SMS, and other communications. The following screens show the event Monitor tab recording the alerts fired when macProperty was set to false by clicking the checkbox in the Mashup.