Skip to main content
12-Amethyst
April 22, 2020
Solved

Issue of SetPropertyValues for Value Stream

  • April 22, 2020
  • 6 replies
  • 2857 views

Hi there,
Today I found an issue in Thingworx 8.4.
Here I have a Thing with 5 attributes(F1/F2/F3/F4/F5) with Value Stream configured.
Now I uses service of SetPropertyValues to update all attributes in the same moment.
- 1st time set to 11/12/13/14/15,
- 2nd time set to 21/22/23/24/25.
So there should be 2 rows in Value Stream.
But I found 3 rows instead, the 2nd update has been recorded into Value Stream in 2 different ms.

Impact:
In Analytics, if we set Dataset as time series data, the training model will track data back, by comparing current cycle VS last cycles, while for last cycles data are queried from Value Stream.
So if we cannot make sure all features/attributes are updated in the same moment(in same row of Value Stream), then the model will check with false data.

Please check it.

Best answer by smainente

Hello,

 

This behavior is normal.

Try to use UpdatePropertyValues() instead and specify the same "time" for all the VTQ values in the InfoTable.

 

For example (java sdk ) :

 

InfoTable vtqs = ...;
final DateTime now = DateTime.now();
for (...) {
 String name = ...;
 BaseTypes type = ...;
 Object value = ...;
 final ValueCollection values = new ValueCollection();
 values.put("name", new StringPrimitive(name));
 values.put("time", new DatetimePrimitive(now));
 values.put("value", BaseTypes.ConvertToPrimitive(value, type));
 vtqs.addRow(values);
}
thing.UpdatePropertyValues(vtqs);

 

 

 

6 replies

5-Regular Member
April 22, 2020

@tallrain 

 

Thank you your post on ThingWorx community.

 

Let me try to reproduce this use case at my end. Could you please confirm you exact Thingworx version 8.4.x?

 

Regards,

Mohit

tallrain12-AmethystAuthor
12-Amethyst
April 22, 2020
It's version 8.4.4
smainente16-PearlAnswer
16-Pearl
April 22, 2020

Hello,

 

This behavior is normal.

Try to use UpdatePropertyValues() instead and specify the same "time" for all the VTQ values in the InfoTable.

 

For example (java sdk ) :

 

InfoTable vtqs = ...;
final DateTime now = DateTime.now();
for (...) {
 String name = ...;
 BaseTypes type = ...;
 Object value = ...;
 final ValueCollection values = new ValueCollection();
 values.put("name", new StringPrimitive(name));
 values.put("time", new DatetimePrimitive(now));
 values.put("value", BaseTypes.ConvertToPrimitive(value, type));
 vtqs.addRow(values);
}
thing.UpdatePropertyValues(vtqs);

 

 

 

tallrain12-AmethystAuthor
12-Amethyst
April 23, 2020
Thank you! Can you paste an example in JavaScript so I can try it in Thingworx Service?
16-Pearl
April 23, 2020

Sorry I don't have the JS service handy.

You can maybe re-use the snippet from this post : https://community.ptc.com/t5/ThingWorx-Developers/UpdatePropertyValues-service/m-p/523874/highlight/true#M18471

 

To get the current date in JS :

 

var now = new Date();