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();
        }
        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();
        }
Example #3
0
        /// <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());
            }
        }
        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());
            }
        }
Example #5
0
        private void Instance_SDKRegistrationStateChanged(SDKRegistrationState state, SDKError errorCode)
        {
            if (errorCode == SDKError.NO_ERROR)
            {
                if (_componentMgr == null)
                {
                    this._componentMgr = DJISDKManager.Instance.ComponentManager;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).VelocityChanged         += DJIDrone_VelocityChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AttitudeChanged         += DJIDrone_AttitudeChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AltitudeChanged         += DJIDrone_AltitudeChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AircraftLocationChanged += DJIDrone_AircraftLocationChanged;
                    DJISDKManager.Instance.ComponentManager.GetBatteryHandler(0, 0).VoltageChanged  += DJIDrone_VoltageChanged;
                    DJISDKManager.Instance.ComponentManager.GetProductHandler(0).ProductTypeChanged += DJIDrone_ProductTypeChanged;
                }

                if (_mgr.Active == null)
                {
                    _mgr.SetActive(new Core.Models.ConnectedUas(this, new DJITransport(this)));
                }
                Debug.WriteLine("Product Registered");
            }
            else
            {
                Debug.WriteLine(errorCode.ToString());
            }
        }
Example #6
0
        //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());
            }
        }
        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 UserAccountManager_UserAccountStateChanged(UserAccountState state, SDKError error)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         accountState = state;
         operationResTextBlock.Text = error.ToString();
     });
 }
Example #10
0
        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);
        }
Example #11
0
        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);
        }
Example #12
0
        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);
        }
        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();
        }
Example #14
0
        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); });
        }
        //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());
            }
        }
Example #16
0
        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);
        }
Example #17
0
        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 async void Instance_SDKRegistrationEvent(SDKRegistrationState state, SDKError resultCode)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         if (state == SDKRegistrationState.Succeeded)
         {
             Debug.WriteLine("Activated.");
         }
         else
         {
             Debug.WriteLine("Not Activated.");
         }
         if (resultCode == SDKError.NO_ERROR)
         {
             Debug.WriteLine("Register success.");
             activateStateTextBlock.Text = "Register Success";
         }
         else
         {
             Debug.WriteLine(resultCode.ToString());
             activateStateTextBlock.Text = resultCode.ToString();
         }
     });
 }
Example #19
0
        private void SDKAuth()
        {
            SDKError err = SdkWrap.Instacne.SDKAuth(new AuthParam()
            {
                //appKey = "miUWGGznzyA9NvGE0mWaHxqH5K62jbQGf9Vi",
                //appSecret = "ktwJENTTfWGOlBOyvCOc81x5Ax4DFCU2lhCO",

                appKey    = "p3TojubkBYyntp8m4rVevr0yYmH1HVW9yPiR",
                appSecret = "JLuhz1VkcWGVSUESJj19biBi7NZcbVWENRXe",
            });

            if (err != SDKError.SDKERR_SUCCESS)
            {
                Logging = false;
                Err     = err.ToString();
            }
        }
        private async void Instance_SDKRegistrationEvent(SDKRegistrationState state, SDKError resultCode)
        {
            if (resultCode == SDKError.NO_ERROR)
            {
                Debug.WriteLine("Register app successfully.");
                DJISDKManager.Instance.ComponentManager.GetProductHandler(0).ProductTypeChanged += Get_Aircraft;
                DJISDKManager.Instance.ComponentManager.GetBatteryHandler(0, 0).ChargeRemainingInPercentChanged += Get_Battery;
                DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AltitudeChanged        += Get_Altitude;

                //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(CoreDispatcherPriority.Normal, () =>
                    {
                        if (value != null && value?.value != ProductType.UNRECOGNIZED)
                        {
                            Debug.WriteLine("The Aircraft is connected now.");
                            //You can load/display your pages according to the aircraft connection state here.
                        }
                        else
                        {
                            Debug.WriteLine("The Aircraft is disconnected now.");
                            //You can hide your pages according to the aircraft connection state here, or show the connection tips to the users.
                        }
                    });
                };

                //If you want to get the latest product connection state manually, you can use the following code
                var productType = (await DJISDKManager.Instance.ComponentManager.GetProductHandler(0).GetProductTypeAsync()).value;
                if (productType != null && productType?.value != ProductType.UNRECOGNIZED)
                {
                    Debug.WriteLine("The Aircraft is connected now.");
                    //You can load/display your pages according to the aircraft connection state here.
                }
            }
            else
            {
                Debug.WriteLine("Register SDK failed, the error is: ");
                Debug.WriteLine(resultCode.ToString());
            }
        }
