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.
05/06/2014
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
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.
Moderators-Specifications
Moderators-Companion
Moderators-Implementation
Moderators-Certification
Moderators-COM
02/24/2014
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
1 Guest(s)