13:04, EEST
July 22, 2014
I am trying to use the client writeAttribute() function to write a value to my (Kepware) OPC UA server.
However, I am constantly getting the error:
com.prosysopc.ua.StatusException: Bad_TypeMismatch(0x80740000) “The value supplied for the attribute is not of the same type as the attribute’s value.”
StatusCode=Bad_TypeMismatch(0x80740000) “The value supplied for the attribute is not of the same type as the attribute’s value.”
From the erroor message, I am assuming that the problem is that the value I am trying to write does not match the server node’s attribute data type.
When the value of the attribute is read, it is a Variant. However, the writeAttribute() function seems to expect an Object.
The node attribute that I am trying to write to on the (Kepware) OPC UA server is listed, on the server, as “Word”. Reading the DatatType using the SDK yields “i=5”. I tried casting my new value to Long and int but neither case was successful (i.e. both cases yielded the above error).
What is the proper process for converting a value to the corresponding attribute data type so that it can be written to the node’s attribute?
16:24, EEST
July 22, 2014
I found the section in the SimpleConsoleClient. Thanks.
For anyone who was running into the same problem, here is the code:
UaDataType dataType = null;
UaVariable uaVar = (UaVaraiable) uaNode;
if(uaVar.getDataType()==null){uaVar.setDataType(client.getAddressSpace().getType(uaVar.getDataType()));}
dataType = (uaDataType) uaVar.getDataType();
Object convertedValue = dataType != null ? client.getAddressSpace().getDataTypeConverter().parseVariant(newValue,dataType) : newValue;
Most Users Ever Online: 1919
Currently Online:
22 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: 731
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1529
Posts: 6471
Newest Members:
inilarythikibia, rickykennion, PromotionToold, HypromeImpupe, toneylapham544, rondawolinski7, Marypof5711, roycedelargie91, kourtneyquisenbe, ellis87832073466Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1032, Jimmy Ni: 26, Matti Siponen: 349, Lusetti: 0
Administrators: admin: 1