Exemplo n.º 1
0
        protected override void Initialize()
        {
            InitializeHealthMonitor(22);

            var pi2PortController = new Pi2PortController();

            AddDevice(new BuiltInI2CBus(Logger));
            AddDevice(new OpenWeatherMapWeatherStation(OpenWeatherMapWeatherStation.DefaultDeviceId, Timer, HttpApiController, Logger));

            var ccToolsFactory = new CCToolsBoardController(this, Device <II2CBus>(), HttpApiController, Logger);
            var hsrt16         = ccToolsFactory.CreateHSRT16(Device.CellarHSRT16, new I2CSlaveAddress(32));

            var garden = this.CreateArea(RoomId.Garden)
                         .WithLamp(Garden.LampTerrace, hsrt16[HSRT16Pin.Relay15])
                         .WithLamp(Garden.LampGarage, hsrt16[HSRT16Pin.Relay14])
                         .WithLamp(Garden.LampTap, hsrt16[HSRT16Pin.Relay13])
                         .WithLamp(Garden.SpotlightRoof, hsrt16[HSRT16Pin.Relay12])
                         .WithLamp(Garden.LampRearArea, hsrt16[HSRT16Pin.Relay11])
                         .WithSocket(Garden.SocketPavillion, hsrt16[HSRT16Pin.Relay10])
                         // 9 = free
                         .WithLamp(Garden.LampParkingLot, new LogicalBinaryOutput().WithOutput(hsrt16[HSRT16Pin.Relay8]).WithOutput(hsrt16[HSRT16Pin.Relay6]).WithOutput(hsrt16[HSRT16Pin.Relay7]))
                         .WithButton(Garden.Button, pi2PortController.GetInput(4).WithInvertedState())
                         .WithStateMachine(Garden.StateMachine, SetupStateMachine);

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

            garden.SetupConditionalOnAutomation()
            .WithActuator(garden.Lamp(Garden.LampParkingLot))
            .WithOnAtNightRange(Device <IWeatherStation>())
            .WithOffBetweenRange(TimeSpan.Parse("22:30:00"), TimeSpan.Parse("05:00:00"));

            Timer.Tick += (s, e) => { pi2PortController.PollOpenInputPorts(); };
        }
Exemplo n.º 2
0
        protected override void Initialize()
        {
            InitializeHealthMonitor(LedGpio);

            var pi2PortController      = new Pi2PortController();
            var ccToolsBoardController = new CCToolsBoardController(this, GetDevice <II2CBus>());

            AddDevice(new BuiltInI2CBus());
            AddDevice(pi2PortController);
            AddDevice(ccToolsBoardController);

            RegisterService(new OpenWeatherMapWeatherService(Timer, ApiController));

            var configurationParser = new ConfigurationParser(this);

            configurationParser.RegisterConfigurationExtender(new DefaultConfigurationExtender(configurationParser, this));
            configurationParser.RegisterConfigurationExtender(new CCToolsConfigurationExtender(configurationParser, this));
            configurationParser.RegisterConfigurationExtender(new I2CHardwareBridgeConfigurationExtender(configurationParser, this));
            configurationParser.ParseConfiguration();

            InitializeAzureCloudApiEndpoint();

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

            ioBoardsInterruptMonitor.InterruptDetected += (s, e) => ccToolsBoardController.PollInputBoardStates();
            ioBoardsInterruptMonitor.StartPollingAsync();
        }
Exemplo n.º 3
0
        protected override async Task ConfigureAsync()
        {
            AddDevice(new BuiltInI2CBus());

            var pi2PortController      = new Pi2PortController();
            var ccToolsBoardController = new CCToolsBoardController(this, GetDevice <II2CBus>());

            AddDevice(pi2PortController);
            AddDevice(ccToolsBoardController);

            ServiceLocator.RegisterService(
                typeof(OpenWeatherMapWeatherService),
                new OpenWeatherMapService(ApiController,
                                          ServiceLocator.GetService <IDateTimeService>(),
                                          ServiceLocator.GetService <ISchedulerService>(),
                                          ServiceLocator.GetService <ISystemInformationService>()));

            var configurationParser = new ConfigurationParser(this);

            configurationParser.RegisterConfigurationExtender(new DefaultConfigurationExtender(configurationParser, this));
            configurationParser.RegisterConfigurationExtender(new CCToolsConfigurationExtender(configurationParser, this));
            configurationParser.RegisterConfigurationExtender(new I2CHardwareBridgeConfigurationExtender(configurationParser, this));
            configurationParser.ParseConfiguration();

            InitializeAzureCloudApiEndpoint();

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

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

            await base.ConfigureAsync();
        }
