19:17, EEST
July 8, 2019
Hello,
New to the SDK I’m trying to update a group of opc tags using the writeValues() method. I’m receiving the mismatch error status code when I do the write:
Bad_TypeMismatch (0x80740000) “The value supplied for the attribute is not of the same type as the attribute’s value.”
Here is the method I’m using to the write;
private void writeValues(Map opcMap) {
try {
int i = 0;
NodeId[] arrNodes = new NodeId[opcMap.keySet().size()];
Variant[] values = new Variant[opcMap.values().size()];
for (Map.Entry entry : opcMap.entrySet()) {
arrNodes[i] = entry.getKey();
values[i] = entry.getValue().getTagValue().getValue();
i++;
}
StatusCode[] ret = client.writeValues(arrNodes, values);
for (StatusCode code : ret) {
log(“StatusCode = ” + code);
}
} catch (ServiceException e) {
printException(e);
} catch (StatusException e) {
printException(e);
}
}
OpcTag is a simple wrapper class that holds some information along with the DataValue object for the nodeId that I scrap when I first start the application.
When I update the value of the OpcTag.DataValue in my application I just create a Variant and pass a String into the object (i.e. object name is VarString). I then use the OpcTag.DataValue.setValue(VarString) to actually update the value in the map.
10:12, EEST
April 3, 2012
17:27, EEST
April 3, 2012
No. Generally the DataType (at least should be) stored and used as the NodeId which is the value of the DataType Attribute of the node (and when storing NodeIds it would be a good idea to store the namespace as uri and not the index).
Due to changes in 4.0.2 (https://downloads.prosysopc.com/opcua/Prosys_OPC_UA_SDK_for_Java_4_Release_Notes.html#version-4-0-2) the DataType NodeIds for the standard model can be found in DataTypeIdentifiers constants (previously they were just in the Identifiers which contains all well known NodeIds for the standard model), however note that these are only for the standard model. Other models define additional types and server can just have their full custom types. Note however that usually they are just custom Structure types i.e. combinations of other types.
However for simple cases you could just use the Java Class objects instead for type mapping. Depending on your application it might be just enough to Read the nodes once when your application starts and then just make sure to Write objects of the same Java class that you read.
Most Users Ever Online: 1919
Currently Online:
12 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: 736
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1524
Posts: 6450
Newest Members:
kristiewinkle8, rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, ThomassnismModerators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1