OPC DA (Net API) How to identify response to Subscription.Refresh(object requestHandle, out IRequest request)|Classic OPC: DA, A&E, HDA, XML-DA, etc.|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
OPC DA (Net API) How to identify response to Subscription.Refresh(object requestHandle, out IRequest request)
Avatar
ken
Member
Members
Forum Posts: 7
Member Since:
02/24/2014
sp_UserOfflineSmall Offline
1
07/14/2021 - 06:28
sp_Permalink sp_Print

Can anyone explain or provide an example for how to identify the OnDataChange() event that matches a Refresh request? In my tests, each OnDataChange event comes with a null value for the requestHandle parameter.

 

I'm testing with code slightly modified from the available download "opc-net-api-sample-clients-2.01.107-20180130". I've changed the Refresh request code in SubscriptionsTreeCtrl to this:

private void Refresh(Subscription subscription)
{
    refreshRequestId++;
    try
    {
        IRequest requestToken = null;
        subscription.Refresh(refreshRequestId, out requestToken);
    }
    catch (Exception e)
    {
        MessageBox.Show(e.Message);
    }
}

... where "refreshRequestId" is an integer.

I can see that the "requestToken" gets values assigned. At this point I'm not concerned about its content so it's just a local variable.

 

In UpdatesListViewCtrl, the event handler:

    private void OnDataChange(object subscriptionHandle, object requestHandle, ItemValueResult[] values)

gets called with data changes but but 'requestHandle' is always null and there doesn't seem to be any other way to pair the callback with a specific refresh request.

 

Thanks

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
07/14/2021 - 08:14
sp_Permalink sp_Print

What you want to do is a hack that the API may not support. i.e. using Refresh is rarely a good design choice and your client should not need to know which responses were sent as a result of a Refresh.

Refresh was removed from OPC UA because it was overused.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 38
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855