예제 #1
0
        private IVectorControllerPlus CreateController(RobotConfiguration robotConfig = null)
        {
            var controller = new VectorControllerPlus();

            controller.OnBehaviourReport += async(report) => { logger?.LogInformation(report.Description); };
            return(controller);
        }
예제 #2
0
        static async Task Main(string[] args)
        {
            System.Console.WriteLine("Hello World!");

            var config = new VectorControllerPlusConfig()
            {
                ReconnectDelay_ms = 2000
            };

            await using (IVectorControllerPlus controller = new VectorControllerPlus())
            {
                controller.OnConnectionChanged += async(previously, state) => System.Console.WriteLine("! Connection: " + state);

                //await controller.AddBehaviourAsync(new MonitoringEventsBehaviour(false));
                await controller.AddBehaviourAsync(new OfferTeaSometimesBehaviour(0));

                await controller.AddBehaviourAsync(new ExterminateCubeOnSightBehaviour(1));

                controller.OnBehaviourReport += async(report) =>
                {
                    System.Console.WriteLine(report.Description);
                    await File.AppendAllLinesAsync(LOG_FILE, new[] { report.Description });
                };

                await controller.ConnectAsync(config);

                cancelSource = new CancellationTokenSource();
                await controller.StartMainLoopAsync(cancelSource.Token);
            }
        }
 public async Task SetupAsync()
 {
     cancelSource       = new CancellationTokenSource();
     controller         = new VectorControllerPlus();
     controllerMainLoop = controller.StartMainLoopAsync(cancelSource.Token);
 }