Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
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.
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.