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.
Setting DataSource when reading values through Python
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
In your case, ReadItemValue is the "simple" method, and there is no way to pass it the DAReadParameters in our COM API. But you can switch to the ReadMultipleItemValues method, and that one should allow you to achieve what you want. I do not have an example ready for you, but in essence, you should do the following:
1. Create an instance of DAReadItemArguments object.
2. Set its properties: It has ServerDescriptor and ItemDescriptor properties under which you set what you want to read (in your example, .ServerDescriptor.ServerClass and .ItemDescriptor.ItemId would suffice). And, it has .ReadParameters property as well: There you can set e.g. .ReadParameters.DataSource, .ReadParameters.ValueAge.
3. Create an array with items to read: In this case, an array with one element - and set that element to your DAReadItemArguments object. I am not sure whether you will be able to use some standard Python array, or whether you need to somehow instantiate COM SafeArray-s: that's a Python<->COM binding thing and we are not experts in it here. Hopefulyl it will be possible to pass in the array somehow.
4. Call ReadMultipleItemValue on the EasyDAClient object, passing it the array you created above.
5. You will receive back an array with one element, of type _ValueResult. Test .Exception of that element for null-ness to see if there was an error; if not, the actual value read is in the .Value.
Best regards
ZZ
Note: Values for .DataSource are an enumeration, but some languages (Python?) will need to use an integer. Here is the encoding:
Please Log in or Create an account to join the conversation.
I was looking for a way to set the datasource to 'device' using a Python implementation of QuickOPC, but I could not find a good way of getting this to work even after searching through the documentation. I see that there is a DAReadParameters class, but I was unable to figure out how to use the class through the Python COM implementation.
Below is a quick excerpt of the code that I have:
I was hoping to either add arguments to the dispatched client, or to the ReadItemValue function to achieve this. Is this something that can be done?
Thanks,
John
Please Log in or Create an account to join the conversation.
I was looking for a way to set the datasource to 'device' using a Python implementation of QuickOPC, but I could not find a good way of getting this to work even after searching through the documentation. I see that there is a DAReadParameters class, but I was unable to figure out how to use the class through the Python COM implementation.
Below is a quick excerpt of the code that I have:
I was hoping to either add arguments to the dispatched client, or to the ReadItemValue function to achieve this. Is this something that can be done?
Thanks,
John
Please Log in or Create an account to join the conversation.