-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
readDeviceCapabilities.ts
52 lines (49 loc) · 1.93 KB
/
readDeviceCapabilities.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { DeviceCapabilities } from "./DeviceCapabilities";
import HPApi from "./HPApi";
import WalkupScanToCompCaps from "./WalkupScanToCompCaps";
import ScanCaps from "./ScanCaps";
export async function readDeviceCapabilities(): Promise<DeviceCapabilities> {
let supportsMultiItemScanFromPlaten = true;
const discoveryTree = await HPApi.getDiscoveryTree();
let walkupScanToCompCaps: WalkupScanToCompCaps | null = null;
if (discoveryTree.WalkupScanToCompManifestURI != null) {
const walkupScanToCompManifest = await HPApi.getWalkupScanToCompManifest(
discoveryTree.WalkupScanToCompManifestURI,
);
if (walkupScanToCompManifest.WalkupScanToCompCapsURI != null) {
walkupScanToCompCaps = await HPApi.getWalkupScanToCompCaps(
walkupScanToCompManifest.WalkupScanToCompCapsURI,
);
supportsMultiItemScanFromPlaten =
walkupScanToCompCaps.supportsMultiItemScanFromPlaten;
}
} else if (discoveryTree.WalkupScanManifestURI != null) {
const walkupScanManifest = await HPApi.getWalkupScanManifest(
discoveryTree.WalkupScanManifestURI,
);
if (walkupScanManifest.walkupScanDestinationsURI != null) {
await HPApi.getWalkupScanDestinations(
walkupScanManifest.walkupScanDestinationsURI,
);
}
} else {
console.log("Unknown device!");
}
let scanCaps: ScanCaps | null = null;
if (discoveryTree.ScanJobManifestURI != null) {
const scanJobManifest = await HPApi.getScanJobManifest(
discoveryTree.ScanJobManifestURI,
);
if (scanJobManifest.ScanCapsURI != null) {
scanCaps = await HPApi.getScanCaps(scanJobManifest.ScanCapsURI);
}
}
return {
supportsMultiItemScanFromPlaten,
useWalkupScanToComp: walkupScanToCompCaps != null,
platenMaxWidth: scanCaps?.platenMaxWidth || null,
platenMaxHeight: scanCaps?.platenMaxHeight || null,
adfMaxWidth: scanCaps?.adfMaxWidth || null,
adfMaxHeight: scanCaps?.adfMaxHeight || null,
};
}