- Posts: 2
- Thank you received: 0
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
- mcerqueira
-
- Offline
- Junior Member
-
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.
- mcerqueira
-
- Offline
- Junior Member
-
- Posts: 2
- Thank you received: 0
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.
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
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Sorry, that's because I could not test it right now. Use this instead:
Best regards
Please Log in or Create an account to join the conversation.
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.
In this example, replace the line with
Best regards
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
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
Please Log in or Create an account to join the conversation.
Thanks for your patience and assistance.
Please Log in or Create an account to join the conversation.