-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from electricimp/feature/docs
Docs updates
- Loading branch information
Showing
2 changed files
with
90 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,61 @@ | ||
# ThingWorx Examples | ||
# ThingWorx Examples # | ||
|
||
This document describes the example application provided with the [ThingWorx library](../README.md). | ||
|
||
## DataSender Example | ||
## DataSender Example ## | ||
|
||
This example creates ThingWorx Thing named `test_thing` (if it does not exist already) with two predefined Properties and periodically updates the Properties values: | ||
- the values are updated every 10 seconds. | ||
- the Properties are: | ||
- `data` - integer value, converted to string, which starts at 1 and increases by 1 with every update. It restarts from 1 every time when the example is restarted. | ||
- `measure_time` - integer value, the time in seconds since the epoch. | ||
This example creates a ThingWorx Thing named `test_thing` (if it does not exist already) with two predefined Properties: | ||
|
||
## Setup and Run | ||
- *data* — An integer value, converted to string, which starts at 1 and increases by 1 with every update. It restarts from 1 every time the example is restarted. | ||
- *measure_time* — An integer value, which is the time in seconds since the epoch. | ||
|
||
### ThingWorx Evaluation Server Configuration | ||
The application updates the Properties values every 10 seconds. | ||
|
||
## Setup and Run ## | ||
|
||
- Login to [ThingWorx Developer Portal](https://developer.thingworx.com/login) in your web browser. | ||
- Click **Evaluation Server** icon in the top right corner of the Developer Portal. **Note:** The initial provisioning of Evaluation Server for a new account usually takes between 3-5 minutes. | ||
- Copy **Hostname** value from the pop up and paste into a plain text document or equivalent. This will be used as the value of the *THING_WORX_ENDPOINT* constant in the imp agent code. | ||
- Click **Launch**. You will be redirected to the ThingWorx Composer page (usually a new tab). | ||
### ThingWorx Evaluation Server Configuration ### | ||
|
||
- Login to the [ThingWorx Developer Portal](https://developer.thingworx.com/login) in your web browser. | ||
- Click the **Evaluation Server** icon in the top right corner. **Note** The initial provisioning of Evaluation Server for a new account usually takes between 3-5 minutes. | ||
- Copy the **Hostname** value from the pop-up and paste it into a plain text document or equivalent. This will be used as the value of the *THING_WORX_ENDPOINT* constant in the imp agent code: | ||
![LaunchThingWorx](../png/LaunchThingWorx.png?raw=true) | ||
- In the **ThingWorx Composer** **Home** tab click **Application Keys "+"** button in the **SECURITY** menu. | ||
- Click **Launch**. You will be redirected to the ThingWorx Composer page (usually a new browser tab) | ||
- In the **ThingWorx Composer** page’s **Home** tab, click **+** under **Application Keys** in the **SECURITY** section: | ||
![AddAppKey](../png/AddAppKey.png?raw=true) | ||
- Enter any Application Key **Name**, eg. `testAppKey`. | ||
- Click **Search** button in **User Name Reference** field and choose **Administrator** user. | ||
- Click **Search** in the **User Name Reference** field under **General Information**, and choose the **Administrator** user: | ||
![AppKeyUser](../png/AppKeyUser.png?raw=true) | ||
- Choose date and time for **Expiration Date** field. | ||
- Click **Done**. | ||
- Click **Save**. | ||
- Choose a date and time for **Expiration Date** field. | ||
- Click **Done** then click **Save**: | ||
![AppKeyExpirationDate](../png/AppKeyExpirationDate.png?raw=true) | ||
- In the **General Information** page of your Application Key select and copy **keyId** field and paste into a plain text document or equivalent. This will be used as the value of the *THING_WORX_APPLICATION_KEY* constant in the imp agent code. | ||
- On the **General Information** page select and copy the **keyId** field and paste into a plain text document or equivalent. This will be used as the value of the *THING_WORX_APPLICATION_KEY* constant in the imp agent code: | ||
![AppKeyId](../png/AppKeyId.png?raw=true) | ||
|
||
### DataSender Example Setup and Run | ||
### Setting Up and Running the Application ### | ||
|
||
- In the [Electric Imp's IDE](https://ide.electricimp.com) create new Product and Development Device Group. | ||
- Assign device to the newly created Device Group. | ||
- Copy the [DataSender source code](./DataSender.agent.nut) and paste it into the IDE as the agent code. | ||
- Set *THING_WORX_ENDPOINT* constant in the agent example code to the value of Evaluation Server Hostname you retrieved and saved in the previous steps, prefixed by `https://`. The value should look like `"https://PP-1802281448E8.Devportal.Ptc.Io"`. | ||
- Set *THING_WORX_APPLICATION_KEY* constant in the agent example code to the value of Application Key Id you retrieved and saved in the previous steps. | ||
- In [Electric Imp’s impCentral™](https://impcentral.electricimp.com) create a Product and Development Device Group. | ||
- Assign a development device to the newly created Device Group. | ||
- Open the code editor for the newly created Device Group. | ||
- Copy the [DataSender source code](./DataSender.agent.nut) and paste it into the code editor as the agent code. | ||
- Set the *THING_WORX_ENDPOINT* constant in the agent example code to the value of Evaluation Server Hostname you retrieved and saved above. Ensure it is prefixed with `https://`. The value should look like `"https://PP-1802281448E8.Devportal.Ptc.Io"`. | ||
- Set the *THING_WORX_APPLICATION_KEY* constant in the agent example code to the value of the Application Key ID you retrieved and saved above: | ||
![SetThingWorxConsts](../png/SetThingWorxConsts.png?raw=true) | ||
- Click **Build and Force Restart**. | ||
- Check from the logs in the IDE that data sendings are successful. | ||
- Use the code editor’s log pane to confirm that data is being sent successfully: | ||
![DataSenderLogs](../png/DataSenderLogs.png?raw=true) | ||
|
||
**Note:** the hosted ThingWorx Evaluation Server is stopped after 3 hours of inactivity and, typically, it takes about one minute to start it again. | ||
You need to ensure the Server is started before running the Example. | ||
To start the Server: | ||
- Click **Evaluation Server** icon in the top right corner of the ThingWorx Developer Portal. | ||
- Check the Server status in the pop up. If it is **Stopped**, click **Start** button. | ||
### Notes ### | ||
|
||
- The hosted ThingWorx Evaluation Server is stopped after three hours of inactivity and, typically, it takes about one minute to start it again. | ||
- You need to ensure the Server is started before running the example. To start the Server: | ||
- Click the **Evaluation Server** icon in the top right corner of the ThingWorx Developer Portal. | ||
- Check the Server status in the pop-up. If it is **Stopped**, click **Start**. | ||
|
||
### Monitor the Properties Values in ThingWorx | ||
### Monitor the Properties Values in ThingWorx ### | ||
|
||
- In the **ThingWorx Composer** **Home** tab click **Things** in the **MODELING** menu. | ||
- Click *test_thing* in the **Things** table. | ||
- In the **ThingWorx Composer** page’s **Home** tab, click **Things** in the **MODELING** section. | ||
- Click *test_thing* in the **Things** table: | ||
![ThingsTable](../png/Things.png?raw=true) | ||
- In the **test_thing** tab click **Properties** in the **ENTITY INFORMATION** menu. | ||
- Ensure the Properties table contains **data** and **measure_time** Properties and their values are updated periodically if **Refresh Properties** button is clicked. | ||
- In the **test_thing** tab, click **Properties** in the **ENTITY INFORMATION** section. | ||
- Ensure the Properties table contains **data** and **measure_time** Properties, and that their values are updated periodically if **Values** column’s refresh button is clicked: | ||
![ThingProperties](../png/ThingProperties.png?raw=true) |
Oops, something went wrong.