コード例 #1
0
 protected async Task ReportAsync(string description)
 {
     var report = new VectorBehaviourPlusReport()
     {
         Description = description,
         Controller  = controller,
         Robot       = controller.Robot,
         Behaviour   = this
     };
     await controller.ReportAsync(report);
 }
コード例 #2
0
        public async Task StartMainLoopAsync(CancellationToken cancel, char?haltOn = ' ')
        {
            mainLoopRunning = true;
            var  examineConsole = true;
            char?lastKeyPress   = null;

            while (!cancel.IsCancellationRequested && mainLoopRunning && (haltOn == null || lastKeyPress != haltOn))
            {
                await Task.Delay(100);

                try
                {
                    if (examineConsole)
                    {
                        lastKeyPress = Console.KeyAvailable ? Console.ReadKey().KeyChar : (char?)null;
                        if (lastKeyPress.HasValue)
                        {
                            OnKeyPress?.Invoke(lastKeyPress.Value);
                            await OfferKeypressToBehavioursAsync(lastKeyPress.Value);
                        }
                    }
                }
                catch (InvalidOperationException e)
                {
                    await ReportAsync(VectorBehaviourPlusReport.FromException(e));

                    examineConsole = false;
                }

                if (AnyBehavioursNeedCameraProcessing)
                {
                    ProcessCameraFrame();
                }

                if (AnyBehavioursNeedPermanentObjectMonitoring)
                {
                    UpdateObjectMonitoring();
                }
            }
        }
コード例 #3
0
 public async Task ReportAsync(VectorBehaviourPlusReport report)
 {
     Reports.Add(report);
     OnBehaviourReport?.Invoke(report);
 }