public IDevice CreateDevice(CCToolsDeviceType type, string id, int address) { if (id == null) { throw new ArgumentNullException(nameof(id)); } var i2CSlaveAddress = new I2CSlaveAddress(address); IDevice deviceInstance; switch (type) { case CCToolsDeviceType.HSPE16_InputOnly: { deviceInstance = new HSPE16InputOnly(id, i2CSlaveAddress, _i2CBusService, _log); break; } case CCToolsDeviceType.HSPE16_OutputOnly: { deviceInstance = new HSPE16OutputOnly(id, i2CSlaveAddress, _i2CBusService, _log); break; } case CCToolsDeviceType.HSPE8_InputOnly: { deviceInstance = new HSPE8InputOnly(id, i2CSlaveAddress, _i2CBusService, _log); break; } case CCToolsDeviceType.HSPE8_OutputOnly: { deviceInstance = new HSPE8OutputOnly(id, i2CSlaveAddress, _i2CBusService, _log); break; } case CCToolsDeviceType.HSRel5: { deviceInstance = new HSREL5(id, i2CSlaveAddress, _i2CBusService, _log); break; } case CCToolsDeviceType.HSRel8: { deviceInstance = new HSREL8(id, i2CSlaveAddress, _i2CBusService, _log); break; } case CCToolsDeviceType.HSRT16: { deviceInstance = new HSRT16(id, i2CSlaveAddress, _i2CBusService, _log); break; } default: throw new NotSupportedException(); } return(deviceInstance); }
private void SetupStairsLamps(IArea floor, IWeatherStation weatherStation, 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(); floor.WithLamp(Floor.LampStairs, output); floor.SetupConditionalOnAutomation() .WithActuator(floor.Lamp(Floor.LampStairs)) .WithOnAtNightRange(weatherStation) .WithOffBetweenRange(TimeSpan.FromHours(23), TimeSpan.FromHours(4)); }
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)); }