8:00, EEST
July 2, 2020
Hi all, I just execute the sampleclient to read some values. The method readValue can retrieve correct value from simulator,but when I change it to readValues it seems doesn’t work. I got status_code “Bad_NodeIdUnknown” in response.
I wonde Is there a known issue or something wrong with my code ? Thanks in advance.
sdk version : Prosys OPC UA SDK for Java v4.3.0-1075
code :
public static void main(String[] args) throws Exception {
UaClient client = new UaClient(“opc.tcp://192.168.0.109:53530/OPCUA/SimulationServer”);
client.setSecurityMode(SecurityMode.NONE);
initialize(client);
client.connect();
DataValue value = client.readValue(Identifiers.Server_ServerStatus_State);
setVarsNode(client);
System.out.println(metrics.size());
DataValue v2 = client.readValue(metrics.get(0));
// v2 returned correct value. DataValue(value=1.0453014, statusCode=GOOD (0x00000000) “”, sourceTimestamp=07/02/20 04:09:01.0000000 GMT, sourcePicoseconds=0, serverTimestamp=07/02/20 04:09:01.9120000 GMT, serverPicoseconds=0)
System.out.println(v2);
// values and values2 both return “Bad_NodeIdUnknown”
DataValue[] values = client.readValues(new ExpandedNodeId[metrics.size()], null, TimestampsToReturn.Both, 0d);
for (DataValue data : values) {
System.out.println(data.getValue());
}
DataValue[] values2 = client.readValues(new NodeId[metrics2.size()], null, TimestampsToReturn.Both, 0d);
for (DataValue data : values2) {
System.out.println(data.getValue());
}
client.disconnect();
}
// metrics structure
public static List metrics = new ArrayList();
public static List metrics2 = new ArrayList();
//—————-
I found the problem, nothing to do with sdk. It’s a code issue.
11:43, EEST
Moderators
February 11, 2020
Hello,
Based on this code, it seems that you’re using empty arrays of ExpandedNodeId and NodeId in client.readValues calls for values and values2. After creating an array you must add entries to it with metrics.toArray(metricsArray), where metricsArray is
ExapndedNodeId[] metricsArray = new ExpandedNodeId[(metrics.size()]
Most Users Ever Online: 1919
Currently Online:
70 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 739
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6453
Newest Members:
shaylamaggard4, rickyjuarez140, jonathonmcintyre, fannielima, kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmonsModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1027, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1