Community Tip - You can change your system assigned username to something more personal in your community settings. X
Hey all! I'm currently trying to figure out a strange situation that seems to not have a clean solution in Thingworx.
In short, I am looking to simulate multiple power meters which will likely have a voltage and current property so kilowatt hours can be calculated. However, this will not always be the case, so I don't want to always have these averages stored.
Currently, have a Thing Template called "Power_Meter_Demo". It has the property "current" and "voltage". In addition, I have a Power_Meter_Rolling_Average Thing Shape which has properties "currentAverage", "rollingWindowSize", "currentWindowTotal", and "totalKilowattHours", which are all to be derived from the "current" and "voltage" properties off of the thingTemplate.
What I would like to do is have a subscription on data change where these values are updated, that way they can be displayed live. It does allow me to create a subscription for data change events on the template, which is decent. The main issue becomes that if I decide I don't want to apply the shape for a particular department, the data change event fires anyway, even though I'm using it for purposes explicitly for items on the shape attached, which I don't want. The best case scenario for this is that I need to do a "shape check" on the thing. I've tried to use a subscription the shape as well, but it simply doesn't give me the option to put it on a template, which half makes sense, as a template really doesn't have data change events. This leads me to believe there is no good way to pass down a subscription where the data change event is on the template, but should only happen when a shape is on the template/thing
What's the best practice on this? Do I just do the shape check every time I get a new value?
Solved! Go to Solution.
Hi @pjbiocco.
What version of ThingWorx are you running? You can have subscriptions on thing shapes at least on ThingWorx 8.5 and above.
You indicated you were using the Thing Shape for calculating property values. This isn't a typical use of the Thing Shape. Have you thought about using service calls to enable/disable a subscription? Each thing will have an enable/disable service. You would want to start with the disabled state until you determine which values are needed. In your mashup, you could also have a button for users to enable the subscription as needed for each thing.
Please let us know if you have further questions.
Regards.
--Sharon
Hi @pjbiocco.
What version of ThingWorx are you running? You can have subscriptions on thing shapes at least on ThingWorx 8.5 and above.
You indicated you were using the Thing Shape for calculating property values. This isn't a typical use of the Thing Shape. Have you thought about using service calls to enable/disable a subscription? Each thing will have an enable/disable service. You would want to start with the disabled state until you determine which values are needed. In your mashup, you could also have a button for users to enable the subscription as needed for each thing.
Please let us know if you have further questions.
Regards.
--Sharon