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

Is there a way to propogate property changes to remote things (ie to the edge sdk clients).

Highlighted
Level 7

Is there a way to propogate property changes to remote things (ie to the edge sdk clients).

We are looking for a way to propagate property values set on a remote thing on the server to the virtual thing inside the edge SDK (.NET ). Is it possible ? What kind of property is require to achieve it (remote / local) ?

Until now we have written all clients using the typical pattern found in examples (ie there is some scanrate and local properties and events are propagated using updateSubscribedProperties and                updateSubscribedEvents(60000) . To have something happen on the client we have always make service calls on remote methods based on some subscription on the server side.

What we want to do is set some remote properties on the server side and have the subscriptions inside the client process. IS that possible ? I could not find any such way in the .NET sdk documentation, but seems like the C SDK has something like that.

int twApi_RegisterProperty(enum entityTypeEnumentityType,
char *entityName,
char *propertyName,
enum BaseTypepropertyType,
char *propertyDescription,
char *propertyPushType,
doublepropertyPushThreshold,
property_cbcb,
void *userdata
)

typedef enum msgCodeEnum(* property_cb) (const char *entityName, const char *propertyName, twInfoTable **value, char isWrite, void *userdata)

where isWrite is true if the server is writing the property.

IS such an API available for .NET , JAVA

Tags (1)
3 REPLIES 3

Re: Is there a way to propogate property changes to remote things (ie to the edge sdk clients).

Hi

In Java - if you set up a property definition that looks like in your remote thing code:

@ThingworxPropertyDefinition(name="MyProperty", description="Demo", baseType="NUMBER", category="Demo", aspects={"dataChangeType:ALWAYS", "dataChangeThreshold:0", "cacheTime:0", "isPersistent:true", "isReadOnly:false", "pushType:Value", "defaultValue:99.00"}),

And bind it to your Modelled Thing on the platform, if you update the value on the Platform it should propagate to the agent. You'll only be able to update the property if the remote thing is connected.

On agent start-up, the property value held on the remote thing will be 0. You can either set it to the default from the annotation:

setProperty("MyProperty", getProperty("MyProperty").getPropertyDefinition().getDefaultValue().getValue());

or

you can use the ConnectedThingClient readProperty() method to pull the current value from the platform.

.Net is very similar:

[ThingworxPropertyDefinition(name="MyProperty", description="Demo", baseType="NUMBER", category="Demo", aspects=new string[] {"dataChangeType:ALWAYS", "dataChangeThreshold:0", "cacheTime:0", "isPersistent:true", "isReadOnly:false", "pushType:Value", "defaultValue:99.00"})]

Initialisation from default:

base.setProperty("MyProperty", getProperty("MyProperty").getPropertyDefinition().getDefaultValue().getValue());

Hope this helps

Regards

Ian

Re: Is there a way to propogate property changes to remote things (ie to the edge sdk clients).

This topic is a few month old now, but i would like to document our solution just because we had the same challenge!

Look for:

processPropertyWrite(PropertyDefinition propertyDefinition, IPrimitiveType value)

A callback method for customization of writes to this VirtualThing.

on

com.thingworx.communications.client.things.VirtualThing

As far as i understood your question, this is what you are looking for. Example is in samples/src/com/thingworx/sdk/simplething/SimpleThing.java

Regards,

Mario Wolff

Re: Is there a way to propogate property changes to remote things (ie to the edge sdk clients).

Noway, i have been looking for the answer all day long. but when  i figured out how to do it at 2:10, you posted your answer after.

This is the answer:

/**
* This is where we handle property writes from the server. The only property we want
* to update is the SetPoint. Temperature and Humidity write requests should be rejected,
* since their values are controlled from within this application.
*
* @see VirtualThing#processPropertyWrite(PropertyDefinition, IPrimitiveType)
*/
@Override
public void processPropertyWrite(PropertyDefinition property, @SuppressWarnings("rawtypes") IPrimitiveType value) throws Exception {

   // Find out which property is being updated
   String propName = property.getName();
   System.out.println(propName);
   System.out.println(value);

  if (!"Directory".equals(propName)) {

   throw new Exception("The property " + propName + " is read only on the simple device.");
   }

   this.setPropertyValue(propName, value);
}