public ConditionalOnAutomation RegisterConditionalOnAutomation(IArea area, Enum id)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));

            var automation =
                new ConditionalOnAutomation(
                    AutomationIdGenerator.Generate(area, id),
                    _schedulerService,
                    _dateTimeService,
                    _daylightService);

            area.AddAutomation(automation);

            return automation;
        }
Example #2
0
        public ConditionalOnAutomation RegisterConditionalOnAutomation(IArea area, Enum id)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));

            var automation =
                new ConditionalOnAutomation(
                    $"{area.Id}.{id}",
                    _schedulerService,
                    _dateTimeService,
                    _daylightService);

            area.RegisterAutomation(automation);

            return automation;
        }
Example #3
0
        public static ConditionalOnAutomation SetupConditionalOnAutomation(this IArea area)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var automation =
                new ConditionalOnAutomation(
                    AutomationIdFactory.CreateIdFrom <ConditionalOnAutomation>(area),
                    area.Controller.Timer);

            area.AddAutomation(automation);

            return(automation);
        }
Example #4
0
        public ConditionalOnAutomation RegisterConditionalOnAutomation(IArea area, Enum id)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var automation =
                new ConditionalOnAutomation(
                    AutomationIdGenerator.Generate(area, id),
                    _schedulerService,
                    _dateTimeService,
                    _daylightService);

            area.AddAutomation(automation);

            return(automation);
        }
Example #5
0
        public static ConditionalOnAutomation SetupConditionalOnAutomation(this IArea area)
        {
            if (area == null)
            {
                throw new ArgumentNullException(nameof(area));
            }

            var automation =
                new ConditionalOnAutomation(
                    AutomationIdFactory.CreateIdFrom <ConditionalOnAutomation>(area),
                    area.Controller.ServiceLocator.GetService <ISchedulerService>(),
                    area.Controller.ServiceLocator.GetService <IDateTimeService>(),
                    area.Controller.ServiceLocator.GetService <IDaylightService>());

            area.AddAutomation(automation);

            return(automation);
        }
        public void Empty_ConditionalOnAutomation()
        {
            var testController = new TestController();
            var automation = new ConditionalOnAutomation(AutomationIdGenerator.EmptyId,
                testController.SchedulerService,
                testController.DateTimeService,
                testController.DaylightService);

            var testButtonFactory = new TestButtonFactory(testController.TimerService, new SettingsService(new BackupService(), new StorageService()));
            var testStateMachineFactory = new TestStateMachineFactory();

            var testButton = testButtonFactory.CreateTestButton();
            var testOutput = testStateMachineFactory.CreateTestStateMachineWithOnOffStates();

            automation.WithTrigger(testButton.GetPressedShortlyTrigger());
            automation.WithActuator(testOutput);

            testOutput.GetState().ShouldBeEquivalentTo(BinaryStateId.Off);
            testButton.PressShortly();
            testOutput.GetState().ShouldBeEquivalentTo(BinaryStateId.On);
        }