コード例 #1
0
        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);
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        private void StartBathode(IArea bathroom)
        {
            var motionDetector = bathroom.GetMotionDetector(LowerBathroom.MotionDetector);

            _settingsService.SetComponentEnabledState(motionDetector, false);

            bathroom.GetLamp(LowerBathroom.LightCeilingDoor).TryTurnOn();
            bathroom.GetLamp(LowerBathroom.LightCeilingMiddle).TryTurnOff();
            bathroom.GetLamp(LowerBathroom.LightCeilingWindow).TryTurnOff();
            bathroom.GetLamp(LowerBathroom.LampMirror).TryTurnOff();

            _bathmodeResetDelayedAction?.Cancel();
            _bathmodeResetDelayedAction = _schedulerService.In(TimeSpan.FromHours(1), () => _settingsService.SetComponentEnabledState(motionDetector, true));
        }
コード例 #4
0
        private void SetupDemo()
        {
            // Get the area from the controller.
            IArea area = this.GetArea(Room.ExampleRoom);

            // Get the single motion detector from the controller.
            IMotionDetector motionDetector        = GetComponent <IMotionDetector>();
            ITrigger        motionDetectedTrigger = motionDetector.GetMotionDetectedTrigger();

            // Get the single temperature and humidity sensor from the controller.
            ITemperatureSensor temperatureSensor = GetComponent <ITemperatureSensor>();
            IHumiditySensor    humiditySensor    = GetComponent <IHumiditySensor>();

            // Get the button with the specified ID from the area (not globally).
            IButton  button        = area.GetButton(ExampleRoom.Button1);
            ITrigger buttonTrigger = button.GetPressedShortlyTrigger();

            // Get a test lamp from the area (not globally).
            ILamp lamp2 = area.GetLamp(ExampleRoom.Lamp2);
            ILamp lamp3 = area.GetLamp(ExampleRoom.Lamp3);

            // Integrate the twitter client if the configuration file is available.
            TwitterClient twitterClient;

            if (TwitterClientFactory.TryCreateFromDefaultConfigurationFile(out twitterClient))
            {
                RegisterService(new TwitterClient());

                IAction tweetAction = twitterClient.GetTweetAction($"Someone is here ({DateTime.Now})... @chkratky");

                motionDetectedTrigger.Attach(tweetAction);
                buttonTrigger.Attach(tweetAction);
            }

            // An automation is "Fulfilled" per default.
            ////var automation = new Automation(new AutomationId("DemoAutomation"))
            ////    .WithTrigger(motionDetectedTrigger)
            ////    .WithActionIfConditionsFulfilled(lamp3.GetTurnOnAction())
            ////    .WithCondition(ConditionRelation.And, new ComponentIsInStateCondition(lamp2, BinaryStateId.Off))
            ////    .WithCondition(ConditionRelation.And, new NumericValueSensorHasValueGreaterThanCondition(humiditySensor, 80));

            //AddAutomation(automation);

            SetupTelegramBot();

            new PersonalAgentToApiDispatcher(this).ExposeToApi(ApiController);
        }
コード例 #5
0
        private void SetupStairsCeilingLamps(IArea room, HSPE8OutputOnly hspe8UpperFloor)
        {
            var output = new LogicalBinaryOutput()
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO4])
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO5])
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO7])
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO6])
                         .WithInvertedState();

            _actuatorFactory.RegisterLamp(room, Floor.LampStairsCeiling, output);

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Floor.LampStairsCeilingAutomation)
            .WithTrigger(room.GetMotionDetector(Floor.StairsLowerMotionDetector))
            .WithTrigger(room.GetMotionDetector(Floor.StairsUpperMotionDetector))
            //.WithTrigger(floor.GetButton(Floor.ButtonStairsUpper).GetPressedShortlyTrigger())
            .WithTarget(room.GetLamp(Floor.LampStairsCeiling));

            var lamp = room.GetLamp(Floor.LampStairsCeiling);

            room.GetButton(Floor.ButtonStairsUpper).PressedShortTrigger.Attach(() => lamp.TryTogglePowerState());
            room.GetButton(Floor.ButtonStairsLowerUpper).PressedShortTrigger.Attach(() => lamp.TryTogglePowerState());
        }
