Thingworx内置的数据存储方式

Methods for Data Storage

Overview

Explore the Value Stream, Stream, Data Table, and Info Table storage methods.

GUIDE CONCEPT

This guide will introduce Values Streams, Streams, Data Tables, and Info Tables.

Value Streams and Streams are methods of storage for time-series data, while Data Tables and Info Tables are methods of storage for non-time-series data.

You will learn how to create and utilize these mass data storage methods.

本指南将介绍值流、流、数据表和信息表。
Value Streams和Streams是时间序列数据的存储方法,而Data Tables和Info Tables是非时间序列数据的存储方法。
您将学习如何创建和利用这些海量数据存储方法。

data-storage-methods

Step 1: Choosing Storage

If your data is largely composed of current values of remote IoT devices (and historical values are unimportant), then the simplest solution is most likely to store them as Properties of Things.

如果您的数据主要由远程 IoT 设备的当前值组成(并且历史值并不重要),那么最简单的解决方案很可能将它们存储为事物的属性。

However, as opposed to instantaneous current values, there is also “mass data”. Mass data can include large datasets composed of historical records or spreadsheet-like grids.

然而,与瞬时值相反,还有“大量数据”。海量数据可以包括由历史记录或类似电子表格的网格组成的大型数据集。

Properties (at least by themselves) aren’t really appropriate in that case, as they typically only store the most recent value.

When it comes to mass data, different storage methods are good for different types.

在这种情况下,属性(至少本身)并不合适,因为它们通常只存储最近的值。
当涉及到海量数据时,不同的存储方法适用于不同的类型。

At an extremely high level, ThingWorx divides mass data into roughly two categories:

  • Time-Series - The Timestamp of the data is one of the most important elements.
  • Non-Time-Series - The Timestamp of data changes is relatively insignificant.

在极高的层面上,ThingWorx 将海量数据大致分为两类:

  • 时间序列 - 数据的时间戳是最重要的元素之一。
  • 非时间序列 - 数据更改的时间戳相对而言无关紧要。

In addition, ThingWorx also subdivides these two categories into either 1) tied to a Thing or 2) independent of any one Thing. Mass data storage that is tied to a Thing will logically only accept information from that one Thing, while independent storage may be used to aggregate information from many Things into a single location.

此外,ThingWorx 还将这两个类别细分为 1) 与事物相关联或 2) 独立于任何事物。与 Thing 相关联的海量数据存储在逻辑上仅接受来自该 Thing 的信息,而独立存储可用于将来自多个 Things 的信息聚合到一个位置。

Storage SolutionTime-Series/时间序列Tied to a single Thing/绑定到一个单一事务
Value StreamsYESYES
StreamsYESNO
Data TablesNONO
Info TablesNOYES

The following pages will address these storage types in-depth.

以下将深入介绍这些存储类型。

Step 2: Value Streams

In this step, we’ll create a Value Stream to be used as a storage location.

Value Streams by themselves do nothing. Instead, they must be tied to a Thing.

在这一步中,我们将创建一个用作存储位置的Value Stream
Value Stream本身什么都不做。但它们必须与事物相关联。

Create Value Stream

  1. On the ThingWorx Composer Browse tab, click Data Storage > Value Streams, + New.
    value-streams

  2. In the Choose Template pop-up, select ValueSteam and click OK.
    value-stream-popup

  3. In the Name field, enter Test_Value_Stream.
    在这里插入图片描述

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

  5. At the top, click Save.

Create Thing

Since Value Streams must be tied to a Thing, we’ll create one now and then attach the previously-created Value Stream.

由于Value Streams必须与事物相关联,我们现在将创建一个,然后附加先前创建的Value Streams。

  1. On the ThingWorx Composer Browse tab, click MODELING > Things, + New.
    things
  2. In the Name field, enter Value_Stream_Test_Thing.
  3. If Project is not already set, search for and select PTCDefaultProject.
  4. In the Thing Template field, search for and select GenericThing.
  5. In the Value Stream field, search for and select Test_Value_Stream.
    01-mfds-new-thing
  6. At the top, click Save.

Create Property

Now that we have a Thing with an attached Value Stream, we’ll create a Property of that Thing and set it to be Logged.

