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; } }
private static bool TryParseDeviceId(string input, out DeviceID devID) { devID = new DeviceID(); string pattern = "VID_([0-9A-F]{4})&PID_([0-9A-F]{4})"; Match match = Regex.Match(input, pattern); if (!match.Success) { return(false); } devID.Vid = UInt16.Parse(match.Groups[1].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture); devID.Pid = UInt16.Parse(match.Groups[2].Value, NumberStyles.HexNumber, CultureInfo.InvariantCulture); return(true); }
private void CheckDevice(DeviceID devID) { if (RTKDevice == null && RTKDeviceIdLookup.Contains(devID)) { Thread initThread = new Thread(() => InitializeDevice(DeviceType.RTKIR, devID)); initThread.SetApartmentState(ApartmentState.STA); initThread.IsBackground = true; initThread.Start(); return; } if (AFDevice == null && AFDeviceIdLookup.Contains(devID)) { Thread initThread = new Thread(() => InitializeDevice(DeviceType.AF9100IR, devID)); initThread.SetApartmentState(ApartmentState.STA); initThread.IsBackground = true; initThread.Start(); } }
public USBDeviceInfo(DeviceID deviceID) { this.DeviceID = deviceID; //this.PnpDeviceID = pnpDeviceID; //this.Description = description; }
public DeviceRemovedEventArgs(DeviceID deviceID) { this.DeviceID = deviceID; }
public DeviceArrivedEventArgs(DeviceID deviceID) { this.DeviceID = deviceID; }
public AF9100IR(DeviceID deviceID) { this.DeviceID = deviceID; }
public RTKIR(DeviceID deviceID) { this.DeviceID = deviceID; }