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.

Difference between WriteValue und WriteMultipleValues

More
14 Jun 2017 14:21 #5240 by support
I am not a Delphi expert, and it is basically up to you. You are not really writing an empty string - and you need to.

I noticed similar things with Delphi earlier. For example, when the string is not in a property variant, Delphi passes NULL instead of an empty string, so we had to change the COM interfaces to allow NULL in place of strings, etc. (all other OLE automation controllers pass in empty strings as non-null BSTR-s, which is how it should be).

I how this is achievable on your side, and I would be curious to know the solution.
If this turns out to be impossible (or too difficult), we would think of how to resolve it in the component. The problem is that doing so, if possible, would bring other risks.

Regards

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

More
14 Jun 2017 14:15 #5239 by RH
It seems to be VT_EMPTY although that's called different in Delphi. How can we prevent this behaviour? Maybe by explicit typecasts prior to value assignment?

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

More
14 Jun 2017 11:22 #5238 by support
Thanks a lot.

And, I am sorry, one more question: Can you verify in debugger that for empty strings, what ends up in lclWriteValueArgument.Value is actually a variant containing an empty VT_BSTR, and not an empty variant (VT_EMPTY) or something else?

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

More
14 Jun 2017 11:10 - 14 Jun 2017 11:12 #5237 by RH
WriteMultipleValues call:
lclArguments := VarArrayCreate([0, lclCurrentCount - 1], varVariant);
        for i := lclCurrentIndex to lclCurrentIndex + lclCurrentCount - 1 do
        begin
          lclIO := lclPendingWriteIOs[i];
 
          lclWriteValueArgument := CoUAWriteValueArguments.Create;
          lclWriteValueArgument.EndpointDescriptor.UrlString := FServerURL;
          lclWriteValueArgument.NodeDescriptor.NodeID.ExpandedText := tOPCUA_IO(lclIO).NodeID;
          lclWriteValueArgument.Value := tOPCUA_IO(lclIO).PendingWriteValue;
          lclArguments[i - lclCurrentIndex] := lclWriteValueArgument;
        end;
 
        // Modify values of nodes
        TVarData(lclResults).VType := varArray or varVariant;
        TVarData(lclResults).VArray := PVarArray
          (mOPCClient.WriteMultipleValues
            (PSafeArray(TVarData(lclArguments).VArray)));


WriteValue call:
tOPCUA_Device(self.FDevice).mOPCClient.WriteValue
                  (tOPCUA_Device(self.FDevice).FServerURL, FNodeID, PendingWriteValue);

PendingWriteValue is a variant variable.
Last edit: 14 Jun 2017 11:12 by RH.

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

More
14 Jun 2017 10:35 #5236 by support
Please post here the piece of code that puts together arguments for WriteMultipleValues and calls the method. The behavior depends on how the arguments are created and passed in. I will explain it all after I see the code.

Best regards

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

More
14 Jun 2017 09:26 #5235 by RH
Hello,

I discovered a critical difference in variant handling between WriteValue and WriteMultipleValues.
When I write an empty string to an OPC variable, it works using the WriteValue procedure. But when I do the same using WriteMultipleValues, I get an exception saying "BadTypeMismatch". For strings inequal empty string it works with both procedures.

Is there a workaround for us, when we want to stay with WriteMultipleValues? Or do you have to fix something in the library?

Regards

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

Moderators: support
Time to create page: 0.051 seconds