Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Bad_NodeIdUnknown when readvalues
July 2, 2020
8:00, EEST
Avatar
sting2005
New Member
Members
Forum Posts: 1
Member Since:
July 2, 2020
sp_UserOfflineSmall Offline

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.Smile

July 2, 2020
11:43, EEST
Avatar
Matti Siponen
Moderator
Members

Moderators
Forum Posts: 33
Member Since:
February 11, 2020
sp_UserOnlineSmall Online

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()]

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 267

Currently Online: Matti Siponen
10 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 100

pramanj: 86

ibrahim: 70

kapsl: 57

gjevremovic: 49

TimK: 41

Fransua33: 39

fred: 38

Rainer Versteeg: 32

Thomas Reuther: 26

Member Stats:

Guest Posters: 0

Members: 1069

Moderators: 14

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 992

Posts: 4191

Newest Members:

carmellentz9, dreampangari, wdongjia, sheilalow452740, VivekRangi, mariannassaki, eugeniarobak, susannahmario, ahussnain, vla

Moderators: Jouni Aro: 846, Otso Palonen: 32, Tuomas Hiltunen: 5, janimakela: 0, Pyry: 1, Terho: 0, Petri: 0, Bjarne Boström: 540, Heikki Tahvanainen: 402, Jukka Asikainen: 1, Teppo Uimonen: 20, Markus Johansson: 18, Matti Siponen: 33, Lusetti: 0

Administrators: admin: 0