//Callback of SDKRegistrationEvent private async void Instance_SDKRegistrationEvent(SDKRegistrationState state, SDKError resultCode) { if (resultCode == SDKError.NO_ERROR) { System.Diagnostics.Debug.WriteLine("Register app successfully."); //Must in UI thread await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { //Raw data and decoded data listener if (videoParser == null) { videoParser = new DJIVideoParser.Parser(); videoParser.Initialize(delegate(byte[] data) { //Note: This function must be called because we need DJI Windows SDK to help us to parse frame data. return(DJISDKManager.Instance.VideoFeeder.ParseAssitantDecodingInfo(0, data)); }); //Set the swapChainPanel to display and set the decoded data callback. videoParser.SetSurfaceAndVideoCallback(0, 0, swapChainPanel, ReceiveDecodedData); DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0).VideoDataUpdated += OnVideoPush; } //get the camera type and observe the CameraTypeChanged event. DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).CameraTypeChanged += OnCameraTypeChanged; var type = await DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).GetCameraTypeAsync(); OnCameraTypeChanged(this, type.value); }); } else { System.Diagnostics.Debug.WriteLine("SDK register failed, the error is: "); System.Diagnostics.Debug.WriteLine(resultCode.ToString()); } }
/// <summary> /// Developer should change the work mode to transcode or playback in order to enhance download speed /// </summary> private async void Mode() { var current = await cameraHandler.GetCameraWorkModeAsync(); var currMode = current.value?.value; if (currMode != CameraWorkMode.PLAYBACK && currMode != CameraWorkMode.TRANSCODE) { var msg = new CameraWorkModeMsg { value = CameraWorkMode.TRANSCODE }; SDKError err = await cameraHandler.SetCameraWorkModeAsync(msg); System.Diagnostics.Debug.WriteLine("Mode {0})", err.ToString()); } else { var msg = new CameraWorkModeMsg { value = CameraWorkMode.SHOOT_PHOTO }; SDKError err = await cameraHandler.SetCameraWorkModeAsync(msg); System.Diagnostics.Debug.WriteLine("Mode {0})", err.ToString()); } }
public async Task <SDKError> TakeOff() { SDKError result = SDKError.UNKNOWN; if (null != DJISDKManager.Instance) { // start take off result = await fcHandler.StartTakeoffAsync(); // check if (result == SDKError.NO_ERROR) { var TakeoffAlt = 1.18; // [m] // take off command send bool achieveTakeOffHeight = Drone.Instance.CurrentState.Altitude > TakeoffAlt; while (!achieveTakeOffHeight) { Thread.Sleep(10); achieveTakeOffHeight = Drone.Instance.CurrentState.Altitude > TakeoffAlt; result = await fcHandler.StartTakeoffAsync(); } Debug.Print("Take off finish") ; Drone.Instance.IsTakeOffFinish = true; } else { // start take off fail } } return(result); }
private async void Instance_SDKRegistrationEvent(SDKRegistrationState state, SDKError resultCode) { //register the application to the DJI Windows SDK if (resultCode == SDKError.NO_ERROR) { System.Diagnostics.Debug.WriteLine("Register app successfully."); //The product connection state will be updated when it changes here. DJISDKManager.Instance.ComponentManager.GetProductHandler(0).ProductTypeChanged += async delegate(object sender, ProductTypeMsg? value) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async() => { if (value != null && value?.value != ProductType.UNRECOGNIZED) { System.Diagnostics.Debug.WriteLine("The Aircraft is connected now."); IsConnected.Text = "The Aircraft is connected now."; this.AirCraftConnected = true; } else { System.Diagnostics.Debug.WriteLine("The Aircraft is disconnected now."); IsConnected.Text = "The Aircraft is disconnected now."; this.AirCraftConnected = false; } }); }; } else { System.Diagnostics.Debug.WriteLine("Register SDK failed, the error is: "); System.Diagnostics.Debug.WriteLine(resultCode.ToString()); } }
private async void Instance_SDKRegistrationEvent(SDKRegistrationState state, SDKError resultCode) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { activateStateTextBlock.Text = state == SDKRegistrationState.Succeeded ? "Activated." : "Not Activated."; activationInformation.Text = resultCode == SDKError.NO_ERROR ? "Register success" : resultCode.ToString(); }); }
private async void Instance_SDKRegistrationEvent(SDKRegistrationState state, SDKError resultCode) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { Debug.WriteLine(state == SDKRegistrationState.Succeeded ? "Activated." : "Not Activated."); Debug.WriteLine(resultCode == SDKError.NO_ERROR ? "Register success" : resultCode.ToString()); }); }
private async void Upload_Mission(object sender, RoutedEventArgs value) { //DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).GetLoadedMission(); SDKError err = await DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).UploadMission(); Debug.WriteLine("Upload mission to aircraft : " + err.ToString()); UploadMissionError.Text = "Upload mission to aircraft : " + err.ToString(); }
protected override void OnStartup(StartupEventArgs e) { SDKError err = SdkWrap.Instacne.Initialize(); if (err != SDKError.SDKERR_SUCCESS) { MessageBox.Show("初始化服务失败!"); } }
protected override void OnExit(ExitEventArgs e) { SDKError err = SdkWrap.Instacne.CleanUp(); if (err != SDKError.SDKERR_SUCCESS) { MessageBox.Show("清理服务失败!"); } }
public async Task <SDKError> UploadMission() { //UploadMission SDKError uploadError = await DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).UploadMission(); System.Diagnostics.Debug.WriteLine("UPLOAD MISSION: " + uploadError.ToString()); return(uploadError); }
public async Task <SDKError> StartMission() { //6. StartMission SDKError errStartMission = await DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).StartMission(); System.Diagnostics.Debug.WriteLine("START MISSION: " + errStartMission.ToString()); return(errStartMission); }
public async Task <SDKError> RotateGimbalByAngle(double pitch, double roll, double yaw, double duration) { SDKError errRotateGimbalByAngle = await DJISDKManager.Instance.ComponentManager.GetGimbalHandler(0, 0).RotateByAngleAsync(new GimbalAngleRotation() { pitch = pitch, roll = roll, yaw = yaw, duration = duration }); System.Diagnostics.Debug.WriteLine(String.Format("Rotate by angle: {0}", errRotateGimbalByAngle.ToString())); return(errRotateGimbalByAngle); }
public async Task <SDKError> SetGroundStationModeEnabled(bool value) { SDKError errSetGroundStationModeEnabled = await DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).SetGroundStationModeEnabledAsync(new BoolMsg() { value = true }); System.Diagnostics.Debug.WriteLine(String.Format("Set Ground Station Mode Enabled to {0}: {1}", value, errSetGroundStationModeEnabled.ToString())); return(errSetGroundStationModeEnabled); }
public async Task <SDKError> SetPrecisionLanding(bool value) { SDKError errSetPrecisionLanding = await DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).SetPrecisionLandingEnabledAsync(new BoolMsg() { value = value }); System.Diagnostics.Debug.WriteLine(String.Format("Set precision landing to {0}: {1}", value, errSetPrecisionLanding.ToString())); return(errSetPrecisionLanding); }
private async Task <SDKError> SetCameraWorkMode(CameraWorkMode mode) { CameraWorkModeMsg workMode = new CameraWorkModeMsg { value = mode, }; SDKError retCode = await DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0).SetCameraWorkModeAsync(workMode); return(retCode); }
private void Load_Mission(object sender, RoutedEventArgs e) { var state = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).GetCurrentState(); Debug.WriteLine(state.ToString()); //WaypointMissionState.Text = state.ToString(); SDKError err = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).LoadMission(WaypointMission); Debug.WriteLine("SDK load mission : " + err.ToString()); //LoadMissionError.Text = "SDK load mission : " + err.ToString(); }
private void SubscribeEvents() { _selectedToken = EventAggregatorManager.Instance.EventAggregator.GetEvent <CardSelectedEvent>().Subscribe((argument) => { switch (argument.Argument.Category) { case Category.DesktopCard: IsDesktopSelected = true; IsDocSelected = false; break; case Category.DocCard: IsDocSelected = true; IsDesktopSelected = false; OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); openFileDialog.Multiselect = false; openFileDialog.Filter = "文档|*.doc;*.docx;*.ppt;*.pptx;*.xls;*.xlsx;*.pdf"; openFileDialog.ShowDialog(); string fileName = openFileDialog.FileName; if (!string.IsNullOrEmpty(fileName)) { } break; } }, ThreadOption.PublisherThread, true, filter => { return(filter.Target == Target.SharingOptionsViewModel); }); _sharingToken = EventAggregatorManager.Instance.EventAggregator.GetEvent <StartSharingEvent>().Subscribe((argument) => { if (IsDesktopSelected) { CMeetingConfigurationDotNetWrap.Instance.SetSharingToolbarVisibility(false); CMeetingUIControllerDotNetWrap.Instance.ShowSharingToolbar(false); IntPtr desktopHandle = Win32APIs.GetDesktopWindow(); SDKError error = CMeetingShareControllerDotNetWrap.Instance.StartAppShare(new HWNDDotNet() { value = (uint)desktopHandle.ToInt32() }); } else if (IsDocSelected) { } else { MessageBox.Show("请选择共享源!"); } }, ThreadOption.PublisherThread, true, filter => { return(filter.Target == Target.SharingOptionsViewModel); }); }
public SDKError Initialize() { InitParam param = new InitParam(); param.brand_name = "云教室"; param.web_domain = "https://zoom.us"; param.language_id = SDK_LANGUAGE_ID.LANGUAGE_Chinese_Simplified; SDKError err = CZoomSDKeDotNetWrap.Instance.Initialize(param); return(err); }
private void SubscribeEvents() { _joinToken = EventAggregatorManager.Instance.EventAggregator.GetEvent <JoinMeetingEvent>().Subscribe((argument) => { if (string.IsNullOrEmpty(MeetingNumber)) { JoinError = "请输入课堂号!"; return; } ulong uint_meeting_number; if (ulong.TryParse(MeetingNumber, out uint_meeting_number)) { SDKError joinError = CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().Join(new JoinParam() { userType = SDKUserType.SDK_UT_APIUSER, apiuserJoin = new JoinParam4APIUser() { userName = "******", meetingNumber = uint_meeting_number, psw = string.Empty, hDirectShareAppWnd = new HWNDDotNet() { value = 0 }, isAudioOff = false, isDirectShareDesktop = false, isVideoOff = false, participantId = string.Empty, toke4enfrocelogin = string.Empty, webinarToken = string.Empty, } }); if (joinError == SDKError.SDKERR_SUCCESS) { MeetingView meetingView = new MeetingView(); meetingView.Show(); } else { MessageBox.Show(joinError.ToString()); } } else { JoinError = "请输入有效的课堂号!"; } }, Prism.Events.ThreadOption.PublisherThread, true, filter => { return(filter.Target == Target.JoinMeetingViewModel); }); }
private async void Load_Mission(object sender, RoutedEventArgs value) { var state = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).GetCurrentState(); WaypointMissionState.Text = state.ToString(); SDKError err = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).LoadMission(WaypointMission); //var WaypointMission2 = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).GetLoadedMission(); //else err = SDKError.MISSION_WAYPOINT_NULL_MISSION; Debug.WriteLine("SDK load mission : " + err.ToString()); LoadMissionError.Text = "SDK load mission : " + err.ToString(); }
public SDKError LoadMission(String json_mision) { JArray points = JArray.Parse(json_mision); int waypointCount = points.Count; double maxFlightSpeed = 15; // meters per second TODO double autoFlightSpeed = 10; // meters per second TODO int missionID = 0; //TODO List <Waypoint> waypoints = new List <Waypoint>(waypointCount); foreach (JObject point in points) { JObject coord = (JObject)point.SelectToken("coord"); JArray coordinates = (JArray)coord.SelectToken("coordinates"); double latitude = (double)coordinates.First[0]; double longitude = (double)coordinates.First[1]; double gimbalPitch = (double)point.SelectToken("angulo"); double speed = (double)point.SelectToken("velocidad"); // meters per second double altitude = (double)point.SelectToken("altura"); int stayTime = (int)point.SelectToken("tiempo"); int rotation = (int)point.SelectToken("rotacion"); waypoints.Add(InitWaypoint(latitude, longitude, altitude, gimbalPitch, speed, stayTime, rotation)); System.Diagnostics.Debug.WriteLine("lat {0}, lng {1})", latitude, longitude); } WaypointMission mission = new WaypointMission() { waypointCount = points.Count, maxFlightSpeed = maxFlightSpeed, autoFlightSpeed = autoFlightSpeed, finishedAction = WaypointMissionFinishedAction.GO_HOME, headingMode = WaypointMissionHeadingMode.AUTO, flightPathMode = WaypointMissionFlightPathMode.NORMAL, gotoFirstWaypointMode = WaypointMissionGotoFirstWaypointMode.SAFELY, exitMissionOnRCSignalLostEnabled = false, gimbalPitchRotationEnabled = true, repeatTimes = 1, missionID = missionID, waypoints = waypoints }; //LoadMission SDKError loadError = DJISDKManager.Instance.WaypointMissionManager.GetWaypointMissionHandler(0).LoadMission(mission); System.Diagnostics.Debug.WriteLine("LOAD MISSION: " + loadError.ToString()); return(loadError); }
//Callback of SDKRegistrationEvent private async void Instance_SDKRegistrationEvent(SDKRegistrationState state, SDKError resultCode) { if (resultCode == SDKError.NO_ERROR) { System.Diagnostics.Debug.WriteLine("Register app successfully."); setup(); } else { System.Diagnostics.Debug.WriteLine("SDK register failed, the error is: "); System.Diagnostics.Debug.WriteLine(resultCode.ToString()); } }
public static string DecodeSdkError(SDKError status) { switch (status) { case SDKError.SDKERR_SUCCESS: return("Success"); case SDKError.SDKERR_NO_IMPL: return("This feature is currently not available"); case SDKError.SDKERR_WRONG_USEAGE: return("Incorrect usage of the feature"); case SDKError.SDKERR_INVALID_PARAMETER: return("Wrong parameter"); case SDKError.SDKERR_MODULE_LOAD_FAILED: return("Loading module failed"); case SDKError.SDKERR_MEMORY_FAILED: return("No memory allocated"); case SDKError.SDKERR_SERVICE_FAILED: return("Internal service error"); case SDKError.SDKERR_UNINITIALIZE: return("SDK is not initialized before the use"); case SDKError.SDKERR_UNAUTHENTICATION: return("SDK is not authorized before the use"); case SDKError.SDKERR_NORECORDINGINPROCESS: return("No recording is in process"); case SDKError.SDKERR_TRANSCODER_NOFOUND: return("Transcoder module is not found"); case SDKError.SDKERR_VIDEO_NOTREADY: return("The video service is not ready"); case SDKError.SDKERR_NO_PERMISSION: return("No permission"); case SDKError.SDKERR_UNKNOWN: return("Unknown error"); case SDKError.SDKERR_OTHER_SDK_INSTANCE_RUNNING: return("Another SDK instance is in process"); case (SDKError)15: return("SDK internal error"); case (SDKError)16: return("No audio device is found"); case (SDKError)17: return("No video device is found"); case (SDKError)18: return("API calls too frequent"); case (SDKError)19: return("User cannot be assigned with the new privilege"); case (SDKError)20: return("The current meeting does not support the request feature"); } return("Unknown"); }
public FlightState(double altitude, double yaw, double pitch, double roll, double vx, double vy, double vz, bool isFlyging, SDKError error) { Altitude = altitude; Yaw = yaw; Pitch = pitch; Roll = roll; Vx = vx; Vy = vy; Vz = vz; IsFlying = isFlyging; Error = error; }
private void Connection_SDKRegistrationEvent(SDKRegistrationState state, SDKError resultCode) { if (resultCode == SDKError.NO_ERROR) { //System.Diagnostics.Debug.WriteLine("Register app successfully."); //The product connection state will be updated when it changes here. //DJISDKManager.Instance.ComponentManager.GetProductHandler(0).ProductTypeChanged += async delegate (object sender, ProductTypeMsg? value) DJISDKManager.Instance.ComponentManager.GetProductHandler(0).ProductTypeChanged += Connection_isProductTypeChangedEvent; } else { isRegisterErrorOccurredEvent("Register SDK failed, the error is: " + resultCode.ToString()); } }
private void OnSdkRegistrationStateChanged(SDKRegistrationState state, SDKError error) { _isSdkRegistered = SDKError.NO_ERROR == error && state == SDKRegistrationState.Succeeded; if (_isSdkRegistered) { _isWorkerEnabled = true; ConfigDroneAsync(); fcHandler = DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0); var videoFeeder = DJISDKManager.Instance.VideoFeeder.GetPrimaryVideoFeed(0); var cameraHandler = DJISDKManager.Instance.ComponentManager.GetCameraHandler(0, 0); if (null != videoFeeder) { VideoParser = new Parser(); VideoParser.Initialize((byte[] data) => { return(DJISDKManager.Instance.VideoFeeder.ParseAssitantDecodingInfo(0, data)); }); VideoParser.SetSurfaceAndVideoCallback(0, 0, null, OnFrameParsed); videoFeeder.VideoDataUpdated += Drone_VideoDataUpdated;; } if (null != cameraHandler) { var res = cameraHandler.GetCameraTypeAsync(); res.Wait(); if (res.Result.error == SDKError.NO_ERROR) { Drone_CameraTypeChanged(null, res.Result.value); } cameraHandler.CameraTypeChanged += Drone_CameraTypeChanged;; } } else { _isWorkerEnabled = false; fcHandler = null; } Thread.Sleep(300); }
private void Application_Startup(object sender, StartupEventArgs e) { //init sdk InitParam param = new InitParam { web_domain = "https://zoom.us", enable_log = true }; SDKError err = CZoomSDKeDotNetWrap.Instance.Initialize(param); if (SDKError.SDKERR_SUCCESS == err) { } else//error handle.todo { Console.WriteLine(err); } }
private async void StartReturnToHome() { SDKError err = await DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).StartGoHomeAsync(); Debug.WriteLine("RTH err : " + err.ToString()); UI_output(rth_status, "RTH err : " + err.ToString()); DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).GoHomeStateChanged += Check_RTHsequence; var RTHstate = await DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).GetGoHomeStateAsync(); Debug.WriteLine("RTH sequence : " + RTHstate.value?.value.ToString()); if (RTHstate.value?.value == FCGoHomeState.COMPLETED) { DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AltitudeChanged += RTH_Landing; DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).GoHomeStateChanged -= Check_RTHsequence; } }
private async void StartTakeOff() { SDKError err = await DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).StartTakeoffAsync(); Debug.WriteLine("Takeoff err : " + err.ToString()); UI_output(call_status, "Takeoff err : " + err.ToString()); /* * if (err == SDKError.NO_ERROR || err == SDKError.REQUEST_TIMEOUT) * { * DJISDKManager.Instance.VirtualRemoteController.UpdateJoystickValue(1, 0, 0, 0); * Thread.Sleep(5000); * DJISDKManager.Instance.VirtualRemoteController.UpdateJoystickValue(0, 0, 1, 0); * Thread.Sleep(2500); * DJISDKManager.Instance.VirtualRemoteController.UpdateJoystickValue(0, 0, 0, 0); * }*/ }
private async void StartStopMissionVideoRecord(object sender, WaypointMissionExecutionState?value) { if (value.Value.state == WaypointMissionExecuteState.INITIALIZING) { await SetCameraModeToRecord(); await StartRecordVideo(); } else if (value.Value.isExecutionFinish) { SDKError err = await StopRecordVideo(); if (err == SDKError.NO_ERROR) { OnVideoMissionRecorded(); } } }