/// <summary>
        /// Updates the UI controller based on the device status.
        /// </summary>
        /// <returns>Whether the action was completed.</returns>
        private bool ProcessRecovery()
        {
            DeviceStatusSnapshot snapshot = _deviceStatusSnapshotRetrievalStrategy();

            if (snapshot.DeviceStreamingProperly())
            {
                _controller.ChangeMessage(string.Empty);
                _controller.SetTitleVisibility(false);
                return(true);
            }

            if (snapshot.StatusOfConnection != ConnectionStatus.CONNECTED)
            {
                _controller.ChangeMessage(HeadsetDisconnectedMessage);
                _controller.SetTitleVisibility(true);
                _recoverySequenceFailed = true;
                return(true);
            }

            bool allImportantSensorsExceptDepthWorking = (snapshot.StreamStatusMask ^ (~(int)SensorStream.DEPTH)
                                                          & DeviceStatusSnapshot.ImportantStreamMask) == DeviceStatusSnapshot.ImportantStreamMask;

            if (allImportantSensorsExceptDepthWorking)
            {
                _controller.ChangeMessage(DepthSensorNotWorkingMessage);
                _controller.SetTitleVisibility(true);
                _recoverySequenceFailed = true;
                return(true);
            }

            return(false);
        }
        private string GetSpecificSensorFailureMessage()
        {
            DeviceStatusSnapshot snapshot = _deviceStatusSnapshotRetrievalStrategy();
            string error = string.Format("Error: ( {0} | {1} | {2} )", snapshot.StreamStatusMask, snapshot.StatusOfConnection, snapshot.StatusOfDevice);

            return(SensorMessage + "\n" + error);
        }
示例#3
0
        private void ScanDevMgr_DeviceStatusChanged(object sender, DeviceStatusChangedEventArgs e)
        {
            DeviceStatusSnapshot status = ScanDeviceController.Instance.GetDeviceStatusSnapshot(macAddress);

            if (status.ConnectionStatus == ConnectionStatus.Connected)
            {
                ScanStart(GetLineScript(10, 2, 1.2, 3.0, 2.0, 5.0));
            }
        }
 public override bool Equals(object obj)
 {
     if (obj is DeviceStatusSnapshot)
     {
         DeviceStatusSnapshot otherStatus = (DeviceStatusSnapshot)obj;
         return(otherStatus.StatusOfConnection == StatusOfConnection &&
                otherStatus.StatusOfDevice == StatusOfDevice &&
                otherStatus.StreamStatusMask == StreamStatusMask);
     }
     return(false);
 }
示例#5
0
 public void Close()
 {
     string[] deviceList = _scanDevMgr.GetDeviceList();
     foreach (string unique in deviceList)
     {
         DeviceStatusSnapshot status = _scanDevMgr.GetDeviceStatusSnapshot(unique);
         if (status.ConnectionStatus == ConnectionStatus.Connected)
         {
             _scanDevMgr.Disconnect(unique);
         }
     }
 }
示例#6
0
 public bool IsConnect()
 {
     if (!string.IsNullOrEmpty(this.macAddress))
     {
         DeviceStatusSnapshot status = ScanDeviceController.Instance.GetDeviceStatusSnapshot(this.macAddress);
         if (status.ConnectionStatus == ConnectionStatus.Connected)
         {
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// Check the sensors for a number of times at a given interval.
        /// </summary>
        /// <param name="numberOfChecks">number of times to check</param>
        /// <param name="checkIntervalSeconds">interval to wait in seconds.</param>
        /// <returns></returns>
        private IEnumerator CheckSensorFrequently(int numberOfChecks, float checkIntervalSeconds)
        {
            for (int i = 0; i < numberOfChecks; ++i)
            {
                DeviceStatusSnapshot snapshot = _deviceStatusSnapshotRetrievalStrategy();
                if (snapshot.DeviceStreamingProperly() && snapshot.StatusOfConnection == ConnectionStatus.CONNECTED)
                {
                    yield break;
                }

                yield return(new WaitForSeconds(checkIntervalSeconds));
            }
        }