Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X
Learn how to create solutions the can help take you to the next level
This project will introduce more complex aspects of the ThingWorx application and solution building.
Following the steps in this guide, you will develop your own IoT application or get a jump start in how to utilize ThingWorx for your needs.
We will teach you how to create a focused rules engine or service level logic to be used with the ThingWorx Platform.
NOTE: The estimated time to complete this guide is 60 minutes
Download the attached FoodIndustry.zip and extract/import the contents. These are to be used as you work through this learning path. For the completed example, download the FoodIndustryComplete.zip. Unzip the download and import the Entities included.
In this tutorial we walk you through a real-world scenario for a food company looking to improve their processes. We manufacture the best sausages in town! We sell directly to people and through participating store locations. The focus will be to provide meaningful data for decision making, constant updates on food quality, logistics, transparency, and safety. See the below table for the list of mashups that we will create in this guide and included in the download.
Name Description
Fizos.LandingPage | The main page that showcases highlights and possibly important information |
Fizos.Deliveries | A look into product delivery and logistics |
Fizos.Alerts | Details about any important actionable information |
Fizos.Factory.User | A user to be used for our automated process |
There is a large set of Entities provided in this download. The application created in this guide is a part of a final version of what we will create throughout this learning path. If you have not learned about Services, Events/Alerts, and Subscriptions, please take a walk through our Implementing Services, Events, and Subscriptions.
This guide will begin the base of our data model, create data for our factories, and show how we can create automated processes using that data. We will then expand on these items as we move forward in this learning path.
Whenever creating a product in ThingWorx, you should evaluate whether to create them using the data model (Things, Thing Templates, Thing Shapes, etc) or create them using Data Tables and Data Shapes. You have to decide the method that works best for you. One way to think about this is whether to have a single ThingWorx entity to encapsulate your product data OR having so many products (especially when easily volatile), that you rather track it at a higher level.
In our scenario, we won't need to track sausages as the individual level, so we can track the machines creating, holding, and packaging them. This also allows for us to run analytics on the data and export the data into our favorite tools to further process the data.
In the ThingWorx Composer, click the + New in the top left of the screen.
3. In the name field, enter Fizos.DataShapes.Products. This data shape will form high level information about our differing products as a whole.
4. Set the Project (ie, PTCDefaultProject) and click Save to store all changes.
5. Click on the Field Definitions tab.
6. Click the + Add button and enter Name in the Name field of the new Field Definition.
7. Setup your Field Definitions to match the below definitions:
ID | Integer | Primary Key. Default 0. Minimum 0. |
Name | String | N/A |
State | String | N/A |
SKU | String | N/A |
Price | Number | Minimum 0. |
Mass | Number | Default 0. Minimum 0. |
Volume | Number | Default 0. Minimum 0. |
We now have the data shape for products. We can go two different routes here as we create the data table for the products. We can make one data table for ALL company products or we can create a data table for each machine that houses these products. If you wanted the latter options, you could have the machine properties and services assocoated directly on the data table. This is a great option to condense the number of entities being used.
The level of granularity or simplicity is up to you. For this guide, we'll keep things simple and have one data table for all products. When we create the machine entities, we will have a table of the product IDs to help keep track of what products are contained in the machine.
In the ThingWorx Composer, click the + New in the top left of the screen.
Select Data Table in the dropdown and select Data Table in the prompt.
In the pop-up, select Data Table.
In the name field, enter Fizos.DataTables.Products. All of our product line will fit this abstract entity.
For the Data Shape field, select Fizos.DataShapes.Products.
We now have our setup complete for company products. Now let's create a DataShape for any Event involving this product template.
In the ThingWorx Composer, click the + New in the top left of the screen.
Select Data Shape in the dropdown.
In the name field, enter Fizos.ProductsEvent and in the Project field, select an existing Project (ie, PTCDefaultProject). All of our product line will use this DataShape as an alert/event.
State | String | N/A |
SKU | String | N/A |
Price | Number | Minimum 0. |
Name | String | N/A |
Now let's create a Thing Template, Stream, and a ValueStream to track some of what is happening with our products at a high level. The ValueStream will automatically track our data. The Stream, we will add data in the latter sections.
In the ThingWorx Composer, click the + New in the top left of the screen.
3. In the name field, enter Fizos.Products as the name and GenericThing as the Base Thing Template.
4. Select a Project (ie, PTCDefaultProject) and click Save to store all changes.
Now, our new Stream.
In the ThingWorx Composer, click the + New in the top left of the screen.
3. Select Stream in the pop-up.
4. In the name field, enter Fizos.ProductsStream and set the Project field (ie, PTCDefaultProject).
5. In the Data Shape field, select Fizos.ProductsEvent.
6. Click Save to store all changes.
Now, the Value Stream.
In the ThingWorx Composer, click the + New in the top left of the screen.
3. Select ValueStream in the pop-up.
4. In the name field, enter Fizos.ProductsValueStream.
5. Set the Project field (ie, PTCDefaultProject) and click Save to store all changes.
6. Open the Fizos.Products Thing Template and set the Fizos.ProductsValueStream as the Value Stream.
We're all set with high level tracking of all of our products. At this point, we can start the creation of the entity that will help provide the business logic for all products.
In the ThingWorx Composer, click the + New in the top left of the screen.
Select Thing in the dropdown.
InspectFactory | Integer - factoryID | Nothing | Yes | Yes | Start an inspection for a specific factory |
ReceiveInspection | JSON - report/ String - guid | Nothing | Yes | Yes | Log/Store an inspection for a specific factory |
At this point, you have the building blocks to begin your industry business logic and rules engine. In the next section, we'll do more development and further build out our model.
Click here to view Part 2 of this guide.