public NexaLampDevice(DeviceCreationInfo creationInfo) : base(new NexaLampState(), creationInfo) { // Enable forced switching since we don't have a closed loop and prediction is causing state changes to be // disregarded since LampDeviceBase thinks it's already in that state. ForceSwitching = true; mService = (RfxComService)creationInfo.ServiceManager.GetService(typeof(RfxComService)); if (mService == null) throw new InvalidOperationException("RfxComService is missing, device cannot run"); ((NexaLampState)mState).Address = int.Parse(creationInfo.Configuration.code); ((NexaLampState)mState).Unit = int.Parse(creationInfo.Configuration.unit); try { ((NexaLampState)mState).Group = bool.Parse(creationInfo.Configuration.group); } catch (RuntimeBinderException) { } try { ((NexaLampState)mState).Dimmable = bool.Parse(creationInfo.Configuration.dimmable); } catch (RuntimeBinderException) { } }
protected LampDeviceBase(LampState state, DeviceCreationInfo creationInfo) : base(state, creationInfo) { ForceSwitching = false; mVoiceName = creationInfo.Configuration.voiceName; }
public EpsonDevice(DeviceCreationInfo creationInfo) : base(new EpsonState(), creationInfo) { int port = int.Parse(creationInfo.Configuration.port); mSerialHelper = new SerialHelper("epson", (uint)port, 9600); mSerialHelper.AddListener(this); }
public ComputerProxyDevice(DeviceCreationInfo creationInfo) : base(new ComputerState(), creationInfo) { State.Address = creationInfo.Configuration.address; State.MacAddress = creationInfo.Configuration.macaddress; mWakeService = (WakeOnLanService)creationInfo.ServiceManager.GetService(typeof(WakeOnLanService)); }
public BluetoothDevice(DeviceCreationInfo creationInfo) : base(new BluetoothState(), creationInfo) { BluetoothState state = (BluetoothState)mState; state.BtName = creationInfo.Configuration.btname; mService = (BluetoothService)creationInfo.ServiceManager.GetService(typeof(BluetoothService)); mService.AddDevice(this); }
public LampDevice(DeviceCreationInfo creationInfo) : base(new LampState(), creationInfo) { mService = (LampServiceBase)creationInfo.ServiceManager.GetService(typeof(LampServiceBase)); if (mService == null) throw new InvalidOperationException("LampService is missing, device cannot run"); State.Dimmable = true; State.Channel = int.Parse(creationInfo.Configuration.channel); }
protected DeviceBase(DeviceState state, DeviceCreationInfo creationInfo) { mState = state; mState.Name = creationInfo.Configuration.name; try { mState.DisplayName = creationInfo.Configuration.displayName; } catch (RuntimeBinderException) { } // Optional mState.Type = GetType().ToString(); }
public EverflourishDevice(DeviceCreationInfo creationInfo) : base(new EverflourishState(), creationInfo) { mService = (RfxComService)creationInfo.ServiceManager.GetService(typeof(RfxComService)); ((EverflourishState)mState).Address = int.Parse(creationInfo.Configuration.code); ((EverflourishState)mState).Unit = int.Parse(creationInfo.Configuration.unit); try { ((EverflourishState)mState).Group = bool.Parse(creationInfo.Configuration.group); } catch (RuntimeBinderException) { } }
public YamahaDevice(DeviceCreationInfo creationInfo) : base(new YamahaState(), creationInfo) { mConfiguration = creationInfo.Configuration; mService = (YamahaService)creationInfo.ServiceManager.GetService(typeof(YamahaService)); mLock = new object(); YamahaState state = (YamahaState)mState; state.Address = creationInfo.Configuration.address; // Set up inputs foreach (var inputConfig in mConfiguration.inputs) state.Inputs.Add(new InputInfo(inputConfig.input, inputConfig.displayName, inputConfig.voiceName)); // Note. Service will trigger a refresh of the device state, however, for a little while until the receiver responds, this device will have a potentially incorrect default state. mService.AddDevice(this); }
public CurtainDevice(DeviceCreationInfo creationInfo) : base(new CurtainState(), creationInfo) { mService = (CurtainService)creationInfo.ServiceManager.GetService(typeof(CurtainService)); CurtainState state = (CurtainState)mState; state.Channel = int.Parse(creationInfo.Configuration.channel); mVoiceName = creationInfo.Configuration.voiceName; /* // TOTO - Look into this in detail. // Somehow we're getting garbage in the first submission with MS serial implementation. // No issues in the previous python implementation, but required beefing up error handling on the arduino side as well // as adding an extra flush from the c# side. byte[] dummy = new byte[] { (byte)'\n' }; mService.SendData(dummy); */ }
public static DeviceBase CreateDevice(DeviceCreationInfo info) { string type; try { type = info.Configuration.type; } catch (RuntimeBinderException) { throw new ArgumentException("Missing type of device"); } Type deviceType = Type.GetType(type); if (deviceType == null) throw new ArgumentException("Invalid device type name " + type); if (!deviceType.IsSubclassOf(typeof(DeviceBase))) throw new ArgumentException("Type is not a subclass of DeviceBase. Type: " + deviceType.Name); Object[] arguments = new Object[] { info }; return (DeviceBase)Activator.CreateInstance(deviceType, arguments); }
public ProxyDevice(DeviceBase.DeviceState state, DeviceCreationInfo creationInfo) : base(state, creationInfo) { }
private void CreateDevices(List<dynamic> configs) { foreach (var deviceConfig in configs) { DeviceBase device; try { DeviceCreationInfo info = new DeviceCreationInfo(deviceConfig, mServiceManager, mDeviceManager); device = DeviceFactory.CreateDevice(info); mDeviceManager.AddDevice(device); } catch (Exception e) { Log.Error("Failed creating device for node with config: " + deviceConfig.name); if (e.InnerException != null) Log.Error("Inner Exception: {0}\nCallstack:\n{1}", e.InnerException.Message, e.InnerException.StackTrace); else Log.Error("Exception: {0}\nCallstack:\n{1}", e.Message, e.StackTrace); continue; } Log.Info("Created device: {0} of type: {1}", device.Name, device.GetType().ToString()); } }
public TestDevice(DeviceCreationInfo info) : base(new DeviceState(), info) { mState.Archetype = "ProperArchetype"; }
public NexaSensorDevice(DeviceCreationInfo creationInfo) : base(new NexaSensorState(), creationInfo) { ((NexaSensorState)mState).Address = int.Parse(creationInfo.Configuration.code); ((NexaSensorState)mState).Unit = int.Parse(creationInfo.Configuration.unit); }
public DummyDevice(DeviceCreationInfo creationInfo) : base(new DummyState(), creationInfo) { }
public SensorDeviceBase(SensorState state, DeviceCreationInfo creationInfo) : base(state, creationInfo) { }
protected CurtainDeviceBase(CurtainState state, DeviceCreationInfo creationInfo) : base(state, creationInfo) { }