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
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.

More
15 Feb 2021 08:22 #9447 by mozesa
Hello!

Thanks for the detailed answer.

I am asking b/c I would like to be aware of (any) drawbacks of using COM objects.

For instance there is an integration tool pythonnet , would it be "more beautiful" than COM objects accesses? There would be a reason for using pythonnet instead of pywin32?

The aim is to have a reliable OPC UA connection with as little overhead as possible - as the OPC UA communication would happen in a thread.
Basically we use OPC UA server as a gateway between the field and the higher controlling system PC.
The requested publishing interval would be some 100 milliseconds, currently we are testing 300 ms as our processes don't require higher refresh rate.

I don't know whether you have experience from customers using this kind of system (QuickOPC, Python, COM, publishing interval ~300 ms)?

Thanks for your help in advance.

Best Regards!

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

More
15 Feb 2021 07:43 #9446 by support
Hello.

pybind11 is a binding to C++. That would not be a good idea with QuickOPC. Most of QuickOPC is written in .NET (C#). There is a COM layer on top of that. That already is somewhat ugly, but makes it consumable from Python. Pybind11 will have to be used on top of that. So you will have QuiOPC.NET -> COM -> C++ -> pybind11 -> Python. Too much complexity and no gain.

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.102 seconds