SteamSensor Example
The Steam Sensor example uses macros that were introduced with the Edge Extensions The ./examples/SteamSensor/ directory has two main subdirectories and the CMakeLists.txt file that you can use to build the example using CMake. The ./examples/SteamSensor/import/ directory contains the SteamSensor_Entities.xml file that you must import into your instance of ThingWorx Platform so that all entities needed when running this example exist in your instance. The ./examples/SteamSensor/src/ directory for this example contains the following files:
main.c—Contains the code that starts a connection to ThingWorx Platform and binds a single Thing (SteamThing). The code that adds a path to load Edge Extensions at runtime follows:
SteamThing.c—Contains the onSteamSensorProcessScanRequest for setting properties of the Steam Thing, determining if there is a fault, and if so, sending an event, and opening the steam release valve. This function uses multiple macros for all this processing, includingTW_SET_PROPERTY, TW_GET_PROPERTY, TW_FIRE_EVENT, TW_PUSH_PROPERTIES, TW_MAKE_BOOL, TW_MAKE_NUMBER, and TW_MAKE_LOC macros (among others).
SteamThing.h—Contains the definitions for this example, including the function that creates the Steam Sensor Thing.
gpsroute.h—Contains the definitions for the locations along the route (based on a GPS) and a variable that contains the number of steps along the route.
To build this example, follow the instructions for building with CMake in How to Build an Edge Application with CMake. This topic explains where to obtain CMake and other documentation for it. Once you have set up CMake, you will find instructions for building on Windows (Building for Windows Platforms with CMake) and on Linux (Building for Linux Platforms with CMake). Once you have built this application, make sure that you have imported the entities in the SteamSensor_Entities.xml file, and you are ready to run it.
Running the Steam Sensor Example from the Command Line
To run the Steam Sensor example from the command line, open a shell or Command Prompt, and navigate to the directory in which the executable is stored. Then enter the following at the command line:
SteamSensor [-h hostname] [-p port] [-k key] [-t thingname] [-s] [-c] [-u]
-h — The host name or IP address of your ThingWorx Platform.
— The port number on the platform for the SteamSensor application to use when connecting to the platform.
-k — The application key that you created for this application.
-t — The thingName of the SteamSensor Thing (imported by the SteamSensor_Entities.xml file)
-u — Using this argument with just SteamSensor displays the help for the syntax.
If you enter the syntax incorrectly, helpful messages are displayed to help you fix the error. If you want to display the help text, type SteamSensor-u, where -u is for "usage".
Was this helpful?