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 SetupLight(StateMachine light, IArea room)
        {
            var lightsCouchOnly = room.CombineActuators(Office.CombinedCeilingLightsCouchOnly)
                                  .WithActuator(room.Lamp(Office.LightCeilingRearRight));

            var lightsDeskOnly = room.CombineActuators(Office.CombinedCeilingLightsDeskOnly)
                                 .WithActuator(room.Lamp(Office.LightCeilingFrontMiddle))
                                 .WithActuator(room.Lamp(Office.LightCeilingFrontLeft))
                                 .WithActuator(room.Lamp(Office.LightCeilingMiddleLeft));

            var lightsOther = room.CombineActuators(Office.CombinedCeilingLightsOther)
                              .WithActuator(room.Lamp(Office.LightCeilingFrontRight))
                              .WithActuator(room.Lamp(Office.LightCeilingMiddleMiddle))
                              .WithActuator(room.Lamp(Office.LightCeilingMiddleRight))
                              .WithActuator(room.Lamp(Office.LightCeilingRearLeft));

            light.WithTurnOffIfStateIsAppliedTwice();

            light.AddOffState()
            .WithActuator(lightsDeskOnly, BinaryActuatorState.Off)
            .WithActuator(lightsCouchOnly, BinaryActuatorState.Off)
            .WithActuator(lightsOther, BinaryActuatorState.Off);

            light.AddOnState()
            .WithActuator(lightsDeskOnly, BinaryActuatorState.On)
            .WithActuator(lightsCouchOnly, BinaryActuatorState.On)
            .WithActuator(lightsOther, BinaryActuatorState.On).
            ConnectApplyStateWith(room.Button(Office.ButtonUpperLeft));

            light.AddState("DeskOnly")
            .WithActuator(lightsDeskOnly, BinaryActuatorState.On)
            .WithActuator(lightsCouchOnly, BinaryActuatorState.Off)
            .WithActuator(lightsOther, BinaryActuatorState.Off)
            .ConnectApplyStateWith(room.Button(Office.ButtonLowerLeft));

            light.AddState("CouchOnly")
            .WithActuator(lightsDeskOnly, BinaryActuatorState.Off)
            .WithActuator(lightsCouchOnly, BinaryActuatorState.On)
            .WithActuator(lightsOther, BinaryActuatorState.Off)
            .ConnectApplyStateWith(room.Button(Office.ButtonLowerRight));
        }
示例#3
0
        private void SetupFan(StateMachine fan, IArea room)
        {
            var fanRelay1 = _hsrel8[HSREL8Pin.Relay0];
            var fanRelay2 = _hsrel8[HSREL8Pin.Relay1];
            var fanRelay3 = _hsrel8[HSREL8Pin.Relay2];

            fan.AddOffState()
            .WithLowPort(fanRelay1)
            .WithLowPort(fanRelay2)
            .WithLowPort(fanRelay3);

            fan.AddState("1").WithHighPort(fanRelay1).WithLowPort(fanRelay2).WithHighPort(fanRelay3);
            fan.AddState("2").WithHighPort(fanRelay1).WithHighPort(fanRelay2).WithLowPort(fanRelay3);
            fan.AddState("3").WithHighPort(fanRelay1).WithHighPort(fanRelay2).WithHighPort(fanRelay3);
            fan.TurnOff();

            fan.ConnectMoveNextAndToggleOffWith(room.Button(Bedroom.ButtonWindowLower));
        }