private void SetMessagesInternal(PluginError errors) { if (errors.HasFlag(PluginError.Initialising)) { statusLabel.Text = "Server is still setting up..."; bonjourError.Clear(); } else if (errors.HasFlag(PluginError.BonjourNotFound)) { statusLabel.Text = "Apple\'s Bonjour is required."; bonjourError.SetError(statusLabel, "Unable to connect to bonjour"); } else { statusLabel.Text = ""; bonjourError.Clear(); } if (errors.HasFlag(PluginError.PortTaken)) { portError.SetError(portLabel, "This port is taken"); } else { portError.Clear(); } }
private static void InitializePreviewWindowPosition() { IntPtr displayHandle = IntPtr.Zero; // Grab the handle to the zSpace display. PluginError error = zcuGetDisplayByType(GlobalState.Instance.Context, DisplayType.zSpace, 0, out displayHandle); if (error != PluginError.Ok) { Debug.LogWarning("zSpace display not found. Unable to position preview window on zSpace display."); return; } int x = 0; int y = 0; // Grab the display's position. error = zcuGetDisplayPosition(displayHandle, out x, out y); if (error != PluginError.Ok) { return; } // Move the preview window. zcuMovePreviewWindow(x, y); }
public ConfigForm(Plugin instance, Settings settings, PluginError errors) { InitializeComponent(); this.instance = instance; SetFormSettingsInternal(settings); SetMessagesInternal(errors); }
////////////////////////////////////////////////////////////////// // Private Helpers ////////////////////////////////////////////////////////////////// private PluginException NewPluginException(PluginError error) { switch (error) { case PluginError.NotImplemented: return(new NotImplementedException()); case PluginError.NotInitialized: return(new NotInitializedException()); case PluginError.InvalidParameter: return(new InvalidParameterException()); case PluginError.InvalidContext: return(new InvalidContextException()); case PluginError.InvalidHandle: return(new InvalidHandleException()); case PluginError.RuntimeIncompatible: return(new RuntimeIncompatibleException()); case PluginError.RuntimeNotFound: return(new RuntimeNotFoundException()); case PluginError.SymbolNotFound: return(new SymbolNotFoundException()); case PluginError.DisplayNotFound: return(new DisplayNotFoundException()); case PluginError.DeviceNotFound: return(new DeviceNotFoundException()); case PluginError.TargetNotFound: return(new TargetNotFoundException()); case PluginError.CapabilityNotFound: return(new CapabilityNotFoundException()); case PluginError.BufferTooSmall: return(new BufferTooSmallException()); case PluginError.SyncFailed: return(new SyncFailedException()); case PluginError.OperationFailed: return(new OperationFailedException()); case PluginError.InvalidAttribute: return(new InvalidAttributeException()); default: return(new PluginException(PluginError.Unknown)); } }
public void RaiseError(string message) { PluginError pluginError = this.OnError; if (pluginError == null) { return; } pluginError(this, message); }
internal void SetMessages(PluginError errors) { if (InvokeRequired) { Invoke(new MethodInvoker(() => SetMessagesInternal(errors))); } else { SetMessagesInternal(errors); } }
private void HandleError(PluginError error, PluginData.PluginDataState failed_state = PluginData.PluginDataState.DISABLED_ERROR) { if (error.plugin == null) { error.plugin = error.device.plugin; } if ((DateTime.Now - error.plugin.last_error_time).TotalSeconds > 60 * 5) //if no errors for 5 minutes reset error count { error.plugin.error_tries_left = DEFAULT_PLUGIN_RETRIES; } error.plugin.last_error_time = DateTime.Now; error.plugin.last_error = error.exception.Message; String restart_msg = error.plugin.error_tries_left > 0 ? " will try to restart/init it " + error.plugin.error_tries_left + " more times" : " will not be restarting it"; Utils.PluginLog(PluginManagerName(), "Plugin " + error.plugin.plugin.ProviderName() + " had an error due to: " + error.exception.Message + "\n" + restart_msg); List <DeviceData> to_remove = new List <DeviceData>(); lock (devices_lock) { foreach (DeviceData device in devices) { if (device.plugin == error.plugin) { try { device.device.SetActive(false); } catch (Exception) { Utils.PluginLog(PluginManagerName(), "While handling error wasn't able to deactivate device, not a major issue"); } to_remove.Add(device); } } } lock (devices_lock) { foreach (DeviceData device in to_remove) { devices.Remove(device); } } error.plugin.plugin.Terminate(); if (error.plugin.error_tries_left-- > 0) { DelayedFunction.DelayedCall("IHeadsetPlugin_PluginStart_ " + error.plugin.plugin.ProviderName(), () => init_plugin(error.plugin), 1000); //give it a second } else { error.plugin.state = failed_state; } }
public ErrorViewModel[] GetAllErrors() { List <ErrorViewModel> toReturn = new List <ErrorViewModel>(); foreach (var container in PluginManager.AllPluginContainers) { if (container.FailureException != null) { var error = new PluginError(); error.PluginContainer = container; toReturn.Add(error); } } return(toReturn.ToArray()); }
private void InitialiseServer() { errors = PluginError.Initialising; try { server = new DAAP.Server(settings.serverName, db, revisionManager); server.Port = settings.serverPort; server.Collision += (o, args) => { if (server.Name.Length > settings.serverName.Length) { int next = int.Parse(server.Name.Substring(server.Name.Length + 1)) + 1; server.Name = settings.serverName + " " + next.ToString(); } else { server.Name += " 2"; } }; server.TrackRequested += OnTrackRequest; server.DatabaseRequested += OnDatabaseRequest; server.UserLogin += revisionManager.OnLogin; server.UserLogout += revisionManager.OnLogout; server.Start(); errors = PluginError.None; } catch (SocketException) { errors = PluginError.PortTaken; } catch (Mono.Zeroconf.Providers.Bonjour.ServiceErrorException) { errors = PluginError.BonjourNotFound; } catch (Exception) { // Fatal. StopPlugin(); mbApi.MB_SendNotification(CallbackType.DisablePlugin); } configForm?.SetMessages(errors); }
private void ShutDown() { if (_isInitialized) { PluginError error = zvuShutDown(_context); if (error != PluginError.Ok) { // Shut down the zView context. Debug.LogWarning(string.Format("Failed to shut down zView context: ({0})", error)); } // Clear out handles. _context = IntPtr.Zero; _modeStandard = IntPtr.Zero; _modeAugmentedReality = IntPtr.Zero; _connection = IntPtr.Zero; _isInitialized = false; } }
private bool Equals(PluginError other) { return(string.Equals(What, other.What)); }
private void HandleError(PluginError error, PluginData.PluginDataState failed_state = PluginData.PluginDataState.DISABLED_ERROR) { if (error.plugin == null) error.plugin = error.device.plugin; if ((DateTime.Now - error.plugin.last_error_time).TotalSeconds > 60 * 5) //if no errors for 5 minutes reset error count error.plugin.error_tries_left = DEFAULT_PLUGIN_RETRIES; error.plugin.last_error_time = DateTime.Now; error.plugin.last_error = error.exception.Message; String restart_msg = error.plugin.error_tries_left > 0 ? " will try to restart/init it " + error.plugin.error_tries_left + " more times" : " will not be restarting it"; Utils.PluginLog(PluginManagerName(), "Plugin " + error.plugin.plugin.ProviderName() + " had an error due to: " + error.exception.Message + "\n" + restart_msg); List<DeviceData> to_remove = new List<DeviceData>(); lock (devices_lock) { foreach (DeviceData device in devices) { if (device.plugin == error.plugin) { try { device.device.SetActive(false); } catch (Exception) { Utils.PluginLog(PluginManagerName(), "While handling error wasn't able to deactivate device, not a major issue"); } to_remove.Add(device); } } } lock (devices_lock) { foreach (DeviceData device in to_remove) devices.Remove(device); } error.plugin.plugin.Terminate(); if (error.plugin.error_tries_left-- > 0) DelayedFunction.DelayedCall("IHeadsetPlugin_PluginStart_ " + error.plugin.plugin.ProviderName(), () => init_plugin(error.plugin), 1000);//give it a second else error.plugin.state = failed_state; }
private void ShowPluginErrorDialog(Plugin plugin, Exception e) { PluginError errorDialog = new PluginError(); errorDialog.Plugin = plugin; errorDialog.Exception = e; errorDialog.ShowDialog(); }
private GlobalState() { // Initialize the zView context. PluginError error = zvuInitialize(NodeType.Presenter, out _context); if (error == PluginError.Ok) { // Set the context's node name. error = zvuSetNodeName(_context, ZView.StringToNativeUtf8(this.GetProjectName())); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to set node name: ({0})", error)); } // Set the context's node status. error = zvuSetNodeStatus(_context, ZView.StringToNativeUtf8(string.Empty)); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to set node status: ({0})", error)); } // Get both standard and augmented reality modes. List <ZVSupportedMode> supportedModes = new List <ZVSupportedMode>(); _modeStandard = this.GetMode(_context, CompositingMode.None, CameraMode.LocalHeadTracked); if (_modeStandard != IntPtr.Zero) { supportedModes.Add( new ZVSupportedMode { mode = _modeStandard, modeAvailability = ModeAvailability.Available }); } _modeAugmentedReality = this.GetMode(_context, CompositingMode.AugmentedRealityCamera, CameraMode.RemoteMovable); if (_modeAugmentedReality != IntPtr.Zero) { supportedModes.Add( new ZVSupportedMode { mode = _modeAugmentedReality, modeAvailability = ModeAvailability.Available }); } // Set the context's supported modes. error = zvuSetSupportedModes(_context, supportedModes.ToArray(), supportedModes.Count); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to set supported modes: ({0})", error)); } // Set the context's supported capabilities. error = zvuSetSupportedCapabilities(_context, null, 0); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to set supported capabilities: ({0})", error)); } // Start listening for new connections. error = zvuStartListeningForConnections(_context, ZView.StringToNativeUtf8(string.Empty)); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to start listening for connections: ({0})", error)); } _isInitialized = true; } else { Debug.LogWarning(string.Format("Failed to initialize zView context: ({0})", error)); _isInitialized = false; } }
private GlobalState() { // Initialize the zSpace Unity plugin. PluginError error = zcuInitialize(out _context); if (error == PluginError.Ok) { // Create the stereo buffer for LR detect. error = zcuCreateStereoBuffer(_context, ZCRenderer.Custom, IntPtr.Zero, out _stereoBufferHandle); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to create stereo buffer: ({0})", error)); } // Create the viewport. error = zcuCreateViewport(_context, out _viewportHandle); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to create viewport: ({0})", error)); } // Grab a reference to the viewport's frustum. error = zcuGetFrustum(_viewportHandle, out _frustumHandle); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to find frustum: ({0})", error)); } else { // Set portal mode to "Angle" by default. zcuSetFrustumPortalMode(_frustumHandle, (int)PortalMode.Angle); } // Grab a reference to the default head target (glasses). error = zcuGetTargetByType(_context, TargetType.Head, 0, out _targetHandles[(int)TargetType.Head]); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to find head target: ({0})", error)); _targetHandles[(int)TargetType.Head] = IntPtr.Zero; } // Grab a reference to the default primary target (stylus). error = zcuGetTargetByType(_context, TargetType.Primary, 0, out _targetHandles[(int)TargetType.Primary]); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to find primary target: ({0})", error)); _targetHandles[(int)TargetType.Primary] = IntPtr.Zero; } else { // Set stylus vibrations to be enabled by default. zcuSetTargetVibrationEnabled(_targetHandles[(int)TargetType.Primary], true); } // Initalize mouse emulation target and button mappings. error = zcuSetMouseEmulationTarget(_context, _targetHandles[(int)TargetType.Primary]); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to initialize mouse emulation target: ({0})", error)); } error = zcuSetMouseEmulationButtonMapping(_context, 0, MouseButton.Left); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to map target button 0 to left mouse button: ({0})", error)); } error = zcuSetMouseEmulationButtonMapping(_context, 1, MouseButton.Right); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to map target button 1 to right mouse button: ({0})", error)); } error = zcuSetMouseEmulationButtonMapping(_context, 2, MouseButton.Center); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to map target button 2 to center mouse button: ({0})", error)); } _isInitialized = true; } else { Debug.LogError(string.Format("Failed to initialize zSpace Core SDK: ({0})", error)); _isInitialized = false; } this.AutoStereoState = ZCore.AutoStereoState.IdleStereo; // Register the logger callback function. LoggerCallbackDelegate callbackDelegate = new LoggerCallbackDelegate(LoggerCallback); IntPtr callbackDelegatePtr = Marshal.GetFunctionPointerForDelegate(callbackDelegate); zcuSetLoggerFunction(callbackDelegatePtr); }
private GlobalState() { // Initialize the zSpace Unity plugin. PluginError error = zcuInitialize(out _context); if (error == PluginError.Ok) { // Create the viewport. error = zcuCreateViewport(_context, out _viewportHandle); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to create viewport: ({0})", error)); } // Grab a reference to the viewport's frustum. error = zcuGetFrustum(_viewportHandle, out _frustumHandle); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to find frustum: ({0})", error)); } else { // Set portal mode to "Angle" by default. zcuSetFrustumPortalMode(_frustumHandle, (int)PortalMode.Angle); } // Grab a reference to the default head target (glasses). error = zcuGetTargetByType(_context, TargetType.Head, 0, out _targetHandles[(int)TargetType.Head]); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to find head target: ({0})", error)); } // Grab a reference to the default primary target (stylus). error = zcuGetTargetByType(_context, TargetType.Primary, 0, out _targetHandles[(int)TargetType.Primary]); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to find primary target: ({0})", error)); } else { // Set stylus vibrations to be enabled by default. zcuSetTargetVibrationEnabled(_targetHandles[(int)TargetType.Primary], true); } // Initalize mouse emulation target and button mappings. error = zcuSetMouseEmulationTarget(_context, _targetHandles[(int)TargetType.Primary]); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to initialize mouse emulation target: ({0})", error)); } error = zcuSetMouseEmulationButtonMapping(_context, 0, MouseButton.Left); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to map target button 0 to left mouse button: ({0})", error)); } error = zcuSetMouseEmulationButtonMapping(_context, 1, MouseButton.Right); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to map target button 1 to right mouse button: ({0})", error)); } error = zcuSetMouseEmulationButtonMapping(_context, 2, MouseButton.Center); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to map target button 2 to center mouse button: ({0})", error)); } _isInitialized = true; } else { Debug.LogError(string.Format("Failed to initialize zSpace Core SDK: ({0})", error)); _isInitialized = false; } this.AutoStereoState = ZCore.AutoStereoState.IdleStereo; }
private IntPtr GetMode(IntPtr context, CompositingMode compositingMode, CameraMode cameraMode) { PluginError error = PluginError.Unknown; IntPtr modeSpec = IntPtr.Zero; // Create the mode spec. error = zvuCreateModeSpec(context, out modeSpec); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to create mode spec: ({0})", error)); return(IntPtr.Zero); } // Specify the mode spec's attributes. error = zvuSetModeSpecAttributeU32(modeSpec, ModeAttributeKey.Version, 0); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to set version attribute: ({0})", error)); } error = zvuSetModeSpecAttributeU32(modeSpec, ModeAttributeKey.CompositingMode, (UInt32)compositingMode); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to set compositing mode attribute: ({0})", error)); } error = zvuSetModeSpecAttributeU32(modeSpec, ModeAttributeKey.PresenterCameraMode, (UInt32)cameraMode); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to set presenter camera mode attribute: ({0})", error)); } error = zvuSetModeSpecAttributeU32(modeSpec, ModeAttributeKey.ImageRowOrder, (UInt32)ImageRowOrder.BottomToTop); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to set image row order attribute: ({0})", error)); } error = zvuSetModeSpecAttributeU32(modeSpec, ModeAttributeKey.ColorImagePixelFormat, (UInt32)PixelFormat.R8G8B8A8); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to set color image pixel format attribute: ({0})", error)); } // Get the mode for the specified spec. IntPtr mode = IntPtr.Zero; error = zvuGetModeForSpec(modeSpec, out mode); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to get mode for mode spec: ({0})", error)); } // Destroy the mode spec since it's no longer being used. error = zvuDestroyModeSpec(modeSpec); if (error != PluginError.Ok) { Debug.LogError(string.Format("Failed to destroy mode spec: ({0})", error)); } return(mode); }