ThingWorx Edge Java SDK > Application Details > VirtualThing Component > Defining Properties > Creating and Pushing Property Changes
  
Creating and Pushing Property Changes
Property values change as your device collects data. The Java SDK uses a VTQ (value, time, quality) structure for properties. Property changes may result from device interrupts and polled values.
The event handlers of the SDK let you know when you have synchronized with the ThingWorx platform. Once synchronization is complete, you can start pushing data to the platform.
Using Methods to Change Property Values
You can programmatically change the value of a property by calling one of the methods below. It is important to keep in mind that you are not changing values on the platform using these methods. You are setting the values of the properties in memory only.
setPropertyVTQ — Sets the value of a property using a VTQ (value, time, and quality) structure. This method takes the following parameters:
name — The name of the property.
value — The primitive that contains the new value.
forceChange — Set this value to true to force the value to be sent to the ThingWorx platform, even if it has not changed. Use this option to send the first value or a value immediately after the device reconnects.
setPropertyValue — Sets the value of a property, using a primitive type. This method takes the following parameters:
name — The name of the property.
value — The VTQ (value, time, and quality) for the value of the property.
setProperty — Sets the value of a property from an object.
name — The name of the property.
value — An object that represents the value to set. The value is cast to the type of property, if possible. Otherwise, an exception is thrown.
Here are examples of using these methods to change the value of a property from within an instance of the VirtualThing class:

//setPropertyVTQ
VTQ vtq = new VTQ();
vtq.setValue(new NumberPrimitive(123.456));
vtq.setTime(new DateTime());
vtq.setQuality(QualityStatus.GOOD);
super.setPropertyVTQ("MyProperty", vtq);

//setPropertyValue
NumberPrimitive value = new NumberPrimitive(123.456);
super.setPropertyValue("MyProperty", value);

//setProperty
super.setProperty("MyProperty", 123.456);
Here is example of using SetPropertyValue to set the values of two properties. This example is from the SimpleThing.java sample:

this.setPropertyValue("Temperature", new IntegerPrimitive(temperature));
this.setPropertyValue("Humidity", new IntegerPrimitive(humidity));
Pushing Data (Subscribed Properties)
If you just make service calls to update your data. Property subscription allows your ThingWorx platform to ask for property values it wants and update them automatically. The subscribed property management suite provides convenient features such as
Allowing changes to be delivered in batches
Pushing changes only when values change, based on a configurable threshold
Allowing changes to be folded or reduced
It is important to keep in mind that, in the Java SDK, all properties are “subscribed” properties in that you must call the updateSubscribedProperties method on the VirtualThing class to push the updated values of properties to the ThingWorx platform. The sample source file, SimpleThing.java, provides an example of calling this method:

// This call evaluates all properties and determines if they should be pushed
// to the server, based on their pushType aspect. A pushType of ALWAYS means the
// property will always be sent to the server when this method is called. A
// setting of VALUE means it will be pushed if has changed since the last
// push. A setting of NEVER means it will never be pushed.
//
// Our Temperature property is set to ALWAYS, so its value will be pushed
// every time processScanRequest is called. This allows the platform to get
// periodic updates and store the time series data. Humidity is set to
// VALUE, so it will only be pushed if it changed.
this.updateSubscribedProperties(10000);