Client - data change filter on Monitored Item

Questions regarding the use of the ANSI C SDK for Server or Client development or integration into customer products ...

Moderator: uasdkc

Post Reply
roman
Jr. Member
Jr. Member
Posts: 1
Joined: 26 Jan 2020, 11:53

Client - data change filter on Monitored Item

Post by roman »

Hello Support Team,

I work with version 1.9.0 ANSI C Based UA SDK. I use modified lesson 2 example project against 3rd party server (Kepware). I have added one new item on server and I am able to read the item on client side.

New item details (client side):
createRequest[2].RequestedParameters.ClientHandle = 2;
createRequest[2].ItemToMonitor.AttributeId = OpcUa_Attributes_Value;
createRequest[2].ItemToMonitor.NodeId.NamespaceIndex = 2;
createRequest[2].ItemToMonitor.NodeId.IdentifierType = OpcUa_IdentifierType_String;
createRequest[2].ItemToMonitor.NodeId.Identifier.String.strContent = "Channel1.Device1.Tag01";
createRequest[2].ItemToMonitor.NodeId.Identifier.String.uLength = strlen("Channel1.Device1.Tag01");

I need to read this item cyclically also without value change therefore my intention turned into applying of Data Change Filter for this item. Firstly I tested my idea with UaExpert against server and Data Change Trigger setting Status/Value/Timestamp worked with expected behavior - item refreshed cyclically also without value change. Now I want to implement similar configuration into modified Lesson 2 code. After more attempts I am not able to achieve the goal. I understand that I should properly modify ExtensionObject Filter in createRequest[2].RequestedParameters.Filter.

Would it be possible to provide any sample code or description how to proceed ?

Thanks & Regards,
Roman

User avatar
Support Team
Hero Member
Hero Member
Posts: 2627
Joined: 18 Mar 2011, 15:09

Re: Client - data change filter on Monitored Item

Post by Support Team »

Dear Roman,

Here is sample code for setting a DataChange filter in the lesson 2 example in function SampleSubscription_CreateMonitoredItem.
The sample code is for setting a deadband value but you can also just set a different trigger and OpcUa_DeadbandType_None.

Code: Select all

        /* Sample code for creation of data change filter */
        /* Trigger setting (default is StatusValue) */
        /* Deadband setting is 0.1% of last value (Absolute) */
        OpcUa_DataChangeFilter* pDataChangeFilter = NULL;
        OpcUa_EncodeableObject_CreateExtension(
            &OpcUa_DataChangeFilter_EncodeableType,
            &createRequest[i].RequestedParameters.Filter,
            (OpcUa_Void**)&pDataChangeFilter);
        if (pDataChangeFilter)
        {
            pDataChangeFilter->DeadbandType = OpcUa_DeadbandType_Absolute;
            pDataChangeFilter->DeadbandValue = 0.1;
            pDataChangeFilter->Trigger = OpcUa_DataChangeTrigger_StatusValue;
        }        
But you should be aware that the setting OpcUa_DataChangeTrigger_StatusValueTimestamp is NOT a cyclic delivery of values even without change. It only delivers a value if the ServerTimeStamp changed. This is normally not the case if the value did not change.

If a server is constantly updating the ServerTimeStamp, I would consider this as a bug or special behavior but you cannot expect this from other OPC UA servers.
Best regards
Unified Automation Support Team

Post Reply