ThingWorx Edge .NET SDK Reference > .NET SDK: VirtualThing Class > Sending Property Value Changes from ThingWorx to Edge Devices
Sending Property Value Changes from ThingWorx to Edge Devices
When properly bound to remote properties on an Edge device, properties on RemoteThing instances can be used for both reading values from and writing new values to devices. For the .NET SDK, this functionality is provided by default when you extend the VirtualThing class to define your device and then use annotations to define the properties for that device.
When a new value is pushed down from ThingWorx Platform, the device has an opportunity to react. For the .NET Edge SDK, the processPropertyWrite(PropertyDefinition, IPrimitiveType) method on the VirtualThing class is called in response to receiving a value that has been pushed down from the ThingWorx Platform. By default, the processPropertyWrite() method does nothing. However, if you expect edge devices to receive data from the ThingWorx Platform, you should override this method and configure the application to validate new values that are pushed down from ThingWorx Platform.
The processPropertyWrite() method executes before committing the data to device memory. It takes the following properties:
The PropertyDefinition property contains the property information for the property that is being set.
The value property contains the new value that is pushed down from the ThingWorx Platform.
If you call the method, getCurrentPropertyValue() for the property specified in the processPropertyWrite() method, the getCurrentPropertyValue() method returns the currently set value (“old”). You can then compare that “old” value to the value that was pushed down and, as applicable, reset the value of the property. If the incoming value is not valid, you can restore the “old” value.
The VirtualThing tracks the new value of the property in its internal property map. If the property is configured to be pushed to the ThingWorx Platform on change and the cache option is set to read from the server cache, the typical result is that the new value of the property is sent back to the ThingWorx Platform. In this case, the new value is not displayed in ThingWorx Composer until the edge device confirms the new value by pushing it back up to the platform.
* 
To ensure that a property displays an accurate value at all times, you can set the Cache Option to Fetch from Remote on Every Read. This setting increases the amount of data sent between ThingWorx platform and the edge device because every request for the property retrieves the data directly from the device. Use this option sparingly with devices on metered connections.
Setting Up Your Application
To propagate property values that are set on a Remote Thing on the ThingWorx Platform to the VirtualThing in your edge application, follow these steps:
1. In your edge application, create the VirtualThing and use annotations to add properties to it. The samples provided with the SDK show how to use annotations to add properties.
2. As long as you have set up the VirtualThing in your edge application to connect to your ThingWorx Platform, start your application.
3. In ThingWorx Composer, use the Manage Bindings button at the top of the Properties page to add the remote properties to your RemoteThing.
4. Save your RemoteThing.
5. In the Properties page for your RemoteThing, click the Set button to set the value of a property. As long as the edge device is connected, this action sends the new value to your edge application.
6. In your VirtualThing, you can override the processPropertyWrite() method in order to react to values sent down for properties from the ThingWorx Platform.
* 
The SDK also provides the method, processPropertyRead(), which you can use to react to requests from the ThingWorx Platform to read property values. If you override the method, you could run some calculations or format the data before responding to such a request.
Was this helpful?