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.

Subscription to datachange in visual foxpro

More
09 Nov 2021 15:02 #10343 by support
There are two ways to do it.

One is with "true" events. That is, you will write an event handler that gets called when there is a notification. That will probably require the use of the EVENTHANDLER() function. I have not done this yet because it is bit longer.

The second approach is with "event pull". That is, your code asks whether there is a new notification available. I have made an example for that, and it is further below.

Note that internally in QuickOPC, BOTH these approaches are equivalent - and they both use genuine OPC UA subscriptions (change-based). The event pull approach just maintains an additional queue and gives you a different way of accessing the same flow of data.

* This example shows how to subscribe to changes of a single monitored item, pull events, and display each change.
 
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)
oClient.SubscribeDataChange("http://opcua.demo-this.com:51211/UA/SampleServer", "nsu=http://test.org/UA/Data/ ;i=10853", 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
 
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Unsubscribing..." + CHR(13) + CHR(10)
oClient.UnsubscribeAllMonitoredItems()
 
THISFORM.OutputEdit.Value = THISFORM.OutputEdit.Value + "Finished." + CHR(13) + CHR(10)

If you need the other approach (event handlers), let me know.

Best regards
The following user(s) said Thank You: info@software2000.it

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

More
09 Nov 2021 09:27 #10341 by support
Hello,

I will try to write such an example. Please allow some time for this. I will post here again when I have an update.

Best regards

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

More
08 Nov 2021 16:53 #10340 by info@software2000.it
Can anyone post me some code snippet to be able to make an OPC-UA subscription with visual foxpro to be able to receive an event that indicates that a value of a tag on a particular node has changed?
I only found examples for reading a single value or reading multiple values ​​but no examples for subscribing and receiving updated values.
Just a small snippet to subscribe and show a message with the vsalue changed.
A thousand thanks

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

Moderators: support
Time to create page: 0.055 seconds