Example #21
0
        private void Login()
        {
            LoginParam loginParam = new LoginParam()
            {
                loginType  = LoginType.LoginType_Email,
                emailLogin = new LoginParam4Email()
                {
                    bRememberMe = RememberPwd,
                    password    = Pwd,
                    userName    = UserName,
                }
            };

            SDKError error = SdkWrap.Instacne.Login(loginParam);

            if (error != SDKError.SDKERR_SUCCESS)
            {
                Logging = false;
                Err     = error.ToString();
            }
        }
        private void Instance_SDKRegistrationStateChanged(SDKRegistrationState state, SDKError errorCode)
        {
            if (errorCode == SDKError.NO_ERROR)
            {
                if (_componentMgr == null)
                {
                    this._componentMgr = DJISDKManager.Instance.ComponentManager;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).VelocityChanged                    += DJIDrone_VelocityChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AreMotorsOnChanged                 += DJIDrone_AreMotorsOnChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).CompassHasErrorChanged             += DJIDrone_CompassHasErrorChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).FlightTimeInSecondsChanged         += DJIDrone_FlightTimeInSecondsChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).IsLowBatteryWarningChanged         += DJIDrone_IsLowBatteryWarningChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AttitudeChanged                    += DJIDrone_AttitudeChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).IsSeriousLowBatteryWarningChanged  += DJIDrone_IsSeriousLowBatteryWarningChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AttitudeChanged                    += DJIDrone_AttitudeChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).IsFlyingChanged                    += DJIDrone_IsFlyingChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AltitudeChanged                    += DJIDrone_AltitudeChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).AircraftLocationChanged            += DJIDrone_AircraftLocationChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).SatelliteCountChanged              += DJIDrone_SatelliteCountChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).GPSSignalLevelChanged              += DJIDrone_GPSSignalLevelChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).RemainingFlightTimeChanged         += DJIDrone_RemainingFlightTimeChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightControllerHandler(0, 0).IsLandingConfirmationNeededChanged += DJIDrone_IsLandingConfirmationNeededChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).IsAscentLimitedByObstacleChanged    += DJIDrone_IsAscentLimitedByObstacleChanged;
                    DJISDKManager.Instance.ComponentManager.GetFlightAssistantHandler(0, 0).VissionDetectionStateChanged        += DJIDrone_VissionDetectionStateChanged;

                    DJISDKManager.Instance.ComponentManager.GetBatteryHandler(0, 0).VoltageChanged += DJIDrone_VoltageChanged;
                    DJISDKManager.Instance.ComponentManager.GetBatteryHandler(0, 0).ChargeRemainingInPercentChanged += DJIDrone_ChargeRemainingInPercentChanged;

                    DJISDKManager.Instance.ComponentManager.GetProductHandler(0).ProductTypeChanged += DJIDrone_ProductTypeChanged;
                }
            }
            else
            {
                Debug.WriteLine("REG: " + errorCode.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();
     });
 }
Example #24
0
 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());
     });
 }
Example #25
0
        private void InitData()
        {
            JoinCommand = new DelegateCommand <CourseModel>((course) =>
            {
                ulong uint_meeting_number;
                if (!ulong.TryParse(course.MeetingNumber, out uint_meeting_number))
                {
                    MessageBox.Show("无效的课堂号!");
                    return;
                }
                ;

                if (course.HostId == App.UserModel.UserName)
                {
                    CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().Add_CB_onLoginRet((loginStatus, accountInfo) =>
                    {
                        switch (loginStatus)
                        {
                        case LOGINSTATUS.LOGIN_IDLE:
                            break;

                        case LOGINSTATUS.LOGIN_PROCESSING:
                            break;

                        case LOGINSTATUS.LOGIN_SUCCESS:

                            SDKError joinError = CZoomSDKeDotNetWrap.Instance.GetMeetingServiceWrap().Join(new JoinParam()
                            {
                                userType       = SDKUserType.SDK_UT_NORMALUSER,
                                normaluserJoin = new JoinParam4NormalUser()
                                {
                                    hDirectShareAppWnd = new HWNDDotNet()
                                    {
                                        value = 0
                                    },
                                    isAudioOff           = false,
                                    isDirectShareDesktop = false,
                                    isVideoOff           = false,
                                    meetingNumber        = uint_meeting_number,
                                    participantId        = string.Empty,
                                    psw          = string.Empty,
                                    userName     = "******",
                                    webinarToken = string.Empty,
                                }
                            });

                            if (joinError == SDKError.SDKERR_SUCCESS)
                            {
                                MeetingView meetingView = new MeetingView();
                                meetingView.Show();
                            }
                            else
                            {
                                MessageBox.Show(joinError.ToString());
                            }



                            break;

                        case LOGINSTATUS.LOGIN_FAILED:
                            break;

                        default:
                            break;
                        }
                    });

                    SDKError loginError = CZoomSDKeDotNetWrap.Instance.GetAuthServiceWrap().Login(new LoginParam()
                    {
                        loginType  = LoginType.LoginType_Email,
                        emailLogin = new LoginParam4Email()
                        {
                            bRememberMe = true,
                            password    = "******",
                            userName    = course.HostId,
                        }
                    });
                }
                else
                {
                    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());
                    }
                }
            });

            CourseList = new ObservableCollection <CourseModel>();
            CourseList.Add(new CourseModel()
            {
                Duration      = "8:00 - 9:00",
                Name          = "语文",
                TeacherName   = "马云",
                MeetingNumber = "286683782",
                HostId        = "*****@*****.**",
                JoinCommand   = JoinCommand,
            });
            CourseList.Add(new CourseModel()
            {
                Duration      = "11:00 - 12:00",
                Name          = "数学",
                TeacherName   = "刘强东",
                MeetingNumber = "286683782",
                HostId        = "*****@*****.**",
                JoinCommand   = JoinCommand,
            });
            CourseList.Add(new CourseModel()
            {
                Duration      = "14:00 - 15:00",
                Name          = "生物",
                TeacherName   = "李海波",
                MeetingNumber = "286683782",
                HostId        = "*****@*****.**",
                JoinCommand   = JoinCommand,
            });
        }
