Reading Tags in IIS
Home Product
Details Free 
Demo Pricing &
Ordering Related
Products Support About Us

Please use our Code Center to obtain source-code and example projects/solutions:

http://codecenter.softwaretoolbox.com

 

Web Based Applications using the OPC Web Client Web Service

Quick links within this page

Objective

    Display the value of a Tag within a web-page.

Reading a Single Tag

    ASP.NET

         Try
             'create the opc web client web-service object
             Dim objOWC As New OPCLabs.EasyOPCDANet.EasyDAWS

             'create a vtq object to receive the tag read
             'and make the call to read the tag
             Dim objVTQ As OPCLabs.EasyOPCDANet.IVTQNet = objOWC.ReadItem _
               ( _
                 "", _
                 "OPCLabs.KitServer.2", _
                 "Simulation.Random" _
               )

             'display the output to the browser
             If Not objVTQ Is Nothing Then
               Response.Write("<p>Value: " & objVTQ.Value & "</p>")
               Response.Write("<p>Quality: " & objVTQ.Quality & "</p>")
               Response.Write("<p>Timestamp: " & objVTQ.Timestamp & "</p>")
             End If

         Catch ex As Exception
             'display exceptions to the browser
             Response.Write("Error: " & ex.Message)
             If Not ex.InnerException Is Nothing Then
               Response.Write("Inner Err: " & ex.InnerException.Message)
             End If
         End Try

Reading Multiple Tags within a single Transaction

    ASP.NET

        Try
             'create an opc web client object
             Dim EasyDA As New OPCLabs.EasyOPCDANet.EasyDAWS

             'create an array to receive the item read results
             Dim VTQs As System.Array

             'make the call to read the items
             VTQs = EasyDA.ReadMultipleItems _
               ( _
                 "", _
                 "OPCLabs.KitServer.2", _
                 New String() _
                   { _
                     "Simulation.Random", _
                     "Trends.Ramp (1 min)", _
                     "Trends.Sine (1 min)", _
                     "Simulation.Register_I4" _
                   } _
                 )

             'now to see what we received
             If Not VTQs Is Nothing Then

               'iterate thru the dictionary
               For Each item As OPCLabs.EasyOPCDANet.IVTQNet In VTQs

                   'write the values to the browser
                   Response.Write(item.Value _
                     & " (" & item.Quality & ")" _
                     & " @ " & item.Timestamp _
                     & "<br>")
               Next

             End If

         Catch ex As Exception
             'send exception details to screen
             Response.Write("Err: " & ex.Message)
         End Try

Copyright Software Toolbox, Inc., 1996-2004, All Rights Reserved Worldwide.
148A East Charles Street, Matthews, North Carolina, USA 28105
Phone: 704-849-2773 or 1-888-665-3678 (US), Fax: 704-849-6388
sales@softwaretoolbox.com | support@softwaretoolbox.com