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.

OPC DA item with an access path

More
22 Aug 2025 17:12 #14355 by mcerqueira
Just found your answer ate the url  OPC Labs - Can´t import modules - OPC Labs Online Forums  and it worked!!!

Thanks a lot!

Please, add this "ignore red squiggles" at the home python examples page. It can help more users with the same issue. I spent one whole day trying to solve it.

Best regards!

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

More
22 Aug 2025 16:58 #14354 by mcerqueira
Hello!
I have an issue during the import of the .NET namespaces:from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *I followed all the instructions:
1) Installed the application;
2) Installed python 3.11;
3) Installed .NET 9.0;
4) Imported the opclabs_quickopc;
5) Pythonnet is also installed.

But when I try to run the very fiisrt code example:import opclabs_quickopc
# Import .NET namespaces.
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *

def main():
print("Hello Pycharm")
client = EasyDAClient()
value = IEasyDAClientExtension.ReadItemValue(client, '', 'OPCLabs.KitServer.2', 'Demo.Single')
print(value)

if __name__ == "__main__":
main()
I have the "Unresolved reference error" on the "OpcLabs" from argument. I searched to see if this is an error related with DLLs, but I could not describe the main reason.

Could you help me on this matter? Thanks!

 

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

More
04 Apr 2025 06:26 #13538 by support
(please create a new forum thread when opening a new issue; you can always hyperlink if there is some relation to other posts)

In your case, you will simply do a "read" on the variable you need. This will be one of the methods like ReadMultipleItems, ReadMultipleItemValues, ReadItem, ReadItemValue.
There are examples for it in the documentation.

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

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

More
03 Apr 2025 16:24 #13536 by wvklemov
I am subscribing to several items and would like to occasionally ask for and get the current data from those items.  How would I go about doing that?

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

More
18 Mar 2025 17:26 #13483 by support
Hello.

Sorry, that's because I could not test it right now. Use this instead:

Code:
IEasyDAClientExtension.SubscribeItem(client, ServerDescriptor('', server_name), item_descriptor, DAGroupParameters(200), None)


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

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

More
18 Mar 2025 16:49 #13482 by wvklemov
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc
import time

# Import .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *

# Item changed event handler.
def itemChanged(sender, e):
    if e.Succeeded:
        print(e.Vtq)
    else:
        print('*** Failure: ', e.ErrorMessageBrief, sep='')


# Instantiate the client object.
client = EasyDAClient()

client.ItemChanged += itemChanged

print('Subscribing item changes...')
# IEasyDAClientExtension.SubscribeItem(client, '', 'OPCLabs.KitServer.2', 'Demo.Ramp', 200)
# Define server, ItemID, and access path
server_name = "MyServer.OPC.1" # Replace with your server's ProgID
item_id = "Time2" # Example ItemID (server-specific)
access_path = "Botch" # Example access path (server-specific)

# Create a DAItemDescriptor with ItemID and access path
item_descriptor = DAItemDescriptor(item_id)
item_descriptor.AccessPath = access_path

client.SubscribeItem(ServerDescriptor('', server_name), item_descriptor, DAGroupParameters(200), None)

print('Processing item change notifications for 30 seconds...')
time.sleep(30)

print('Unsubscribing all items...')
client.UnsubscribeAllItems()

client.ItemChanged -= itemChanged

print('Finished.')

Error being returned is:
    client.SubscribeItem(ServerDescriptor('', server_name), item_descriptor, DAGroupParameters(200), None)
AttributeError: 'EasyDAClient' object has no attribute 'SubscribeItem'
 

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

More
18 Mar 2025 16:11 - 18 Mar 2025 16:12 #13481 by support
The basic example for a subscription is here  opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Late...%20to%20a%20single%20item.html and it looks like this (sorry I could not test it at the moment but hopefully it is the right thing):

Code:
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc import time # Import .NET namespaces. from OpcLabs.EasyOpc import * from OpcLabs.EasyOpc.DataAccess import * # Item changed event handler. def itemChanged(sender, e): if e.Succeeded: print(e.Vtq) else: print('*** Failure: ', e.ErrorMessageBrief, sep='') # Instantiate the client object. client = EasyDAClient() client.ItemChanged += itemChanged print('Subscribing item changes...') IEasyDAClientExtension.SubscribeItem(client, '', 'OPCLabs.KitServer.2', 'Demo.Ramp', 200) print('Processing item change notifications for 30 seconds...') time.sleep(30) print('Unsubscribing all items...') client.UnsubscribeAllItems() client.ItemChanged -= itemChanged print('Finished.')


In this example, replace the line with 
Code:
IEasyDAClientExtension.SubscribeItem(client, '', 'OPCLabs.KitServer.2', 'Demo.Ramp', 200)
by something like the following:

Code:
# Define server, ItemID, and access path server_name = "Matrikon.OPC.Simulation" # Replace with your server's ProgID item_id = "Random.Int4" # Example ItemID (server-specific) access_path = "SimulatedData" # Example access path (server-specific) # Create a DAItemDescriptor with ItemID and access path item_descriptor = DAItemDescriptor(item_id) item_descriptor.AccessPath = access_path client.SubscribeItem(ServerDescriptor('', 'OPCLabs.KitServer.2'), item_descriptor, DAGroupParameters(200), None)


Best regards
Last edit: 18 Mar 2025 16:12 by support.

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

More
18 Mar 2025 15:51 #13480 by wvklemov
I made the changes that you suggested and I'm not sure what's next.  I looked thru the examples and I'm not sure how to subscribe.  Thanks for the assistance.

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

More
18 Mar 2025 00:08 - 18 Mar 2025 00:08 #13479 by support
I was referring to your own code that you posted here.
You have written that you get error on this line:

item_descriptor = DAItemDescriptor(item_id, access_path)     

So I am suggesting to replace this line by the code I have posted, i.e.

item_descriptor = DAItemDescriptor(item_id)
item_descriptor.AccessPath = access_path

Regards

 
Last edit: 18 Mar 2025 00:08 by support.
The following user(s) said Thank You: wvklemov

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

More
18 Mar 2025 00:03 #13478 by wvklemov
I looked thru the python examples, and I am not sure what method to use or how to use the item_descriptor and access path.

Thanks for your patience and assistance.

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

Moderators: support
Time to create page: 0.156 seconds