protected void ConnectButtonGUI(string targetIpString, DeviceInfoObserver remoteDevice) { string tooltip = string.Empty; IPAddress targetIp; bool validAddress = ParseAddress(targetIpString, out targetIp); if (remoteDevice == null) { tooltip = $"{nameof(HolographicCameraObserver)} is missing from the scene."; } else if (!Application.isPlaying) { tooltip = "The scene must be in play mode to connect."; } else if (!validAddress) { tooltip = "The IP address for the remote device is not valid."; } GUI.enabled = validAddress && Application.isPlaying && remoteDevice != null; string label = remoteDevice != null && remoteDevice.NetworkManager != null && remoteDevice.NetworkManager.IsConnecting ? "Disconnect" : "Connect"; if (GUILayout.Button(new GUIContent(label, tooltip), GUILayout.Width(connectAndDisconnectButtonWidth)) && remoteDevice != null) { if (remoteDevice.NetworkManager.IsConnecting) { remoteDevice.NetworkManager.Disconnect(); } else { remoteDevice.NetworkManager.ConnectTo(targetIpString); } } GUI.enabled = true; }
private void NetworkConnectionGUI() { EditorGUILayout.BeginHorizontal(); { DeviceInfoObserver stateSynchronizationDevice = null; if (StateSynchronizationObserver.IsInitialized) { stateSynchronizationDevice = StateSynchronizationObserver.Instance.GetComponent <DeviceInfoObserver>(); } DeviceInfoObserver holographicCameraDevice = GetHolographicCameraDevice(); HolographicCameraNetworkConnectionGUI( AppDeviceTypeLabel, stateSynchronizationDevice, GetSpatialCoordinateSystemParticipant(stateSynchronizationDevice), showCalibrationStatus: false, showSpatialLocalization: true, ref appIPAddress); HolographicCameraNetworkConnectionGUI( HolographicCameraDeviceTypeLabel, holographicCameraDevice, GetSpatialCoordinateSystemParticipant(holographicCameraDevice), showCalibrationStatus: true, showSpatialLocalization: true, ref holographicCameraIPAddress); } EditorGUILayout.EndHorizontal(); }
private void UpdatePerformanceInformation() { DeviceInfoObserver stateSynchronizationDevice = null; if (StateSynchronizationObserver.IsInitialized) { stateSynchronizationDevice = StateSynchronizationObserver.Instance.GetComponent <DeviceInfoObserver>(); } HolographicCameraNetworkConnectionGUI( AppDeviceTypeLabel, stateSynchronizationDevice, GetSpatialCoordinateSystemParticipant(stateSynchronizationDevice), showCalibrationStatus: false, showSpatialLocalization: false, ref appIPAddress); if (StateSynchronizationObserver.Instance.PerformanceFeatureCount == 0) { RenderTitle("Waiting for performance information...", Color.yellow); } else { RenderTitle("HoloLens application performance information", Color.green); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); IReadOnlyList <double> times = StateSynchronizationObserver.Instance.AverageTimePerFeature; for (int i = 0; i < times.Count; i++) { double time = times[i]; GUILayout.Label($"Feature {(StateSynchronizationPerformanceFeature)i}:{time.ToString("G4")}"); } EditorGUILayout.EndScrollView(); } }
private void UpdatePerformanceInformation() { DeviceInfoObserver stateSynchronizationDevice = null; if (StateSynchronizationObserver.IsInitialized) { stateSynchronizationDevice = StateSynchronizationObserver.Instance.GetComponent <DeviceInfoObserver>(); } HolographicCameraNetworkConnectionGUI( AppDeviceTypeLabel, stateSynchronizationDevice, GetSpatialCoordinateSystemParticipant(stateSynchronizationDevice), showCalibrationStatus: false, showSpatialLocalization: false, ref appIPAddress); RenderTitle("HoloLens application performance information", Color.green); GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Enable Performance Monitoring", "Turns on performance monitoring mode for the attached HoloLens."))) { StateSynchronizationObserver.Instance.SetPerformanceMonitoringMode(true); } if (GUILayout.Button(new GUIContent("Disable Performance Monitoring", "Turns off performance diagnostic mode for the attached HoloLens."))) { StateSynchronizationObserver.Instance.SetPerformanceMonitoringMode(false); } GUILayout.EndHorizontal(); scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition); GUILayout.Label($"Performance Monitoring Enabled:{StateSynchronizationObserver.Instance.PerformanceMonitoringModeEnabled}"); if (StateSynchronizationObserver.Instance.PerformanceMonitoringModeEnabled) { if (StateSynchronizationObserver.Instance.PerformanceEventDurations != null) { RenderTitle("Event Durations (ms per frame)", Color.green); foreach (var duration in StateSynchronizationObserver.Instance.PerformanceEventDurations) { GUILayout.Label($"{duration.Item1}:{duration.Item2.ToString("G4")}"); } } if (StateSynchronizationObserver.Instance.PerformanceEventCounts != null) { GUILayout.Space(defaultSpacing); RenderTitle("Event Counts (per frame)", Color.green); foreach (var count in StateSynchronizationObserver.Instance.PerformanceEventCounts) { GUILayout.Label($"{count.Item1}:{count.Item2}"); } } } EditorGUILayout.EndScrollView(); }
protected void ConnectionStatusGUI(DeviceInfoObserver deviceInfo, ref string ipAddressField) { GUIStyle boldLabelStyle = new GUIStyle(GUI.skin.label); boldLabelStyle.fontStyle = FontStyle.Bold; if (deviceInfo != null && deviceInfo.NetworkManager != null && deviceInfo.NetworkManager.IsConnected) { GUILayout.BeginHorizontal(); { GUILayout.Label("Connection status", boldLabelStyle); if (GUILayout.Button(new GUIContent("Disconnect", "Disconnects the network connection to the holographic camera."), GUILayout.Width(connectAndDisconnectButtonWidth))) { deviceInfo.NetworkManager.Disconnect(); } } GUILayout.EndHorizontal(); if (deviceInfo.NetworkManager.ConnectedIPAddress == deviceInfo.DeviceIPAddress) { GUILayout.Label($"Connected to {deviceInfo.DeviceName} ({deviceInfo.DeviceIPAddress})"); } else { GUILayout.Label($"Connected to {deviceInfo.DeviceName} ({deviceInfo.NetworkManager.ConnectedIPAddress} -> {deviceInfo.DeviceIPAddress})"); } EditorGUILayout.Space(); } else { GUILayout.BeginHorizontal(); { ipAddressField = EditorGUILayout.TextField(ipAddressField); ConnectButtonGUI(ipAddressField, deviceInfo); } GUILayout.EndHorizontal(); GUILayout.Label(notConnectedMessage); EditorGUILayout.Space(); } }
protected void HolographicCameraNetworkConnectionGUI(string deviceTypeLabel, DeviceInfoObserver deviceInfo, SpatialCoordinateSystemParticipant spatialCoordinateSystemParticipant, bool showCalibrationStatus, bool showSpatialLocalization, ref string ipAddressField) { GUIStyle boldLabelStyle = new GUIStyle(GUI.skin.label); boldLabelStyle.fontStyle = FontStyle.Bold; CompositionManager compositionManager = GetCompositionManager(); EditorGUILayout.BeginVertical("Box"); { Color titleColor; if (deviceInfo != null && deviceInfo.NetworkManager != null && deviceInfo.NetworkManager.IsConnected && spatialCoordinateSystemParticipant != null && spatialCoordinateSystemParticipant.PeerDeviceTrackingState == TrackingState.Tracking && spatialCoordinateSystemParticipant.PeerSpatialCoordinateIsLocated && !spatialCoordinateSystemParticipant.PeerIsLocatingSpatialCoordinate && !deviceInfo.IsTrackingStalled && (!showCalibrationStatus || (compositionManager != null && compositionManager.IsCalibrationDataLoaded))) { titleColor = Color.green; } else { titleColor = Color.yellow; } RenderTitle(deviceTypeLabel, titleColor); ConnectionStatusGUI(deviceInfo, ref ipAddressField); GUI.enabled = deviceInfo != null && deviceInfo.NetworkManager != null && deviceInfo.NetworkManager.IsConnected && spatialCoordinateSystemParticipant != null; string sharedSpatialCoordinateStatusMessage; if (deviceInfo == null || deviceInfo.NetworkManager == null || !deviceInfo.NetworkManager.IsConnected || spatialCoordinateSystemParticipant == null) { sharedSpatialCoordinateStatusMessage = notConnectedMessage; } else if (spatialCoordinateSystemParticipant.PeerDeviceTrackingState == TrackingState.LostTracking) { sharedSpatialCoordinateStatusMessage = trackingLostStatusMessage; } else if (deviceInfo.IsTrackingStalled) { sharedSpatialCoordinateStatusMessage = trackingStalledStatusMessage; } else if (spatialCoordinateSystemParticipant.PeerIsLocatingSpatialCoordinate) { sharedSpatialCoordinateStatusMessage = locatingSharedSpatialCoordinate; } else if (!spatialCoordinateSystemParticipant.PeerSpatialCoordinateIsLocated) { sharedSpatialCoordinateStatusMessage = notLocatedSharedSpatialCoordinate; } else if (spatialCoordinateSystemParticipant.PeerDeviceTrackingState == TrackingState.Unknown) { sharedSpatialCoordinateStatusMessage = unknownTrackingStatusMessage; } else { sharedSpatialCoordinateStatusMessage = locatedSharedSpatialCoordinateMessage; } if (showSpatialLocalization) { GUILayout.Label("Shared spatial coordinate status", boldLabelStyle); GUILayout.Label(sharedSpatialCoordinateStatusMessage); } string calibrationStatusMessage; if (compositionManager != null && compositionManager.IsCalibrationDataLoaded) { calibrationStatusMessage = calibrationLoadedMessage; } else { calibrationStatusMessage = calibrationNotLoadedMessage; } EditorGUILayout.Space(); if (showCalibrationStatus) { GUILayout.Label("Calibration status", boldLabelStyle); GUILayout.Label(calibrationStatusMessage); } else { // Empty label to remain as a placeholder for the Calibration status GUILayout.Label(string.Empty, boldLabelStyle); GUILayout.Label(string.Empty); } if (showSpatialLocalization) { EditorGUILayout.Space(); GUILayout.Label("Spatial Alignment", boldLabelStyle); GUILayout.Space(4); SpatialLocalizationGUI(deviceTypeLabel, spatialCoordinateSystemParticipant); } GUI.enabled = true; } EditorGUILayout.EndVertical(); }
protected SpatialCoordinateSystemParticipant GetSpatialCoordinateSystemParticipant(DeviceInfoObserver device) { if (device != null && device.NetworkConnection != null && SpatialCoordinateSystemManager.IsInitialized) { if (SpatialCoordinateSystemManager.Instance.TryGetSpatialCoordinateSystemParticipant(device.NetworkConnection, out SpatialCoordinateSystemParticipant participant)) { return(participant); } else { Debug.LogError("Expected to be able to find participant for an endpoint"); return(null); } } else { return(null); } }
protected void HolographicCameraNetworkConnectionGUI(string deviceTypeLabel, DeviceInfoObserver deviceInfo, SpatialCoordinateSystemParticipant spatialCoordinateSystemParticipant, bool showCalibrationStatus, ref string ipAddressField) { GUIStyle boldLabelStyle = new GUIStyle(GUI.skin.label); boldLabelStyle.fontStyle = FontStyle.Bold; CompositionManager compositionManager = GetCompositionManager(); EditorGUILayout.BeginVertical("Box"); { Color titleColor; if (deviceInfo != null && deviceInfo.NetworkManager != null && deviceInfo.NetworkManager.IsConnected && spatialCoordinateSystemParticipant != null && spatialCoordinateSystemParticipant.PeerDeviceHasTracking && spatialCoordinateSystemParticipant.PeerSpatialCoordinateIsLocated && !spatialCoordinateSystemParticipant.PeerIsLocatingSpatialCoordinate && !deviceInfo.IsTrackingStalled && (!showCalibrationStatus || (compositionManager != null && compositionManager.IsCalibrationDataLoaded))) { titleColor = Color.green; } else { titleColor = Color.yellow; } RenderTitle(deviceTypeLabel, titleColor); if (deviceInfo != null && deviceInfo.NetworkManager != null && deviceInfo.NetworkManager.IsConnected) { GUILayout.BeginHorizontal(); { GUILayout.Label("Connection status", boldLabelStyle); if (GUILayout.Button(new GUIContent("Disconnect", "Disconnects the network connection to the holographic camera."), GUILayout.Width(connectAndDisconnectButtonWidth))) { deviceInfo.NetworkManager.Disconnect(); } } GUILayout.EndHorizontal(); if (deviceInfo.NetworkManager.ConnectedIPAddress == deviceInfo.DeviceIPAddress) { GUILayout.Label($"Connected to {deviceInfo.DeviceName} ({deviceInfo.DeviceIPAddress})"); } else { GUILayout.Label($"Connected to {deviceInfo.DeviceName} ({deviceInfo.NetworkManager.ConnectedIPAddress} -> {deviceInfo.DeviceIPAddress})"); } EditorGUILayout.Space(); } else { GUILayout.BeginHorizontal(); { ipAddressField = EditorGUILayout.TextField(ipAddressField); ConnectButtonGUI(ipAddressField, deviceInfo); } GUILayout.EndHorizontal(); GUILayout.Label(notConnectedMessage); EditorGUILayout.Space(); } GUI.enabled = deviceInfo != null && deviceInfo.NetworkManager != null && deviceInfo.NetworkManager.IsConnected && spatialCoordinateSystemParticipant != null; string sharedSpatialCoordinateStatusMessage; if (deviceInfo == null || deviceInfo.NetworkManager == null || !deviceInfo.NetworkManager.IsConnected || spatialCoordinateSystemParticipant == null) { sharedSpatialCoordinateStatusMessage = notConnectedMessage; } else if (!spatialCoordinateSystemParticipant.PeerDeviceHasTracking) { sharedSpatialCoordinateStatusMessage = trackingLostStatusMessage; } else if (deviceInfo.IsTrackingStalled) { sharedSpatialCoordinateStatusMessage = trackingStalledStatusMessage; } else if (spatialCoordinateSystemParticipant.PeerIsLocatingSpatialCoordinate) { sharedSpatialCoordinateStatusMessage = locatingSharedSpatialCoordinate; } else if (!spatialCoordinateSystemParticipant.PeerSpatialCoordinateIsLocated) { sharedSpatialCoordinateStatusMessage = notLocatedSharedSpatialCoordinate; } else { sharedSpatialCoordinateStatusMessage = locatedSharedSpatialCoordinateMessage; } GUILayout.Label("Shared spatial coordinate status", boldLabelStyle); GUILayout.Label(sharedSpatialCoordinateStatusMessage); string calibrationStatusMessage; if (compositionManager != null && compositionManager.IsCalibrationDataLoaded) { calibrationStatusMessage = calibrationLoadedMessage; } else { calibrationStatusMessage = calibrationNotLoadedMessage; } EditorGUILayout.Space(); if (showCalibrationStatus) { GUILayout.Label("Calibration status", boldLabelStyle); GUILayout.Label(calibrationStatusMessage); } else { // Empty label to remain as a placeholder for the Calibration status GUILayout.Label(string.Empty, boldLabelStyle); GUILayout.Label(string.Empty); } EditorGUILayout.Space(); GUILayout.Label("Spatial Alignment", boldLabelStyle); GUILayout.Space(4); SpatialLocalizationGUI(deviceTypeLabel, spatialCoordinateSystemParticipant); GUI.enabled = true; } EditorGUILayout.EndVertical(); }