Пример #1
0
        public void Apply()
        {
            var hsrel5 = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.KitchenHSREL5, new I2CSlaveAddress(58));
            var hspe8  = _ccToolsBoardService.RegisterHSPE8OutputOnly(InstalledDevice.KitchenHSPE8, new I2CSlaveAddress(39));

            var input0            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input0);
            var input1            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1);
            var input2            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 11;

            var room = _areaService.CreateArea(Room.Kitchen);

            _sensorFactory.RegisterWindow(room, Kitchen.Window, w => w.WithCenterCasement(input0.GetInput(6), input0.GetInput(7)));

            _sensorFactory.RegisterTemperatureSensor(room, Kitchen.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, Kitchen.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(room, Kitchen.MotionDetector, input1.GetInput(8));

            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingPassageOuter, hspe8.GetOutput(2).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingMiddle, hsrel5.GetOutput(5).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingDoor, hspe8.GetOutput(0).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Kitchen.LightCeilingPassageInner, hspe8.GetOutput(1).WithInvertedState());

            _actuatorFactory.RegisterSocket(room, Kitchen.SocketWall, hsrel5.GetOutput(2));
            _actuatorFactory.RegisterRollerShutter(room, Kitchen.RollerShutter, hsrel5.GetOutput(4), hsrel5.GetOutput(3));
            _sensorFactory.RegisterButton(room, Kitchen.ButtonKitchenette, input1.GetInput(11));
            _sensorFactory.RegisterButton(room, Kitchen.ButtonPassage, input1.GetInput(9));
            _sensorFactory.RegisterRollerShutterButtons(room, Kitchen.RollerShutterButtonUp, input2.GetInput(15),
                                                        Kitchen.RollerShutterButtonDown, input2.GetInput(14));

            room.GetLamp(Kitchen.LightCeilingMiddle).ConnectToggleActionWith(room.GetButton(Kitchen.ButtonKitchenette));
            room.GetLamp(Kitchen.LightCeilingMiddle).ConnectToggleActionWith(room.GetButton(Kitchen.ButtonPassage));

            _automationFactory.RegisterRollerShutterAutomation(room, Kitchen.RollerShutterAutomation)
            .WithRollerShutters(room.GetRollerShutter(Kitchen.RollerShutter));

            room.GetRollerShutter(Kitchen.RollerShutter).ConnectWith(
                room.GetButton(Kitchen.RollerShutterButtonUp), room.GetButton(Kitchen.RollerShutterButtonDown));

            _actuatorFactory.RegisterLogicalActuator(room, Kitchen.CombinedAutomaticLights)
            .WithActuator(room.GetLamp(Kitchen.LightCeilingWall))
            .WithActuator(room.GetLamp(Kitchen.LightCeilingDoor))
            .WithActuator(room.GetLamp(Kitchen.LightCeilingWindow));

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Kitchen.CombinedAutomaticLightsAutomation)
            .WithTrigger(room.GetMotionDetector(Kitchen.MotionDetector))
            .WithTarget(room.GetActuator(Kitchen.CombinedAutomaticLights))
            .WithEnabledAtNight();

            _synonymService.AddSynonymsForArea(Room.Kitchen, "Küche", "Kitchen");
        }
