3 Replies Latest reply on Nov 13, 2017 7:43 AM by tmousaw RSS
    mnudel Explorer

    How to change specific ThingShape property definition programmatically?

    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!

      • Re: How to change specific ThingShape property definition programmatically?
        stevegr Apprentice

        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);

          • Re: How to change specific ThingShape property definition programmatically?
            mnudel Explorer

            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!