Siemens SIMOTION Serie Information Produit page 51

Table des Matières

Publicité

'called at program end
Private Sub Form_Unload(Cancel As Integer)
End Sub
'called after connection loss or access fault
Private Sub TimerInit_Timer()
End Sub
'called at OPC server shutdown
Private Sub myOPCserver_ServerShutDown(ByVal Reason As String)
End Sub
'initialize OPC connection
Private Sub Init()
InitError:
End Sub
SIMATIC NET(XP) SIMOTION
Information produit, 05/2009
Call Destroy
TimerInit.Enabled = False 'disable timer
Call Destroy
Call Init
Debug.Print Now & " server shutdown"
TimerInit.Interval = 10000 'try to reconnect after 10 seconds
TimerInit.Enabled = True
On Error GoTo InitError
Set myOPCserver = New OPCServer ' server
myOPCserver.Connect ("OPC.SimaticNET")
Set myOPCgroup = myOPCserver.OPCGroups.Add("Test") 'group
With myOPCgroup
.IsActive = False 'read synchronous from device
.IsSubscribed = False 'read synchronous from device
'synchronous
With myOPCgroup.OPCItems
Set myOPCitem1 = .AddItem("P350.VARIABLE.db1", 1)
Set myOPCitem2 = .AddItem("P350.ST_1.array1", 1)
Set myOPCitem3 = .AddItem("P350.ST_1.dint1", 1)
End With
End With
ServerHandles(0) = myOPCitem1.ServerHandle
ServerHandles(1) = myOPCitem2.ServerHandle
ServerHandles(2) = myOPCitem3.ServerHandle
Debug.Print Now & " server connected"
Timer1.Interval = 500 'poll data every 500ms
Timer1.Enabled = True 'poll data
Exit Sub
MsgBox "Error connecting OPC server: " & Err.Number & " " &
Err.Description
Astuces
5.7 Exemple d'application
51

Publicité

Table des Matières
loading

Ce manuel est également adapté pour:

Simotion scoutSimatic net simotionSimatic net xp simotion

Table des Matières