Пример #2
0
        public void Apply()
        {
            var hsrel5            = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.ReadingRoomHSREL5, new I2CSlaveAddress(62));
            var input2            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 9;

            var room = _areaService.CreateArea(Room.ReadingRoom);

            _sensorFactory.RegisterWindow(room, ReadingRoom.Window, w => w.WithCenterCasement(input2.GetInput(8))); // Tilt = input2.GetInput(9) -- currently broken!

            _sensorFactory.RegisterTemperatureSensor(room, ReadingRoom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, ReadingRoom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _actuatorFactory.RegisterLamp(room, ReadingRoom.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO0]);

            _actuatorFactory.RegisterRollerShutter(room, ReadingRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3]);
            _sensorFactory.RegisterRollerShutterButtons(room, ReadingRoom.RollerShutterButtonUp, input2.GetInput(12),
                                                        ReadingRoom.RollerShutterButtonDown, input2.GetInput(11));

            _actuatorFactory.RegisterSocket(room, ReadingRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0]);
            _actuatorFactory.RegisterSocket(room, ReadingRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1]);
            _actuatorFactory.RegisterSocket(room, ReadingRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2]);

            _sensorFactory.RegisterButton(room, ReadingRoom.Button, input2.GetInput(13));

            room.GetLamp(ReadingRoom.LightCeilingMiddle).ConnectToggleActionWith(room.GetButton(ReadingRoom.Button));

            _automationFactory.RegisterRollerShutterAutomation(room, ReadingRoom.RollerShutterAutomation)
            .WithRollerShutters(room.GetRollerShutter(ReadingRoom.RollerShutter));

            room.GetRollerShutter(ReadingRoom.RollerShutter)
            .ConnectWith(room.GetButton(ReadingRoom.RollerShutterButtonUp), room.GetButton(ReadingRoom.RollerShutterButtonDown));

            _synonymService.AddSynonymsForArea(Room.ReadingRoom, "Lesezimmer", "Gästezimmer", "ReadingRoom");
        }
Пример #3
0
        public void Apply()
        {
            var hsrel5            = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.ReadingRoomHSREL5.ToString(), new I2CSlaveAddress(62));
            var input2            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2.ToString());
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 9;

            var area = _areaService.RegisterArea(Room.ReadingRoom);

            _sensorFactory.RegisterWindow(area, ReadingRoom.Window, new PortBasedWindowAdapter(input2.GetInput(8))); // Tilt = input2.GetInput(9) -- currently broken!

            _sensorFactory.RegisterTemperatureSensor(area, ReadingRoom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(area, ReadingRoom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _actuatorFactory.RegisterLamp(area, ReadingRoom.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO0]);

            _actuatorFactory.RegisterRollerShutter(area, ReadingRoom.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3]);
            _sensorFactory.RegisterRollerShutterButtons(area, ReadingRoom.RollerShutterButtonUp, input2.GetInput(12),
                                                        ReadingRoom.RollerShutterButtonDown, input2.GetInput(11));

            _actuatorFactory.RegisterSocket(area, ReadingRoom.SocketWindow, hsrel5[HSREL5Pin.Relay0]);
            _actuatorFactory.RegisterSocket(area, ReadingRoom.SocketWallLeft, hsrel5[HSREL5Pin.Relay1]);
            _actuatorFactory.RegisterSocket(area, ReadingRoom.SocketWallRight, hsrel5[HSREL5Pin.Relay2]);

            _sensorFactory.RegisterButton(area, ReadingRoom.Button, input2.GetInput(13));

            area.GetButton(ReadingRoom.Button).PressedShortTrigger.Attach(() => area.GetLamp(ReadingRoom.LightCeilingMiddle).TryTogglePowerState());

            _automationFactory.RegisterRollerShutterAutomation(area, ReadingRoom.RollerShutterAutomation)
            .WithRollerShutters(area.GetRollerShutter(ReadingRoom.RollerShutter));

            area.GetRollerShutter(ReadingRoom.RollerShutter)
            .ConnectWith(area.GetButton(ReadingRoom.RollerShutterButtonUp), area.GetButton(ReadingRoom.RollerShutterButtonDown));
        }
