M
Hello,
I have this code(VB .NET), but the DataChange Event of group Object Never Run.. why?
when I clicked the botton, show perfect the actual value of the Tag that OPC Server sended
BUT Never DataChange Event is executed ... why? why? why?
Imports System.Runtime.InteropServices
Imports OPCAutomation
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Dim WithEvents server As OPCServerClass
Dim WithEvents groups As OPCGroupsClass
Dim WithEvents group As OPCGroupClass
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
server = New OPCAutomation.OPCServerClass()
server.Connect("KEPware.KEPServerEx.V4")
groups = CType(Marshal.CreateWrapperOfType(server.OPCGroups,GetType(OPCGroupsClass)),
OPCGroupsClass)
groups.DefaultGroupIsActive = True
groups.DefaultGroupDeadband = 0
group = groups.Add("MyNewGroup")
group.IsActive = True
group.IsSubscribed = True
group.UpdateRate = 1000
Dim items As OPCItems = group.OPCItems
items.DefaultIsActive = True
Dim item As OPCItem = items.AddItem("Channel1.Device1.R0",
1234)
Dim rdval As Object
item.Read(OPCDataSource.OPCDevice, rdval)
MsgBox(rdval.ToString())
End Sub
Sub group_DataChange(ByVal TransactionID As Integer, ByVal
NumItems As Integer, _
ByRef ClientHandles As System.Array, ByRef ItemValues As
System.Array, _
ByRef Qualities As System.Array, ByRef TimeStamps As
System.Array)
If NumItems = 1 Then
If CInt(ClientHandles.GetValue(1)) = 1234 Then
TextBox1.Text = ItemValues.GetValue(1)
End If
End If
End Sub
End Class
I have this code(VB .NET), but the DataChange Event of group Object Never Run.. why?
when I clicked the botton, show perfect the actual value of the Tag that OPC Server sended
BUT Never DataChange Event is executed ... why? why? why?
Imports System.Runtime.InteropServices
Imports OPCAutomation
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Dim WithEvents server As OPCServerClass
Dim WithEvents groups As OPCGroupsClass
Dim WithEvents group As OPCGroupClass
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button1.Click
server = New OPCAutomation.OPCServerClass()
server.Connect("KEPware.KEPServerEx.V4")
groups = CType(Marshal.CreateWrapperOfType(server.OPCGroups,GetType(OPCGroupsClass)),
OPCGroupsClass)
groups.DefaultGroupIsActive = True
groups.DefaultGroupDeadband = 0
group = groups.Add("MyNewGroup")
group.IsActive = True
group.IsSubscribed = True
group.UpdateRate = 1000
Dim items As OPCItems = group.OPCItems
items.DefaultIsActive = True
Dim item As OPCItem = items.AddItem("Channel1.Device1.R0",
1234)
Dim rdval As Object
item.Read(OPCDataSource.OPCDevice, rdval)
MsgBox(rdval.ToString())
End Sub
Sub group_DataChange(ByVal TransactionID As Integer, ByVal
NumItems As Integer, _
ByRef ClientHandles As System.Array, ByRef ItemValues As
System.Array, _
ByRef Qualities As System.Array, ByRef TimeStamps As
System.Array)
If NumItems = 1 Then
If CInt(ClientHandles.GetValue(1)) = 1234 Then
TextBox1.Text = ItemValues.GetValue(1)
End If
End If
End Sub
End Class