예제 #1
0
        private void ProcessCommand(ReadedCommandData rcd)
        {
            var responce = BasicResponce.Create((Commands)rcd.Code, rcd.Data);

            if (ReceivedResponce != null)
            {
                Console.WriteLine(responce.ToString());
                ReceivedResponce(responce);
            }

            //Console.WriteLine("FRF: Received command:" + rcd.Code.ToString());
        }
예제 #2
0
파일: Thinker.cs 프로젝트: vmusulainen/Robo
        public void MainLoop()
        {
            while (true)
            {
                BasicResponce responce = null;
                if (_responces.Count > 0)
                {
                    responce = _responces.Dequeue();
                }

                if (_currentMetaCommand != null)
                {
                    var result = _currentMetaCommand.ProcessResponce(responce);
                    switch (result.Action)
                    {
                    case MetaCommandAction.Command:
                        result.Command.Execute(_port);
                        break;

                    case MetaCommandAction.NewMetaCommand:
                        _currentMetaCommand = result.MetaCommand;
                        break;

                    case MetaCommandAction.Done:
                        _currentMetaCommand = null;
                        break;

                    default:
                        break;
                    }
                }

                Thread.Sleep(1);
            }

            /*var cmd = new TurnCommand(TurnDirection.Left, 180, 255, true, 500);
             * cmd.Execute(_port);*/

            /*while (true)
             * {
             *  //var cmd = new RangeScanCommand(11, 11, 3500);
             *  var cmd = new StatusCommand(11, 500);
             *  cmd.Execute(_port);
             * }*/
        }
예제 #3
0
파일: Thinker.cs 프로젝트: vmusulainen/Robo
 private void PortOnReceivedResponce(BasicResponce cmd)
 {
     _responces.Enqueue(cmd);
 }