コード例 #6
0
        private void SetupStairsLamps(IArea room, HSPE16OutputOnly hspe16FloorAndLowerBathroom)
        {
            var output = new LogicalBinaryOutput()
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO8])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO9])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO10])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO11])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO13])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO12])
                         .WithInvertedState();

            _actuatorFactory.RegisterLamp(room, Floor.LampStairs, output);

            _automationFactory.RegisterConditionalOnAutomation(room, Floor.LampStairsAutomation)
            .WithComponent(room.GetLamp(Floor.LampStairs))
            .WithOnAtNightRange()
            .WithOffBetweenRange(TimeSpan.FromHours(23), TimeSpan.FromHours(4));
        }
コード例 #7
0
        private void SetupStairsLamps(IArea floor, HSPE16OutputOnly hspe16FloorAndLowerBathroom)
        {
            var output = new LogicalBinaryOutput()
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO8])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO9])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO10])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO11])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO13])
                         .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO12])
                         .WithInvertedState();

            floor.WithLamp(Floor.LampStairs, output);

            floor.SetupConditionalOnAutomation()
            .WithActuator(floor.GetLamp(Floor.LampStairs))
            .WithOnAtNightRange()
            .WithOffBetweenRange(TimeSpan.FromHours(23), TimeSpan.FromHours(4));
        }
コード例 #8
0
        private void SetupStairsCeilingLamps(IArea floor, HSPE8OutputOnly hspe8UpperFloor)
        {
            var output = new LogicalBinaryOutput()
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO4])
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO5])
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO7])
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO6])
                         .WithInvertedState();

            floor.WithLamp(Floor.LampStairsCeiling, output);

            floor.SetupTurnOnAndOffAutomation()
            .WithTrigger(floor.GetMotionDetector(Floor.StairsLowerMotionDetector))
            .WithTrigger(floor.GetMotionDetector(Floor.StairsUpperMotionDetector))
            //.WithTrigger(floor.GetButton(Floor.ButtonStairsUpper).GetPressedShortlyTrigger())
            .WithTarget(floor.GetStateMachine(Floor.LampStairsCeiling))
            .WithOnDuration(TimeSpan.FromSeconds(10));

            var lamp = floor.GetLamp(Floor.LampStairsCeiling);

            floor.GetButton(Floor.ButtonStairsUpper).GetPressedShortlyTrigger().Triggered += (s, e) =>
            {
                if (lamp.GetState().Equals(BinaryStateId.On))
                {
                    lamp.SetState(BinaryStateId.Off, new AnimateParameter().WithReversedOrder());
                }
                else
                {
                    lamp.SetState(BinaryStateId.On, new AnimateParameter());
                }
            };

            floor.GetButton(Floor.ButtonStairsLowerUpper).GetPressedShortlyTrigger().Triggered += (s, e) =>
            {
                if (lamp.GetState().Equals(BinaryStateId.On))
                {
                    lamp.SetState(BinaryStateId.Off, new AnimateParameter());
                }
                else
                {
                    lamp.SetState(BinaryStateId.On, new AnimateParameter().WithReversedOrder());
                }
            };
        }
