Rework
This commit is contained in:
@@ -16,7 +16,6 @@ type
|
||||
|
||||
TScanCallback = reference to procedure( DevicePath: string);
|
||||
|
||||
|
||||
TUsbDeviceInfo = class
|
||||
private
|
||||
fDriverClass : TUsbDriverClass;
|
||||
@@ -41,27 +40,14 @@ type
|
||||
|
||||
IUsbDriverMap = IDictionary<string, TUsbDeviceInfo>;
|
||||
|
||||
|
||||
|
||||
|
||||
TAnsiStringList = TList<AnsiString>;
|
||||
TList = spring.Collections.IList<string>;
|
||||
|
||||
|
||||
TUsbDriver = class abstract(TDriver, IUsbDriver)
|
||||
TUsbDriver = class abstract(TDriver)
|
||||
public
|
||||
class procedure Scan( ScanCallback: TScanCallback); virtual; abstract;
|
||||
|
||||
public
|
||||
class procedure ParseInstanceId( InstanceId : string;
|
||||
var VendorID : word;
|
||||
var ProductID : word;
|
||||
var Location : string;
|
||||
var Description : string);
|
||||
|
||||
protected
|
||||
class var fDriverID: TGUID;
|
||||
|
||||
protected
|
||||
fVendorID : word;
|
||||
fProductID : word;
|
||||
@@ -138,6 +124,8 @@ type
|
||||
implementation
|
||||
uses
|
||||
mr.dev.usb,
|
||||
mr.dev.manager,
|
||||
System.Win.Registry,
|
||||
System.SysUtils;
|
||||
|
||||
{ TUsbDriver }
|
||||
@@ -160,7 +148,7 @@ begin
|
||||
fDevicePath := DevicePath;
|
||||
fDeviceSpeed := LowSpeed;
|
||||
|
||||
ParseInstanceId( fDevicePath, fVendorID, fProductID, fLocation, fDescription);
|
||||
ParseDevicePath( fDevicePath, fVendorID, fProductID, fLocation, fDescription);
|
||||
end;
|
||||
|
||||
// @@@: INTERNALS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
@@ -172,57 +160,6 @@ end;
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
// ================================================================================================
|
||||
// parse instance id
|
||||
// ================================================================================================
|
||||
class procedure TUsbDriver.ParseInstanceId( InstanceId : string;
|
||||
var VendorID : word;
|
||||
var ProductID : word;
|
||||
var Location : string;
|
||||
var Description : string);
|
||||
var
|
||||
i : integer;
|
||||
l : integer;
|
||||
id : string;
|
||||
loc: string;
|
||||
dsc: string;
|
||||
|
||||
begin
|
||||
i := 1;
|
||||
l := Length(InstanceId);
|
||||
|
||||
while (i<=l) and (InstanceId[i] <> '\') do
|
||||
inc(i);
|
||||
|
||||
inc(i);
|
||||
|
||||
while (i<=l) and (InstanceId[i] <> '\') do
|
||||
begin
|
||||
id := id + InstanceId[i];
|
||||
inc(i)
|
||||
end;
|
||||
|
||||
inc(i);
|
||||
|
||||
while (i<=l) and (InstanceId[i] <> '#') do
|
||||
begin
|
||||
loc := loc + InstanceId[i];
|
||||
inc(i)
|
||||
end;
|
||||
|
||||
inc(i);
|
||||
|
||||
while (i<=l) do
|
||||
begin
|
||||
dsc := dsc + InstanceId[i];
|
||||
inc(i)
|
||||
end;
|
||||
|
||||
VendorId := StrToInt('$'+Copy( id, 5, 4));
|
||||
ProductId := StrToInt('$'+Copy( id, 14, 4));
|
||||
Location := loc;
|
||||
Description := dsc;
|
||||
end;
|
||||
|
||||
{ TUsbDeviceInfo }
|
||||
|
||||
@@ -244,7 +181,7 @@ begin
|
||||
fDevicePath := DevicePath;
|
||||
fDriverClass := DriverClass;
|
||||
|
||||
DriverClass.ParseInstanceId( fDevicePath, fVendorID, fProductID, fLocation, fDescription)
|
||||
ParseDevicePath( fDevicePath, fVendorID, fProductID, fLocation, fDescription)
|
||||
end;
|
||||
|
||||
// ================================================================================================
|
||||
|
||||
Reference in New Issue
Block a user