Пример #4
0
        public void Apply()
        {
            var hsrel5            = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.BedroomHSREL5, new I2CSlaveAddress(38));
            var hsrel8            = _ccToolsBoardService.RegisterHSREL8(InstalledDevice.BedroomHSREL8, new I2CSlaveAddress(21));
            var input5            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input5);
            var input4            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input4);
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 6;

            var room = _areaService.CreateArea(Room.Bedroom);

            _sensorFactory.RegisterWindow(room, Bedroom.WindowLeft, w => w.WithCenterCasement(input5.GetInput(2)));
            _sensorFactory.RegisterWindow(room, Bedroom.WindowRight, w => w.WithCenterCasement(input5.GetInput(3)));

            _sensorFactory.RegisterTemperatureSensor(room, Bedroom.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(room, Bedroom.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(room, Bedroom.MotionDetector, input5.GetInput(12));

            _sensorFactory.RegisterButton(room, Bedroom.ButtonWindowUpper, input5.GetInput(10));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonWindowLower, input5.GetInput(13));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonBedLeftInner, input4.GetInput(2));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonBedLeftOuter, input4.GetInput(0));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonBedRightInner, input4.GetInput(1));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonBedRightOuter, input4.GetInput(3));
            _sensorFactory.RegisterButton(room, Bedroom.ButtonDoor, input5.GetInput(11));

            _sensorFactory.RegisterRollerShutterButtons(room, Bedroom.RollerShutterButtonsUpperUp, input5.GetInput(6),
                                                        Bedroom.RollerShutterButtonsUpperDown, input5.GetInput(7));

            _sensorFactory.RegisterRollerShutterButtons(room, Bedroom.RollerShutterButtonsLowerUp, input5.GetInput(4),
                                                        Bedroom.RollerShutterButtonsLowerDown, input5.GetInput(5));

            _actuatorFactory.RegisterLamp(room, Bedroom.LightCeiling, hsrel5.GetOutput(5).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Bedroom.LightCeilingWindow, hsrel5.GetOutput(6).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Bedroom.LightCeilingWall, hsrel5.GetOutput(7).WithInvertedState());
            _actuatorFactory.RegisterLamp(room, Bedroom.LampBedLeft, hsrel5.GetOutput(4));
            _actuatorFactory.RegisterLamp(room, Bedroom.LampBedRight, hsrel8.GetOutput(8).WithInvertedState());

            _actuatorFactory.RegisterSocket(room, Bedroom.SocketWindowLeft, hsrel5[HSREL5Pin.Relay0]);
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketWindowRight, hsrel5[HSREL5Pin.Relay1]);
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketWall, hsrel5[HSREL5Pin.Relay2]);
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketWallEdge, hsrel5[HSREL5Pin.Relay3]);
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketBedLeft, hsrel8.GetOutput(7));
            _actuatorFactory.RegisterSocket(room, Bedroom.SocketBedRight, hsrel8.GetOutput(9));

            _actuatorFactory.RegisterRollerShutter(room, Bedroom.RollerShutterLeft, hsrel8[HSREL8Pin.Relay6], hsrel8[HSREL8Pin.Relay5]);
            _actuatorFactory.RegisterRollerShutter(room, Bedroom.RollerShutterRight, hsrel8[HSREL8Pin.Relay3], hsrel8[HSREL8Pin.Relay4]);

            room.GetRollerShutter(Bedroom.RollerShutterLeft)
            .ConnectWith(room.GetButton(Bedroom.RollerShutterButtonsUpperUp), room.GetButton(Bedroom.RollerShutterButtonsUpperDown));

            room.GetRollerShutter(Bedroom.RollerShutterRight)
            .ConnectWith(room.GetButton(Bedroom.RollerShutterButtonsLowerUp), room.GetButton(Bedroom.RollerShutterButtonsLowerDown));

            _actuatorFactory.RegisterLogicalActuator(room, Bedroom.CombinedCeilingLights)
            .WithActuator(room.GetLamp(Bedroom.LightCeilingWall))
            .WithActuator(room.GetLamp(Bedroom.LightCeilingWindow))
            .ConnectToggleActionWith(room.GetButton(Bedroom.ButtonDoor))
            .ConnectToggleActionWith(room.GetButton(Bedroom.ButtonWindowUpper));

            room.GetButton(Bedroom.ButtonDoor).GetPressedLongTrigger().Attach(() =>
            {
                room.GetStateMachine(Bedroom.LampBedLeft).TryTurnOff();
                room.GetStateMachine(Bedroom.LampBedRight).TryTurnOff();
                room.GetStateMachine(Bedroom.CombinedCeilingLights).TryTurnOff();
            });

            _automationFactory.RegisterRollerShutterAutomation(room, Bedroom.RollerShuttersAutomation)
            .WithRollerShutters(room.GetRollerShutters())
            .WithDoNotOpenBefore(TimeSpan.FromHours(7).Add(TimeSpan.FromMinutes(15)))
            .WithCloseIfOutsideTemperatureIsGreaterThan(24)
            .WithDoNotOpenIfOutsideTemperatureIsBelowThan(3);

            _automationFactory.RegisterTurnOnAndOffAutomation(room, Bedroom.LightCeilingAutomation)
            .WithTrigger(room.GetMotionDetector(Bedroom.MotionDetector))
            .WithTarget(room.GetStateMachine(Bedroom.LightCeiling))
            .WithTurnOnIfAllRollerShuttersClosed(room.GetRollerShutter(Bedroom.RollerShutterLeft), room.GetRollerShutter(Bedroom.RollerShutterRight))
            .WithEnabledAtNight()
            .WithSkipIfAnyActuatorIsAlreadyOn(room.GetLamp(Bedroom.LampBedLeft), room.GetLamp(Bedroom.LampBedRight));

            _actuatorFactory.RegisterStateMachine(room, Bedroom.Fan, (s, r) => SetupFan(s, r, hsrel8));

            room.GetButton(Bedroom.ButtonBedLeftInner).WithPressedShortlyAction(() => room.GetLamp(Bedroom.LampBedLeft).SetNextState());
            room.GetButton(Bedroom.ButtonBedLeftInner).WithPressedLongAction(() => room.GetStateMachine(Bedroom.CombinedCeilingLights).SetNextState());
            room.GetButton(Bedroom.ButtonBedLeftOuter).WithPressedShortlyAction(() => room.GetStateMachine(Bedroom.Fan).SetNextState());
            room.GetButton(Bedroom.ButtonBedLeftOuter).WithPressedLongAction(() => room.GetStateMachine(Bedroom.Fan).TryTurnOff());

            room.GetButton(Bedroom.ButtonBedRightInner).WithPressedShortlyAction(() => room.GetLamp(Bedroom.LampBedRight).SetNextState());
            room.GetButton(Bedroom.ButtonBedRightInner).WithPressedLongAction(() => room.GetStateMachine(Bedroom.CombinedCeilingLights).SetNextState());
            room.GetButton(Bedroom.ButtonBedRightOuter).WithPressedShortlyAction(() => room.GetStateMachine(Bedroom.Fan).SetNextState());
            room.GetButton(Bedroom.ButtonBedRightOuter).WithPressedLongAction(() => room.GetStateMachine(Bedroom.Fan).TryTurnOff());

            _synonymService.AddSynonymsForArea(Room.Bedroom, "Schlafzimmer", "Bedroom");
        }
