Professional OPC
Development Tools

logos

QuickOPC in Python

More
14 Sep 2018 15:01 #6648 by steve.korber
Replied by steve.korber on topic QuickOPC in Python
Hello,

I am trying to get the Python QuickOPC working. I changed the endoint on Read.Main.py but when I run the file it cannot find win32com.py.

Please point me to where this file is installed.

Thanks

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

More
19 Jun 2018 16:20 #6459 by support
Replied by support on topic QuickOPC in Python
Hello,

without further details I cannot tell what is the cause of "could not create certificate..." error, but at least one hint: Have you run your application (at least once) with elevated privileges? The first time the app is run, it generates and creates an application certificate, and that might require administrator rights.

Best regards

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

More
18 Jun 2018 15:42 #6456 by hkhodabandehlou
Replied by hkhodabandehlou on topic QuickOPC in Python
Hello,
I wrote that post and then found the source of the problem and fixed it, therefore i decided to remove the post but couldn't find delete post, thats why i edited the post.
For now i am facing the error "could not crate certificate..." which is for .Net version. If i fail to find the solution, i will get back to you.
Best Regards,
Hamid

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

More
18 Jun 2018 06:27 #6455 by support
Replied by support on topic QuickOPC in Python
Hello,
thank you.

I have received a forum notification with a text where you described "Could not create a certificate via a proxy" error, and also claimed that "Also there is a bug here, the QuickOPC Returns "Could not create a certificate via a proxy" but at the same time it returns "The operation completed successfully"".

I cannot locate this post now on the forum, so it looks like that you have edited it and removed the original text?

Anyway, it is not quite clear what you mean by saying that QuickOPC has returned *two* results at the same time. That's not physically possible. If, what you have meant, is the fact that e.g. WriteMultipleItemValues method itself has returned a success, while there are errors in the individual result objects, then that is perfectly correct and by design. QuickOPC methods that operate on multiple items never return an error themselves (except in case of invalid arguments). The actual operation-related errors are always in the result objects only. If you think about it, it must be that way, because an exception thrown by the method would mean that you won't be able to see the individual results at all - because there would be none returned.

This is described in the documentation: opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...iple-Element%20Operations.html .

Best regards

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

More
15 Jun 2018 21:53 - 15 Jun 2018 22:08 #6454 by hkhodabandehlou
Replied by hkhodabandehlou on topic QuickOPC in Python
Thank you for valuable help.
Best,
Hamid
Last edit: 15 Jun 2018 22:08 by hkhodabandehlou.

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

More
15 Jun 2018 06:58 #6451 by support
Replied by support on topic QuickOPC in Python
Hello,

I should say that we are absolutely Python beginners here. QuickOPC can be used from so many tools and languages that it is impossible to grasp that all.

However, with some hint from mail.python.org/pipermail/python-win32/2005-February/002923.html , I was able to extract the values by placing the following code below the bottom of your code:
Result1 = win32com.client.Dispatch(val[0][0])
Result2 = win32com.client.Dispatch(val[0][1])
Result3 = win32com.client.Dispatch(val[0][2])
Result4 = win32com.client.Dispatch(val[0][3])
 
Value1 = Result1.Value
Value2 = Result2.Value
Value3 = Result3.Value
Value4 = Result4.Value

It's unclear to me why a two-dimensional array is returned to Python - because what we return from our side is one-dimensional. Only the [0] row at the first dimension in Python seems to contain the actual data. This transformation is something that occurs inside win32com.client so we cannot influence it I think.

I hope this help
Best regards

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

More
14 Jun 2018 22:46 #6450 by hkhodabandehlou
Replied by hkhodabandehlou on topic QuickOPC in Python
Hello,
Thank you for your reply but still i am struggling with the package. looked at the examples and tried to read multiple items at once. It looks like that i am able to read the values but then can not extract the value of items. Please take a look at my code and help me on extracting the values of trags from variable "val".
Thank you,
HK
Attachments:

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

More
13 Jun 2018 10:23 #6440 by support
Replied by support on topic QuickOPC in Python
Hello.

Ad 1. We have methods like ReadMultipleItems, ReadMultipleItemValues, WriteMultipleItemValues, precisely for that purpose. And they should be used if you have more things to be read or written at the same time, instead of single-item operations in a loop. There are no example for Python with them, though; for start, look for examples in other languages.

These methods take an array of arguments as input, and return array of results as output. I also have a feeling that we had a problem passing the arrays to/from Python through COM, but I am not sure, If you run into problems with arrays, let me know and I will have another look.

Ad 2. This may be normal. In OPC the constant portion of the time for each operation may be quite high, but with relatively little dependence on number of items affected. So, it is quite possible that reading one item may take 0.1 seconds, and reading 10 items still 0.1 seconds. That is why it is highly advisable to read or write multiple items at once.

Another factor is connection time - QuickOPC establishes the connection automatically upon first request, and keeps it open for some time then - but not on subsequent requests if it is still open. So, the connection time is added to the first operation but not necessarily to the others.

Ad 3. Pass in the name of the computer as the first argument to the methods - that's where you have an empty string ('') now. Do not be surprised if you run into DCOM security/configuration headaches with remote access then - that's kind of normal :-(

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

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

More
12 Jun 2018 17:13 #6436 by hkhodabandehlou
Hello,
I am trying to write a client code in Python using QuickOPC and have few questions:
1)Is there any way to read and write groups instead of reading and writing item by item?
2)Right now I am reading and writing values to Matrikon OPC Simulation server. each read takes 0.1 seconds and it is the same for writing values, each write takes 0.1 seconds. Is this normal or i am doing something wrong?
3) How i can access a server on remote computer?
Attached is my simple code to read and write values from Matrikon Simulation server. I am using Python 3.6.5, 64-bit version on a pc with core i7 processor, 16GB Ram, and 64 bit Win 10 operating system
Thank you,
Hamid
Attachments:

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

Moderators: support
Time to create page: 0.209 seconds

      

 Recommend this on Google