Ejemplo n.º 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());
        }
Ejemplo n.º 2
0
        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);
             * }*/
        }
Ejemplo n.º 3
0
 private void PortOnReceivedResponce(BasicResponce cmd)
 {
     _responces.Enqueue(cmd);
 }