If a Value Stream is attached to a Thing, value-changes of all Logged Properties will get automatically recorded along with a timestamp.

现在我们有一个带有附加Value Stream的事物,我们将创建该事物的属性并将其设置为记录。
如果Value Stream附加到事物,所有记录属性的值变化将与时间戳一起自动记录。

  1. At the top, click Properties and Alerts.
    value-stream-properties

  2. Click + Add.

  3. In the Name field, enter Value_Property.

  4. Change the Base Type to Number.

  5. Check the Persistent checkbox.

    • This causes the value of the Property to persist through system reboots.
    • 这会导致该属性的值在系统重新启动后保持不变。
  6. Check the Logged checkbox.

    • This causes all value changes to be logged to the attached Value Stream.
    • 这会导致所有值更改都记录到附加的Value Stream中。

    在这里插入图片描述

  7. At the top-right, click the “Check” button for Done.

  8. At the top, click Save.

Set Property Values

In a real-world application, Property value changes would likely occur through a connection to a remote IoT device.

For simplicity, we’ll instead manually change the values.

Because the Property is Logged and there is a connected Value Stream, each change will be recorded and timestamped.

在现实的应用程序中,属性值的更改可能会通过与远程 IoT 设备的连接发生。
为简单起见,我们将改为手动更改值。
由于该属性已记录并且存在连接的Value Stream,因此将记录每个更改并添加时间戳。

  1. Under the Value column for Value_Property, click the “pencil icon” for Set value of property.
    01-mdsv92-set-value
  2. At the top-right in the Set value of property field, enter 1.
    02-mdsv92-value-1
  3. At the top-right, click the “Check” button for Done.
  4. Again, click the “pencil icon” for Set value of property.
  5. At the top-right in the Set value of property field, enter 2.
    03-mdsv92-value-2
  6. At the top-right, click the “Check” button for Done.
  7. Again, click the “pencil icon” for Set value of property.
  8. At the top-right in the Set value of property field, enter 3.
    04-mdsv92-value-3
  9. At the top-right, click the “Check” button for Done.
  10. At the top, click Save.

Retrieve Logged Values

One of the most common ways to retrieve time-series information is with the built-in QueryPropertyHistory Service.

QueryPropertyHistory may be used to retrieve logged value-changes for usage in a different, custom Service which could manipulate the data, as well as in Mashups for Widgets like a Grid or Line Chart.

检索时间序列信息的最常用方法之一是使用内置的 QueryPropertyHistory 服务。
QueryPropertyHistory 可用于检索记录的值更改,以便在可以操作数据的不同自定义服务以及网格或折线图等小部件的混搭中使用。

  1. At the top, click Services.
    value-stream-services

  2. Expand the Generic section.
    05-mdsv92-expand-generic

  3. Scroll down and find the QueryPropertyHistory Service.
    06-mdsv92-queryprophis

  4. Click the “Play” button for Execute service.
    07-mdsv92-execserv

  5. In the bottom-right of the Execute Service: QueryPropertyHistory pop-up, click Execute.

    • Note the previously entered values of 1, 2, and 3, as well as their associated timestamps.

    08-mdsv92-execresults

  6. At the bottom-right, click Done.

A Value Stream is a simple and easy way to record all time-series changes of a particular Thing Property’s values.

The QueryPropertyHistory built-in Service may be used both in a custom Service to extract the value changes and Timestamps from a Value Stream, as well as in a Mashup to display how values change over time (in a Line Chart, for instance).

Value Stream是一种记录特定事物属性值的所有时间序列变化的简单方法。
QueryPropertyHistory 内置服务既可用于自定义服务以从Value Stream中提取值更改和时间戳,也可用于 Mashup 以显示值如何随时间变化(例如在折线图中)。

Step 3: Streams

Mass data is typically stored in a structure functionally similar to a spreadsheet.

海量数据通常存储在功能类似于电子表格的结构中。

Each separate column of the spreadsheet is exclusively one type of data (with each field directly beneath it holding different entries of that same type), while the rows determine the specific entry.

电子表格的每个单独列都是一种类型的数据(其正下方的每个字段都包含相同类型的不同条目),而行确定特定条目。

Combine a column’s “type” with the row’s “index”, and you have the particular piece of data about which you care.

