Skip to main content
1-Visitor
September 27, 2017
Question

How to change specific ThingShape property definition programmatically?

  • September 27, 2017
  • 1 reply
  • 3271 views

Hello all,

I need to change ThingShape property definition programmatically, namely dataChangeThreshold parameter along with dataChangeType. The idea is to choose the most appropriate deadband based on historical data. I mistakenly thought that AddPropertyDefinition() service would be able to do it, but apparently it cannot. SetRemotePropertyBinding() service cannot do it either.

I recently learnt about the aspects in ThingWorx and came up with the way of extracting dataChangeTreshold, link. Now I need to learn how to set this value in ThingWorx. Many thanks!

1 reply

16-Pearl
September 27, 2017

I'm not sure of the code you are attempting to execute but the following may help

var tsExist = ThingShapes[subscriptionThingShapeName];

try {

     if (tsExist === null || tsExist === undefined ) {

                   Resources["EntityServices"].CreateThingShape(params);

.

.

.

.

     }

}

.

.

.

ThingShapes[ThingShapeName].AddPropertyDefinition(params);

but prior to making changes I would use

ThingShapes[ThingShapeName].RemoveRemotePropertyBinding(params); 

ThingShapes[ThingShapeName].RemovePropertyDefinition(params);

Michail1-VisitorAuthor
1-Visitor
September 28, 2017

Steve Grey-Wilson​, thank you for your reply! I'll try to elaborate on the problem.

Say I've got ~100 things connected already (OPC DA client). All of those things have one shape in common which represents physical machine parameters (a lot of them). At the moment all received values are being stored in the database, irrespective of a log deadband (dataChangeThreshold). The latter results in rapid database growth.

It would be easy to pick a sensible value and set it manually in the Composer. However, the issue is that some machines use different hardware, thus parameter scaling can be different. Incorrect deadband may result in data loss. I developed a mashup which queries historical parameter data from all things, determines min/max datachange values and gives a suggestion for a deadband.

The final part is to enable user to set dataChangeThreshold along with dataChangeType. The way you suggested seems doable, however, I'm not sure how OPC DA client would react on the machine end. It will be difficult to monitor the reaction for that many machines. Is there a more 'elegant' solution?

Shall I dive into Java SDK? Perhaps I could write a service which would be able to set ASPECT_DATACHANGETHRESHOLD aspect field value? Never done it before though. Thank you!

5-Regular Member
November 13, 2017

After some investigation, I do not believe there is any way for you to accomplish what you are trying programmatically.  I do believe that what you are trying to do ​should​ be available programmatically.  Therefore, I would suggest you submit a support ticket for your use case.