Пример #1
0
        public Task ApplyAsync()
        {
            var hsrt16 = _deviceRegistryService.GetDevice <HSRT16>("HSRT16");

            var garden = _areaService.RegisterArea("Garden");

            var parkingLotOutput = new LogicalBinaryOutput(hsrt16[HSRT16Pin.Relay6], hsrt16[HSRT16Pin.Relay7], hsrt16[HSRT16Pin.Relay8]);

            _actuatorFactory.RegisterLamp(garden, Garden.LampParkingLot, parkingLotOutput);
            // Relay 9 is free.
            _actuatorFactory.RegisterSocket(garden, Garden.SocketPavillion, hsrt16[HSRT16Pin.Relay10]);
            _actuatorFactory.RegisterLamp(garden, Garden.LampRearArea, hsrt16[HSRT16Pin.Relay11]);
            _actuatorFactory.RegisterLamp(garden, Garden.SpotlightRoof, hsrt16[HSRT16Pin.Relay12]);
            _actuatorFactory.RegisterLamp(garden, Garden.LampTap, hsrt16[HSRT16Pin.Relay13]);
            _actuatorFactory.RegisterLamp(garden, Garden.LampGarage, hsrt16[HSRT16Pin.Relay14]);
            _actuatorFactory.RegisterLamp(garden, Garden.LampTerrace, hsrt16[HSRT16Pin.Relay15]);
            var stateMachine = _actuatorFactory.RegisterStateMachine(garden, Garden.StateMachine, InitializeStateMachine);

            var button = _sensorFactory.RegisterButton(garden, Garden.Button, _gpioService.GetInput(4, GpioPullMode.High, GpioInputMonitoringMode.Interrupt).WithInvertedState());

            button.CreatePressedShortTrigger(_messageBroker).Attach(() => stateMachine.TrySetNextState());
            button.CreatePressedLongTrigger(_messageBroker).Attach(() => stateMachine.TryTurnOff());

            _automationFactory.RegisterConditionalOnAutomation(garden, Garden.LampParkingLotAutomation)
            .WithComponent(garden.GetLamp(Garden.LampParkingLot))
            .WithOnAtNightRange()
            .WithOffBetweenRange(TimeSpan.Parse("22:30:00"), TimeSpan.Parse("05:00:00"));

            return(Task.FromResult(0));
        }
Пример #2
0
        public Task ApplyAsync()
        {
            var hsrt16 = _ccToolsBoardService.RegisterHSRT16("HSRT16", new I2CSlaveAddress(32));

            var garden = _areaService.RegisterArea("Garden");

            var parkingLotLamp = new LogicalBinaryOutput(hsrt16[HSRT16Pin.Relay6], hsrt16[HSRT16Pin.Relay7], hsrt16[HSRT16Pin.Relay8]);

            _actuatorFactory.RegisterLamp(garden, Garden.LampParkingLot, parkingLotLamp);
            // Relay 9 is free.
            _actuatorFactory.RegisterSocket(garden, Garden.SocketPavillion, hsrt16[HSRT16Pin.Relay10]);
            _actuatorFactory.RegisterLamp(garden, Garden.LampRearArea, hsrt16[HSRT16Pin.Relay11]);
            _actuatorFactory.RegisterLamp(garden, Garden.SpotlightRoof, hsrt16[HSRT16Pin.Relay12]);
            _actuatorFactory.RegisterLamp(garden, Garden.LampTap, hsrt16[HSRT16Pin.Relay13]);
            _actuatorFactory.RegisterLamp(garden, Garden.LampGarage, hsrt16[HSRT16Pin.Relay14]);
            _actuatorFactory.RegisterLamp(garden, Garden.LampTerrace, hsrt16[HSRT16Pin.Relay15]);
            var stateMachine = _actuatorFactory.RegisterStateMachine(garden, Garden.StateMachine, InitializeStateMachine);

            var button = _sensorFactory.RegisterButton(garden, Garden.Button, _pi2GpioService.GetInput(4).WithInvertedState());

            button.PressedShortTrigger.Attach(() => stateMachine.TrySetNextState());
            button.PressedLongTrigger.Attach(() => stateMachine.TryTurnOff());

            _automationFactory.RegisterConditionalOnAutomation(garden, Garden.LampParkingLotAutomation)
            .WithComponent(garden.GetLamp(Garden.LampParkingLot))
            .WithOnAtNightRange()
            .WithOffBetweenRange(TimeSpan.Parse("22:30:00"), TimeSpan.Parse("05:00:00"));

            var ioBoardsInterruptMonitor = new InterruptMonitor(_pi2GpioService.GetInput(4), _logService);

            ioBoardsInterruptMonitor.AddCallback(_ccToolsBoardService.PollInputBoardStates);
            ioBoardsInterruptMonitor.Start();

            return(Task.FromResult(0));
        }
Пример #3
0
            public Task ApplyAsync()
            {
                var hsrt16 = _ccToolsBoardService.RegisterHSRT16(InstalledDevice.CellarHSRT16, new I2CSlaveAddress(32));

                var garden = _areaService.CreateArea(Room.Garden);

                var parkingLotLamp = new LogicalBinaryOutput(hsrt16[HSRT16Pin.Relay6], hsrt16[HSRT16Pin.Relay7], hsrt16[HSRT16Pin.Relay8]);

                _actuatorFactory.RegisterLamp(garden, Garden.LampParkingLot, parkingLotLamp);
                // Relay 9 is free.
                _actuatorFactory.RegisterSocket(garden, Garden.SocketPavillion, hsrt16[HSRT16Pin.Relay10]);
                _actuatorFactory.RegisterLamp(garden, Garden.LampRearArea, hsrt16[HSRT16Pin.Relay11]);
                _actuatorFactory.RegisterLamp(garden, Garden.SpotlightRoof, hsrt16[HSRT16Pin.Relay12]);
                _actuatorFactory.RegisterLamp(garden, Garden.LampTap, hsrt16[HSRT16Pin.Relay13]);
                _actuatorFactory.RegisterLamp(garden, Garden.LampGarage, hsrt16[HSRT16Pin.Relay14]);
                _actuatorFactory.RegisterLamp(garden, Garden.LampTerrace, hsrt16[HSRT16Pin.Relay15]);
                _actuatorFactory.RegisterStateMachine(garden, Garden.StateMachine, InitializeStateMachine);

                _sensorFactory.RegisterButton(garden, Garden.Button, _pi2GpioService.GetInput(4).WithInvertedState());

                garden.GetStateMachine(Garden.StateMachine).ConnectMoveNextAndToggleOffWith(garden.GetButton(Garden.Button));

                _automationFactory.RegisterConditionalOnAutomation(garden, Garden.LampParkingLotAutomation)
                .WithActuator(garden.GetLamp(Garden.LampParkingLot))
                .WithOnAtNightRange()
                .WithOffBetweenRange(TimeSpan.Parse("22:30:00"), TimeSpan.Parse("05:00:00"));

                var ioBoardsInterruptMonitor = new InterruptMonitor(_pi2GpioService.GetInput(4));

                ioBoardsInterruptMonitor.InterruptDetected += (s, e) => _ccToolsBoardService.PollInputBoardStates();
                ioBoardsInterruptMonitor.Start();

                return(Task.FromResult(0));
            }
Пример #4
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));
        }