Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X
This project will introduce you to the principles of ThingWorx Foundation by creating a working web application. Following the steps in this guide, you will create the building blocks of your first application for the Internet of Things (IoT). You will use ThingWorx Composer to create Thing Templates, which are then used to create Things that model the application domain. A simulator is imported to generate time-series data that is saved to a Value Stream. After modeling the application in ThingWorx Composer, you'll use Mashup Builder to create the web application Graphical User Interface (GUI). No coding is required in modeling the application, or in composing the web GUI that displays dynamically-generated data. NOTE: This guide’s content aligns with ThingWorx 9.3. The estimated time to complete ALL 5 parts of this guide is 30 minutes.
Model-based design with reusable building blocks makes your applications scalable and flexible. A ThingWorx application is built from Things, each based on a Thing Template that defines the common Properties (characteristics) and Services (behaviors) for a set of entities. Once a Thing Template is created, you can easily instantiate multiple Things without duplicating effort.
In this tutorial, we will develop an application for a house including a thermostat, an electrical meter, and a sensor data simulator. We will demonstrate how to capture, store, and visualize data using the ThingWorx Foundation Server.
You will create Thing Shapes that model both a thermostat and an electric meter. You will then create a Thing Template that represents a house based on these shapes and other Properties.
Thing Shapes are components that contain Properties and Services. In Java programming terms, they are similar to an interface. In this section, you will build Thing Shapes for an electric meter and a thermostat.
NOTE: Thing Shape names are case sensitive
4. If Project is not already set, choose PTCDefaultProject.
5. Click Save.
Name | Base Type | Persistent? | Logged? |
meterID | STRING | X | |
currentPower | NUMBER | X | |
costPerKWh | NUMBER | X | X |
currentCost | NUMBER |
4. Select the Base Type from the drop-down menu that is listed in the table next to the Property name.
5. Check Persistent and/or Logged if there is an X in the table row of the Property.
NOTE: There is a new Index checkbox that is unique to Thingworx 9.3. Users will be able to run high performant quick “search” queries across thousands of connected assets. In addition, they can pre-filter query resultsets for better overall query performance leveraging database Indexing capabilities.
NOTE: When Persistent is selected, the property value will be retained when a Thing is restarted. Properties that are not persisted will be reset to the default during a restart. When Logged is selected, every property value change will be automatically logged to a specified Value Stream.
6. Click ✓+ button.
TIP: When adding multiple properties at once, click Done and Add after each, once you've entered a Name, selected a Base Type and any other criteria. If adding a single property, click Done.
7. Repeat steps 2 through 6 for each of the properties in the rows of the table.
8. Click the done ✓ Button. You'll see that these Properties have been created for the Meter Thing Shape.
9. Click Save.
TIP: This is a shortcut you can use to create anything you can access from the Home tab in Composer.
2. Type ThermostatShape in the Name field.
3. If Project is not already set, choose PTCDefaultProject.
4. Select the Properties and Alerts tab at the top.
5. Click + Add and create the following properties following the same steps as before:
Name | Base Type | Persistent? | Logged? |
thermostatID | STRING | X | |
temperature | NUMBER | X | X |
setTemperature | NUMBER | X | X |
message | STRING | X |
6. Click Save. You'll see that these Properties have been created for the Thermostat Thing Shape.
You can create reusable building blocks called Thing Templates in ThingWorx to maintain scalability and flexibility of your application development. With Thing Templates you define a set of similar objects by specifying the Properties (characteristics) and Services (behaviors) that are common for all the objects. In Java programming terms, a Thing Template is like an abstract class and can be created by extending other Thing Templates. Once a Thing Template is defined and saved in ThingWorx Foundation Server, you can replicate multiple Things to model a complete set without duplicating effort. In this step, you will create a Thing Template that defines properties for a building. This building Template could be used to create multiple Things that each represent a specific home, business, or other building structure.
NOTE: Thing Template names are case sensitive
4. If Project is not already set, click the + in the Project text box and select the PTCDefaultProject.
5. In the Base Thing Template box, click + to choose GenericThing as the Template.
6. In the Implemented Shapes field, click the + to select the MeterShape Thing Shape.
7. Click Save.
In this step, you will specify the Properties that represent the characteristics of a building. Some Properties like the building location may never change (static), while other properties like power and temperature information may change every few seconds (dynamic).
NOTE: When Persistent is selected, the property value will be retained during a system restart. Properties that are not persisted will be reset to the default during a system restart. When Logged is selected, every property value change will be automatically logged to a specified Value Stream.
6. Click the ✓+ button.
TIP: When adding multiple properties at once, click Check+ after each, once you've entered a Name, selected a Base Type and any other criteria. If adding a single property, click Check button.
7. Repeat steps 3 through 6 for each of the properties in the rows of the table.
Name | Base Type | Persistent | Logged |
buildingID | STRING | x | |
building_lat_long | LOCATION | x | |
watts | NUMBER | x | x |
8. After entering the final property, click the ✓ button.
9. Click Save.
You should see the following properties in your Composer.
In the next part of this introductory exercise, we will create a single Thing based on this Template to represent a house.
Click here to view Part 2 of this guide.
Good