Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Bytestring parameter EasyOPC

More
13 May 2015 19:44 #3138 by support
There are several in play together which prevent the OPC UA byte array from working in QuickOPC-UA for method calls.

The first thing is, that it is not really possible to have a TypeCode for a ByteArray. TypeCode-s are very limited. Our software is actually written in .NET, and there we have much wider choice (the Type type) that can cover different cases. But when projecting the .NET API to COM, we had to make some limitations, and the use of TypeCode-s is one of them.

The second thing is, even with .NET Type-s, OPC UA byte arrays are a bit problematic, because there is no direct .NET representation for them. The closest is a simple array of Byte,; the problem with it is that OPC UA can *also* work with an array of Byte, thus the two would become indistinguishable in .NET, unless we chose a special representation "of our own making" just for byte arrays.

The third issue is that OPC UA requires the argument be passed precisely in the type it has. The UA server is not required to convert any "similar" types. Therefore the code you write must somehow be able to precise instruct which type to use - that's why we have these TypeCode-s as an input argument in the first place.

And the fourth issue: Similar problem happens with OPC UA Write-s. For writing, the caller needs to specify the input arguments, similar to the OPC UA (method) Call. We allow omitting the type code for Write. If that happens, we first interrogate the server for the value type, and then convert the value as necessary. This is less efficient, but much more convenient for the user. The similar "workaround" would probably be possible with OPC UA methods Call-s, but it is not implemented yet.

The bottom line, and an answer to your question is: With the current QuickOPC, you cannot pass the byte arrays as inputs to OPC UA method calls. We can, however, have a look at implementing the necessary extra code for auto-determining the type from the server. When this is implemented, you would: 1) pass a COM safe array of bytes in place of UA byte string, and 2) specify the corresponding type code as Empty (0).

We have some other things planned, therefore expected delivery of such change would be somewhere in 2-3 weeks from now. Would that work for you?

Best regards

Please Log in or Create an account to join the conversation.

More
13 May 2015 19:31 #3137 by support
From: OPC Labs Contact Form - A.
Sent: Wednesday, May 13, 2015 4:32 PM
To: Zbynek Zahradnik
Subject: OPC Labs Contact Form - Bytestring parameter EasyOPC

[...]
Hi,

i'm testing your product for my customer and i was finalizing the project but im not able to pass to a method a bytestring value.

This is the code
var
  I: Cardinal;
  Inputs: OleVariant;
  Outputs: OleVariant;
  TypeCodes: OleVariant;
begin
  Inputs := VarArrayCreate([0, 4], varVariant);       //10
  Inputs[0] := 1;    //preparation=1   run=0
  Inputs[1] := 1;
  Inputs[2] := 1;
  Inputs[3] := 1;
 
 
  Inputs[4] := mach_bytestring; **** SEE HERE ****
 
 
 
 
  TypeCodes := VarArrayCreate([0, 4], varVariant);       //10
  TypeCodes[0] := TypeCode_Int16;
  TypeCodes[1] := TypeCode_Int16;
  TypeCodes[2] := TypeCode_Int16;
  TypeCodes[3] := TypeCode_Int16;
 
  TypeCodes[4] := TypeCode_Object  **** SEE HERE ****;
 
 
 
 
  // Perform the operation
  TVarData(Outputs).VType := varArray or varVariant;
  TVarData(Outputs).VArray := PVarArray(DMOPC_UA.Client[pressa].CallMethod(
 
 
 
    DMOPC_UA.presse[pressa].indirizzoip,
    c_basensu+c_objidprogrammi,
    c_basensu+c_nodeid_programwrite,
 
    PSafeArray(TVarData(Inputs).VArray),
    PSafeArray(TVarData(TypeCodes).VArray)));
end;
you can see in the *** SEE HERE *** locations.

What combinations of values i've to write to pass a bytestring in parameter [4].... wath about the declaration of mach_bytestring type?... a string is not valid... the OPC return BAdInvalidArgument ..

Regards

A

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.049 seconds