Topic RSS16:39, EET
September 11, 2024
OfflineHello,
I am reading AnalogItem nodes with EURange properties in my custom OPC UA Client that uses the Prosys OPC UA SDK for Java.
The Range objects from the server have null Low/High values, as shown in the Prosys Simulation Server browser:
https://i.snipboard.io/pASd0y.jpg
In my Java code, I read the Range like this:
In my Java code that looks like this:
“`
DataValue dataValue = client.readValue(nodeId);
Object value = dataValue.getValue().getValue();
if (value instanceof Range)
{
Range range = (Range) value;
Double low = range.getLow(); // Returns 0.0, expected null
Double high = range.getHigh(); // Returns 0.0, expected null
}
“`
The values being returned by the SDK’s Range.getLow() and Range.getHigh() methods are 0.0 instead of null. See debugger screenshot here:
https://i.snipboard.io/wTR8KE.jpg
Interestingly, range.toString() shows Range [Low=”0.0″, High=”0.0″] rather than Range [Low=”null”, High=”null”], confirming the SDK has already converted null to 0.0 during decoding.
My questions:
1. Is this the expected behavior when the server sends null Double values in a Structure?
2. What would be the right way to identify when the Range Low/High values are actually null vs. intentionally set to 0.0?
3. Is there a way to access the raw encoded data or status to detect null fields before the SDK converts them?
We need to distinguish between “no range specified” (null) and “range is 0 to 0” (valid) to properly configure alarm limits on our control points.
SDK Version: 5.4.0-201
Server: Prosys OPC UA Simulation Server
Thanks.
Mithun,
Tridium Inc.
Thanks.
9:42, EET
Moderators
February 11, 2020
OfflineHello,
When double values are encoded and decoded, it becomes impossible for Clients to distinguish between null and zero because both use the same encoded form. This also applies when they are used in Structure fields such as Low and High fields of Range. In fact, double is a non-nullable DataType in OPC UA and therefore it is technically not possible to set such values to null. The UI of Simulation Server is simply being misleading as it shows the value without any encoding and decoding and in “Java world” it is possible for the values of these fields to be null.
The OPC UA specification states the following for Range:
If a limit is not known a NaN shall be used. (https://reference.opcfoundatio…..docs/5.6.2)
I’ve verified that NaN can be used in Simulation Server as the value of the Low and High fields of Range. Thus, you should use that instead of null. Simply type NaN to the text field where you would enter Low and High values and it should be accepted and handled properly by the Server and the Client.
1 Guest(s)

Log In
Register