Required data type conversion handling in UA server|OPC UA Standard|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Required data type conversion handling in UA server
Avatar
Toshihisa Fujii
Member
Members
Forum Posts: 6
Member Since:
02/24/2014
sp_UserOfflineSmall Offline
1
09/01/2016 - 22:14
sp_Permalink sp_Print

Hello.

As a conformance point of view, is it acceptable that UA server processes data type conversion from write data type to source data type when they are not equal? Or should the UA server return BadTypeMismatch unless they are equal?

Avatar
Guest
Guests
2
09/02/2016 - 06:34
sp_Permalink sp_Print

OPC UA is strongly typed. Generally speaking, you shouldn't be type-casting automatically. The UA specification does state that automatic conversion between Byte[] and Bytestring is required behavior, and conversions between supertype/subtype types.

Avatar
Guest
Guests
3
09/04/2016 - 21:58
sp_Permalink sp_Print

Here is the text in UA Part 4 (Write Service):

A Server shall return a Bad_TypeMismatch error if the data type of the written value is not the same type or subtype of the Attribute’s DataType. Based on the DataType hierarchy, subtypes of the Attribute DataType shall be accepted by the Server. For the Value Attribute the DataType is defined through the DataType Attribute. A ByteString is structurally the same as a one dimensional array of Byte. A Server shall accept a ByteString if an array of Byte is expected.

 

So, for example, if you have a Variable with DataType UInteger the Client is allowed to write any size of UInteger. But the Server shall not allow an Integer or Boolean.

Avatar
jopi
New Member
Members
Forum Posts: 2
Member Since:
05/06/2014
sp_UserOfflineSmall Offline
4
09/19/2016 - 06:29
sp_Permalink sp_Print

Hi,

I've been following your conversation.

So in which cases should a server return Bad_TypeMismatch?

- a client tries to write the value 100000 to a variable of type Int16 (-32768 to +32767)

- a client tries to write "hello" to a variable of type Integer

- a client tries to write the value 12 of type Int16 to a variable of type Int32

- a client tries to write a boolean value to a variable of type Int16

- a client tries to write an UInt16 value to a variable of type Int16

What value should have the returned value itself for each case? 0?

 

Thanks

jopi

Avatar
Guest
Guests
5
09/19/2016 - 06:48
sp_Permalink sp_Print

Hello,

When writing a value you do inherently specify the data-type. Therefore, if there data-type does not match (exceptions apply, see prior comments) then a BadTypeMismatch should be returned.

Now, it doesn't matter if the value exceeds the range of the data-type because we would expect the server to "handle it"; whether that means to simply go into negative values (overflow) or reset at zero, or perhaps error out with a range-related error.

Avatar
Paul Hunkar
Cleveland, Ohio, USA
Moderator
Members

Moderators-Specifications

Moderators-Companion

Moderators-Implementation

Moderators-Certification

Moderators-COM
Forum Posts: 109
Member Since:
02/24/2014
sp_UserOfflineSmall Offline
6
09/19/2016 - 20:43
sp_Permalink sp_Print

jopi,

First are you using XML or a binary encoding for the message transport? I'm assumming the defined data type is what you are listing.

– a client tries to write the value 100000 to a variable of type Int16 (-32768 to +32767)

In binary this would have to be something larger then Int16 - since a client can't send 100,000 unless it is an Int32 - Bad_TypeMismatch

– a client tries to write “hello” to a variable of type Integer

In binary, must be a string type on the wire - type  Bad_TypeMismatch

– a client tries to write the value 12 of type Int16 to a variable of type Int32

In binary, must be int32 type on the wire (not an Int16) - type  Bad_TypeMismatch

– a client tries to write a boolean value to a variable of type Int16

In binary, boolean is not Int16 - type  Bad_TypeMismatch

– a client tries to write an UInt16 value to a variable of type Int16

In binary, must be a int16, uint16 is not a match - type  Bad_TypeMismatch

 

What value should have the returned value itself for each case? 0?

There is no returned value , since nothing was written, just a status Bad_TypeMismatch

If the Data assigned to the variable was Int or Numeric type then the variable can have a current value that is an int16 and you can write and Int32 to it which would just change the datatype of the current value to Int32 (since both are subtype of int or numeric).  o if you want the server to be able to accept more data types the define the datatype of the variable to be an abstract data type - then it can be modified at run time.  Note: this can give some clients a headache that want to map the variable to some internal construct like a PLC datatype, so you need to know the use cases you are looking at before defining an variable with an abstract data type.

Paul Hunkar - DSInteroperability

Avatar
jopi
New Member
Members
Forum Posts: 2
Member Since:
05/06/2014
sp_UserOfflineSmall Offline
7
09/24/2016 - 03:16
sp_Permalink sp_Print

Hi,

thanks for your posts.

They definitively helped to make this issue clearer for me.

Greetings

jopi

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 17
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1351
Posts: 4579