UTGARD how to write struct to opc item ?

85 views
Skip to first unread message

Aron Lau

unread,
Nov 4, 2015, 12:03:08 AM11/4/15
to openSCADA
Hi,
anyone know how to write struct to opc server using utgard?

i can red struct from opc server and get array of unsinedbyte and decode it as struct,
but i write struct as  item value is failed.

struct {
  UINT a;
  UINT b;
  UINT c;
  UINT d;
  UINT e;
}

UINT  : 2 byte  width 

total size of this struct is 10 bytes


code like this:
Byte[] bytes = new Byte[]{0x01,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
JIArray v = new JIArray(bytes,true);
value = new JIVariant(v);
int code = item.write(value);

return code = 2147352571   i checked, that means datatype not match.



Jens Reimann

unread,
Nov 4, 2015, 1:41:03 AM11/4/15
to openSCADA

A Byte is 8bit. So if you want two byte (16bit) the Short type would be the correct one. However I think that jinterop also has some JUnsignedShort type. But would have to look this up myself.

--
You received this message because you are subscribed to the Google Groups "openSCADA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openscada+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aron Lau

unread,
Nov 4, 2015, 8:54:08 AM11/4/15
to openSCADA
i have tried Short[] , failed code same as array of Byte. 

 i can read this struct, return Type is JIArray of JIUsignedByte, so  i try to send 10 bytes as struct.  but it not work.   

in jinterop UnsignedShort is not Public.


在 2015年11月4日星期三 UTC+8下午2:41:03,Jens Reimann写道:

Jens Reimann

unread,
Nov 4, 2015, 9:04:12 AM11/4/15
to openSCADA
I just checked:

JIUnsignedShort and JIUnsignedByte are both public classes. However they do have a non-public constructor.

However in the same package, beside the JIUnsigned* classes is the JIUnsignedFactory, which will create JIUnsigned instances for you.

Maybe this helps.

Jens

Aron Lau

unread,
Nov 4, 2015, 9:26:49 AM11/4/15
to openSCADA
thanks for you reply, it helps.
i will try it tomorrow.


在 2015年11月4日星期三 UTC+8下午10:04:12,Jens Reimann写道:
Reply all
Reply to author
Forward
0 new messages