cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Methods for Data Storage Part 4

No ratings

 

Step 4: Data Tables (cont.)


Set Properties

We now have the Thing with Properties that we want logged, the Service to do said logging, and the Data Table to where the values will be stored

 

  1. At the top, click Properties and Alerts.

    • Note Data_Table_Test_Thing’s Index_Property and Value_Property.

    27-mds-data-table-thing-properties.png

     

  2. On the Index_Property line under the Value column, click the "Pencil" icon for Set value of property.

    28-mds-data-table-set-property.png

     

  3. In the slide-out on the right, enter 1.

    45-mdsv92-set-index-1.png

     

  4. At the top-right, click the "Check" button for Set.

  5. On the Value_Property line under the Value column, click the "Pencil" icon for Set value of property.

  6. In the slide-out on the right, enter 10.

    46-mdsv92-set-value-10.png

     

  7. At the top-right, click the "Check" button for Set.

  8. At the top, click Save.

    29-mds-data-table-thing-save.png

 

 

Store to Data Table

  1. At the top, click Services.

    30-mds-data-table-thing-services.png

     

  2. On the Add_Data_Table_Entry_Service line under the Execute column, click the "Play" icon for Execute service.

    • A pop-up will open.

    88_dsi_execute_service_popup.png

     

  3. At the bottom-right, click Execute.

    Stream43.png

  4. At the bottom-right, click Done.

Retrieve from Data Table

  1. Return to Test_Data_Table.

    31-mds-test-data-table.png

     

  2. At the top, click Services.

  3. Scroll down and locate the QueryDataTableEntries built-in Service.

    32-mds-querydatatableentries.png

     

  4. On the QueryDataTableEntries line, click the "Play" icon for Execute service.

    • A pop-up will open.

  5. On the bottom-right of the pop-up, click Execute.

    • Note that you should see a single entry, showing the Index_Field at 1 and the the Value_Field at 10

    92_dsi_query_executed.png

     

  6. On the bottom-right, click Done.

If so desired, you may repeat the previous steps to add additional entries to the Data Table. You will note that the Index and Value fields of the Data Table continue to change in each entry to whatever you have set.

Utilizing the functionality of the QueryDataTableEntries built-in Service was just a way to show that the Index and Value items had been correctly logged to the external Data Table.

If you wanted to visualize the Data Tables in a grid, it would be as simple as utilizing the Grid Widget and tying Test_Data_Table -> QueryDataTableEntries -> All Data to said Grid.



Step 5: Info Tables

Just like with Streams and Data Tables, an Info Table requires a Data Shape to format it.

In this example, we'll actually use the exact same Data Shape we previously created for the Stream.

Create Thing

Info Tables are another way to perform non-time-series data storage within the ThingWorx platform.

Info Tables used for storage are tied directly to a particular Thing. As such, they are somewhat non-optimal for situations where you’re wanting to aggregate data across multiple Things.

Info Tables are a Property Base Type in ThingWorx, in the same manner as a Number, Integer, or String.

  1. On the ThingWorx Composer Browse tab, click Modeling > Things, + New.

    Stream44.png
     
  2. In the Name field, enter Test_Info_Table_Thing.

  3. If Project is not already set, search for and select PTCDefaultProject.

  4. In the Thing Template field, search for and select GenericThing.

    Stream45.png
     
  5. At the top, click Properties and Alerts.

  6. Click + Add.

  7. In the Name field, enter Info_Table_Property.

  8. Change the Base Type to INFOTABLE.

  9. In the Data Shape field, search for and select Test_Data_Shape.

    • This is the same Data Shape we previously created for the Stream. We're just reusing it for formatting the Info Table.

  10. Check the Persistent checkbox.

    Stream46.png
     
  11. At the top-right, click the "Check" button for Done.

  12. At the top, click Save.

    Stream467.png
     

     

Set First Value

