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.

WriteValue with Delphi

More
07 Feb 2018 12:14 #5973 by support
Replied by support on topic WriteValue with Delphi
Thank you. This is very helpful. It means that the original hypothesis (with type library mismatch) was incorrect.

Can you please obtain and tell me the values of DataType and ValueRank attributes of the node you are trying to write to? Either by writing a program for that, or simply by looking at the node with UaExpert. (in that case, please send a whole screenshot of UaExpert with that node, it may give me even more useful info).

Best regards

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

More
07 Feb 2018 09:59 #5969 by alex2027
Replied by alex2027 on topic WriteValue with Delphi
I have done some further tests and I can write fine with my program and the UADocExamples to your test server.

The problem occurs when I try to write to my server (A Siemens PLC).

The only difference is that to connect to my server I need the lines:

OPCClientConfig := TEasyUAClientConfiguration.Create(nil);
OPCClientConfig.AdaptableParameters.SessionParameters.EndpointSelectionPolicy.AllowedMessageSecurityModes := UAMessageSecurityModes_SecurityNone;
OPCClientConfig.AdaptableParameters.SessionParameters.UserIdentity.UserNameTokenInfo.UserName := '******';
OPCClientConfig.AdaptableParameters.SessionParameters.UserIdentity.UserNameTokenInfo.Password := '******'; 

Then I can connect and read values fine but get this error on writing.

If I use the same settings in UaExpert to connect to the PLC I can write fine.

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

More
06 Feb 2018 18:48 #5968 by support
Replied by support on topic WriteValue with Delphi
Unfortunately I cannot reproduce it here.

I installed the current QuickOPC version (2017.2) on a new, otherwise empty computer with Delphi. There is a project with Delphi examples, and it contains the Write examples that are equivalent to your - and it ran well out of the box (it is in the UADocExamples part).

So at this moment I do not know how to help you further.

Can you try the examples that we deliver with QuickOPC, to see whether they work or not?

Regards

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

More
06 Feb 2018 09:50 - 06 Feb 2018 11:10 #5966 by alex2027
Replied by alex2027 on topic WriteValue with Delphi
This was the way I installed it the first time but to be sure I removed the previous package from Delphi and deleted it then created and installed the new one and still get the same error.

Also just tested and I get the same error using Write and WriteMultipleValues.
Last edit: 06 Feb 2018 11:10 by alex2027.

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

More
05 Feb 2018 17:54 #5955 by support
Replied by support on topic WriteValue with Delphi
This almost looks like that another method is actually being called, because a cast to Object[] is attempted, but WriteValue does not expect arrays as input arguments. It could be caused by the Delphi units being out of sync with the actual COM objects.

Have you done the import of type libraries as described here: opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...20Libraries%20to%20Delphi.html , with the actual version you are using? If not, please do so, rebuild your project, and retest.

Best regards

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

More
05 Feb 2018 16:41 #5952 by alex2027
I'm trying to write a string value with WriteValue in delphi, I have tried:

OPCClient := TEasyUAClient.Create(nil);
OPCClient.WriteValue('opc.tcp://127.0.0.1:4840', 'ns=2;s=/NC/_N_NC_GD1_ACX/_TEST', '12345');

But I get the message "Invalid cast from 'System.String' to 'System.Object[]'"

I have also tried the same to a Decimal value and get an Invalid cast from System.Decimal to
System.Object when trying this.

ReadValue works ok in this way but the WriteValue isn't.

Alex.

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

Moderators: support
Time to create page: 0.064 seconds