コード例 #1
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.MotionDetector(Floor.StairsLowerMotionDetector), new AnimateParameter())
            .WithTrigger(floor.MotionDetector(Floor.StairsUpperMotionDetector))
            //.WithTrigger(floor.Button(Floor.ButtonStairsUpper))
            .WithTarget(floor.BinaryStateOutput(Floor.LampStairsCeiling))
            .WithOnDuration(TimeSpan.FromSeconds(10));

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

            floor.Button(Floor.ButtonStairsUpper).GetPressedShortlyTrigger().Triggered += (s, e) =>
            {
                if (lamp.GetState() == BinaryActuatorState.On)
                {
                    lamp.TurnOff(new AnimateParameter().WithReversedOrder());
                }
                else
                {
                    lamp.TurnOn(new AnimateParameter());
                }
            };

            floor.Button(Floor.ButtonStairsLowerUpper).GetPressedShortlyTrigger().Triggered += (s, e) =>
            {
                if (lamp.GetState() == BinaryActuatorState.On)
                {
                    lamp.TurnOff(new AnimateParameter());
                }
                else
                {
                    lamp.TurnOn(new AnimateParameter().WithReversedOrder());
                }
            };
        }
コード例 #2
0
        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);
        }