Reputation: 430
I have built a Java Application to fetch data from OPC UA Server. I have used Eclipse Milo UA Client SDK to build the client. I am facing a problem in OpcUaClient.readValues method. I am passing a list of NodeId created from Tags defined and if I traverse the DataValue array returned by readValues method, I get follwing error for some of the elements
DataValue{value=Variant{value=null}, status=StatusCode{name=Bad_NodeIdUnknown, value=0x80340000, quality=bad},
Sudo code looks like
List<NodeId> nodeIds = new ArrayList<NodeId>();
List<Parameter> parameters = device.getParameters();
for (int i = 0; i < parameters.size(); i++) {
Parameter parameter = parameters.get(i);
nodeIds.add(new NodeId(device.getNsID(), parameter.getTagName()));
}
List<DataValue> values = client.readValues( 0.0, TimestampsToReturn.Both, nodeIds).get();
for (int i = 0; i < values .size(); i++) {
DataValue dvalue = values.get(i);
if( dvalue.getValue().getValue() != null) {
Integer intValue = (Integer) values.get(i).getValue().getValue();
logger.info("captured Value is {}", value);
}
else
{
logger.error("Error fetching value for {} , {}", parameter.getName(),dvalue.toString());
}
}
The error is flagged from else clause.
My application is running on a separate computer than the SCADA Server ( OPC UA). A peculiar behavior observed is , If I use ProSys Client to check value of failing tag, and if I re-run my application, data is fetched correctly. I am completely clueless about how ProSys client and my application is related. Is prosys client triggering something on the server side to load the tags in some cache... Any clues/pointers will help. Thanks in advance.
Upvotes: 0
Views: 318
Reputation: 7005
It sure sounds like the Rockwell server doesn't actually "build" the Node instances until you've browsed it first.
You aren't doing anything wrong in the client; this is stupid behavior on the server's part. You may have to program your client to recursively browse the hierarchy you're interested in before reading or creating monitored items.
Upvotes: 0