public Thinker(ComPort port) { _port = port; _port.ReceivedResponce += PortOnReceivedResponce; //_currentMetaCommand = new ScanMetaCommand(); //_currentMetaCommand = new SimpleMovementMetaCommand(); _currentMetaCommand = new ExplorerMetaCommand(); }
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); * }*/ }
public BasicMetaCommandResult(MetaCommandAction action, BaseCommand command = null, IMetaCommand metaCommand = null) { Action = action; Command = command; MetaCommand = metaCommand; }