示例#1
0
        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) { }
        }
示例#2
0
        protected LampDeviceBase(LampState state, DeviceCreationInfo creationInfo)
            : base(state, creationInfo)
        {
            ForceSwitching = false;

            mVoiceName = creationInfo.Configuration.voiceName;
        }
示例#3
0
 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);
 }
示例#4
0
        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));
        }
示例#5
0
        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);
        }
示例#6
0
        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);
        }
示例#7
0
        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();
        }
示例#8
0
        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();
        }
示例#9
0
        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) { }
        }
示例#10
0
        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);
        }
示例#11
0
        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);
             */
        }
示例#12
0
        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);
        }
示例#13
0
 public ProxyDevice(DeviceBase.DeviceState state, DeviceCreationInfo creationInfo)
     : base(state, creationInfo)
 {
 }
示例#14
0
        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());
            }
        }
示例#15
0
 public ProxyDevice(DeviceBase.DeviceState state, DeviceCreationInfo creationInfo)
     : base(state, creationInfo)
 {
 }
示例#16
0
 public TestDevice(DeviceCreationInfo info)
     : base(new DeviceState(), info)
 {
     mState.Archetype = "ProperArchetype";
 }
示例#17
0
 public NexaSensorDevice(DeviceCreationInfo creationInfo)
 : base(new NexaSensorState(), creationInfo)
 {
     ((NexaSensorState)mState).Address = int.Parse(creationInfo.Configuration.code);
     ((NexaSensorState)mState).Unit = int.Parse(creationInfo.Configuration.unit);
 }
示例#18
0
 public DummyDevice(DeviceCreationInfo creationInfo)
     : base(new DummyState(), creationInfo)
 {
 }
示例#19
0
 public SensorDeviceBase(SensorState state, DeviceCreationInfo creationInfo)
     : base(state, creationInfo)
 {
 }
示例#20
0
 protected CurtainDeviceBase(CurtainState state, DeviceCreationInfo creationInfo)
     : base(state, creationInfo)
 {
 }