Пример #5
0
        public void Apply()
        {
            var hsrel5 = _ccToolsBoardService.RegisterHSREL5(InstalledDevice.KitchenHSREL5.ToString(), new I2CSlaveAddress(58));
            var hspe8  = _ccToolsBoardService.RegisterHSPE8OutputOnly(InstalledDevice.KitchenHSPE8.ToString(), new I2CSlaveAddress(39));

            var input0            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input0.ToString());
            var input1            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input1.ToString());
            var input2            = _deviceService.GetDevice <HSPE16InputOnly>(InstalledDevice.Input2.ToString());
            var i2CHardwareBridge = _deviceService.GetDevice <I2CHardwareBridge>();

            const int SensorPin = 11;

            var area = _areaService.RegisterArea(Room.Kitchen);

            _sensorFactory.RegisterWindow(area, Kitchen.Window, new PortBasedWindowAdapter(input0.GetInput(6), input0.GetInput(7)));

            _sensorFactory.RegisterTemperatureSensor(area, Kitchen.TemperatureSensor,
                                                     i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(SensorPin));

            _sensorFactory.RegisterHumiditySensor(area, Kitchen.HumiditySensor,
                                                  i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(SensorPin));

            _sensorFactory.RegisterMotionDetector(area, Kitchen.MotionDetector, input1.GetInput(8));

            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingMiddle, hsrel5[HSREL5Pin.GPIO0].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingWindow, hsrel5[HSREL5Pin.GPIO1].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingWall, hsrel5[HSREL5Pin.GPIO2].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingDoor, hspe8[HSPE8Pin.GPIO0].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingPassageInner, hspe8[HSPE8Pin.GPIO1].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightCeilingPassageOuter, hspe8[HSPE8Pin.GPIO2].WithInvertedState());
            _actuatorFactory.RegisterLamp(area, Kitchen.LightKitchenette, _outpostDeviceService.GetRgbAdapter("RGBSK1"));

            _actuatorFactory.RegisterSocket(area, Kitchen.SocketKitchenette, hsrel5[HSREL5Pin.Relay1]); // 0?
            _actuatorFactory.RegisterSocket(area, Kitchen.SocketWall, hsrel5[HSREL5Pin.Relay2]);
            _actuatorFactory.RegisterSocket(area, Kitchen.SocketCeiling1, hspe8[HSPE8Pin.GPIO3].WithInvertedState());
            _actuatorFactory.RegisterSocket(area, Kitchen.SocketCeiling2, hspe8[HSPE8Pin.GPIO4].WithInvertedState());

            _systemEventsService.StartupCompleted += (s, e) =>
            {
                area.GetComponent(Kitchen.SocketCeiling1).TryTurnOn();
            };

            _actuatorFactory.RegisterRollerShutter(area, Kitchen.RollerShutter, hsrel5[HSREL5Pin.Relay4], hsrel5[HSREL5Pin.Relay3]);

            _sensorFactory.RegisterButton(area, Kitchen.ButtonKitchenette, input1.GetInput(11));
            _sensorFactory.RegisterButton(area, Kitchen.ButtonPassage, input1.GetInput(9));
            _sensorFactory.RegisterRollerShutterButtons(area, Kitchen.RollerShutterButtonUp, input2.GetInput(15),
                                                        Kitchen.RollerShutterButtonDown, input2.GetInput(14));

            area.GetButton(Kitchen.ButtonKitchenette).PressedShortTrigger.Attach(() => area.GetLamp(Kitchen.LightCeilingMiddle).TryTogglePowerState());
            area.GetButton(Kitchen.ButtonPassage).PressedShortTrigger.Attach(() => area.GetLamp(Kitchen.LightCeilingMiddle).TryTogglePowerState());

            _automationFactory.RegisterRollerShutterAutomation(area, Kitchen.RollerShutterAutomation)
            .WithRollerShutters(area.GetRollerShutter(Kitchen.RollerShutter));

            area.GetRollerShutter(Kitchen.RollerShutter).ConnectWith(
                area.GetButton(Kitchen.RollerShutterButtonUp), area.GetButton(Kitchen.RollerShutterButtonDown));

            area.GetButton(Kitchen.RollerShutterButtonUp).PressedLongTrigger.Attach(() =>
            {
                var light = area.GetComponent(Kitchen.LightKitchenette);
                light.TryTogglePowerState();
                light.TrySetColor(0D, 0D, 1D);
            });

            _actuatorFactory.RegisterLogicalComponent(area, Kitchen.CombinedAutomaticLights)
            .WithComponent(area.GetLamp(Kitchen.LightCeilingWall))
            .WithComponent(area.GetLamp(Kitchen.LightCeilingDoor))
            .WithComponent(area.GetLamp(Kitchen.LightCeilingWindow));

            _automationFactory.RegisterTurnOnAndOffAutomation(area, Kitchen.CombinedAutomaticLightsAutomation)
            .WithTrigger(area.GetMotionDetector(Kitchen.MotionDetector))
            .WithTarget(area.GetComponent(Kitchen.CombinedAutomaticLights))
            .WithEnabledAtNight();
        }