Skip to main content
May 23, 2018 5:23 AM UTC
Solved

Adding values dynamically to a ValueStream

Hi I am trying to update values to my value stream using the Extension SDK. However the values are not getting changed on Thingworx.

 

InfoTableFunctions functions = new InfoTableFunctions();
InfoTable table = functions.CreateInfoTableFromDataShape(propertyName, propertyName+"Shape");
		
ValueCollection row = new ValueCollection();
for (Entry<String, Double> entry: dataMap.entrySet()) {
	row.SetStringValue(keyField, entry.getKey());
	row.SetNumberValue(valueField, entry.getValue());
	row.SetDateTimeValue("ds_timestamp", now);
	table.addRow(row.clone());
}
myThing.AddInfoTableValueStreamEntry(now, propertyName, table);
//mtConnectDeviceThing.setPropertyValue(propertyName, new InfoTablePrimitive(table)); // this works, but not sure if it will add to the stream.
AdamRAnswer
May 23, 2018 4:29 PM UTC

mtConnectDeviceThing.setPropertyValue(propertyName, new InfoTablePrimitive(table));

 

This will work as long as your property is configured to be "logged".

 

Another question is why in the code snippet is one line trying to log to "myThing" and in the code above it is named "mtConnectDeviceThing".  Are these two different Things?


Thanks,

Adam

2 replies

AdamRAnswer
May 23, 2018 4:29 PM UTC

mtConnectDeviceThing.setPropertyValue(propertyName, new InfoTablePrimitive(table));

 

This will work as long as your property is configured to be "logged".

 

Another question is why in the code snippet is one line trying to log to "myThing" and in the code above it is named "mtConnectDeviceThing".  Are these two different Things?


Thanks,

Adam

May 24, 2018 2:43 PM UTC

Thanks Adam. I have added the 'isLogged' aspect to the Thing properties and it is working fine now.

 

The 'mtConnectDeviceThing' was a typo. I forgot to update it in the commented code.