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(); }
protected override async Task ConfigureAsync() { AddDevice(new BuiltInI2CBus()); var ccToolsBoardController = new CCToolsBoardController(this, GetDevice <II2CBus>()); AddDevice(new Pi2PortController()); AddDevice(ccToolsBoardController); AddDevice(new I2CHardwareBridge(new I2CSlaveAddress(50), GetDevice <II2CBus>(), ServiceLocator.GetService <ISchedulerService>())); AddDevice(SetupRemoteSwitchController()); ServiceLocator.RegisterService(typeof(SynonymService), new SynonymService()); ServiceLocator.RegisterService(typeof(OpenWeatherMapService), new OpenWeatherMapService( ApiController, ServiceLocator.GetService <IDateTimeService>(), ServiceLocator.GetService <ISchedulerService>(), ServiceLocator.GetService <ISystemInformationService>())); SetupTelegramBot(); SetupTwitterClient(); ServiceLocator.GetService <SynonymService>().TryLoadPersistedSynonyms(); ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input0, new I2CSlaveAddress(42)); ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input1, new I2CSlaveAddress(43)); ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input2, new I2CSlaveAddress(47)); ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input3, new I2CSlaveAddress(45)); ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input4, new I2CSlaveAddress(46)); ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.Input5, new I2CSlaveAddress(44)); new BedroomConfiguration(this).Setup(); new OfficeConfiguration(this).Setup(); new UpperBathroomConfiguration(this).Setup(); new ReadingRoomConfiguration(this).Setup(); new ChildrensRoomRoomConfiguration(this).Setup(); new KitchenConfiguration(this).Setup(); new FloorConfiguration(this).Setup(); new LowerBathroomConfiguration(this).Setup(); new StoreroomConfiguration(this).Setup(); new LivingRoomConfiguration(this).Setup(); ServiceLocator.GetService <SynonymService>().RegisterDefaultComponentStateSynonyms(this); InitializeAzureCloudApiEndpoint(); var ioBoardsInterruptMonitor = new InterruptMonitor(GetDevice <Pi2PortController>().GetInput(4)); ioBoardsInterruptMonitor.InterruptDetected += (s, e) => ccToolsBoardController.PollInputBoardStates(); ioBoardsInterruptMonitor.Start(); await base.ConfigureAsync(); }
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(); }
protected override async Task ConfigureAsync() { AddDevice(new BuiltInI2CBus()); var piPortController = new Pi2PortController(); AddDevice(piPortController); var ccToolsBoardController = new CCToolsBoardController(this, GetDevice <II2CBus>()); AddDevice(ccToolsBoardController); // Setup the remote switch 433Mhz sender which is attached to the I2C bus (Arduino Nano). AddDevice(new I2CHardwareBridge(new I2CSlaveAddress(50), GetDevice <II2CBus>(), ServiceLocator.GetService <ISchedulerService>())); ServiceLocator.RegisterService(typeof(SynonymService), new SynonymService()); ServiceLocator.RegisterService(typeof(OpenWeatherMapService), new OpenWeatherMapService(ApiController, ServiceLocator.GetService <IDateTimeService>(), ServiceLocator.GetService <ISchedulerService>(), ServiceLocator.GetService <ISystemInformationService>())); SetupRoom(); ServiceLocator.GetService <SynonymService>().TryLoadPersistedSynonyms(); ServiceLocator.GetService <SynonymService>().RegisterDefaultComponentStateSynonyms(this); Timer.Tick += (s, e) => { piPortController.PollOpenInputPorts(); ccToolsBoardController.PollInputBoardStates(); }; SetupDemo(); await base.ConfigureAsync(); }
protected override void Initialize() { // Setup the health monitor which tracks the average time and let an LED blink if everything is healthy. InitializeHealthMonitor(LedGpio); // Setup the controller which provides ports from the GPIOs of the Pi2. var pi2PortController = new Pi2PortController(); // Setup the wrapper for I2C bus access. var i2CBus = new BuiltInI2CBus(Logger); // Setup the controller which creates ports for IO boards from CCTools (or based on PCF8574/MAX7311/PCA9555D). var ccToolsBoardController = new CCToolsBoardController(this, i2CBus, HttpApiController, Logger); var hspe16 = ccToolsBoardController.CreateHSPE16InputOnly(InstalledDevice.HSPE16, new I2CSlaveAddress(41)); var hsrel8 = ccToolsBoardController.CreateHSREL8(InstalledDevice.HSRel8, new I2CSlaveAddress(40)); var hsrel5 = ccToolsBoardController.CreateHSREL5(InstalledDevice.HSRel5, new I2CSlaveAddress(56)); // Setup the remote switch 433Mhz sender which is attached to the I2C bus (Arduino Nano). var i2CHardwareBridge = new I2CHardwareBridge(new DeviceId("HB"), new I2CSlaveAddress(50), i2CBus, Timer); var remoteSwitchSender = new LPD433MHzSignalSender(i2CHardwareBridge, I2CHardwareBridge433MHzSenderPin, HttpApiController); // Setup the controller which creates ports for wireless sockets (433Mhz). var ic = new IntertechnoCodeSequenceProvider(); var remoteSwitchController = new RemoteSocketController(new DeviceId("RemoteSocketController"), remoteSwitchSender, Timer) .WithRemoteSocket(0, ic.GetSequence(IntertechnoSystemCode.A, IntertechnoUnitCode.Unit1, RemoteSocketCommand.TurnOn), ic.GetSequence(IntertechnoSystemCode.A, IntertechnoUnitCode.Unit1, RemoteSocketCommand.TurnOff)); // Setup the weather station which provides sunrise and sunset information. AddDevice(new OpenWeatherMapWeatherStation(OpenWeatherMapWeatherStation.DefaultDeviceId, Timer, HttpApiController, Logger)); // Add the example area with the example actuators. var area = this.CreateArea(Room.ExampleRoom) .WithTemperatureSensor(ExampleRoom.TemperatureSensor, i2CHardwareBridge.DHT22Accessor.GetTemperatureSensor(5)) .WithHumiditySensor(ExampleRoom.HumiditySensor, i2CHardwareBridge.DHT22Accessor.GetHumiditySensor(5)) .WithMotionDetector(ExampleRoom.MotionDetector, hspe16.GetInput(8)) .WithWindow(ExampleRoom.Window, w => w.WithCenterCasement(hspe16.GetInput(0))) .WithLamp(ExampleRoom.Lamp1, remoteSwitchController.GetOutput(0)) .WithSocket(ExampleRoom.Socket1, hsrel5.GetOutput(0)) .WithSocket(ExampleRoom.Socket2, hsrel5.GetOutput(4)) .WithSocket(ExampleRoom.BathroomFan, hsrel5.GetOutput(3)) .WithLamp(ExampleRoom.Lamp2, hsrel8.GetOutput(0)) .WithLamp(ExampleRoom.Lamp3, hsrel8.GetOutput(1)) .WithLamp(ExampleRoom.Lamp4, hsrel8.GetOutput(2)) .WithLamp(ExampleRoom.Lamp5, hsrel8.GetOutput(3)) .WithLamp(ExampleRoom.Lamp6, hsrel8.GetOutput(4)) .WithButton(ExampleRoom.Button1, hspe16.GetInput(1)) .WithButton(ExampleRoom.Button2, hspe16.GetInput(2)) .WithVirtualButtonGroup(ExampleRoom.LedStripRemote, g => SetupLEDStripRemote(i2CHardwareBridge, g)) .WithStateMachine(ExampleRoom.CeilingFan, (sm, r) => SetupCeilingFan(sm)); area.Lamp(ExampleRoom.Lamp5).ConnectToggleActionWith(area.Button(ExampleRoom.Button1)); area.Lamp(ExampleRoom.Lamp6).ConnectToggleActionWith(area.Button(ExampleRoom.Button1), ButtonPressedDuration.Long); area.StateMachine(ExampleRoom.CeilingFan).ConnectMoveNextAndToggleOffWith(area.Button(ExampleRoom.Button2)); SetupHumidityDependingOutput(area.HumiditySensor(ExampleRoom.HumiditySensor), hsrel8.GetOutput(5)); area.SetupTurnOnAndOffAutomation() .WithTrigger(area.MotionDetector(ExampleRoom.MotionDetector)) .WithTarget(area.BinaryStateOutput(ExampleRoom.BathroomFan)) .WithTarget(area.BinaryStateOutput(ExampleRoom.Lamp2)) .WithOnDuration(TimeSpan.FromSeconds(10)); Timer.Tick += (s, e) => { pi2PortController.PollOpenInputPorts(); ccToolsBoardController.PollInputBoardStates(); }; }