예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var config = new SirenSettings();

            Configuration.Bind("Siren", config);
            services.AddSingleton(config);

            services.AddControllers();

            services.AddHostedService <MotionHost>();

            services.AddSingleton <IMotionSiren, MotionSiren>();

            bool isTargetPlatform = true;

#if DEBUG
            isTargetPlatform = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
#endif

            if (isTargetPlatform)
            {
                services.AddSingleton <IGpioService, GpioService>();
                services.AddSingleton <ICameraService, CameraService>();
            }
            else
            {
                services.AddSingleton <IGpioService, SimulatedGpioService>();
                services.AddSingleton <ICameraService, SimulatedCameraService>();
            }
        }
 public SimulatedCameraService(
     ILogger <SimulatedCameraService> logger,
     SirenSettings settings)
 {
     this.settings = settings;
     this.logger   = logger;
 }
예제 #3
0
        public CameraService(
            SirenSettings settings,
            ILogger <CameraService> logger,
            ILoggerFactory loggerFactory)
        {
            this.settings = settings;
            this.logger   = logger;

            MMALLog.LoggerFactory = loggerFactory;
        }
예제 #4
0
 public MotionSiren(
     SirenSettings settings,
     ILogger <MotionSiren> logger,
     IGpioService gpio,
     ICameraService cameraService)
 {
     this.settings      = settings;
     this.logger        = logger;
     this.gpio          = gpio;
     this.cameraService = cameraService;
     this.machine       = CreateStateMachine();
 }