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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to model association pattern using Things

unnikrisvp
11-Garnet

How to model association pattern using Things

I want to implement the below structure in Thingworx.

Device

    - List<Axis> {A1, A2}

    - List<Rotor> {R1, R2, R3}

Axis

    - Position (Number)

    - Temperature (Number)

Rotor

    - Speed (Number)

There is an option to provide a ThingName as a property, however List is not supported.

 

Currently I have modeled the above structure using Infotables.

Device

    - AxisPosition Infotable  eg: {A1X - 26, A1Y - 67, A2X - 56, A2Y - 0}

    - AxisTemperature Infotable eg: {A1 - 156, A2 - 167}

    - RotorSpeed Infotable {R1 - 34, R2 - 45, R3 - 50}

Each infotable will have multiple rows of axis/rotor and position/temp/speed values. And the infotable properties are logged to a ValueStream.

 

However this structure cannot be mapped to a Time series chart, as the ValueStream timestamp is associated with the Device and the chart don't support infotable on any axis.

If List could have been supported, I could have retrieved all the axis/rotor Things of a particular device and then mapped individual properties to the time series chart

 

Can you please suggest how this structure can be alternatively modeled, so that it can be used in a TimeSeriesChart.

 

 

 

7 REPLIES 7
PaiChung
22-Sapphire I
(To:unnikrisvp)

Looks like you are fairly well on your way.

to get the data to chart with your setup, you will need to use the DataChange and Subscription event/subscription to create a service to log the data into a regular stream.

Then of course create a service to pull it out to display properly.

A slightly longer way to do it is to model each as a Thing and relate them to each other in a Network. Which in this use case may not make as much sense.

Finally you could break all of the items out in separate properties and then you can leverage ValueStream

Thanks Pai.

I will have a look on creating a custom service logic to extract the require data using the event and subscriptions. Do you have any code excerpts which depict how to log the data into a regular stream.

I am also interested in checking the Network solution. Do you have any references for the same.

PaiChung
22-Sapphire I
(To:unnikrisvp)

If you have access to our Fundamentals course on precision LMS there are examples there.

In the Snippets if you go to datatable/stream/blog/wiki there is an AddStreamEntry example

Networks you should be able to figure out fairly easily, comes with a ton of additional useful services as well.

Thanks Pai.

I have one query with regards to the infotable type field of the 'Infotable' property. There are options to set the type to 'Is Data Table' and 'Is Stream Entry', which both automatically add timestamps to the infotable. How can the timestamp be updated for such Infotable entries? Are these timestamps updated when a value is logged to the infotable.

The reason I am asking the above is if the timestamps can be logged onto the infotable, may be I can just directly map this infotable to the Time Series chart.

Please advise.

PaiChung
22-Sapphire I
(To:unnikrisvp)

First of all not sure if you are familiar with the term VTQ which stands for Value Time Quality

Any property in Thingworx is actually VTQ, you can see this best when you look at a DataChange event where you will see oldValue - Value, Time, Quality and newValue - Value, Time, Quality

That means that automatically for a property when it is updated, it will have a new timestamp that you can retrieve using for example GetPropertyValuesVTQ or GetPropertyValueVTQ

Now if your system is specifically submitting a timestamp, then I recommend just adding a field to hold that information, don't use timestamp since that will be a reserved word.

Using the is DataTable/Stream would allow that as well, but that adds the default fields of that type of entity timestamp, source, sourcetype, location, tags I would reserve that for the use with actual data coming from DataTables/Streams etc. instead.

Pai, Thanks for the VTQ info.

To elaborate on my above query, this is the structure I am currently checking on (as represented in Mashup data tab).

- QueryImplementingThingsWithPropertyHistory (MyDeviceTemplate)

    - Returned Data

        - Selected Rows (A single device)

            - AxisLoad (infotable with type as 'Is Stream entry')

                 - Axis

                 - Load

                 - timeStamp  

            - timestamp

The template has a valuestream assigned and the AxisLoad property is 'logged'.

In this scenario can the Axis load property timestamp be populated similarly as the Thing timestamp. Should I associate the Infotable property to a stream, if yes, then how.

 

Sorry for the repeated queries and thanks for your patience, but I just wanted to explore all possible options that can lead to a correct design.

 

One more update from my side: I checked on the Network solution, but it doesn't seem to suit my requirement as the network mapping is done on a Thing level, and you will have to set the network only after creating the Things. In my case, the device Things are dynamically created during runtime, and mapping this to any Axis Things can be done only after the creation and will require user involvement, which I want to avoid as part of the extension.

Announcements


Top Tags