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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How to get dataChangeThreshold property of a remote thing?

Michail
10-Marble

How to get dataChangeThreshold property of a remote thing?

Hi there, I'm desperately trying to find a service which determines dataChangeThreshold value of a remote thing. I'd be grateful for your help!

GetPropertyDefinition() service output is limited.

There are some datashapes which have necessary fields, but I don't know what service is using any of them.

ACCEPTED SOLUTION

Accepted Solutions
supandey
19-Tanzanite
(To:Michail)

I believe this should get you going with the pattern to access the aspects Iterating Through a Thing's Properties

View solution in original post

6 REPLIES 6
supandey
19-Tanzanite
(To:Michail)

Hi Mnudel, since these values are part of Thing's Aspects have you tried Class Aspects and Class AspectCollection that should return array of collection. Plus this enum DataChangeType

Not sure if this helps

Sushant Pandey​, thank you for your response! I'm not familiar with Thing Aspects; is there a tutorial on this matter or a sample code I could use perhaps? Many thanks.

supandey
19-Tanzanite
(To:Michail)

I believe this should get you going with the pattern to access the aspects Iterating Through a Thing's Properties

Sushant Pandey​​​, I deduced that the outputs of the services like GetPropertyDefinitions() and GetPropertyValues() have fields with associated 'aspects' objects. The former has the 'aspects' field as an output. I can solve my problem, however, it seems quite burdensome calling a service which gets a list of all properties beforehand. Is there a different, more direct way of extracting 'aspects' for a particular property?

How one could experiment with java classes and methods in ThingWorx? So far I was bound to JavaScript only. Thank you.

supandey
19-Tanzanite
(To:Michail)

mnudel​ sorry I'm not aware of any other options at the moment. May be someone here has more idea on this.

I usually experiment the other way i.e. setting up Extension SDK and then building stuff together and then import that extension in ThingWorx. I'm not sure how much this would of help, but you can may be try something like what's discussed here javascript - Calling Java function from Rhino - Stack Overflow

Here is the best solution I could come up with


var propertyName = "someProperty";

try {

     var itemsJson = { "items": [propertyName] }

     var prop = Things["someThing"].GetNamedProperties( {propertyNames: itemsJson} );

     var fields = prop.dataShape.fields;  

    if (prop.rows.length > 0) {

        var result = fields[propertyName].aspects.dataChangeThreshold;

    } else {

        var result = 0;

    }

} catch(err) {

     var result = 0;

}

Announcements


Top Tags