将列的“类型”与行的“索引”结合起来,您就拥有了您关心的特定数据。

ThingWorx mass data storage functions in roughly the same way. However, ThingWorx does have one differentiation from many spreadsheet implementations.

ThingWorx 海量数据存储的功能大致相同。但是,ThingWorx 确实与许多电子表格实现有一个区别。

In ThingWorx, the type that defines each column is not held internally to the data structure itself. Instead, it is abstracted out as a Data Shape.

在 ThingWorx 中,定义每一列的类型并不保存在数据结构本身内部。相反,它被抽象为Data Shape。

A Data Shape is the definition of what each column contains.

A Stream requires a Data Shape in order to define its structure.

数据形状是每列包含的内容的定义。
一个流需要一个数据形状来定义它的结构。

Create Data Shape

  1. On the ThingWorx Composer Browse tab, click Modeling -> Data Shapes, + New.
    data-shapes

  2. In the Name field, enter Test_Data_Shape.
    data-shape-name

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

  4. At the top, click Field Definitions.
    data-shape-field-defs

  5. Click + Add.

  6. On the right in the Name field, enter Index_Field.

  7. Change the Base Type to INTEGER.

  8. Check the Is Primary Key checkbox.

    • All Data Shapes must have a Primary Key, and Index_Field is an appropriate choice, as it will keep track of the number of entries.

    09-mdsv92-index-field

  9. At the top-right, click the “Check with a +” button for Done and Add.

  10. In the Name field, enter Value_Field.

  11. Change the Base Type to NUMBER.
    10-mdsv92-value-field

  12. At the top-right, click the “Check” button for Done.

  13. At the top, click Save.

    11-mdsv92-data-shape-save

Once again, the Data Shape does nothing by itself.

It simply defines that some other mass data structure (such as a Stream) follows the particular format of the Data Shape.

So a Stream assigned the Test_Data_Shape above would have two fields per entry, i.e. an Index and a Value.

再次提醒,数据形状本身什么都不做。
它只是定义了一些其他海量数据结构(例如流)遵循数据形状的特定格式。
因此,上面分配了 Test_Data_Shape 的流每个条目将有两个字段,即索引和值。

Create Stream

Streams are a mass data storage option optimized for Time-Series data.

They are utilized in much the same way as Value Streams, but possess additional functionality.

For one, Streams do not have to be tied to Things in the way that Value Streams are. They can be entirely independent, or even accept inputs from multiple different Things.

This can be useful when you want to have a master list of what every similar Thing was doing at particular points throughout some timeframe.

Streams是针对时间序列数据优化的海量数据存储选项。
它们的使用方式与Value Streams大致相同,但具有额外的功能。
一方面,Streams不必像Value Streams那样与事物联系在一起。它们可以完全独立,甚至可以接受来自多个不同事物的输入。
当您想要在某个时间范围内的特定时间点拥有每个类似事物在做什么的主列表时,这可能很有用。

  1. On the ThingWorx Composer Browse tab, click DATA STORAGE -> Streams, + New.
    streams

  2. On the Choose Template pop-up, select Stream and click OK.
    02-mfds-stream-popup

  3. In the Name field, enter Test_Stream.
    stream-name

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

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

  6. At the top, click Save.

    12-mdsv92-test-stream-save

Create Thing

Now that the Stream is created, you’ll create a Thing from which you can log some Properties.

现在创建了 Stream,您将创建一个 Thing,您可以从中记录一些属性。

  1. On the ThingWorx Composer Browse tab, click MODELING -> Things, + New.
    stream-thing
  2. In the Name field, enter Stream_Test_Thing.
  3. If Project is not already set, search for and select PTCDefaultProject.
  4. In the Thing Template field, search for and select GenericThing.
    04-mfds-new-stream-thing
  5. At the top, click Properties and Alerts.
    stream-thing-properties
  6. Click + Add.
  7. In the Name field, enter Index_Property.
  8. Change the Base Type to Integer.
  9. Check the Persistent checkbox.
    13-mdsv92-index-prop
  10. At the top-right, click the “Check with a +” button for Done and Add.
  11. In the Name field, enter Value_Property.
  12. Change the Base Type to Number.
  13. Check the Persistent checkbox.
    14-mdsv92-value-prop
  14. At the top-right, click the “Check” button for Done.

