ThingWorx Edge Java SDK Edge Extensions > What Is an Edge Thing Shape (ETS)?
What Is an Edge Thing Shape (ETS)?
The Edge Thing Shape (ETS) framework of the Java SDK provides a useful set of building blocks of functionality that enable you to accomplish the common but complex tasks required to interact with hardware and software used for data acquisition and management in your IoT environment. The blocks of functionality can be assembled in different combinations into a Thing that represents a device. An example usage is for a device such as a Raspberry PI, which reports the status of a sensor but also collects data from a custom peripheral that writes to a file from a daemon. By combining an Edge Thing Shape for PI GPIO access with an Edge Thing Shape for parsing files, you can synthesize a new Thing that would deliver all of the collected data toThingWorx without having to write new code.
The ETS framework provides the following entities:
EdgeThingTemplate — An object that extends the VirtualThing class and provides the additional features that are required by the ETS framework. Use this class in place of the VirtualThing class whenever you want to use one or more Edge Thing Shapes. For more details, see About the EdgeThingTemplate.
EdgeThing — An instance of Thing on a remote system that extends the EdgeThingTemplate.
EdgeThingShape — An object that contains a unit of functionality that you want to add to your EdgeThingTemplate. You can add one or more Edge Thing Shapes to a single Edge Thing Template. All of the Edge Thing Shapes are compounded into a single EdgeThing at runtime.
The Edge Thing Shapes provide the following capabilities that are local to the edge:
A configuration file defines the functionality of an Edge Thing Shape.
The library that supports the Edge Thing Shapes can be loaded on the device before the device is deployed.
Loading an ETS into your application, you need to write a little code.
The following scenarios are possible with the Edge Thing Shape framework:
To write an edge application that uses an out-of-the-box Edge Thing Shape from ThingWorx, you would:
1. Create a configuration file, using a Data Shape. The configuration file specifies the directories to watch and a file name that matches a regular expression. It also specifies the frequency at which each directory should be checked for changes. The configuration file is placed in the specified directory.
2. Write an edge application, creating an EdgeThingTemplate whose constructor calls the addEdgeShape() method. This method takes the name that is used to uniquely identify the driver at runtime as well as the class name of the driver. The Java SDK loads the configuration file and handles the initialization.
3. On the ThingWorx Platform, install the file-watcher-extension.zip, which loads the following entities:
FileWatcher Thing Shape
FileWatcherEvent Data Shape
FileWatcherConfig Data Shape
FileWatcherEvent Event
4. Create a new Remote Thing called FileWatch1 and apply the FileWatcher Thing Shape to it. When a file change is detected at the edge, the driver will fire the FileWatcherEvent.
5. To test this, create a subscription to the Thing that writes to the script log.
6. Start the edge application, making sure to configure it to use the Thing Name, FileWatch1.
As a device developer, you want to create a custom Edge Thing Shape (ETS) to provide easy integration with the company’s latest device You would implement the interfaces that provide methods that initialize, open, configure, and close an ETS. These methods provide a way for you to register properties, services, and events with the Edge Thing Template that is loading the ETS.
Was this helpful?