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.

Read multiple OPC tags

More
15 Nov 2015 18:31 #3662 by support
Replied by support on topic Read multiple OPC tags
Please post the exception message, and if it has an inner exception, its message as well.

Best regards

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

More
15 Nov 2015 14:28 - 15 Nov 2015 18:32 #3661 by pvs
Read multiple OPC tags was created by pvs
I was able to read a single variable.
Now I want to go one step further and I extended my code with lines to periodically read multiple (=4) variables.
See below.
To application will not run it comes with a error-message at the line indicated.
What is missing?
THe application also eats most of the CPU-power if I run it in debug moden onder VS2013.

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.DataAccess.Generic
Imports OpcLabs.EasyOpc.DataAccess.OperationModel
Imports System.Threading
 
Public Class Form1
    Public TotalItems As Integer
    Public NumberOfGroups As Integer
    Public ItemsInGroup As Integer
    Public itemDescriptors() As DAItemDescriptor
 
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim OPCTags(0 To 4) As String
        Dim Index As Integer
 
        OPCTags(0) = "Simulation.Random"
        OPCTags(1) = "Trends.Ramp (1 min)"
        OPCTags(2) = "Trends.Sine (1 min)"
        OPCTags(3) = "Simulation.Register_I4"
        OPCTags(4) = "Dummy"
 
        NumberOfGroups = 1
        ItemsInGroup = 4
        Index = 0
        ' Create an array of item descriptors for all items
 
        TotalItems = NumberOfGroups * ItemsInGroup
        Dim itemDescriptors = New DAItemDescriptor(TotalItems - 1) {}
 
        For iLoop As Integer = 0 To NumberOfGroups - 1
            For iItem As Integer = 0 To ItemsInGroup - 1
                itemDescriptors(Index) = New DAItemDescriptor(String.Format(OPCTags(iItem), iLoop + 1, iItem + 1))
                Index = Index + 1
            Next iItem
        Next iLoop
 
 
    End Sub
 
 
    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        Dim successCount As Integer = 0
 
        TextBox1.Text = EasyDAClient1.ReadItemValue("", "OPCLabs.KitServer.2", "Trends.Ramp (1 min)")
 
        ' Perform the OPC read
 
'' THE NEXT LINE GENETRATES the ERROR ''
 
        Dim vtqResults() As DAVtqResult = EasyDAClient1.ReadMultipleItems("OPCLabs.KitServer.2", itemDescriptors)
 
        ' Count successful results (totalling to previous value)
        For iItem As Integer = 0 To ItemsInGroup - 1
            Debug.Assert(vtqResults(iItem) IsNot Nothing)
            If vtqResults(iItem).Succeeded Then
                successCount = successCount + 1
            End If
        Next iItem
 
    End Sub
 
End Class
Last edit: 15 Nov 2015 18:32 by support.

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

Moderators: support
Time to create page: 0.057 seconds