Hi
I am wondering if you could tell me how to improve my code so I can read over 1000 elements into a listview in real time.
The OP Server is Rockwell FactoryTalk Gateway.
Tag_Description = "Result " & i.ToString & " LVDT #1 TIR / 2"
Tag_Shortcut = "[L6]Results[1].Result"
Dim itemChild As New BetterListViewItem(New String() {Tag_Description, Tag_Shortcut, "0.0", "n/a", "n/a"})
ListView.Items(0).ChildItems.Add(itemChild)
I then repeat this in a for loop incrementing I, from 1 to 750.
I then use a subscribe method to add the tags to an OPC Group;
IsSubscribed = True
' Prepare an array describing what we want to subscribe to and how
Dim count As Integer = ListView.Items(0).ChildItems.Count
'Dim count As Integer = SetupParameters.Count
Dim Row_i As Integer = 0
Dim argumentsArray(count - 1) As DAItemGroupArguments
Row_i = 0
For i As Integer = 0 To count - 1
Dim listViewItem As BetterListViewItem = ListView.Items(0).ChildItems(i)
If listViewItem.Visible = True Then
Dim itemId As String = listViewItem.SubItems(1).Text 'Text
argumentsArray(Row_i) = New DAItemGroupArguments("FactoryTalk Gateway", itemId, 50, listViewItem)
Row_i += 1
End If
'Next
Next
ReDim Preserve argumentsArray(Row_i - 1) 'As DAItemGroupArguments
' Execute the Subscribe operation
EasyDAClient.SubscribeMultipleItems(argumentsArray)
I then have a callback and update list view function;
Public Sub EasyDAClient_ItemChanged(sender As Object, e As EasyDAItemChangedEventArgs) Handles EasyDAClient.ItemChanged
BeginInvoke(Sub()
ListView.BeginUpdate()
Dim listViewItem As BetterListViewItem = CType(e.arguments.State, BetterListViewItem)
UpdateListViewItem(listViewItem, e.Exception, e.Vtq)
ListView.EndUpdate()
End Sub)
End Sub
' Updates ListViewItem (from reading or change notification) with exception and value/timestamp/quality
Private Shared Sub UpdateListViewItem(ByVal listViewItem As BetterListViewItem, ByVal exception As Exception, ByVal vtq As DAVtq)
Dim vtqText As String = ""
Dim exceptionText As String = ""
If (exception Is Nothing) Then
If vtq.Value Is Nothing Then
listViewItem.SubItems(2).Text = "0"
listViewItem.SubItems(3).Text = "No Data"
listViewItem.SubItems(4).Text = Now()
Else
listViewItem.SubItems(2).Text = vtq.Value.ToString ' vtqText
listViewItem.SubItems(3).Text = Get_Quality_String(vtq.Quality.InternalValue)
listViewItem.SubItems(4).Text = vtq.Timestamp.ToString("dd/MM/yy HH:mm:ss.fff")
'vtqText = vtq.ToString()
End If
Else
listViewItem.SubItems(3).Text = exception.Message
End If
End Sub
The values are displayed but not in real time, there is a lag of approximately 10seconds, then it displays, then there’s another lag then it displays.
What am I doing wrong or is there a better way of achieving this with later release? If I reduce the number of tags then it works perfectly.
If you wish I can send the Visual Studio project file if its easier (VB.net).
Neil