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
Matching Data Types When Writing Node Attributes
July 24, 2014
13:04, EEST
Avatar
OndrejBlazek
Member
Members
Forum Posts: 19
Member Since:
July 22, 2014
sp_UserOfflineSmall Offline

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? Confused

July 24, 2014
16:24, EEST
Avatar
OndrejBlazek
Member
Members
Forum Posts: 19
Member Since:
July 22, 2014
sp_UserOfflineSmall Offline

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;

Laugh

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online: atdemir
20 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 77

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 680

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1467

Posts: 6259

Newest Members:

sagarchau, elviralangwell4, Donnavek, Eddiefauth, DonaldPooma, fidelduke938316, Jan-Pfizer, DavidROunc, fen.pang@woodside.com, aytule

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 983, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 321, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1