aes70 2.0.17 → 2.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/printDevice.js +14 -3
- package/dist/AES70.es5.js +44 -11
- package/package.json +1 -1
- package/src/connection.js +2 -0
- package/src/controller/abstract_udp_connection.js +7 -0
- package/src/controller/client_connection.d.ts +13 -1
- package/src/controller/client_connection.js +20 -3
- package/src/controller/fetch_device_content.js +15 -8
package/bin/printDevice.js
CHANGED
|
@@ -7,19 +7,25 @@ import { UDPConnection } from '../src/controller/udp_connection.js';
|
|
|
7
7
|
import { fetchDeviceContent } from '../src/controller/fetch_device_content.js';
|
|
8
8
|
|
|
9
9
|
function badArguments() {
|
|
10
|
-
console.log(
|
|
10
|
+
console.log(
|
|
11
|
+
'Usage: node print_tree.js [--json] [--udp] [--progress] <ip> <port>'
|
|
12
|
+
);
|
|
11
13
|
exit(1);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
let jsonMode = false;
|
|
15
17
|
let useUdp = false;
|
|
16
18
|
const rest = [];
|
|
19
|
+
let progress = false;
|
|
17
20
|
|
|
18
21
|
argv.slice(2).forEach((option) => {
|
|
19
22
|
switch (option) {
|
|
20
23
|
case '--json':
|
|
21
24
|
jsonMode = true;
|
|
22
25
|
break;
|
|
26
|
+
case '--progress':
|
|
27
|
+
progress = true;
|
|
28
|
+
break;
|
|
23
29
|
case '-h':
|
|
24
30
|
case '--help':
|
|
25
31
|
badArguments();
|
|
@@ -76,8 +82,13 @@ function printTreeJson(content) {
|
|
|
76
82
|
|
|
77
83
|
async function printDevice(device) {
|
|
78
84
|
try {
|
|
79
|
-
const
|
|
80
|
-
|
|
85
|
+
const reportProgress = progress
|
|
86
|
+
? (finished, total) => {
|
|
87
|
+
process.stderr.write(`\r${finished} of ${total}`);
|
|
88
|
+
}
|
|
89
|
+
: undefined;
|
|
90
|
+
const content = await fetchDeviceContent(device, reportProgress);
|
|
91
|
+
if (progress) process.stderr.write(`\ndone.\n`);
|
|
81
92
|
if (jsonMode) {
|
|
82
93
|
printTreeJson(content);
|
|
83
94
|
} else {
|
package/dist/AES70.es5.js
CHANGED
|
@@ -1382,6 +1382,8 @@
|
|
|
1382
1382
|
|
|
1383
1383
|
const t = seconds * 1000;
|
|
1384
1384
|
|
|
1385
|
+
if (this.keepalive_interval === t) return;
|
|
1386
|
+
|
|
1385
1387
|
this.keepalive_interval = t;
|
|
1386
1388
|
|
|
1387
1389
|
// Notify the other side about our new keepalive
|
|
@@ -1816,6 +1818,19 @@
|
|
|
1816
1818
|
this.name = name;
|
|
1817
1819
|
this.lastSent = 0;
|
|
1818
1820
|
this.retries = 0;
|
|
1821
|
+
this.duration = 0;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
/**
|
|
1825
|
+
* Sets the expected processing time for this command on the device.
|
|
1826
|
+
* This duration is used when scheduling retries.
|
|
1827
|
+
* Only has an effect for UDP connections.
|
|
1828
|
+
*
|
|
1829
|
+
* @param {number} interval
|
|
1830
|
+
* The interval in milliseconds.
|
|
1831
|
+
*/
|
|
1832
|
+
set_duration(interval) {
|
|
1833
|
+
this.duration = interval;
|
|
1819
1834
|
}
|
|
1820
1835
|
|
|
1821
1836
|
get_arguments() {
|
|
@@ -1886,7 +1901,7 @@
|
|
|
1886
1901
|
this._scheduledPendingCommands = new Set();
|
|
1887
1902
|
// All pending commands wich have been sent.
|
|
1888
1903
|
this._sentPendingCommands = new Set();
|
|
1889
|
-
this.
|
|
1904
|
+
this._lastCommandHandle = 0;
|
|
1890
1905
|
this._subscribers = new Map();
|
|
1891
1906
|
this._sendCommandsTimer = new Timer(
|
|
1892
1907
|
() => {
|
|
@@ -1970,8 +1985,8 @@
|
|
|
1970
1985
|
}
|
|
1971
1986
|
|
|
1972
1987
|
do {
|
|
1973
|
-
handle = this.
|
|
1974
|
-
this.
|
|
1988
|
+
handle = this._lastCommandHandle;
|
|
1989
|
+
this._lastCommandHandle = (handle + 1) | 0;
|
|
1975
1990
|
} while (pendingCommands.has(handle));
|
|
1976
1991
|
|
|
1977
1992
|
return handle;
|
|
@@ -1993,6 +2008,10 @@
|
|
|
1993
2008
|
}
|
|
1994
2009
|
}
|
|
1995
2010
|
|
|
2011
|
+
get_last_pending_command() {
|
|
2012
|
+
return this._pendingCommands.get(this._lastCommandHandle);
|
|
2013
|
+
}
|
|
2014
|
+
|
|
1996
2015
|
send_command(command, returnTypes, callback, stack, name) {
|
|
1997
2016
|
const executor = (resolve, reject) => {
|
|
1998
2017
|
const handle = this._getNextCommandHandle();
|
|
@@ -29173,6 +29192,13 @@
|
|
|
29173
29192
|
|
|
29174
29193
|
_sentPendingCommands.delete(pendingCommand);
|
|
29175
29194
|
|
|
29195
|
+
if (pendingCommand.lastSent + pendingCommand.duration > retryTime) {
|
|
29196
|
+
// This command is expected to take longer. Simply push it back to the queue,
|
|
29197
|
+
// we will pick it up later.
|
|
29198
|
+
_sentPendingCommands.add(pendingCommand);
|
|
29199
|
+
continue;
|
|
29200
|
+
}
|
|
29201
|
+
|
|
29176
29202
|
if (pendingCommand.retries >= this.retry_count) {
|
|
29177
29203
|
failed.push(pendingCommand);
|
|
29178
29204
|
} else {
|
|
@@ -29346,9 +29372,9 @@
|
|
|
29346
29372
|
if (typeof value === 'object') {
|
|
29347
29373
|
if (value instanceof Arguments) {
|
|
29348
29374
|
return {
|
|
29349
|
-
[name]: value.item(0),
|
|
29350
|
-
['Min' + name]: value.item(1),
|
|
29351
|
-
['Max' + name]: value.item(2),
|
|
29375
|
+
[name]: formatValue(value.item(0)),
|
|
29376
|
+
['Min' + name]: formatValue(value.item(1)),
|
|
29377
|
+
['Max' + name]: formatValue(value.item(2)),
|
|
29352
29378
|
};
|
|
29353
29379
|
} else {
|
|
29354
29380
|
value = formatValue(value);
|
|
@@ -29356,7 +29382,7 @@
|
|
|
29356
29382
|
}
|
|
29357
29383
|
|
|
29358
29384
|
return {
|
|
29359
|
-
[name]: value,
|
|
29385
|
+
[name]: formatValue(value),
|
|
29360
29386
|
};
|
|
29361
29387
|
}
|
|
29362
29388
|
|
|
@@ -29388,7 +29414,11 @@
|
|
|
29388
29414
|
|
|
29389
29415
|
Object.assign(info, formatReturnValue(name, currentValue));
|
|
29390
29416
|
} catch (err) {
|
|
29391
|
-
|
|
29417
|
+
// 8 - NotImplemented
|
|
29418
|
+
// 11 - BadMethod
|
|
29419
|
+
// Note: Some implementations respond with BadMethod for methods which have been
|
|
29420
|
+
// defined in more recent vrsions of aes70
|
|
29421
|
+
if (err.status != 8 && err.status != 11)
|
|
29392
29422
|
console.error(
|
|
29393
29423
|
'Fetching property',
|
|
29394
29424
|
o.ClassName,
|
|
@@ -29416,10 +29446,13 @@
|
|
|
29416
29446
|
}
|
|
29417
29447
|
}
|
|
29418
29448
|
|
|
29419
|
-
async function fetchDeviceContentRec(objects) {
|
|
29449
|
+
async function fetchDeviceContentRec(objects, reportProgress) {
|
|
29420
29450
|
const result = [];
|
|
29421
29451
|
|
|
29422
29452
|
for (let i = 0; i < objects.length; i++) {
|
|
29453
|
+
if (reportProgress) {
|
|
29454
|
+
reportProgress(i, objects.length);
|
|
29455
|
+
}
|
|
29423
29456
|
const o = objects[i];
|
|
29424
29457
|
const info = await fetchObjectInfo(o);
|
|
29425
29458
|
|
|
@@ -29438,7 +29471,7 @@
|
|
|
29438
29471
|
return result;
|
|
29439
29472
|
}
|
|
29440
29473
|
|
|
29441
|
-
async function fetchDeviceContent(device) {
|
|
29474
|
+
async function fetchDeviceContent(device, reportProgress) {
|
|
29442
29475
|
const objects = await device.GetDeviceTree();
|
|
29443
29476
|
const managers = [
|
|
29444
29477
|
device.DeviceManager,
|
|
@@ -29460,7 +29493,7 @@
|
|
|
29460
29493
|
if (await managerExists(manager)) objects.push(manager);
|
|
29461
29494
|
}
|
|
29462
29495
|
|
|
29463
|
-
return await fetchDeviceContentRec(objects);
|
|
29496
|
+
return await fetchDeviceContentRec(objects, reportProgress);
|
|
29464
29497
|
}
|
|
29465
29498
|
|
|
29466
29499
|
/*
|
package/package.json
CHANGED
package/src/connection.js
CHANGED
|
@@ -192,6 +192,13 @@ export class AbstractUDPConnection extends ClientConnection {
|
|
|
192
192
|
|
|
193
193
|
_sentPendingCommands.delete(pendingCommand);
|
|
194
194
|
|
|
195
|
+
if (pendingCommand.lastSent + pendingCommand.duration > retryTime) {
|
|
196
|
+
// This command is expected to take longer. Simply push it back to the queue,
|
|
197
|
+
// we will pick it up later.
|
|
198
|
+
_sentPendingCommands.add(pendingCommand);
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
|
|
195
202
|
if (pendingCommand.retries >= this.retry_count) {
|
|
196
203
|
failed.push(pendingCommand);
|
|
197
204
|
} else {
|
|
@@ -25,7 +25,17 @@ export interface PendingCommand {
|
|
|
25
25
|
* If available, returns the arguments of this
|
|
26
26
|
* remote method call.
|
|
27
27
|
*/
|
|
28
|
-
get_arguments():
|
|
28
|
+
get_arguments(): unknown[] | undefined;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Sets the expected processing time for this command on the device.
|
|
32
|
+
* This duration is used when scheduling retries.
|
|
33
|
+
* Only has an effect for UDP connections.
|
|
34
|
+
*
|
|
35
|
+
* @param {number} interval
|
|
36
|
+
* The interval in milliseconds.
|
|
37
|
+
*/
|
|
38
|
+
set_duration(interval: number): void;
|
|
29
39
|
}
|
|
30
40
|
|
|
31
41
|
/**
|
|
@@ -42,4 +52,6 @@ export declare class ClientConnection extends Connection {
|
|
|
42
52
|
* Keepalive interval in seconds.
|
|
43
53
|
*/
|
|
44
54
|
wait_for_keepalive(interval: number): Promise<void>;
|
|
55
|
+
|
|
56
|
+
get_last_pending_command(): PendingCommand | undefined;
|
|
45
57
|
}
|
|
@@ -27,6 +27,19 @@ class PendingCommand {
|
|
|
27
27
|
this.name = name;
|
|
28
28
|
this.lastSent = 0;
|
|
29
29
|
this.retries = 0;
|
|
30
|
+
this.duration = 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Sets the expected processing time for this command on the device.
|
|
35
|
+
* This duration is used when scheduling retries.
|
|
36
|
+
* Only has an effect for UDP connections.
|
|
37
|
+
*
|
|
38
|
+
* @param {number} interval
|
|
39
|
+
* The interval in milliseconds.
|
|
40
|
+
*/
|
|
41
|
+
set_duration(interval) {
|
|
42
|
+
this.duration = interval;
|
|
30
43
|
}
|
|
31
44
|
|
|
32
45
|
get_arguments() {
|
|
@@ -97,7 +110,7 @@ export class ClientConnection extends Connection {
|
|
|
97
110
|
this._scheduledPendingCommands = new Set();
|
|
98
111
|
// All pending commands wich have been sent.
|
|
99
112
|
this._sentPendingCommands = new Set();
|
|
100
|
-
this.
|
|
113
|
+
this._lastCommandHandle = 0;
|
|
101
114
|
this._subscribers = new Map();
|
|
102
115
|
this._sendCommandsTimer = new Timer(
|
|
103
116
|
() => {
|
|
@@ -181,8 +194,8 @@ export class ClientConnection extends Connection {
|
|
|
181
194
|
}
|
|
182
195
|
|
|
183
196
|
do {
|
|
184
|
-
handle = this.
|
|
185
|
-
this.
|
|
197
|
+
handle = this._lastCommandHandle;
|
|
198
|
+
this._lastCommandHandle = (handle + 1) | 0;
|
|
186
199
|
} while (pendingCommands.has(handle));
|
|
187
200
|
|
|
188
201
|
return handle;
|
|
@@ -204,6 +217,10 @@ export class ClientConnection extends Connection {
|
|
|
204
217
|
}
|
|
205
218
|
}
|
|
206
219
|
|
|
220
|
+
get_last_pending_command() {
|
|
221
|
+
return this._pendingCommands.get(this._lastCommandHandle);
|
|
222
|
+
}
|
|
223
|
+
|
|
207
224
|
send_command(command, returnTypes, callback, stack, name) {
|
|
208
225
|
const executor = (resolve, reject) => {
|
|
209
226
|
const handle = this._getNextCommandHandle();
|
|
@@ -37,9 +37,9 @@ function formatReturnValue(name, value) {
|
|
|
37
37
|
if (typeof value === 'object') {
|
|
38
38
|
if (value instanceof Arguments) {
|
|
39
39
|
return {
|
|
40
|
-
[name]: value.item(0),
|
|
41
|
-
['Min' + name]: value.item(1),
|
|
42
|
-
['Max' + name]: value.item(2),
|
|
40
|
+
[name]: formatValue(value.item(0)),
|
|
41
|
+
['Min' + name]: formatValue(value.item(1)),
|
|
42
|
+
['Max' + name]: formatValue(value.item(2)),
|
|
43
43
|
};
|
|
44
44
|
} else {
|
|
45
45
|
value = formatValue(value);
|
|
@@ -47,7 +47,7 @@ function formatReturnValue(name, value) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return {
|
|
50
|
-
[name]: value,
|
|
50
|
+
[name]: formatValue(value),
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -79,7 +79,11 @@ async function fetchObjectInfo(o) {
|
|
|
79
79
|
|
|
80
80
|
Object.assign(info, formatReturnValue(name, currentValue));
|
|
81
81
|
} catch (err) {
|
|
82
|
-
|
|
82
|
+
// 8 - NotImplemented
|
|
83
|
+
// 11 - BadMethod
|
|
84
|
+
// Note: Some implementations respond with BadMethod for methods which have been
|
|
85
|
+
// defined in more recent vrsions of aes70
|
|
86
|
+
if (err.status != 8 && err.status != 11)
|
|
83
87
|
console.error(
|
|
84
88
|
'Fetching property',
|
|
85
89
|
o.ClassName,
|
|
@@ -107,10 +111,13 @@ async function managerExists(manager) {
|
|
|
107
111
|
}
|
|
108
112
|
}
|
|
109
113
|
|
|
110
|
-
async function fetchDeviceContentRec(objects) {
|
|
114
|
+
async function fetchDeviceContentRec(objects, reportProgress) {
|
|
111
115
|
const result = [];
|
|
112
116
|
|
|
113
117
|
for (let i = 0; i < objects.length; i++) {
|
|
118
|
+
if (reportProgress) {
|
|
119
|
+
reportProgress(i, objects.length);
|
|
120
|
+
}
|
|
114
121
|
const o = objects[i];
|
|
115
122
|
const info = await fetchObjectInfo(o);
|
|
116
123
|
|
|
@@ -129,7 +136,7 @@ async function fetchDeviceContentRec(objects) {
|
|
|
129
136
|
return result;
|
|
130
137
|
}
|
|
131
138
|
|
|
132
|
-
export async function fetchDeviceContent(device) {
|
|
139
|
+
export async function fetchDeviceContent(device, reportProgress) {
|
|
133
140
|
const objects = await device.GetDeviceTree();
|
|
134
141
|
const managers = [
|
|
135
142
|
device.DeviceManager,
|
|
@@ -151,5 +158,5 @@ export async function fetchDeviceContent(device) {
|
|
|
151
158
|
if (await managerExists(manager)) objects.push(manager);
|
|
152
159
|
}
|
|
153
160
|
|
|
154
|
-
return await fetchDeviceContentRec(objects);
|
|
161
|
+
return await fetchDeviceContentRec(objects, reportProgress);
|
|
155
162
|
}
|