Skip to main content
1-Visitor
May 23, 2018
Solved

Adding values dynamically to a ValueStream

  • May 23, 2018
  • 2 replies
  • 1796 views

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.
Best answer by AdamR

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

AdamR14-AlexandriteAnswer
14-Alexandrite
May 23, 2018

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

1-Visitor
May 24, 2018

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.