Example #26
0
        private void SubscribeEvents()
        {
            _cardSelectedToken = EventAggregatorManager.Instance.EventAggregator.GetEvent <CardSelectedEvent>().Subscribe((argument) =>
            {
                switch (argument.Argument.Category)
                {
                case Category.MainCard:
                    IsMainCardSelected    = true;
                    IsHistoryCardSelected = false;
                    break;

                case Category.HistoryCard:
                    IsMainCardSelected    = false;
                    IsHistoryCardSelected = true;
                    break;
                }
            }, ThreadOption.PublisherThread, true, filter => { return(filter.Target == Target.MainViewModel); });


            _startClassToken = EventAggregatorManager.Instance.EventAggregator.GetEvent <StartClassEvent>().Subscribe((argument) =>
            {
                RegisterCallbacks();

                CustomMeetingUI();

                StartHook();


                StartParam startParam = new StartParam()
                {
                    userType = SDKUserType.SDK_UT_NORMALUSER,
                };

                //StartParam4APIUser apiuserStart = new StartParam4APIUser()
                //{
                //    userID = "704311",
                //    userToken = "Izi6atSDBiwtIqk3GQX9txjxjj8SZLIa6s7v",
                //    userName = "******",
                //    meetingNumber = 3398415968,

                //};

                StartParam4NormalUser normalUser = new StartParam4NormalUser()
                {
                    meetingNumber = 3398415968,
                };

                startParam.normaluserStart = normalUser;



                SDKError error = SdkWrap.Instacne.Start(startParam);

                if (error == SDKError.SDKERR_SUCCESS)
                {
                    EventAggregatorManager.Instance.EventAggregator.GetEvent <WindowHideEvent>().Publish(new EventArgument()
                    {
                        Target = Target.MainView,
                    });

                    _meetingView = new MeetingView();
                    _meetingView.Show();
                }
                else
                {
                    MessageBox.Show(error.ToString());
                }
            }, ThreadOption.PublisherThread, true, filter => { return(filter.Target == Target.MainViewModel); });
        }
