瀏覽代碼

Allow external reporting of friendly names for DATAQ hardware

Neal Wilson 11 年之前
父節點
當前提交
ec89aacaf4
共有 1 個檔案被更改,包括 16 行新增5 行删除
  1. 16
    5
      src/dataqsdk.w

+ 16
- 5
src/dataqsdk.w 查看文件

31
 		Q_INVOKABLE void setClockRate(double Hz);
31
 		Q_INVOKABLE void setClockRate(double Hz);
32
 		Q_INVOKABLE void start();
32
 		Q_INVOKABLE void start();
33
 		QStringList detectPorts();
33
 		QStringList detectPorts();
34
+		QStringList detectHardware(); // Friendly names
34
 };
35
 };
35
 
36
 
36
 @ The |DataqSdkDevice| class has as a private member an instance of a class
37
 @ The |DataqSdkDevice| class has as a private member an instance of a class
425
 detected. This is also used for automatic detection.
426
 detected. This is also used for automatic detection.
426
 
427
 
427
 @<DataqSdkDevice implementation@>=
428
 @<DataqSdkDevice implementation@>=
428
-QStringList DataqSdkDevice::detectPorts()
429
+QStringList DataqSdkDevice::detectHardware()
429
 {
430
 {
430
 	QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
431
 	QSettings deviceLookup("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\usbser\\Enum",
431
 	             QSettings::NativeFormat);
432
 	             QSettings::NativeFormat);
444
 	{
445
 	{
445
 		QString deviceKey = QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
446
 		QString deviceKey = QString("HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Enum\\USB\\VID_0683&PID_1450\\%1").arg(device);
446
 		QSettings deviceEntry(deviceKey, QSettings::NativeFormat);
447
 		QSettings deviceEntry(deviceKey, QSettings::NativeFormat);
447
-		QString friendlyName = deviceEntry.value("FriendlyName").toString();
448
-		friendlyName.remove(0, friendlyName.indexOf("COM"));
449
-		friendlyName.chop(1);
450
-		portList.append(friendlyName);
448
+		portList.append(deviceEntry.value("FriendlyName").toString());
449
+	}
450
+	return portList;
451
+}
452
+
453
+QStringList DataqSdkDevice::detectPorts()
454
+{
455
+	QStringList friendlyNames = detectHardware();
456
+	QStringList portList;
457
+	foreach(QString name, friendlyNames)
458
+	{
459
+		name.remove(0, name.indexOf("COM"));
460
+		name.chop(1);
461
+		portList.append(name);
451
 	}
462
 	}
452
 	return portList;
463
 	return portList;
453
 }
464
 }

Loading…
取消
儲存