Ejemplo n.º 1
0
        static async Task Main()
        {
            CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
            locationProvider           = new LocationTracker();
            var min = new LocationDTO {
                Longitude = -10, Latitude = -10
            };
            var max = new LocationDTO {
                Longitude = 10, Latitude = 10
            };

            locationReporter = new LocationReporter(Mapper.Map(min), Mapper.Map(max));

            locationReporter.Subscribe(locationProvider,
                                       Console.WriteLine,
                                       (x) => Console.WriteLine(x.Message),
                                       (x) => { },
                                       TurnOffAll,
                                       TurnOnAll
                                       );
            deviceProvider = new DeviceTracker();
            deviceReporter = new DeviceReporter();
            deviceReporter.Subscribe(deviceProvider,
                                     Console.WriteLine,
                                     (x) => Console.WriteLine(x.Message),
                                     (x) => { _ = CurrentConnection.SendAsync(MessageParser.CreateMessage("OnNext", x, x.GetType().Name)); }
                                     );
            await CreateServer();
        }
        static DeviceSelectorViewModel()
        {
            void InitAndTrack()
            {
                ThreadPool.QueueUserWorkItem(cb => {
                    var res = DeviceManager.Init(err => {
                        Logger.WriteLine($"{nameof(AdbViewerViewModel)}->{err.Code}:{err.Message}");
                    });

                    if (res)
                    {
                        //部署设备检测器;
                        if (_deviceTracker == null)
                        {
                            _deviceTracker = new DeviceTracker();
                            _deviceTracker.BeginTrackDevices(devices => {
                                _trackedDevices = devices;
                                PopTrackDevices();
                                //若静态常量为空,则不设置;
                                if (_devSelectorVM != null)
                                {
                                    _devSelectorVM.PopupDevices(devices);
                                }
                            }, err => {
                                InitAndTrack();
                                MsgBoxService.ShowError($"{LanguageService.FindResourceString("FailedToDetectAdbDevices")}:" + err.Message);
                            });
                        }
                    }
                });
            };
            InitAndTrack();
        }
 private void DisableCameraIfNotNeeded()
 {
     if (this.mEyewearBehaviour.GetEyewearType() != DigitalEyewearARController.EyewearType.OpticalSeeThrough && !this.mVideoBackgroundMgr.VideoBackgroundEnabled)
     {
         bool          flag    = false;
         bool          flag2   = false;
         DeviceTracker tracker = TrackerManager.Instance.GetTracker <DeviceTracker>();
         if (tracker != null)
         {
             flag = tracker.IsActive;
         }
         if (this.mEyewearBehaviour.GetEyewearType() == DigitalEyewearARController.EyewearType.VideoSeeThrough && this.mEyewearBehaviour.GetStereoCameraConfig() != DigitalEyewearARController.StereoFramework.Vuforia)
         {
             flag2 = true;
         }
         if (flag | flag2)
         {
             Debug.Log("Vuforia is configured for VR, checking if the camera and default trackers can be stopped...");
             bool flag3;
             bool arg_74_0 = VuforiaRuntimeUtilities.StopCameraIfPossible(out flag3);
             if (flag3)
             {
                 Debug.Log("VuforiaBehaviour: The ObjectTracker was disabled because it is not in use.");
             }
             if (arg_74_0)
             {
                 Debug.Log("VuforiaBehaviour: The Camera was stopped because it is not in use.");
             }
         }
     }
 }
        public override T InitTracker <T>()
        {
            if (!VuforiaRuntimeUtilities.IsVuforiaEnabled())
            {
                return(default(T));
            }
            bool flag = true;

            if (VuforiaRuntimeUtilities.IsPlayMode() && (typeof(T) == typeof(DeviceTracker) || typeof(T) == typeof(RotationalDeviceTracker)))
            {
                flag = false;
            }
            if (flag && VuforiaWrapper.Instance.TrackerManagerInitTracker((int)TypeMapping.GetTypeID(typeof(T))) == 0)
            {
                Debug.LogError("Could not initialize the tracker.");
                return(default(T));
            }
            if (typeof(T) == typeof(ObjectTracker))
            {
                if (this.mObjectTracker == null)
                {
                    this.mObjectTracker = new ObjectTrackerImpl();
                }
                return(this.mObjectTracker as T);
            }
            if (typeof(T) == typeof(TextTracker))
            {
                if (this.mTextTracker == null)
                {
                    this.mTextTracker = new TextTrackerImpl();
                }
                return(this.mTextTracker as T);
            }
            if (typeof(T) == typeof(SmartTerrainTracker))
            {
                if (this.mSmartTerrainTracker == null)
                {
                    this.mSmartTerrainTracker = new SmartTerrainTrackerImpl();
                }
                return(this.mSmartTerrainTracker as T);
            }
            if (typeof(T) == typeof(DeviceTracker) || typeof(T) == typeof(RotationalDeviceTracker))
            {
                if (this.mDeviceTracker == null)
                {
                    if (VuforiaRuntimeUtilities.IsPlayMode())
                    {
                        this.mDeviceTracker = new RotationalPlayModeDeviceTrackerImpl();
                    }
                    else
                    {
                        this.mDeviceTracker = new RotationalDeviceTrackerImpl();
                    }
                }
                return(this.mDeviceTracker as T);
            }
            Debug.LogError("Could not initialize tracker. Unknown tracker type.");
            return(default(T));
        }