Example #27
0
        public async void OnSocketDataReceivedAsync(Stream clientStream, String message)
        {
            System.Diagnostics.Debug.WriteLine("MESSAGE RECEIVED: OnSocketDataReceivedAsync print: {0}", message);

            // {"COMMAND": 'GET_LOCATION',
            //  "COMMAND_TYPE": 'TELEMETRY',
            //  "COMMAND_INFO": "NONE",
            // }

            JObject messageObject = null;

            try
            {
                messageObject = JObject.Parse(message);
            }
            catch (Newtonsoft.Json.JsonException e)
            {
                sendStringMessageToClient(clientStream, buildResponse(false, "JSON_PARSE_ERROR", null));
                System.Diagnostics.Debug.WriteLine("JSON PARSE ERROR: OnSocketDataReceivedAsync print {0}", e.ToString());
                return;
            }


            string command     = (string)messageObject.SelectToken("COMMAND");
            string commandTpye = (string)messageObject.SelectToken("COMMAND_TYPE");

            string  resultCode   = null;
            JObject dataToClient = null;

            if (commandTpye.Equals("MISSION"))
            {
                if (command.Equals("SET_PRECISION_LANDING"))
                {
                    SDKError err = await DJIComponentManager.Instance.SetPrecisionLanding(true); //TODO use command_info to set false too

                    resultCode = err.ToString();
                }
                else if (command.Equals("SET_GSME"))
                {
                    SDKError err = await DJIComponentManager.Instance.SetGroundStationModeEnabled(true); //TODO use command_info to set false too

                    resultCode = err.ToString();
                }
                else if (command.Equals("LOAD_MISSION"))
                {
                    JArray   infoCommand = (JArray)messageObject.SelectToken("COMMAND_INFO");
                    SDKError err         = DJIMissionManager.Instance.LoadMission(infoCommand.ToString());
                    resultCode = err.ToString();
                }
                if (command.Equals("UPLOAD_MISSION"))
                {
                    SDKError err = await DJIMissionManager.Instance.UploadMission();

                    resultCode = err.ToString();
                }
                else if (command.Equals("START_MISSION"))
                {
                    SDKError err = await DJIMissionManager.Instance.StartMission();

                    resultCode = err.ToString();
                }
                else if (command.Equals("GET_MISSION_STATE"))
                {
                    resultCode = SDKError.NO_ERROR.ToString();
                    dynamic jsonObject = new JObject();
                    jsonObject.MISSION_STATE = DJIMissionManager.Instance.WaypointMissionCurrentState(); //make an object
                    dataToClient             = jsonObject;
                }
            }
            else if (commandTpye.Equals("TELEMETRY"))
            {
                if (command.Equals("GET_LOCATION"))
                {
                    if (await DJIComponentManager.Instance.AircraftConnected())
                    {
                        dynamic jsonObject = new JObject();
                        jsonObject.latitude  = DJIComponentManager.Instance.AircraftLocation.latitude;
                        jsonObject.longitude = DJIComponentManager.Instance.AircraftLocation.longitude;
                        jsonObject.altitude  = DJIComponentManager.Instance.AircraftAltitude;
                        //String jsonString = JsonConvert.SerializeObject(jsonObject);
                        resultCode   = SDKError.NO_ERROR.ToString();
                        dataToClient = jsonObject;
                    }
                    else
                    {
                        resultCode = SDKError.DISCONNECTED.ToString();
                    }
                }
            }
            else if (commandTpye.Equals("VIDEO_STREAMING"))
            {
                if (command.Equals("START_VIDEO_STREAMING"))
                {
                    DJIVideoManager.Instance.InitializeVideoFeedModule();
                    resultCode = SDKError.NO_ERROR.ToString(); //TODO
                }
                else if (command.Equals("STOP_VIDEO_STREAMING"))
                {
                    DJIVideoManager.Instance.UninitializeVideoFeedModule();
                    resultCode = SDKError.NO_ERROR.ToString();//TODO
                }
                else if (command.Equals("RESTART_VIDEO_STREAMING"))
                {
                    DJIVideoManager.Instance.UninitializeVideoFeedModule();
                    DJIVideoManager.Instance.InitializeVideoFeedModule();
                    resultCode = SDKError.NO_ERROR.ToString();//TODO
                }
                else if (command.Equals("ESTABLISH_CONNECTION"))
                {
                    DJIVideoManager.Instance.videoClient = clientStream; //set a video stream client
                    resultCode = SDKError.NO_ERROR.ToString();           //TODO
                }
            }
            else if (commandTpye.Equals("GIMBAL"))
            {
                if (command.Equals("ROTATE_GIMBAL"))
                {
                    double  factor      = 15.0;
                    JObject infoCommand = (JObject)messageObject.SelectToken("COMMAND_INFO");
                    double  pitch       = (double)infoCommand.SelectToken("y");
                    double  roll        = 0.0; //(double)infoCommand.SelectToken("roll");
                    double  yaw         = (double)infoCommand.SelectToken("x");
                    double  duration    = 1;   //(double)infoCommand.SelectToken("duration");
                    System.Diagnostics.Debug.WriteLine("mensaje");
                    SDKError err = await DJIComponentManager.Instance.RotateGimbalByAngle(pitch *factor, roll *factor, yaw *factor, duration);

                    resultCode = err.ToString();
                }
            }
            else if (commandTpye.Equals("VIRTUAL_CONTROLLER"))
            {
                //TODO
            }

            sendStringMessageToClient(clientStream, buildResponse(resultCode == SDKError.NO_ERROR.ToString(), resultCode, dataToClient));
        }
Example #28
0
        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);
        }
Example #29
0
        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);
        }