Exemplo n.º 4
0
        protected override void Initialize()
        {
            InitializeHealthMonitor(22);

            var pi2PortController = new Pi2PortController();

            AddDevice(new BuiltInI2CBus(Logger));
            AddDevice(new I2CHardwareBridge(new DeviceId("HB"), new I2CSlaveAddress(50), Device <II2CBus>(), Timer));
            AddDevice(new OpenWeatherMapWeatherStation(OpenWeatherMapWeatherStation.DefaultDeviceId, Timer, HttpApiController, Logger));

            var ccToolsBoardController = new CCToolsBoardController(this, Device <II2CBus>(), HttpApiController, Logger);

            var configurationParser = new ConfigurationParser(this);

            configurationParser.RegisterConfigurationExtender(new CCToolsConfigurationExtender(configurationParser, this));
            configurationParser.ParseConfiguration();

            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input0, new I2CSlaveAddress(42));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input1, new I2CSlaveAddress(43));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input2, new I2CSlaveAddress(47));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input3, new I2CSlaveAddress(45));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input4, new I2CSlaveAddress(46));
            ccToolsBoardController.CreateHSPE16InputOnly(Main.Device.Input5, new I2CSlaveAddress(44));

            RemoteSocketController remoteSwitchController = SetupRemoteSwitchController();

            new BedroomConfiguration(this, ccToolsBoardController).Setup();
            new OfficeConfiguration().Setup(this, ccToolsBoardController, remoteSwitchController);
            new UpperBathroomConfiguration(this, ccToolsBoardController).Setup();
            new ReadingRoomConfiguration().Setup(this, ccToolsBoardController);
            new ChildrensRoomRoomConfiguration().Setup(this, ccToolsBoardController);
            new KitchenConfiguration().Setup(this, ccToolsBoardController);
            new FloorConfiguration().Setup(this, ccToolsBoardController);
            new LowerBathroomConfiguration().Setup(this);
            new StoreroomConfiguration().Setup(this, ccToolsBoardController);
            new LivingRoomConfiguration().Setup(this, ccToolsBoardController);

            //AttachAzureEventHubPublisher(home);

            var localCsvFileWriter = new CsvHistory(Logger, HttpApiController);

            localCsvFileWriter.ConnectActuators(this);
            localCsvFileWriter.ExposeToApi(HttpApiController);

            var ioBoardsInterruptMonitor = new InterruptMonitor(pi2PortController.GetInput(4), Logger);

            ioBoardsInterruptMonitor.InterruptDetected += (s, e) => ccToolsBoardController.PollInputBoardStates();
            ioBoardsInterruptMonitor.StartPollingAsync();
        }
Exemplo n.º 5
0
        protected override async Task ConfigureAsync()
        {
            var pi2PortController = new Pi2PortController();

            AddDevice(new BuiltInI2CBus());

            ServiceLocator.RegisterService(typeof(OpenWeatherMapWeatherService),
                                           new OpenWeatherMapService(ApiController,
                                                                     ServiceLocator.GetService <IDateTimeService>(),
                                                                     ServiceLocator.GetService <ISchedulerService>(),
                                                                     ServiceLocator.GetService <ISystemInformationService>()));

            var ccToolsFactory = new CCToolsBoardController(this, GetDevice <II2CBus>());
            var hsrt16         = ccToolsFactory.CreateHSRT16(Device.CellarHSRT16, new I2CSlaveAddress(32));

            var garden = this.CreateArea(RoomId.Garden)
                         .WithLamp(Garden.LampTerrace, hsrt16[HSRT16Pin.Relay15])
                         .WithLamp(Garden.LampGarage, hsrt16[HSRT16Pin.Relay14])
                         .WithLamp(Garden.LampTap, hsrt16[HSRT16Pin.Relay13])
                         .WithLamp(Garden.SpotlightRoof, hsrt16[HSRT16Pin.Relay12])
                         .WithLamp(Garden.LampRearArea, hsrt16[HSRT16Pin.Relay11])
                         .WithSocket(Garden.SocketPavillion, hsrt16[HSRT16Pin.Relay10])
                         // 9 = free
                         .WithLamp(Garden.LampParkingLot, new LogicalBinaryOutput().WithOutput(hsrt16[HSRT16Pin.Relay8]).WithOutput(hsrt16[HSRT16Pin.Relay6]).WithOutput(hsrt16[HSRT16Pin.Relay7]))
                         .WithButton(Garden.Button, pi2PortController.GetInput(4).WithInvertedState())
                         .WithStateMachine(Garden.StateMachine, SetupStateMachine);

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

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

            Timer.Tick += (s, e) => { pi2PortController.PollOpenInputPorts(); };

            await base.ConfigureAsync();
        }