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.

Read ad Write multiple values

More
20 Feb 2024 17:41 #12566 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:35 #12397 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
20 Aug 2019 06:11 #7634 by support
Hello.

It looks like that we have worked on similar issue in Python before. The results array is weird - but it still can be processed. Please see www.opclabs.com/forum/general-issues-building/2466-quickopc-in-python#6436 , and attempt to extract the results (roughly) like this:

Result1 = win32com.client.Dispatch(val[0][0])
Result2 = win32com.client.Dispatch(val[0][1])
Result3 = win32com.client.Dispatch(val[0][2])
 
Vtq1 = Result1.Vtq
Vtq2 = Result2.Vtq
Vtq3 = Result3.Vtq
Best regards

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

More
17 Aug 2019 20:03 #7632 by Jesus Rodriguez
Hi, thanks for your reply, I just tried to run it in python. This is what I got:


import win32com.client

ReadItemArguments1 = win32com.client.Dispatch("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments1.ItemDescriptor.ItemID = "Demo.Single"

ReadItemArguments2 = win32com.client.Dispatch("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments2.ItemDescriptor.ItemID = "Demo.Single"

arguments = [ReadItemArguments1, ReadItemArguments2]

client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient')

results = client.ReadMultipleItemValues(arguments)


There is no error at this point but still I think is not correct since I cannot get the values.

Thank you for your help

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

More
14 Aug 2019 07:51 #7621 by support
There are ReadMultipleItems and ReadMultipleItemValues methods for this purpose. See e.g. opclabs.doc-that.com/files/onlinedocs/QuickOpc/Latest/User%2...ding%20just%20the%20value.html .

I do not have Python example at hand. hopefully you can derive it from code given in other languages. If you run into an issue, let me know here. Here is a VBScript example for ReadMultipleItemValues:
Rem This example shows how to read values of 4 items at once, and display them.
 
Option Explicit
 
Dim ReadItemArguments1: Set ReadItemArguments1 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments1.ItemDescriptor.ItemID = "Simulation.Random"
 
Dim ReadItemArguments2: Set ReadItemArguments2 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)"
 
Dim ReadItemArguments3: Set ReadItemArguments3 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)"
 
Dim ReadItemArguments4: Set ReadItemArguments4 = CreateObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
ReadItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
ReadItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4"
 
Dim arguments(3)
Set arguments(0) = ReadItemArguments1
Set arguments(1) = ReadItemArguments2
Set arguments(2) = ReadItemArguments3
Set arguments(3) = ReadItemArguments4
 
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
Dim results: results = Client.ReadMultipleItemValues(arguments)
 
Dim i: For i = LBound(results) To UBound(results)
    WScript.Echo "results(" & i & ").Value: " & results(i).Value
Next

Best regards

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

More
13 Aug 2019 05:36 #7620 by admin
Replied by admin on topic Read ad Write multiple values
Please be [patient. Will reply later this week, as soon as possible. We have a vacation period.

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

More
12 Aug 2019 18:26 #7619 by Jesus Rodriguez
Hi

I have the following code to read and write:

import win32com.client
client = win32com.client.Dispatch('OpcLabs.EasyOpc.DataAccess.EasyDAClient')

value = client.ReadItemValue('', 'CoDeSys.OPC.02', '.Inputs[9]')
client.WriteItemValue('', 'CoDeSys.OPC.02', '.Inputs[9]', 7)

They work well but I would like to know how to read and write multiple values in just one function. Is there any function already doing this?

Thank you.

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

Moderators: support
Time to create page: 0.056 seconds