private void Setup() { _controller = new TestController(); _controller.SetTime(TimeSpan.Parse("12:00")); _weatherStation = new TestWeatherStation { OutdoorTemperature = 20 }; _rollerShutter = new RollerShutter("Test", new TestRollerShutterAdapter(), _controller.GetInstance <ITimerService>(), _controller.GetInstance <ISettingsService>()); _controller.GetInstance <IComponentRegistryService>().RegisterComponent(_rollerShutter); _automation = new RollerShutterAutomation( "Test", _controller.GetInstance <INotificationService>(), _controller.GetInstance <ISchedulerService>(), _controller.GetInstance <IDateTimeService>(), _controller.GetInstance <IDaylightService>(), _weatherStation, _controller.GetInstance <IComponentRegistryService>(), _controller.GetInstance <ISettingsService>(), _controller.GetInstance <IResourceService>()); _automation.WithRollerShutters(_rollerShutter); }
public AutomaticRollerShutterAutomation WithRollerShutter(RollerShutter rollerShutter) { if (rollerShutter == null) throw new ArgumentNullException(nameof(rollerShutter)); _rollerShutters.Add(rollerShutter); return this; }
public void RollerShutter_Reset() { var testController = new TestController(); var adapter = new TestRollerShutterAdapter(); var rollerShutter = new RollerShutter("Test", adapter, testController.GetInstance <ITimerService>(), testController.GetInstance <ISettingsService>()); rollerShutter.TryReset(); Assert.AreEqual(1, adapter.StartMoveUpCalledCount); Assert.IsTrue(rollerShutter.GetState().Has(PowerState.On)); Assert.IsTrue(rollerShutter.GetState().Has(VerticalMovingState.MovingUp)); }
public void RollerShutter_AutoOff() { var testController = new TestController(); var adapter = new TestRollerShutterAdapter(); var rollerShutter = new RollerShutter("Test", adapter, testController.GetInstance <ITimerService>(), testController.GetInstance <ISettingsService>()); rollerShutter.TryReset(); rollerShutter.TryMoveDown(); Assert.AreEqual(1, adapter.StartMoveUpCalledCount); Assert.AreEqual(1, adapter.StartMoveDownCalledCount); testController.Tick(TimeSpan.FromHours(1)); Assert.AreEqual(1, adapter.StopCalledCount); }
public IRollerShutter RegisterRollerShutter(IArea area, Enum id, IBinaryOutput powerOutput, IBinaryOutput directionOutput) { if (area == null) throw new ArgumentNullException(nameof(area)); if (powerOutput == null) throw new ArgumentNullException(nameof(powerOutput)); if (directionOutput == null) throw new ArgumentNullException(nameof(directionOutput)); var rollerShutter = new RollerShutter( ComponentIdGenerator.Generate(area.Id, id), new PortBasedRollerShutterEndpoint(powerOutput, directionOutput), _timerService, _schedulerService, _settingsService); area.AddComponent(rollerShutter); return rollerShutter; }
private static void HandleBlindButtonPressedEvent(RollerShutter rollerShutter, RollerShutterButtonDirection direction) { if (direction == RollerShutterButtonDirection.Up && rollerShutter.State == RollerShutterState.MovingUp) { rollerShutter.Stop(); } else if (direction == RollerShutterButtonDirection.Down && rollerShutter.State == RollerShutterState.MovingDown) { rollerShutter.Stop(); } else if (direction == RollerShutterButtonDirection.Down) { rollerShutter.StartMoveDown(); } else if (direction == RollerShutterButtonDirection.Up) { rollerShutter.StartMoveUp(); } else { throw new InvalidOperationException(); } }