Rockwell Automation 1789-L10_L30_L60 SoftLogix 5800 System User Manual User Manual

Page 155

Advertising
background image

Rockwell Automation Publication 1789-UM002J-EN-P - December 2012

155

Program Windows Events to Monitor and Change Controller Execution

Chapter 8


hOutbound(0) = CreateEvent(ByVal 0&, 0, 0, "SOFTLOGIX_01_SHUTDOWN")
ErrorCodeEvent1 = Err.LastDllError
hOutbound(1) = CreateEvent(ByVal 0&, 0, 0, "SOFTLOGIX_01_PROGRAM")
ErrorCodeEvent1 = Err.LastDllError
hOutbound(2) = CreateEvent(ByVal 0&, 0, 0, "SOFTLOGIX_01_RUN")
ErrorCodeEvent1 = Err.LastDllError
hCounter = CreateEvent(ByVal 0&, 0, 0, "Counter")
ErrorCodeEvent1 = Err.LastDllError
If ErrorCodeEvent1 <> 183 Then '183 = Event already exists which is OK

'handle error

End If

noHandle:

End Sub

Private Sub Form_Unload(Cancel As Integer)
CloseHandle (hCounter)
CloseHandle (hOutbound(0))
CloseHandle (hOutbound(1))
CloseHandle (hOutbound(2))
End Sub

Private Sub pbCounter_Click(Index As Integer)
Dim ErrorCodeEvent1 As Long

SetEvent (hCounter)
ErrorCodeEvent1 = Err.LastDllError
If ErrorCodeEvent1 Then

'Handle error

End If
End Sub

Private Sub Timer1_Timer()
Dim inMode As Long
Dim ErrorDescription As String

inMode = WaitForMultipleObjects(3&, hOutbound(0), False, 0)
Select Case inMode
Case WAIT_OBJECT_0 + 2
Label3.BackColor = &HFF00&
Label3.Caption = "Run Mode"
Case WAIT_OBJECT_0 + 1
Label3.BackColor = &HFF8080
Label3.Caption = "Program Mode"
Case WAIT_OBJECT_0
Label3.BackColor = &HFF00FF
Label3.Caption = "SHUTDOWN Mode"
Case Else
Label3.BackColor = &HFFFFFF
Label3.Caption = "Other Mode"
End Select

End Sub

Advertising