How do I get items name inside DataChange event in C#|OPC UA Standard|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
How do I get items name inside DataChange event in C#
Avatar
Denis Pozarko
Member
Members
Forum Posts: 8
Member Since:
04/11/2021
sp_UserOfflineSmall Offline
1
05/13/2021 - 05:25
sp_Permalink sp_Print

How I added items to the server from ListView:

serverName.opGroup.OPCItems.AddItem(“itemName”, listView.Items.Count);

This runs each time I click the button to add a new item to ListView.

 

Now when I try to update a listView with DataChange event

public void StructOPCServer_DataChange(int TransactionID, int NumItems, ref Array ClientHandles, ref Array ItemValues, ref Array Qualities, ref Array TimeStamps){

foreach(int item in ClientHandles){

     listViewName.Items[item-1].SubItems[1].Text = ItemValues.GetValue(item).ToString();

}

}

ClientHandles get mixed up somehow although I haven’t changed the position of items in my listview. 
For exmaple:

ListViewItem[0] should be ClientHandle = 1

ListViewItem[1] should be ClientHandle = 2

ListViewItem[3] should be ClientHandle = 3

 

Instead I get for exmaple:

ListViewItem[0] should be ClientHandle = 3

ListViewItem[1] should be ClientHandle = 1

ListViewItem[3] should be ClientHandle = 2

 and each time I run the app and do the same process (adding same items in same order) each time ClientHandle mixes up a different way. 

So I was hoping if there is solution to this or can I somehow access items name withing DataChange event (that I have added in AddItem() method). So what way I could compare if a new value ive got is from the item with same name like the one I got in ListView.

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOnlineSmall Online
2
05/13/2021 - 06:34
sp_Permalink sp_Print

The OPC interfaces use client handles specifically because the order of updates is not predicable.

All client side UI update logic needs to use the client handle to look up the correct UI element.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online: Randy Armstrong
Guest(s) 58
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1445
Posts: 4889