Now that we have a Thing with an Info Table Property (formatted by our Data Shape), you can set some values for later display in a Mashup.

  1. On the new Info_Table_Property line under the Value column, click the "Pencil" button for Set value of property.

    Stream47.png
     
  2. On the new pop-up, click the + Add button.

    stream48.png
     
  3. In the Index_Field, enter 1.

  4. In the Value_Field, enter 11.

    stream48.png
     
  5. At the bottom-right of the pop-up, click Add.

Set Second Value

  1. On the pop-up, click the + Add button.

  2. In the Index_Field, enter 2.

  3. In the Value_Field, enter 22.

    Stream49.png
     
  4. At the bottom-right of the pop-up, click Add.

Set Third Value

  1. On the pop-up, click the + Add button.

  2. In the Index_Field, enter 3.

  3. In the Value_Field, enter 33.

    Stream51.png
     
  4. At the bottom-right of the pop-up, click Add.

    Stream52.png
     
  5. At the bottom-right of the pop-up, click Save.

  6. At the top, click Save.

    Stream53.png
     

     

Create Mashup

Now that we have a Thing with an InfoTable Property and some value-entries in said InfoTable, let's create a Mashup to display those values by using the Grid Widget.

  1. On the ThingWorx Composer Browse tab, click VISUALIZATION > Mashups, + New.

    Stream54.png
     
  2. On the New Mashup pop-up, leave the defaults, and click OK.

    Stream55.png
     
  3. In the Name field, enter Test_Info_Table_Mashup.

  4. If Project is not already set, search for and select PTCDefaultProject

  5. At the top, click Save.

    Stream56.png
     
  6. At the top, click Design.

  7. With the Widgets tab selected in the top-left, drag-and-drop a Grid Advanced Widget onto the central Canvas area.


    Stream57.png

     

     

Bind Data

  1. On the far-right, ensure that the Data tab is selected.

    • Note that you may have to expand this area from the far-right.

      Stream58.png
     
  2. Click the + icon.

    • The Add Data pop-up will appear.

      Stream59.png
     
  3. In the Entity Filter field, search for and select Test_Info_Table_Thing.

  4. In the Services Filter field, enter getprop.

  5. Click the right arrow beside the GetPropertyValues Service.

  6. On the right under Selected Services, check the Execute on Load checkbox.

    Stream60.png
     
  7. At the bottom-right of the pop-up, click Done.

    • Note that Test_Info_Thing -> GetPropertyValues is now available under the Data tab at the far-right.

  8. Expand GetPropertyValues > Returned Data > All Data.

    Stream61.png

     

  9. Drag-and-drop GetPropertyValues > Returned Data > All Data > Info_Table_Property onto the Grid Advanced Widget in the central Canvas area.

    62.png
     
  10. On the Select Binding Target pop-up, select Data.

    Stream63.png
     
  11. At the top, click Save.

  12. At the top, click View Mashup.

    Stream64.png
     

The new Mashup displays all of the Index and Value fields you had previously entered.

If you were to add additional entries to the Info Table Property and then refreshed the Mashup, you would see those additional entries as well.


 

Step 6: Next Steps


Congratulations!

In this guide, you've learned how to:

  • Differentiate between data storage methods
  • Create a Data Shape to format a Stream, Data Table, and Info Table
  • Create a Value Stream and Stream to store Time-Series Data
  • Create a Data Table and Info Table to store non-Time-Series Data
  • Use built-in methods to log data to a Value Stream or Info Table
  • Create custom Services which log data to a Stream or Data Table
  • Confirm data storage value changes via a built-in Service or Grid Widget

Learn More

 

We recommend the following resources to continue your learning experience:

   
CapabilityGuide
BuildImplement Services, Events, and Subscriptions

Additional Resources

 

If you have questions, issues, or need additional information, refer to:
        

Resource Link
CommunityDeveloper Community Forum
SupportData Storage Help Center



Version history
Last update:
‎Nov 15, 2022 08:54 AM
Updated by:
Labels (1)
Contributors