Пример #1
0
        static void ReadTrigger(CancellationToken token)
        {
            Task.Run(() =>
            {
                while (true)
                {
                    if (token.IsCancellationRequested)
                    {
                        break;
                    }

                    int trigger = robotManager.GetTriggerSignal();
                    Debug.WriteLine("Trigger = {0}", trigger);

                    Thread.Sleep(500);
                }
            });
        }
Пример #2
0
        /// <summary>
        /// Trigger signale pooling & send to client
        /// </summary>
        /// <param name="token"></param>
        private void GetTriggerSignal(CancellationToken token)
        {
            Task.Factory.StartNew(() =>
            {
                int triggerIndex = -1;

                while (true)
                {
                    if (token.IsCancellationRequested)
                    {
                        break;
                    }

                    int newTriggerIndex = robotManager.GetTriggerSignal();
                    if (triggerIndex != newTriggerIndex)
                    {
                        triggerIndex = newTriggerIndex;

                        if (lastStep == 3 || lastStep == 5)
                        {
                            string message = string.Format("/trigger:{0}", triggerIndex.ToString());
                            SendToClientMessage(message);
                            Thread.Sleep(500);
                            SendToClientMessage(message);
                            Thread.Sleep(500);
                            SendToClientMessage(message);
                            Thread.Sleep(500);
                            SendToClientMessage(message);
                        }
                        //else if (lastStep >= 1 || lastStep >= 6)
                        //{
                        //    string message = "/trigger:0";
                        //    SendToClientMessage(message);
                        //}
                    }

                    Thread.Sleep(200);
                }
            });
        }