コード例 #9
0
ファイル: FloorConfiguration.cs プロジェクト: v1ku/HA4IoT
        private void SetupStairsCeilingLamps(IArea room, HSPE8OutputOnly hspe8UpperFloor)
        {
            var output = new LogicalBinaryOutput()
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO4])
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO5])
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO7])
                         .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO6])
                         .WithInvertedState();

            _actuatorFactory.RegisterLamp(room, Floor.LampStairsCeiling, output);

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Floor.LampStairsCeilingAutomation)
            .WithTrigger(room.GetMotionDetector(Floor.StairsLowerMotionDetector))
            .WithTrigger(room.GetMotionDetector(Floor.StairsUpperMotionDetector))
            //.WithTrigger(floor.GetButton(Floor.ButtonStairsUpper).GetPressedShortlyTrigger())
            .WithTarget(room.GetStateMachine(Floor.LampStairsCeiling));

            var lamp = room.GetLamp(Floor.LampStairsCeiling);

            room.GetButton(Floor.ButtonStairsUpper).GetPressedShortlyTrigger().Triggered += (s, e) =>
            {
                if (lamp.GetState().Equals(BinaryStateId.On))
                {
                    lamp.SetState(BinaryStateId.Off, new AnimateParameter().WithReversedOrder());
                }
                else
                {
                    lamp.SetState(BinaryStateId.On, new AnimateParameter());
                }
            };

            room.GetButton(Floor.ButtonStairsLowerUpper).GetPressedShortlyTrigger().Triggered += (s, e) =>
            {
                if (lamp.GetState().Equals(BinaryStateId.On))
                {
                    lamp.SetState(BinaryStateId.Off, new AnimateParameter());
                }
                else
                {
                    lamp.SetState(BinaryStateId.On, new AnimateParameter().WithReversedOrder());
                }
            };
        }
コード例 #10
0
        private void SetupStateMachine(StateMachine stateMachine, IArea garden)
        {
            stateMachine.AddOffState()
                .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("Te"))
                .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("G"))
                .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("W"))
                .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("D"))
                .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("Ti"))
                .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.On);

            stateMachine.AddState(new NamedComponentState("G+W"))
                .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("Te+G+W"))
                .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
                .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("Te+G+W+D+Ti"))
                .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.On)
                .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.On);
        }
コード例 #11
0
ファイル: Configuration.cs プロジェクト: wuzhenda/HA4IoT
        private void InitializeStateMachine(StateMachine stateMachine, IArea garden)
        {
            var turnOffCommand = new TurnOffCommand();
            var turnOnCommand  = new TurnOnCommand();

            stateMachine.ResetStateId = StateMachineStateExtensions.OffStateId;

            stateMachine.AddOffState()
            .WithCommand(garden.GetComponent(Garden.LampTerrace), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampTerrace), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampGarage), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampTap), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.SpotlightRoof), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampRearArea), turnOffCommand);

            stateMachine.AddState("Te")
            .WithCommand(garden.GetLamp(Garden.LampTerrace), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.LampGarage), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampTap), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.SpotlightRoof), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampRearArea), turnOffCommand);

            stateMachine.AddState("G")
            .WithCommand(garden.GetLamp(Garden.LampTerrace), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampGarage), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.LampTap), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.SpotlightRoof), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampRearArea), turnOffCommand);

            stateMachine.AddState("W")
            .WithCommand(garden.GetLamp(Garden.LampTerrace), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampGarage), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampTap), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.SpotlightRoof), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampRearArea), turnOffCommand);

            stateMachine.AddState("D")
            .WithCommand(garden.GetLamp(Garden.LampTerrace), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampGarage), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampTap), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.SpotlightRoof), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.LampRearArea), turnOffCommand);

            stateMachine.AddState("Ti")
            .WithCommand(garden.GetLamp(Garden.LampTerrace), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampGarage), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampTap), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.SpotlightRoof), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampRearArea), turnOnCommand);

            stateMachine.AddState("G+W")
            .WithCommand(garden.GetLamp(Garden.LampTerrace), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampGarage), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.LampTap), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.SpotlightRoof), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampRearArea), turnOffCommand);

            stateMachine.AddState("Te+G+W")
            .WithCommand(garden.GetLamp(Garden.LampTerrace), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.LampGarage), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.LampTap), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.SpotlightRoof), turnOffCommand)
            .WithCommand(garden.GetLamp(Garden.LampRearArea), turnOffCommand);

            stateMachine.AddOnState()
            .WithCommand(garden.GetLamp(Garden.LampTerrace), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.LampGarage), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.LampTap), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.SpotlightRoof), turnOnCommand)
            .WithCommand(garden.GetLamp(Garden.LampRearArea), turnOnCommand);
        }
