using System;
using System.Threading;
using System.Threading.Tasks;
using Autolabor.Robobase;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace Autolabor.Benz.ObstacleDetection
{
    public class Worker : BackgroundService
    {
        private readonly ILogger<Worker> _logger;

        public Worker(ILogger<Worker> logger)
        {
            _logger = logger;
        }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            
            // 创建用户配置文件
            var app = Kits.GetAutolaborDataPath();
            var path = System.IO.Path.Combine(app, "BenzObstacleDetection.bin");
            UserDataManager.Initialize(path);
            
            // 输出日志
            TestKit.Logger.Trace("BenzObstacleDetection start");
            // 启动顶层组件
            var detection = new Detection();
            detection.Enable = true;
            // while (!stoppingToken.IsCancellationRequested)
            // {
            //     if (_logger.IsEnabled(LogLevel.Information))
            //     {
            //         _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
            //     }
            //
            //     await Task.Delay(1000, stoppingToken);
            // }
        }
    }
}