/// <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); }
/// <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)); } }