private void CancelTimeoutIfMotionDetectorDeactivated(object sender, ValueChangedEventArgs <bool> e) { bool isDeactivated = !e.NewValue; if (isDeactivated) { _turnOffTimeout?.Cancel(); } }
private void CancelTimeoutIfMotionDetectorDeactivated(object sender, SettingValueChangedEventArgs eventArgs) { if (eventArgs.SettingName != AutomationSettingsWrapper.IsEnabledName) { return; } bool isDeactivated = !eventArgs.NewValue.GetBoolean(); if (isDeactivated) { _turnOffTimeout?.Cancel(); } }
private void CancelTimeoutIfMotionDetectorDeactivated(IMotionDetector motionDetector, SettingValueChangedEventArgs eventArgs) { if (eventArgs.SettingName != "IsEnabled") { return; } if (!motionDetector.Settings.IsEnabled) { lock (_syncRoot) { _turnOffTimeout?.Cancel(); } } }
private void RestartTracking() { _movingDuration.Restart(); _autoOffTimer?.Cancel(); _autoOffTimer = _timer.In(_settings.AutoOffTimeout).Do(() => SetState(RollerShutterStateId.Off)); }
public void CancelTest() { var called = false; var sw = new Stopwatch(); ManualResetEvent mre = new ManualResetEvent(false); Action act = new Action(() => { called = true; sw.Stop(); mre.Set(); }); var delayedAction = new TimedAction(act); sw.Start(); delayedAction.RunWithDelay(2000); delayedAction.Cancel(); var signaled = mre.WaitOne(3000); Assert.IsFalse(called); Assert.IsFalse(signaled); Assert.IsTrue(sw.IsRunning); }
private void RestartTracking() { _movingDuration.Restart(); _autoOffTimer?.Cancel(); _autoOffTimer = _schedulerService.In(_settings.AutoOffTimeout).Execute(() => SetState(RollerShutterStateId.Off)); }
private void Start() { _powerGpioPin.Write(BinaryState.High); _movingDuration.Restart(); _autoOffTimer?.Cancel(); _autoOffTimer = _timer.In(Settings.AutoOffTimeout.Value).Do(() => SetState(RollerShutterState.Stopped)); }
private void TurnOn(object sender, EventArgs e) { if (!this.GetIsEnabled()) { } _timeout?.Cancel(); _actuator?.SetState(new StatefulComponentState("1")); }
private void TurnOn(object sender, EventArgs e) { if (!this.IsEnabled()) { return; } _timeout?.Cancel(); _actuator?.SetState(new NamedComponentState("1")); }
private void HandleIsEnabledStateChanged(IHomeAutomationTimer timer) { if (!this.GetIsEnabled()) { Log.Info(Id + ": Disabled for 1 hour"); _autoEnableAction = timer.In(TimeSpan.FromHours(1)).Do(this.Enable); } else { _autoEnableAction?.Cancel(); } }
private void HandleIsEnabledStateChanged() { if (!this.IsEnabled()) { Log.Info(Id + ": Disabled for 1 hour"); _autoEnableAction = _schedulerService.In(TimeSpan.FromHours(1)).Execute(this.Enable); } else { _autoEnableAction?.Cancel(); } }
private void StartBathode(IArea bathroom) { bathroom.MotionDetector().Settings.IsEnabled.Value = false; bathroom.Lamp(LowerBathroom.LightCeilingDoor).TurnOn(); bathroom.Lamp(LowerBathroom.LightCeilingMiddle).TurnOff(); bathroom.Lamp(LowerBathroom.LightCeilingWindow).TurnOff(); bathroom.Lamp(LowerBathroom.LampMirror).TurnOff(); _bathmodeResetTimer?.Cancel(); _bathmodeResetTimer = bathroom.Controller.Timer.In(TimeSpan.FromHours(1)).Do(() => bathroom.MotionDetector().Settings.IsEnabled.Value = true); }
private void StartBathode(IArea bathroom) { bathroom.GetMotionDetector().Disable(); bathroom.GetLamp(LowerBathroom.LightCeilingDoor).TryTurnOn(); bathroom.GetLamp(LowerBathroom.LightCeilingMiddle).TryTurnOff(); bathroom.GetLamp(LowerBathroom.LightCeilingWindow).TryTurnOff(); bathroom.GetLamp(LowerBathroom.LampMirror).TryTurnOff(); _bathmodeResetTimer?.Cancel(); _bathmodeResetTimer = bathroom.Controller.ServiceLocator.GetService <ISchedulerService>().In(TimeSpan.FromHours(1)).Execute(() => bathroom.GetMotionDetector().Enable()); }
private void HandleIsEnabledStateChanged(IHomeAutomationTimer timer, ILogger logger) { if (!Settings.IsEnabled.Value) { logger.Info(Id + ": Disabled for 1 hour"); _autoEnableAction = timer.In(TimeSpan.FromHours(1)).Do(() => Settings.IsEnabled.Value = true); } else { _autoEnableAction?.Cancel(); } }
private void StartBathode(IArea bathroom) { bathroom.GetMotionDetector().Settings.IsEnabled = false; bathroom.GetLamp(LowerBathroom.LightCeilingDoor).TryTurnOn(); bathroom.GetLamp(LowerBathroom.LightCeilingMiddle).TryTurnOff(); bathroom.GetLamp(LowerBathroom.LightCeilingWindow).TryTurnOff(); bathroom.GetLamp(LowerBathroom.LampMirror).TryTurnOff(); _bathmodeResetTimer?.Cancel(); _bathmodeResetTimer = _schedulerService.In(TimeSpan.FromHours(1)).Execute(() => bathroom.GetMotionDetector().Settings.IsEnabled = true); }
private void HandleIsEnabledStateChanged() { if (!Settings.IsEnabled) { Log.Info(Id + ": Disabled for 1 hour"); _autoEnableAction = _schedulerService.In(Settings.AutoEnableAfter).Execute(() => Settings.IsEnabled = true); } else { _autoEnableAction?.Cancel(); } }
private void TurnOn(object sender, EventArgs e) { _timeout?.Cancel(); _actuator?.SetState("1"); }