Dear Friends,
I am using MS Visual Studio 2010 for creating a OPC DA Client (VB).
i have written the following code for connection/ disconnection of OPC Server
'Connect
Try
ConnectedOPCServer = New OPCAutomation.OPCServer
ConnectedOPCServer.Connect("OPC.SimaticNet.1")
Connect.Enabled = False
Disconnect.Enabled = True
MessageBox.Show("OPC Server is Connected")
Catch ex As Exception
ConnectedOPCServer = Nothing
MessageBox.Show("OPC server connect failed: " + ex.Message, "Exception", MessageBoxButtons.OK)
End Try
Try
ConnectedOPCServer.OPCGroups.DefaultGroupIsActive = True
ConnectedOPCServer.OPCGroups.DefaultGroupDeadband = 0
ConnectedGroup = ConnectedOPCServer.OPCGroups.Add("A")
ConnectedGroup.UpdateRate = 10
ConnectedGroup.IsSubscribed = True
Catch ex As Exception
MessageBox.Show("OPC server add group failed: " + ex.Message, "Exception", MessageBoxButtons.OK)
End Try
'Disconnect
If Not ConnectedGroup Is Nothing Then
Try
ConnectedOPCServer.OPCGroups.Remove("A")
Catch ex As Exception
MessageBox.Show("OPC server remove group failed: " + ex.Message, "Exception", MessageBoxButtons.OK)
Finally
ConnectedGroup = Nothing
End Try
End If
If Not ConnectedOPCServer Is Nothing Then
Try
ConnectedOPCServer.Disconnect()
Connect.Enabled = True
Disconnect.Enabled = False
MessageBox.Show("OPC Server is disconnected")
Catch ex As Exception
MessageBox.Show("OPC server disconnect failed: " + ex.Message, "Exception", MessageBoxButtons.OK)
Finally
ConnectedOPCServer = Nothing
End Try
End If
So far there are no problems with this code. Can anyone guide me with Data Read/Write Code ??
Sorry for my bad English
With Regards,
NandGate.
I am using MS Visual Studio 2010 for creating a OPC DA Client (VB).
i have written the following code for connection/ disconnection of OPC Server
'Connect
Try
ConnectedOPCServer = New OPCAutomation.OPCServer
ConnectedOPCServer.Connect("OPC.SimaticNet.1")
Connect.Enabled = False
Disconnect.Enabled = True
MessageBox.Show("OPC Server is Connected")
Catch ex As Exception
ConnectedOPCServer = Nothing
MessageBox.Show("OPC server connect failed: " + ex.Message, "Exception", MessageBoxButtons.OK)
End Try
Try
ConnectedOPCServer.OPCGroups.DefaultGroupIsActive = True
ConnectedOPCServer.OPCGroups.DefaultGroupDeadband = 0
ConnectedGroup = ConnectedOPCServer.OPCGroups.Add("A")
ConnectedGroup.UpdateRate = 10
ConnectedGroup.IsSubscribed = True
Catch ex As Exception
MessageBox.Show("OPC server add group failed: " + ex.Message, "Exception", MessageBoxButtons.OK)
End Try
'Disconnect
If Not ConnectedGroup Is Nothing Then
Try
ConnectedOPCServer.OPCGroups.Remove("A")
Catch ex As Exception
MessageBox.Show("OPC server remove group failed: " + ex.Message, "Exception", MessageBoxButtons.OK)
Finally
ConnectedGroup = Nothing
End Try
End If
If Not ConnectedOPCServer Is Nothing Then
Try
ConnectedOPCServer.Disconnect()
Connect.Enabled = True
Disconnect.Enabled = False
MessageBox.Show("OPC Server is disconnected")
Catch ex As Exception
MessageBox.Show("OPC server disconnect failed: " + ex.Message, "Exception", MessageBoxButtons.OK)
Finally
ConnectedOPCServer = Nothing
End Try
End If
So far there are no problems with this code. Can anyone guide me with Data Read/Write Code ??
Sorry for my bad English
With Regards,
NandGate.