コード例 #1
0
        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);
                });
            });
        }
コード例 #2
0
        /// <summary>
        /// Uninitializes this object.
        /// </summary>
        public void Uninitialize()
        {
            m_state = m_state.Uninitialize();

            OnPreUninitialize();
            OnUninitialize();
            OnPostUninitialize();

            Uninitialized?.Invoke(this);
        }
コード例 #3
0
        public void Uninitialize()
        {
            if (isInitialized)
            {
                isInitialized              = false;
                natNetClient.OnFrameReady -= ProcessFrame;
                natNetClient.Uninitialize();

                Uninitialized?.Invoke(this, EventArgs.Empty);
            }
        }
コード例 #4
0
ファイル: RobotEmulator.cs プロジェクト: kborowicz/PingPong2
        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);
        }
コード例 #5
0
ファイル: UrhoAppView.cs プロジェクト: florin-chelaru/urho
 /// <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();
 }