Add Service

Since you now have both a Thing and a Stream, we can write a Service which logs the Properties’ values when the Service is executed.

由于您现在拥有一个事物和一个Stream,我们可以编写一个服务,在服务执行时记录属性的值。

  1. At the top, click Services.
    15-mdsv92-services

  2. At the top, click + Add.

  3. In the Name field, enter Add_Stream_Entry_Service.
    16-mdsv92-add-stream-entry-service

  4. On the left under New Service, click the Snippets tab.
    17-mdsv92-snippets

  5. In the Filter field, type add str.
    18-mdsv92-filter-add-str

  6. Expand the Stream, Blog, Data Table section to reveal the Add Stream Entry Snippet.
    service_add_stream_entry

  7. Click the right arrow beside Add Stream Entry.

    • An Add Stream Entry pop-up will open.

    add_stream_entry_popup

  8. In the Search Streams field, enter test.
    popup_search_test

  9. Select Test_Stream.
    popup_insert_code_snippet

  10. Click the Insert Code Snippet button.

    • Note that a section of Javascript code has now been added to the Script window.

    19-mdsv92-insert-snippet

Modify Snippet

The inserted Javascript Snippet has already done most of the work of creating a custom Service for us.

All which you need to do now is modify the code Snippet to store the particular Property values from your Thing.

插入的 Javascript Snippet 已经完成了为我们创建自定义 Service 的大部分工作。
您现在需要做的就是修改代码 Snippet 以存储 Thing 中的特定属性值。

  1. On the 10th line of code, double-click undefined to select it.
    20-mdsv92-highlight-undefined-1

  2. On the left, click the Me/Entities tab.
    21-mdsv92-me-entities

  3. Under the Me/Entities tab, expand Properties.

    • Note that this is not the Properties and Alerts at the top of Composer.

    22-mdsv92-expand-prop

  4. Click the right arrow beside Value_Property.

    • Note that undefined has been replaced by me.Value_Property.

    23-mdsv92-value-prop

  5. On the 11th line of code, double-click the remaining undefined to select it.
    24-mdsv92-other-undefined

  6. Click the right arrow beside Index_Property.

    • Note that the second “undefined” has been replaced by “me.Index_Property”.

    25-mdsv92-index-prop

  7. At the top, click Done to close the Add_Stream_Entry_Service editing window.
    26-mdsv92-service-done

  8. At the top, click Save.

Store to Stream

Now that the Stream, the Thing (and its Properties), and the Thing’s Service are all in place, we can execute the Service (along with some Property changes) to demonstrate that the values are getting archived externally to the Stream.

现在 Stream、Thing(及其属性)和 Thing 的服务都已准备就绪,我们可以执行服务(以及一些属性更改)以证明这些值正在外部存档到 Stream。

  1. At the top, click Properties and Alerts.

    • Note the previously-created Index_Property and Value_Property.

    stream-properties

  2. For Index_Property’s Value column, click the “pencil” icon for Set value of property.
    27-mdsv92-index-set-value

  3. In the slide-out on the right, enter 1.
    28-mdsv92-index-set-1

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

  5. For Value Property, click the “Pencil” icon for Set value of property.
    29-mdsv92-value-set-prop

  6. In the slide-out on the right, enter 10.
    30-dsv92-value-set-10

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

  8. At the top, click Save.

    31-mdsv92-stream-test-thing-save

With the Thing’s Properties set to new values, you can now call your custom Service to store those values to the external Stream (along with an auto-generated timestamp).

将事物的属性设置为新值后,您现在可以调用自定义服务将这些值存储到外部流(以及自动生成的时间戳)。

  1. At the top, click Services.
    08-mfds-services-add-stream-entry
  2. On the Add_Stream_Entry_Service line, click the “Play” button for Execute Service.
    32-mdsv92-execute-service
  3. At the bottom-right of the pop-up, click the Execute button.execute_popup
  4. At the bottom-right, click the Done button.execute_results

Retrieve from Stream

To confirm that our Thing’s custom Service is correctly logging our Property values, we’ll now use a built-in Service of the Stream to retrieve the stored values.

