Thing Templates
Thing Templates provide base functionality with properties, services, events, and subscriptions that Thing instances use in their execution. Every Thing is created from a Thing Template. A Thing Template can extend another Thing Template. When you release a new version of a product, you simply add the additional characteristics of the version without having to redefine the entire model. This model configuration provides multiple levels of generalization of an asset. A Thing Template can derive one or more additional characteristics by implementing Thing Shapes. When you make a change to the Thing Template, the change is propagated to the Things that implement that Thing Template; so again, maintaining the model is quick and easy. A Thing Template can be used to classify the kind of a Thing or asset class or as a specific product model with unique capabilities. If you have two product models and their interaction with the solution is the same (same properties, services, and events), you could model them as one Thing Template. Classifying Thing Templates is useful for aggregating Things into collections, which are useful in mashups. You may want separate Thing Templates for indexing, searching, and future evolutions of the products.
System-Defined Thing Templates
There are a number of system-defined Thing Templates that can be used to create Things for specific tasks. Some of these Thing Templates can be useful as utilities for various services and capabilities when building out applications.
The system-defined Thing Templates are the following:
Blog — A blog Thing is used to implement a blog, comments, and/or discussion forum collaboration objects in your mashups.
Content Crawler — A Thing designed to handle a specific interface to an external system or content area. You define a service to get a list of external content to be indexed and a service to retrieve the details for each content object, and ThingWorx will index the data and make it available via the ThingWorx search functions.
Database — A JDBC connection to any third-party relational database system.
Data Table — A Data Table is similar to a table in a relational database and can be used to store transactional rows of data in ThingWorx.
File Repository — A defined ThingWorx entity for external file content to be stored. When you transfer files to/from an Edge Thing, you do so to/from a specific repository. A file repository points to a folder in the server’s ThingworxStorage/repository folder. The services of a file repository allow you to view and manipulate files in its folder.
Generic Thing — A base Thing with minimal inherited characteristics. It is a best practice to define a Thing Template of your own, but there may be cases where you have a one-off Thing definition and you want to use a generic Thing.
Mail Server — A mail server Thing can be created if you want to send email messages from your application.
Edge — An Edge Thing is a device or data source that is installed at another server, usually through a firewall to different network. An Edge Thing communicates to the server through a locally installed EMS. An example of an Edge Thing is an OPC-DA server.
Edge Database— An Edge database Thing is for communicating to an OLE-DB or ADO.NET database or data source on a different server or workstation. Examples of an Edge Database is Microsoft Excel or Microsoft Access.
Edge Enhanced— a server model Thing corresponding to a remotely installed device or data store that needs to support remote desktop tunneling or file transfer.
Scheduler — A scheduler Thing can be used to run jobs based on a cron pattern (such as once a day or once an hour).
Source Control Repository — A source control repository can point to any folder on the server’s file system, which can be the root of your local repository. It is used by Import/Export > Source Control Entities.
Stream — Time series data storage.
Timer — A simple timer that fires an event on a defined interval.
Wiki — A collaboration object for sharing documents and related comments within your mashups.
When you create a specific instance of one of the system Thing Templates, you can configure it to the needs of your application and IT landscape.
System-Defined Remote Templates
There are several system-defined Thing Templates that are used to communicate over Web sockets to edge devices or data stores. RemoteThing is the naming convention for using Web sockets to communicate to another node, or Thing, in the network. The specific Thing Templates for the WSEMS and the SDKs are as follows:
RemoteDatabase — a remote OLE-DB data source.
RemoteThing — a Remote Thing with no file transfer or tunneling needs. Also used for OPC-DA data source things. Supports properties, services, and events.
RemoteThingWithFileTransfer — a Remote Thing plus file transfer enablement.
RemoteThingWithTunnels — a Remote Thing plus tunneling enablement.
RemoteThingWithTunnelsAndFileTransfer — a Remote Thing with file transfer and tunneling.
EMSGateway — The EMSGateway Thing Template is used when you wish to be able to address the WSEMS as a standalone Thing. This may be useful in situations where the WSEMS is running on a gateway computer and handling communication for one or more Remote Things, which may reside on different IP addresses within a local area network.
SDKGateway — Similar to the EMSGateway, but to be used when you are using an SDK implementation as a gateway.
In addition to the above Thing Templates, there are additional remote templates that can be used in a federated storage scenario, where you want to offload the persistence objects to another server that is optimized for disk IO:
RemoteStream — create a local proxy object to a stream Thing which is running and persisting data on another ThingWorx server.
RemoteValueStream — create a local proxy object to a value stream Thing which is running and persisting data on another ThingWorx server.
RemoteDataTable — create a local proxy object to a Data Table Thing which is running and persisting data on another ThingWorx server.
RemoteBlog — create a local proxy object to a blog Thing which is running and persisting data on another ThingWorx server.
RemoteWiki — create a local proxy object to a wiki Thing which is running and persisting data on another ThingWorx server.
Creating Thing Templates with an Extension
Thing Templates created with an extension are basically the same as those created in ThingWorx Composer. They are base templates that are used to create Things with the same properties, configuration parameters, services, and so forth. The difference between creating them in Composer and inside an extension framework is the language used for the services and visibility of those services.
Composer Template:
Uses JavaScript for services
Source code is visible
Extension SDK Template:
Uses Java for services
Source code is not visible
Can define configuration values