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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Setting ValueStream programatically to a ThingTemplate

unnikrisvp
10-Marble

Setting ValueStream programatically to a ThingTemplate

I have created a template using the Extension Java SDK and am setting the ValueStream on initialization as below:

public void initializeThing() throws Exception {
		
	super.initializeThing();
		
	Thing deviceVS = ThingUtilities.findThing("MyValueStream");
	if (deviceVS != null) {
		this.SetValueStream(deviceVS.getName());
	}
}

Is this the correct way of doing so? Is there any other way of specifying the ValueStream on the Template, just like we specify a property using the @ThingworxPropertyDefinition annotation.

 

Thanks in advance.

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

Don't really have the answer, but what is your use case for setting a ValueStream to a Template programmatically?

Actually, the implementation I have shared is a programmatic one, which is not at all required as I am just setting an existing stream to the Template ( the stream is packaged as a entity in the extension). What I am checking is that, is there a static way - like for property definitions, which can be used to set the ValueStream.

 

My use case is to have all the Things created using a Template to share the same value stream. Though there are multiple Things, the Thing data will only be occasionally logged in, so having a stream for each Thing doesn't make sense IMO.

Top Tags