This same QueryStreamEntriesWithData Service could alternately be used to populate various Mashup Widgets to view the data in a more convenient format.

为了确认我们 Thing 的自定义服务正确记录了我们的属性值,我们现在将使用流的内置服务来检索存储的值。
这个相同的 QueryStreamEntriesWithData 服务可以交替地用于填充各种 Mashup Widget,以更方便的格式查看数据。

  1. Return to the Test_Stream Entity.
    return-test-stream

  2. On the top, click Services.
    33-mdsv92-services

  3. Scroll down and locate the QueryStreamEntriesWithData Service’s Execute service button.
    34-mdsv92-querystreamentrieswithdata

  4. At the bottom-right of the pop-up, click Execute.

    • Note that you should see a single entry, showing the Index_Field at 1, the Value_Field at 10, and a timestamp of when the information was pushed to the Stream.

    query_result

  5. At the bottom-right, click Done.

To further confirm external storage to the Stream, you may repeat the previous steps to confirm additional Property Value Storage with timestamping.

Furthermore, you could create a Mashup utilizing either the Time-Series Chart or a Grid to display the data stored within the Stream.

要进一步确认流的外部存储,您可以重复前面的步骤以确认带有时间戳的附加属性值存储。
此外,您可以创建一个 Mashup 使用时间序列图表或网格来显示存储在流中的数据。

Step 4: Data Tables

Just like with Streams, you also need a Data Shape to format a Data Table.

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

就像使用 Streams 一样,您还需要一个 Data Shape 来格式化数据表。
在这个例子中,我们实际上将使用我们之前为流创建的完全相同的数据形状。

Create Data Table

Both Data Tables and Info Tables may be appropriate for your non-time-series mass data storage needs.

However, a Data Table is not tied to a Thing as an Info Table Property would be.

If your non-time-series information is coming from multiple different sources, then it would generally be appropriate to use a Data Table.

数据表和信息表都可能适合您的非时间序列海量数据存储需求。
但是,数据表并不像信息表属性那样与事物相关联。
如果您的非时间序列信息来自多个不同的来源,那么使用数据表通常是合适的。

  1. On the ThingWorx Composer Browse tab, click Data Storage > Data Tables, + New.data-tables

  2. On the Choose Template pop-up, select DataTable, and click OK.
    datatable_popup

  3. In the Name field, enter Test_Data_Table.
    data-table-name

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

  5. 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 Data Table.
  6. At the top, click Save.

    05-mfds-data-table-save

Create Thing

Now that we have a Data Table, let’s create a Thing with some Properties that we’ll eventually log to the external Data Table.

现在我们有一个数据表,让我们创建一个带有一些属性的事物,我们最终将记录到外部数据表。

  1. On the ThingWorx Composer Browse tab, click MODELING -> Things, + New.things
  2. In the Name field, enter Data_Table_Test_Thing.
  3. If Project is not already set, search for and select PTCDefaultProject.
  4. In the Thing Template field, search for and select GenericThing.
    06-mfds-data-table-thing
  5. At the top, click Properties and Alerts.
    data-table-thing-properties
  6. Click + Add.
  7. In the Name field, enter Index_Property.
  8. Change the Base Type to Integer.
  9. Check the Persistent checkbox.
    35-mdsv92-thing-property
  10. At the top, click the “Check with a +” button for Done and Add.
  11. In the Name field, enter Value_Property.
  12. Change the Base Type to Number.
  13. Check the Persistent checkbox.
    36-mdsv92-second-property
  14. At the top-right, click the “Check” button for Done.

Create Service

We now have both a Data Table and a Thing with Properties that we want logged.

Now we need to create a Service which does the logging.

我们现在有一个数据表和一个我们想要记录的带有属性的事物。
现在我们需要创建一个进行日志记录的服务。

  1. At the top, click Services.
    data-table-thing-services

  2. Click + Add.

  3. In the Name field, enter Add_Data_Table_Entry_Service.
    37-mdsv92-add-service

  4. Under New Service on the left, click the Snippets tab.
    38-mdsv92-snippets

  5. In the Filter field, type data table.
    39-mdsv92-filter-data-table

  6. Expand the Stream, Blog, Data Table section.
    40-mdsv92-expand-stream

  7. Beside Add/Update Data Table, click the right arrow.

    • A pop-up will open.

    snippet_popup

  8. In the Search Data Tables field, type test.
    snippet_etst_search

  9. Select Test_Data_Table.
    insert_code_snippet

  10. Click the green Insert Code Snippet button.

    • Note that a section of Javascript code has now been added to the Script window.

    41-mdsv92-insert-code-snippet

