public MotionDetector(ComponentId id, IMotionDetectorEndpoint endpoint, ISchedulerService schedulerService) : base(id) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (schedulerService == null) { throw new ArgumentNullException(nameof(schedulerService)); } _schedulerService = schedulerService; SetState(MotionDetectorStateId.Idle); endpoint.MotionDetected += (s, e) => UpdateState(MotionDetectorStateId.MotionDetected); endpoint.DetectionCompleted += (s, e) => UpdateState(MotionDetectorStateId.Idle); Settings.ValueChanged += (s, e) => { if (e.SettingName == "IsEnabled") { HandleIsEnabledStateChanged(); } }; }
public MotionDetector(ComponentId id, IMotionDetectorEndpoint endpoint, IHomeAutomationTimer timer) : base(id) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } SetState(MotionDetectorStateId.Idle); endpoint.MotionDetected += (s, e) => UpdateState(MotionDetectorStateId.MotionDetected); endpoint.DetectionCompleted += (s, e) => UpdateState(MotionDetectorStateId.Idle); Settings.ValueChanged += (s, e) => { if (e.SettingName == "IsEnabled") { HandleIsEnabledStateChanged(timer); } }; }
public MotionDetector(ComponentId id, IMotionDetectorEndpoint endpoint, ISchedulerService schedulerService, ISettingsService settingsService) : base(id) { if (endpoint == null) throw new ArgumentNullException(nameof(endpoint)); if (schedulerService == null) throw new ArgumentNullException(nameof(schedulerService)); if (settingsService == null) throw new ArgumentNullException(nameof(settingsService)); _schedulerService = schedulerService; settingsService.CreateSettingsMonitor<MotionDetectorSettings>(Id, s => Settings = s); SetState(MotionDetectorStateId.Idle); endpoint.MotionDetected += (s, e) => UpdateState(MotionDetectorStateId.MotionDetected); endpoint.DetectionCompleted += (s, e) => UpdateState(MotionDetectorStateId.Idle); Settings.ValueChanged += (s, e) => { if (e.SettingName == nameof(Settings.IsEnabled)) { HandleIsEnabledStateChanged(); } }; }