コード例 #12
0
        private void SetupStairsLamps(IArea room, HSPE16OutputOnly hspe16FloorAndLowerBathroom)
        {
            var output = new LogicalBinaryOutput()
                .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO8])
                .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO9])
                .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO10])
                .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO11])
                .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO13])
                .WithOutput(hspe16FloorAndLowerBathroom[HSPE16Pin.GPIO12])
                .WithInvertedState();

            _actuatorFactory.RegisterLamp(room, Floor.LampStairs, output);

            _automationFactory.RegisterConditionalOnAutomation(room, Floor.LampStairsAutomation)
                .WithActuator(room.GetLamp(Floor.LampStairs))
                .WithOnAtNightRange()
                .WithOffBetweenRange(TimeSpan.FromHours(23), TimeSpan.FromHours(4));
        }
コード例 #13
0
        private void SetupStairsCeilingLamps(IArea room, HSPE8OutputOnly hspe8UpperFloor)
        {
            var output = new LogicalBinaryOutput()
                .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO4])
                .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO5])
                .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO7])
                .WithOutput(hspe8UpperFloor[HSPE8Pin.GPIO6])
                .WithInvertedState();

            _actuatorFactory.RegisterLamp(room, Floor.LampStairsCeiling, output);

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Floor.LampStairsCeilingAutomation)
                .WithTrigger(room.GetMotionDetector(Floor.StairsLowerMotionDetector))
                .WithTrigger(room.GetMotionDetector(Floor.StairsUpperMotionDetector))
                //.WithTrigger(floor.GetButton(Floor.ButtonStairsUpper).GetPressedShortlyTrigger())
                .WithTarget(room.GetStateMachine(Floor.LampStairsCeiling));

            var lamp = room.GetLamp(Floor.LampStairsCeiling);

            room.GetButton(Floor.ButtonStairsUpper).GetPressedShortlyTrigger().Triggered += (s, e) =>
            {
                if (lamp.GetState().Equals(BinaryStateId.On))
                {
                    lamp.SetState(BinaryStateId.Off, new AnimateParameter().WithReversedOrder());
                }
                else
                {
                    lamp.SetState(BinaryStateId.On, new AnimateParameter());
                }
            };

            room.GetButton(Floor.ButtonStairsLowerUpper).GetPressedShortlyTrigger().Triggered += (s, e) =>
            {
                if (lamp.GetState().Equals(BinaryStateId.On))
                {
                    lamp.SetState(BinaryStateId.Off, new AnimateParameter());
                }
                else
                {
                    lamp.SetState(BinaryStateId.On, new AnimateParameter().WithReversedOrder());
                }
            };
        }
コード例 #14
0
        private void SetupStateMachine(StateMachine stateMachine, IArea garden)
        {
            stateMachine.AddOffState()
            .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("Te"))
            .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("G"))
            .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("W"))
            .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("D"))
            .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("Ti"))
            .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.On);

            stateMachine.AddState(new NamedComponentState("G+W"))
            .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("Te+G+W"))
            .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.Off)
            .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.Off);

            stateMachine.AddState(new NamedComponentState("Te+G+W+D+Ti"))
            .WithActuator(garden.GetLamp(Garden.LampTerrace), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.LampGarage), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.LampTap), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.SpotlightRoof), BinaryStateId.On)
            .WithActuator(garden.GetLamp(Garden.LampRearArea), BinaryStateId.On);
        }
コード例 #15
0
        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);
        }