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.

Instantiate the client objects multiple times

More
20 Feb 2024 17:48 #12577 by support
Examples for OPC client and subscriber development in Python are now on GitHub: github.com/OPCLabs/Examples-QuickOPC-Python .

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

More
21 Nov 2023 13:30 #12392 by support
Note: QuickOPC now supports Python in much better way, cleaner syntax, and public packages (pypi.org/project/opclabs-quickopc/) on Python Package Index . See What's new in QuickOPC 2023.2 for more information. And, over 270 examples are available in the User's Guide!

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

More
23 Mar 2021 06:48 #9538 by support
Great, thanks for letting me know.

Yes, definitely. Unless there are some "hidden" problems that we do not know about yet, with pythonnet you get at least three advantages:

1) Cleaner architecture (and a chance for better performance) - the unnecessary COM layer in between QuickOPC and Python goes away.
2) Cleaner and shorter syntax.
3) Ability to use more features of QuickOPC (not everything is directly exposed in COM - but everything in available in .NET).

Best regards
The following user(s) said Thank You: mozesa

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

More
22 Mar 2021 19:27 #9535 by mozesa
Hello!

I actually forgot to mention that I successfully used 'extension' methods with 'pythonnet'.

Here is the implementation of 'WriteValue'.


Part of the message is hidden for the guests. Please log in or register to see it.


So you mean that using clr directly is much better than COM objects could be?

Thanks in advance.

Best Regrads!
The following user(s) said Thank You: support

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

More
22 Mar 2021 11:53 #9527 by mozesa
Hello!

Never mind, I could refine the code.

I have to test it further but I think it's already worth to show it (pythonnet.github.io) as an alternative way besides win32com.client.

Thanks for your cooperation.

Best Regards.



Part of the message is hidden for the guests. Please log in or register to see it.

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

More
22 Mar 2021 05:54 #9525 by support
Hello.
So, in the example you posted, you are actually not using the extension methods approach, you are using the "core" ReadMultiple methods. That is fine too, of course.

I do not quite understand your question. What do you mean by that you "have to" do it this way? Have you tried the shorter syntax (and if so, what was the code and what was the problem), or do you know the shorter syntax at all?

Best regards

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

More
21 Mar 2021 14:05 #9523 by mozesa
Hello!

I really appreciate your help. It works! :)


Warning: Spoiler!



I noticed some things.
In the example , ReadMultiple's method constructor is given an array of UAReadArguments, which can be instantiated with the necessary parameters. In contrast to Python, where as you can see, I first (have to) create the array, then assign a new empty UAReadArguments object to each index, then I have to provide the right EndpointDescriptor, and NodeDescriptor. Could you shed some light on this "behavior"?
// Obtain attribute data. By default, the Value attributes of the nodes will be read.
UAAttributeDataResult[] attributeDataResultArray = client.ReadMultiple(new[]
    {
        new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/;i=10845"),
        new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/;i=10853"),
        new UAReadArguments(endpointDescriptor, "nsu=http://test.org/UA/Data/;i=10855")
    });

Thanks for your cooperation in advance.

Best Regards!

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

More
21 Mar 2021 10:11 #9522 by support
Thank you - I think you are making progress!
And, most likely I know what is causing your problem.

The EasyUAClient object actually only has a handful methods on it - those that do the "core" work. The remaining methods are implement as so-called extension methods over the IEasyUAClient interface that EasyUAClient implements. The extension methods are not methods on EasyUAClient or IEasyUAClient. They are actually static methods on an "unrelated" class, and the IEasyUAClient interface needs to be passed to them as an addition first argument. C# and VB.NET can make the extension methods "appear" as if they were true methods on the object or interface, but most likely pythonnet cannot do that.

Look here: opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...c.UA.EasyUAClient_members.html

You will find that for reading, there is only the ReadMultiple method listed under "Public Methods". The ReadValue method you are trying to use, and many other ReadXXXX methods, are listed under "Extension Methods". All these other methods simply transform the inputs and outputs of the ReadMultiple method, but otherwise they do the same thing (reading), so there is no reason for them to exist on the IEasyUAClient interface. And, if you click on the ReadValue method link, it will lead you here:

opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...ClientExtension~ReadValue.html

From there, you can see how you will need to call the ReadValue method in pythonnet: You need to figure out how to call static methods on IEasyUAClientExtension class. I can see something about it, with an example, right here: pythonnet.github.io/ .

You will then then pass in your "client" variable as an additional first argument.

Note: I could not read what is in the image you have attached, it is blurred, but it probably is not needed at this moment..

Best regards
The following user(s) said Thank You: mozesa

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

More
20 Mar 2021 19:51 #9521 by mozesa
Dear OPC Labs,

I would like to use pythonnet, and access directly to .NET types.


Part of the message is hidden for the guests. Please log in or register to see it.



I could achieve some results, for instance I could import the EasyUAClient but it throws the below error.


Part of the message is hidden for the guests. Please log in or register to see it.


I enclosed the client object how I can see in PyCharm.

Could you help me figuring out why I cannot access ReadValue.
I tried the C# example as well with no luck.


Part of the message is hidden for the guests. Please log in or register to see it.


Thanks for your help in advance.

Best Regards!
Attachments:

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

More
15 Feb 2021 15:48 #9449 by support
Hello.

Thank you for pointing the attention to pythonnet. I was not aware of this tool. From my point of view, in principle that should be definitely much better approach, even better than going through COM (pywin32). But, as opposed to pywin32, we have not tried or tested with pythonnet at all yet. So I cannot guarantee whether it will work or well.

Since this looks like a nice tool, at some we will look at it and if it works, even provide some guidance and example. But cannot do that right now - there is other development work ongoing. If you want to try it out, you will be more than welcome!

Regarding your other question which seems to be involved with the performance: Getting value at rates like 100 milliseconds is definitely achievable - but you also need to tell how many such items you will monitor, because the more items the more bandwidth & other resources are needed.

You can use the trial version to test out everything upfront.

Best regards
The following user(s) said Thank You: mozesa

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

Moderators: support
Time to create page: 0.086 seconds