PropertyValue Type
When a reference to an object property is obtained it is possible to read its attributes as defined in the object model or in its instance itself. The property attributes can be retrieved using the attributes
property of the PropertyValue
data type. For further reference, see the following table.
Property | Type | Description |
descriptor | String | Localized descriptor for the property. |
error | In case of error, it indicates the reason why the operation failed. | |
max | Object | Maximum value for the PropertyValue, if defined. |
min | Object | Minimum value for the PropertyValue, if defined. |
propertyName | String | Name of the property. |
resolution | Integer | Data resolution for data types where resolution is available (such as, |
type | String | Data type of the value. |
unitDescriptor | Integer | Unit of measurement represented as localized string for those data types where unit is applicable (such as, |
uintId | Integer | Numeric identifier of the unit of measurement for data types where unit is applicable. |
value | Value | Value of the property. For further reference, see the following value table. |
isScaled | Boolean | Flag indicating whether the property has a scaled unit, if applicable. |
factor | Double | The scaling factor, if applicable. |
offset | Double | The value offset, if applicable. |
A read of property values is returned in the following cases:
Value
The Value
property type of the PropertyValue data type allows retrieving the values of the referenced system object property as defined in the object model or in the property itself. For further reference, see the following table.
Property | Type | Description |
displayValue | String | Property value for display purpose (such as, display in the Operation tab). It display the value with unit and resolution (if applicable), and enumerated texts. |
quality | Quality flags as returned when reading the property value. | |
qualityGood | Boolean | Flag that indicates whether the device is reachable when the value of the property is read. |
timestamp | DateTime | The time when the value is read from the device. For more details, see Date- and Time-related Functions. |
type | String | Data type for this value. |
value | Object | Raw value. It can be of any type, including arrays. If a scaled unit is specified for the property, the value is scaled according to the scaled unit. |
When using the virtual objects it is possible to verify the differences between the supported properties. Any type of virtual object supports a different data type.
Examples of Use
How to print any property attributes after a read
var property = read("System1.ApplicationView:ApplicationView.Logics.Scripts.script", "Notes");
printPropertyAttributes(property);
function printPropertyAttributes(property) {
console(
"Value: " + property.value.value +
"\nDisplayValue: " + property.value.displayValue +
"\nPropertyName: " + property.propertyName +
"\nDescriptor: " + property.descriptor +
"\nType: " + property.value.type +
"\nMin: " + property.min +
"\nMax: " + property.max +
"\nUnitDescriptor: " + property.unitDescriptor +
"\nResolution: " + property.resolution);
}
How to print any attributes for a property on which a callback is executed
subscribeValues("System1.ApplicationView:ApplicationView.Logics", "StatusPropagation.AggregatedSummaryStatus", function(object, values){
printPropertyAttributes(values["StatusPropagation.AggregatedSummaryStatus"]);
});
function printPropertyAttributes(property) {
console(
"Value: " + property.value.value +
"\nDisplayValue: " + property.value.displayValue +
"\nPropertyName: " + property.propertyName +
"\nDescriptor: " + property.descriptor +
"\nType: " + property.value.type +
"\nMin: " + property.min +
"\nMax: " + property.max +
"\nUnitDescriptor: " + property.unitDescriptor +
"\nResolution: " + property.resolution);
}
Note that values
is a dictionary
(key-values couples) that contains any system object properties that changed (keys) and their new value. Consequently, it is necessary to:
- Choose the in the dictionary using dot notation or bracket notation. For example:
values["StatusPropagation.AggregatedSummaryStatus"]
- Access the property attributes.
values["StatusPropagation.AggregatedSummaryStatus"].DisplayValue, values["StatusPropagation.AggregatedSummaryStatus"].Min
Anyway, it is also possible to access the value of the concerned property like in a standard callback. For example: values["StatusPropagation.AggregatedSummaryStatus"].Value