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.

Testing OPC read/write with trial version - FoxPro

More
26 Jul 2023 15:27 #11957 by Ferlaino
Hello,

I'm trying out the OPC library for integrating with an industrial machine. I use VisualFoxPro as a language with the trial version and for testing purposes, with the prospect of purchasing the full license.
During my tests, I managed to connect to my own virtual machine using the 'easyuaclientform' example present in the folder of the examples proposed by you and verifying the nodes on the other side with the OPCExpert tool.
I can easily acquire the data of the nodes in reading but, I don't know why, I have difficulty trying to write some value on some node (I think due to syntax problems or in my practices).
I tried different methods like 'WriteValue' or 'WriteValueEx', integrating them in your example. However I always get errors 0x8002000e or 0x80020006.

After various attempts, I suspect that something is wrong in the configuration, or that the free version doesn't allow me to work in writing...

I would like to make sure I can both read and write to a node of an OPC server to continue the tests and purchase the license...

I'm here to ask for help precisely because I would like to understand the functioning of the processes... for example, how could I modify your example so that I can write to an OPC node?
What is the best way to do a basic test?
Based on the code I share, does this seem right as an approach?

I put '00000' as a port number for sample purpose (to keep it private) and I got the error in runtime after the orange line.

Thanks for any help and support
GiacoF


DECLARE INTEGER GetTickCount IN kernel32

THISFORM.OutputEdit.Value = ""

* Instantiate the client object.
oClient = CREATEOBJECT("OpcLabs.EasyOpc.UA.EasyUAClient")

* In order to use event pull, you must set a non-zero queue capacity upfront.
oClient.PullDataChangeNotificationQueueCapacity = 1000

THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Subscribing..." + CHR(13) + CHR(10)

* Specify the OPC server item you want to subscribe to
cSubscriptionItemID = "i=15183"

oSubscription = oClient.SubscribeDataChange("opc.tcp://vm-sviluppo:00000/opcexpert", "nsu=http://opcfoundation.org/UA/;i=15183", 1000)

THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Processing data change notification events for 1 minute..." + CHR(13) + CHR(10)

EndTick = GetTickCount() + 60000
DO WHILE GetTickCount() < EndTick
oEventArgs = oClient.PullDataChangeNotification(2*1000)
IF NOT ISNULL(oEventArgs)
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + oEventArgs.DisplayString + CHR(13) + CHR(10)
ENDIF
ENDDO

LOCAL cItemId, nValueToWrite

* Writing to OPC server after connection
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Writing to OPC server..." + CHR(13) + CHR(10)

* Specify the OPC server item you want to write to
cWriteItemID = "i=15183"
cValueToWrite = "Hello"

* Write the value to the OPC server item as a string value
oWriteResult = oClient.WriteValue("opc.tcp://vm-sviluppo:57888/opcexpert", cWriteItemID, cValueToWrite, "String")

IF oWriteResult.Succeeded
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Write succeeded." + CHR(13) + CHR(10)
ELSE
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Write failed: " + oWriteResult.Exception + CHR(13) + CHR(10)
ENDIF

THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Unsubscribing..." + CHR(13) + CHR(10)
oSubscription.Unsubscribe()

THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Finished." + CHR(13) + CHR(10)


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

Moderators: supportvaclav.zaloudek
Time to create page: 0.130 seconds