public void Initialize() { if (isInitialized) { return; } if (config == null) { throw new InvalidOperationException("Robot configuration is not set."); } Task.Run(() => { Task communicationTask = Connect(); communicationTask.ContinueWith(task => { string robotAdress = ToString(); rsiAdapter.Disconnect(); if (task.IsFaulted) { var args = new ErrorOccuredEventArgs { RobotIp = robotAdress, Exception = task.Exception.GetBaseException() }; ErrorOccured?.Invoke(this, args); } isInitialized = false; Uninitialized?.Invoke(this, EventArgs.Empty); }); }); }
/// <summary> /// Uninitializes this object. /// </summary> public void Uninitialize() { m_state = m_state.Uninitialize(); OnPreUninitialize(); OnUninitialize(); OnPostUninitialize(); Uninitialized?.Invoke(this); }
public void Uninitialize() { if (isInitialized) { isInitialized = false; natNetClient.OnFrameReady -= ProcessFrame; natNetClient.Uninitialize(); Uninitialized?.Invoke(this, EventArgs.Empty); } }
private void Connect() { IsCancellationRequested = false; InputFrame receivedFrame = new InputFrame { Position = HomePosition, AxisPosition = RobotAxisVector.Zero, IPOC = 0 }; generator.Initialize(receivedFrame.Position); lock (receivedDataSyncLock) { position = receivedFrame.Position; HomePosition = receivedFrame.Position; } isInitialized = true; Initialized?.Invoke(this, EventArgs.Empty); // Start loop for receiving and sending data try { while (!IsCancellationRequested) { long IPOC = ReceiveDataAsync(); SendData(IPOC); Thread.Sleep(4); } } catch (Exception e) { var args = new ErrorOccuredEventArgs { RobotIp = ToString(), Exception = e }; ErrorOccured?.Invoke(this, args); } isInitialized = false; Uninitialized?.Invoke(this, EventArgs.Empty); }
/// <summary> /// Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView /// class is torn down while the app is in the foreground. // This method is not often used, but IFrameworkView requires it and it will be called for // holographic apps. /// </summary> public void Uninitialize() { Uninitialized?.Invoke(); }