Modify Snippet

  1. On the 6th line of code, double-click undefined to select it.

  2. On the left, expand the Me/Entities tab.

  3. Under the Me/Entities tab, expand Properties.

    • Note that this is not the Properties and Alerts at the top of Composer

    42-mdsv92-expand-prop

  4. Click the right arrow beside Value_Property.

    • Note that undefined has been replaced by me.Value_Property.

    在这里插入图片描述

  5. On the 7th line of code, double-click the remaining undefined to select it.

  6. Click the right arrow beside Index_Property.

    • Note that the second undefined has been replaced by me.Index_Property.

    44-mdsv92-replace-index-prop

  7. Click Done to stop editing the custom Service.
    data-table-service-done

  8. At the top, click Save.
    data-table-thing-save

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.

    data-table-thing-properties

  2. On the Index_Property line under the Value column, click the “Pencil” icon for Set value of property.
    data-table-set-property

  3. In the slide-out on the right, enter 1.
    45-mdsv92-set-index-1

  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

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

  8. At the top, click Save.
    data-table-thing-save

Store to Data Table

  1. At the top, click Services.
    data-table-thing-services

  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.

    execute_service_popup

  3. At the bottom-right, click Execute.service_executed

  4. At the bottom-right, click Done.

Retrieve from Data Table

  1. Return to Test_Data_Table.
    test-data-table

  2. At the top, click Services.

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

  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

    query_executed

  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.

如果需要,您可以重复前面的步骤以向数据表添加其他条目。您会注意到数据表的索引和值字段在每个条目中继续更改为您设置的任何内容。
利用 QueryDataTableEntries 内置服务的功能只是显示索引和值项目已正确记录到外部数据表的一种方式。
如果您想在网格中可视化数据表,就像使用网格小部件并将 Test_Data_Table -> QueryDataTableEntries -> 所有数据绑定到所述网格一样简单。

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.

信息表是另一种在 ThingWorx 平台内执行非时间序列数据存储的方法。
用于存储的信息表直接与特定事物相关联。因此,对于您希望跨多个事物聚合数据的情况,它们有些非最佳。
信息表是 ThingWorx 中的属性基本类型,与数字、整数或字符串的方式相同。

  1. On the ThingWorx Composer Browse tab, click Modeling > Things, + New.things
  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.
    07-mfds-info-table-thing
  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.
    47-mdsv92-info-table-thing-prop
  11. At the top-right, click the “Check” button for Done.
  12. At the top, click Save.
    info-table-thing-save

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.
    info-table-set-value
  2. On the new pop-up, click the + Add button.
    setvalue_popup
  3. In the Index_Field, enter 1.
  4. In the Value_Field, enter 11.
    set_first_entry
  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.
    set_second_value
  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.
    set_third_value
  4. At the bottom-right of the pop-up, click Add.
    all_values_set
  5. At the bottom-right of the pop-up, click Save.
  6. At the top, click Save.
    info-table-thing-save

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.

现在我们有了一个带有 InfoTable 属性的 Thing 和 InfoTable 中的一些值条目,让我们创建一个 Mashup 来使用 Grid Widget 来显示这些值。

  1. On the ThingWorx Composer Browse tab, click VISUALIZATION > Mashups, + New.
    mashups
  2. On the New Mashup pop-up, leave the defaults, and click OK.
    new-mashup-popup
  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.
    mashup-saved
  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.grid-advanced

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.

    data-tab

  2. Click the + icon.

    • The Add Data pop-up will appear.

    add-data

  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.
    getprop

  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.
    48-mdsv92-expand-getpropval

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

  10. On the Select Binding Target pop-up, select Data.
    data-bound

  11. At the top, click Save.

  12. At the top, click View Mashup.
    view-mashup

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:

ResourceLink
CommunityDeveloper Community Forum
SupportData Storage Help Center
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值