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

More
17 Mar 2025 22:56 - 17 Mar 2025 22:57 #13477 by support
Unrelated to the access path issue, I would like to note that you are not using QuickOPC from Python the way we have documented. It seems that you are somehow referencing the assemblies yourself. But, we have a Python package that does everything for you. Simply install it using 

pip install opclabs_quickopc

and then, in your code, start with

import opclabs_quickopc

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


See our Python examples (there are more than 200 of them).

Best regards
 
Last edit: 17 Mar 2025 22:57 by support.

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

More
17 Mar 2025 22:51 - 17 Mar 2025 22:52 #13476 by support
Hello,
I guess I can still be surprised ( by the access path usage ).

In order to specify the access path, you can create the item descriptor like this:

item_descriptor = DAItemDescriptor(item_id)
item_descriptor.AccessPath = access_path

I hope this helps.
Best regards
Last edit: 17 Mar 2025 22:52 by support.

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

More
17 Mar 2025 21:49 #13475 by wvklemov
I am not actually using the Matrikon OPC Server to subscribe to and read data.  I am trying to connect to one of our local OPC Servers that does require an access path to be used for all data items.  I need to subscribe to, get subscription data and then unsubscribe from the item.

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

More
17 Mar 2025 21:24 #13474 by support
Hello.

If really needed, I can help with properly specifying the access path. However, I seriously doubt that access path is what you are looking for. I am involved with OPC almost from its beginnings, 25-30 years. And in this whole period, I have *never* seen an actual OPC server that would require or even support access paths. Access paths are esoteric feature that only existed in OPC DA specification 1.0, and has been removed in all subsequent versions of the spec.

I suggest that you rather describe what you want to achieve or why you have asked for the access path. I think that with Matrikon OPC server, the ItemID should be sufficient for the server to identify what you want to read, write, or subscribe to.

Best regards

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

Moderators: support
Time to create page: 0.163 seconds