Ejemplo n.º 5
0
        private void StopDeviceTracker()
        {
            DeviceTracker tracker = TrackerManager.Instance.GetTracker <DeviceTracker>();

            if (tracker != null && tracker.IsActive)
            {
                tracker.Stop();
            }
        }
Ejemplo n.º 6
0
    public void TrackerRefresh()
    {
        DeviceTracker _deviceTracker = GetComponent <DeviceTracker>();

        if (_deviceTracker != null)
        {
            _deviceTracker.Refresh();
        }
    }
Ejemplo n.º 7
0
    public void RefreshTracker()
    {
        DeviceTracker dt = GetComponent <DeviceTracker> ();

        if (dt != null)
        {
            dt.Refresh();
        }
    }
Ejemplo n.º 8
0
        public void RegisterTrackerStartedCallback(Action callback)
        {
            this.mTrackerStarted = (Action)Delegate.Combine(this.mTrackerStarted, callback);
            DeviceTracker tracker = TrackerManager.Instance.GetTracker <DeviceTracker>();

            if (tracker != null && tracker.IsActive)
            {
                callback();
            }
        }
Ejemplo n.º 9
0
        private void StopDeviceTracker()
        {
            Debug.Log("Stopping Device Tracker");
            DeviceTracker tracker = TrackerManager.Instance.GetTracker <DeviceTracker>();

            if (tracker != null)
            {
                tracker.Stop();
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 获取设备列表
        /// </summary>
        public static List <Device> GetDevices(Action <ErrorResult> error)
        {
            var devices = new List <Device>();
            var track   = new DeviceTracker();

            track.GetDevices(list =>
            {
                devices = list;
            }, error);
            return(devices);
        }
        protected override void OnDestroy()
        {
            ((StateManagerImpl)TrackerManager.Instance.GetStateManager()).ClearTrackableBehaviours();
            ObjectTracker tracker = TrackerManager.Instance.GetTracker <ObjectTracker>();

            if (tracker != null)
            {
                tracker.DestroyAllDataSets(false);
                tracker.Stop();
            }
            TextTracker tracker2 = TrackerManager.Instance.GetTracker <TextTracker>();

            if (tracker2 != null)
            {
                tracker2.Stop();
            }
            SmartTerrainTracker tracker3 = TrackerManager.Instance.GetTracker <SmartTerrainTracker>();

            if (tracker3 != null)
            {
                tracker3.Stop();
            }
            DeviceTracker tracker4 = TrackerManager.Instance.GetTracker <DeviceTracker>();

            if (tracker4 != null)
            {
                tracker4.Stop();
            }
            VuforiaManager.Instance.Deinit();
            if (tracker != null)
            {
                TrackerManager.Instance.DeinitTracker <ObjectTracker>();
            }
            if (tracker2 != null)
            {
                TrackerManager.Instance.DeinitTracker <TextTracker>();
            }
            if (tracker3 != null)
            {
                tracker3.SmartTerrainBuilder.Deinit();
                TrackerManager.Instance.DeinitTracker <SmartTerrainTracker>();
            }
            if (tracker4 != null)
            {
                TrackerManager.Instance.DeinitTracker <DeviceTracker>();
            }
            this.mHasStartedOnce = false;
            if (this.mOnVuforiaDeinitialized != null)
            {
                this.mOnVuforiaDeinitialized.InvokeWithExceptionHandling();
            }
        }
Ejemplo n.º 12
0
 protected virtual void Start()
 {
     m_DeviceTracker        = TrackerManager.Instance.InitTracker <PositionalDeviceTracker>();
     m_InsManager           = FindObjectOfType <InstructionManager>();
     m_SceneController      = FindObjectOfType <SceneController>();
     m_ImageTargetBehaviour = GetComponent <ImageTargetBehaviour>();
     mTrackableBehaviour    = GetComponent <TrackableBehaviour>();
     if (mTrackableBehaviour)
     {
         mTrackableBehaviour.RegisterTrackableEventHandler(this);
     }
     mainObstacle = GameObject.FindGameObjectWithTag("Obstacle");
 }
Ejemplo n.º 13
0
        protected override void OnDisable()
        {
            DeviceTracker tracker = TrackerManager.Instance.GetTracker <DeviceTracker>();

            if (tracker != null)
            {
                this.mTrackerWasActiveBeforeDisabling = tracker.IsActive;
                if (tracker.IsActive)
                {
                    this.StopDeviceTracker();
                }
            }
        }
Ejemplo n.º 14
0
        private void StartDeviceTracker()
        {
            Debug.Log("Starting Device Tracker");
            DeviceTracker tracker = TrackerManager.Instance.GetTracker <DeviceTracker>();

            if (tracker != null)
            {
                tracker.Start();
                if (this.mTrackerStarted != null)
                {
                    this.mTrackerStarted.InvokeWithExceptionHandling();
                }
            }
        }
Ejemplo n.º 15
0
        internal void OnPause(bool pause)
        {
            DeviceTracker tracker = TrackerManager.Instance.GetTracker <DeviceTracker>();

            if (tracker != null)
            {
                if (pause)
                {
                    this.mTrackerWasActiveBeforePause = tracker.IsActive;
                    if (tracker.IsActive)
                    {
                        this.StopDeviceTracker();
                        return;
                    }
                }
                else if (this.mTrackerWasActiveBeforePause)
                {
                    this.StartDeviceTracker();
                }
            }
        }
        public override bool DeinitTracker <T>()
        {
            bool flag = true;

            if (VuforiaRuntimeUtilities.IsPlayMode() && (typeof(T) == typeof(DeviceTracker) || typeof(T) == typeof(RotationalDeviceTracker)))
            {
                flag = false;
            }
            if (flag && VuforiaWrapper.Instance.TrackerManagerDeinitTracker((int)TypeMapping.GetTypeID(typeof(T))) == 0)
            {
                Debug.LogError("Could not deinitialize the tracker.");
                return(false);
            }
            if (typeof(T) == typeof(ObjectTracker))
            {
                this.mObjectTracker = null;
            }
            else if (typeof(T) == typeof(TextTracker))
            {
                this.mTextTracker = null;
            }
            else if (typeof(T) == typeof(SmartTerrainTracker))
            {
                this.mSmartTerrainTracker = null;
            }
            else
            {
                if (typeof(T) != typeof(DeviceTracker) && typeof(T) != typeof(RotationalDeviceTracker))
                {
                    Debug.LogError("Could not deinitialize tracker. Unknown tracker type.");
                    return(false);
                }
                this.mDeviceTracker = null;
            }
            return(true);
        }
Ejemplo n.º 17
0
 /// <summary>
 ///  监控Android设备的连接与断开
 /// </summary>
 /// <param name="handler"></param>
 /// <param name="error"></param>
 public static void TrackDevices(Action <List <Device> > handler, Action <ErrorResult> error)
 {
     tracker = new DeviceTracker();
     tracker.BeginTrackDevices(handler, error);
 }