Sub CreateHardwareStateListener
Dim RemoteController As JavaObject = aircraft
RemoteController = RemoteController.RunMethod("getRemoteController", Null)
Dim callback As Object = RemoteController.CreateEventFromUI("dji.common.remotecontroller.HardwareState$HardwareStateCallback", "HardwareState", Null)
RemoteController.RunMethod("setHardwareStateCallback", Array(callback))
End Sub
Sub HardwareState_Event (MethodName As String, Args() As Object) As Object
Log(MethodName)
Dim HardwareState As JavaObject = Args(0)
Dim c1button As JavaObject = HardwareState.RunMethod("getC1Button", Null)
Dim IsClicked As Boolean = c1button.RunMethod("isClicked", Null)
Log($"C1 button: ${IsClicked}"$)
Return Null
End Sub
Sub AfterAircraftConnected
If aircraft.CameraReady = False Or aircraft.BatteryReady = False Then
Log("Camera / battery not ready")
Sleep(500)
If aircraft.Connected Then AfterAircraftConnected
Return
End If
aircraft.RegisterBatteryStateEvent
controller.Initialize("controller", aircraft)
Log($"simulator: ${controller.SimulatorStarted)}"$
camera.Initialize("camera", aircraft)
pnlCamera.AddView(camera.CreateVideoView, 0, 0, pnlCamera.Width, pnlCamera.Height)
timer1.Enabled = True
WaypointOperator.Initialize("WaypointOperator")
aircraftName = "N/A"
Wait for (aircraft.GetName) Aircraft_ResultWithValue (Success As Boolean, ErrorMessage As String, Value As Object)
If Success Then
aircraftName = Value
End If
CreateHardwareStateListener
CreateHardwareStateListener1
End Sub
Sub CreateHardwareStateListener
Dim RemoteController As JavaObject = aircraft
RemoteController = RemoteController.RunMethod("getRemoteController", Null)
Dim callback As Object = RemoteController.CreateEventFromUI("dji.common.remotecontroller.HardwareState$HardwareStateCallback", "HardwareState", Null)
RemoteController.RunMethod("setHardwareStateCallback", Array(callback))
End Sub
Sub CreateHardwareStateListener1
Dim RemoteController As JavaObject = aircraft
RemoteController = RemoteController.RunMethod("getRemoteController", Null)
Dim callback As Object = RemoteController.CreateEventFromUI("dji.common.remotecontroller.HardwareState$HardwareStateCallback", "HardwareState", Null)
RemoteController.RunMethod("setHardwareStateCallback", Array(callback))
End Sub
Sub HardwareState_Event (MethodName As String, Args() As Object) As Object
Log(MethodName)
Dim HardwareState As JavaObject = Args(0)
Dim c1button As JavaObject = HardwareState.RunMethod("getC1Button", Null)
Dim IsClicked As Boolean = c1button.RunMethod("isClicked", Null)
Log($"C1 button: ${IsClicked}"$)
ToastMessageShow($"C1 button: ${IsClicked}"$,False)
Return Null
End Sub
Sub HardwareState_Event1 (MethodName As String, Args() As Object) As Object
Log(MethodName)
Dim HardwareState As JavaObject = Args(0)
Dim c2button As JavaObject = HardwareState.RunMethod("getC2Button", Null)
Dim IsClicked As Boolean = c2button.RunMethod("isClicked", Null)
Log($"C2 button: ${IsClicked}"$)
ToastMessageShow($"C2 button: ${IsClicked}"$,False)
Return Null
End Sub
Sub CreateHardwareStateListener1
Dim RemoteController As JavaObject = aircraft
RemoteController = RemoteController.RunMethod("getRemoteController", Null)
Dim callback As Object = RemoteController.CreateEventFromUI("dji.common.remotecontroller.HardwareState$HardwareStateCallback", "HardwareState1", Null)
RemoteController.RunMethod("setHardwareStateCallback", Array(callback))
End Sub
Sub HardwareState1_Event (MethodName As String, Args() As Object) As Object
Log(MethodName)
Dim HardwareState As JavaObject = Args(0)
Dim c1button As JavaObject = HardwareState.RunMethod("getC1Button", Null)
Dim IsClicked As Boolean = c1button.RunMethod("isClicked", Null)
Log($"C1 button: ${IsClicked}"$)
ToastMessageShow($"C1 button: ${IsClicked}"$,False)
Return Null
End Sub
Sub CreateHardwareStateListener2
Dim RemoteController As JavaObject = aircraft
RemoteController = RemoteController.RunMethod("getRemoteController", Null)
Dim callback As Object = RemoteController.CreateEventFromUI("dji.common.remotecontroller.HardwareState$HardwareStateCallback", "HardwareState2", Null)
RemoteController.RunMethod("setHardwareStateCallback", Array(callback))
End Sub
Sub HardwareState2_Event (MethodName As String, Args() As Object) As Object
Log(MethodName)
Dim HardwareState As JavaObject = Args(0)
Dim c2button As JavaObject = HardwareState.RunMethod("getC2Button", Null)
Dim IsClicked As Boolean = c1button.RunMethod("isClicked", Null)
Log($"C2 button: ${IsClicked}"$)
ToastMessageShow($"C2 button: ${IsClicked}"$,False)
Return Null
End Sub
Sub CreateHardwareStateListener
Dim RemoteController As JavaObject = aircraft
RemoteController = RemoteController.RunMethod("getRemoteController", Null)
Dim callback As Object = RemoteController.CreateEventFromUI("dji.common.remotecontroller.HardwareState$HardwareStateCallback", "HardwareState", Null)
RemoteController.RunMethod("setHardwareStateCallback", Array(callback))
End Sub
Sub HardwareState_Event (MethodName As String, Args() As Object) As Object
Log(MethodName)
Dim HardwareState As JavaObject = Args(0)
Dim c1button As JavaObject = HardwareState.RunMethod("getC1Button", Null)
Dim c1Clicked As Boolean = c1button.RunMethod("isClicked", Null)
Dim c2button As JavaObject = HardwareState.RunMethod("getC2Button", Null)
Dim c2Clicked As Boolean = c2button.RunMethod("isClicked", Null)
Log($"C1 button: ${c1Clicked}"$)
Log($"C2 button: ${c2Clicked}"$)
Return Null
End Sub