Example #1
0
        void broadcastReceiver_DeviceRemoved(object sender, DeviceRemovedEventArgs e)
        {
            if (RTKDevice != null && RTKDevice.DeviceID.Equals(e.DeviceID))
            {
                lock (RTKDevice)
                {
                    RTKDevice = null;
                }
                OnIRDeviceRemoved(new IRDeviceChangeEventArgs()
                {
                    Device = DeviceType.RTKIR, DeviceID = e.DeviceID
                });
                return;
            }

            if (AFDevice != null && AFDevice.DeviceID.Equals(e.DeviceID))
            {
                lock (AFDevice)
                {
                    AFDevice = null;
                }
                OnIRDeviceRemoved(new IRDeviceChangeEventArgs()
                {
                    Device = DeviceType.AF9100IR, DeviceID = e.DeviceID
                });
            }
        }
Example #2
0
        private void InitializeDevice(DeviceType type, DeviceID id)
        {
            // Wait a few seconds until device becomes ready
            Thread.Sleep(2000);
            switch (type)
            {
            case DeviceType.RTKIR:
                RTKIR rtk = new RTKIR(id);
                if (rtk.TryInitIRDevice())
                {
                    RTKDevice = rtk;
                    OnIRDeviceArrived(new IRDeviceChangeEventArgs()
                    {
                        Device = DeviceType.RTKIR, DeviceID = id
                    });
                }
                break;

            case DeviceType.AF9100IR:
                AF9100IR af = new AF9100IR(id);
                if (af.TryInitIRDevice())
                {
                    AFDevice = af;
                    OnIRDeviceArrived(new IRDeviceChangeEventArgs()
                    {
                        Device = DeviceType.AF9100IR, DeviceID = id
                    });
                }
                break;
            }
        }