node-opcua-samples 2.166.0 → 2.167.0

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.
@@ -2,17 +2,23 @@
2
2
  /* eslint-disable complexity */
3
3
  /* eslint-disable no-case-declarations */
4
4
  /* eslint no-process-exit: 0 */
5
- "use strict";
6
- const util = require("util");
7
- const fs = require("fs");
8
- const path = require("path");
9
- const os = require("os");
5
+ const util = require("node:util");
6
+ const fs = require("node:fs");
7
+ const path = require("node:path");
8
+ const os = require("node:os");
10
9
  const readline = require("node:readline");
11
10
  const chalk = require("chalk");
12
11
  const treeify = require("treeify");
13
12
  const { sprintf } = require("sprintf-js");
14
13
 
15
- const { DataType, OPCUAClient, makeNodeId, coerceNodeId, ObjectIds, StatusCodes, parseEndpointUrl } = require("node-opcua");
14
+ const {
15
+ DataType,
16
+ OPCUAClient,
17
+ makeNodeId,
18
+ coerceNodeId,
19
+ ObjectIds,
20
+ parseEndpointUrl
21
+ } = require("node-opcua");
16
22
  const { UAProxyManager } = require("node-opcua-client-proxy");
17
23
  const { analyze_object_binary_encoding } = require("node-opcua-packet-analyzer");
18
24
  const utils = require("node-opcua-utils");
@@ -90,7 +96,7 @@ function completer(line, callback) {
90
96
  }
91
97
  }
92
98
  assert(completions.length >= 0);
93
- hits = completions.filter(function (c) {
99
+ hits = completions.filter(function(c) {
94
100
  return c.indexOf(line) === 0;
95
101
  });
96
102
  return callback(null, [hits.length ? hits : completions, line]);
@@ -107,7 +113,7 @@ rl.setPrompt(the_prompt);
107
113
  rl.prompt();
108
114
 
109
115
  function save_history(callback) {
110
- const history_uniq = [ ... new Set(rl.history)];
116
+ const history_uniq = [... new Set(rl.history)];
111
117
  fs.writeFileSync(history_file, history_uniq.join("\n"), "utf-8");
112
118
  callback();
113
119
  }
@@ -193,7 +199,7 @@ function setCurrentNode(node) {
193
199
  const curNodeBrowseName = lowerFirstLetter(curNode.browseName.name.toString());
194
200
  nodePathName.push(curNodeBrowseName);
195
201
  nodePath.push(node);
196
- curNodeCompletion = node.$components.map(function (c) {
202
+ curNodeCompletion = node.$components.map(function(c) {
197
203
  if (!c.browseName) {
198
204
  return "???";
199
205
  }
@@ -233,26 +239,26 @@ async function getRootFolder() {
233
239
  }
234
240
  }
235
241
 
236
- client.on("send_chunk", function (message_chunk) {
242
+ client.on("send_chunk", function(message_chunk) {
237
243
  if (dumpMessageChunk) {
238
244
  process.stdout.write(">> " + message_chunk.length + "\r");
239
245
  }
240
246
  });
241
247
 
242
- client.on("receive_chunk", function (message_chunk) {
248
+ client.on("receive_chunk", function(message_chunk) {
243
249
  if (dumpMessageChunk) {
244
250
  process.stdout.write("<< " + message_chunk.length + "\r");
245
251
  }
246
252
  });
247
253
 
248
- client.on("send_request", function (message) {
254
+ client.on("send_request", function(message) {
249
255
  if (dumpPacket) {
250
256
  log(chalk.red(" sending request"));
251
257
  analyze_object_binary_encoding(message);
252
258
  }
253
259
  });
254
260
 
255
- client.on("receive_response", function (message) {
261
+ client.on("receive_response", function(message) {
256
262
  if (dumpPacket) {
257
263
  assert(message);
258
264
  log(chalk.cyan.bold(" receive response"));
@@ -289,15 +295,15 @@ if (rl.history) {
289
295
  }
290
296
  }
291
297
 
292
- process.on("uncaughtException", function (e) {
298
+ process.on("uncaughtException", function(e) {
293
299
  log(chalk.red(e.stack));
294
300
  rl.prompt();
295
301
  });
296
302
 
297
303
  function apply_command(cmd, func, callback) {
298
- callback = callback || function () {};
304
+ callback = callback || function() { };
299
305
  rl.pause();
300
- func(function (err) {
306
+ func(function(err) {
301
307
  callback();
302
308
  rl.resume();
303
309
  rl.prompt(the_prompt);
@@ -309,7 +315,7 @@ function apply_on_valid_session(cmd, func, callback) {
309
315
  assert(func.length === 2);
310
316
 
311
317
  if (the_session) {
312
- apply_command(cmd, function (callback) {
318
+ apply_command(cmd, function(callback) {
313
319
  func(the_session, callback);
314
320
  });
315
321
  } else {
@@ -388,7 +394,7 @@ function open_session(callback) {
388
394
  }
389
395
  callback();
390
396
  });
391
- client.on("close", function () {
397
+ client.on("close", () => {
392
398
  log(chalk.red(" Server has disconnected "));
393
399
  the_session = null;
394
400
  });
@@ -396,8 +402,8 @@ function open_session(callback) {
396
402
  }
397
403
 
398
404
  function close_session(outer_callback) {
399
- apply_on_valid_session("closeSession", function (session, inner_callback) {
400
- session.close(function (err) {
405
+ apply_on_valid_session("closeSession", (session, inner_callback) {
406
+ session.close(function(err) {
401
407
  the_session = null;
402
408
  if (!outer_callback) {
403
409
  inner_callback(err);
@@ -446,8 +452,8 @@ function process_line(line) {
446
452
  log(" hostname : ", chalk.yellow(hostname || "<null>"));
447
453
  log(" port : ", chalk.yellow(port));
448
454
 
449
- apply_command(cmd, function (callback) {
450
- client.connect(endpointUrl, function (err) {
455
+ apply_command(cmd, function(callback) {
456
+ client.connect(endpointUrl, function(err) {
451
457
  if (err) {
452
458
  log("client connected err=", err);
453
459
  } else {
@@ -455,7 +461,7 @@ function process_line(line) {
455
461
 
456
462
  add_endpoint_to_history(endpointUrl);
457
463
 
458
- save_history(function () {});
464
+ save_history(function() { });
459
465
  }
460
466
  callback(err);
461
467
  });
@@ -464,8 +470,8 @@ function process_line(line) {
464
470
 
465
471
  case "fs":
466
472
  case "FindServers":
467
- apply_command(cmd, function (callback) {
468
- client.findServers({}, function (err, data) {
473
+ apply_command(cmd, function(callback) {
474
+ client.findServers({}, function(err, data) {
469
475
  const { servers, endpoints } = data;
470
476
  if (err) {
471
477
  log(err.message);
@@ -477,8 +483,8 @@ function process_line(line) {
477
483
  break;
478
484
  case "gep":
479
485
  case "getEndpoints":
480
- apply_command(cmd, function (callback) {
481
- client.getEndpoints(function (err, endpoints) {
486
+ apply_command(cmd, function(callback) {
487
+ client.getEndpoints(function(err, endpoints) {
482
488
  if (err) {
483
489
  log(err.message);
484
490
  }
@@ -495,19 +501,19 @@ function process_line(line) {
495
501
  break;
496
502
 
497
503
  case "closeSession":
498
- close_session(function () {});
504
+ close_session(function() { });
499
505
  break;
500
506
 
501
507
  case "disconnect":
502
508
  if (the_session) {
503
- close_session(function (callback) {
504
- client.disconnect(function () {
509
+ close_session(function(callback) {
510
+ client.disconnect(function() {
505
511
  rl.write("client disconnected");
506
512
  callback();
507
513
  });
508
514
  });
509
515
  } else {
510
- client.disconnect(function () {
516
+ client.disconnect(function() {
511
517
  rl.write("client disconnected");
512
518
  });
513
519
  }
@@ -515,15 +521,15 @@ function process_line(line) {
515
521
 
516
522
  case "b":
517
523
  case "browse":
518
- apply_on_valid_session(cmd, function (the_session, callback) {
524
+ apply_on_valid_session(cmd, function(the_session, callback) {
519
525
  nodes = [args[1]];
520
526
 
521
- the_session.browse(nodes, function (err, nodeResults) {
527
+ the_session.browse(nodes, function(err, nodeResults) {
522
528
  if (err) {
523
529
  log(err);
524
530
  log(nodeResults);
525
531
  } else {
526
- save_history(function () {});
532
+ save_history(function() { });
527
533
 
528
534
  for (let i = 0; i < nodeResults.length; i++) {
529
535
  log("Node: ", nodes[i]);
@@ -538,14 +544,14 @@ function process_line(line) {
538
544
  break;
539
545
 
540
546
  case "rootFolder":
541
- apply_on_valid_session(cmd, function (the_session, callback) {
542
- getRootFolder().then(()=>callback()).catch((err)=>callback(err));
547
+ apply_on_valid_session(cmd, function(the_session, callback) {
548
+ getRootFolder().then(() => callback()).catch((err) => callback(err));
543
549
  });
544
550
  break;
545
551
 
546
552
  case "hr":
547
553
  case "readHistoryValue":
548
- apply_on_valid_session(cmd, function (the_session, callback) {
554
+ apply_on_valid_session(cmd, function(the_session, callback) {
549
555
  // example:
550
556
  // hr ns=2;s=Demo.History.DoubleWithHistory 13:45 13:59
551
557
  nodes = [args[1]];
@@ -559,12 +565,12 @@ function process_line(line) {
559
565
  }
560
566
  nodes = nodes.map((n) => coerceNodeId(n));
561
567
 
562
- the_session.readHistoryValue(nodes, startTime, endTime, function (err, historyReadResults) {
568
+ the_session.readHistoryValue(nodes, startTime, endTime, function(err, historyReadResults) {
563
569
  if (err) {
564
570
  log(err);
565
571
  log(historyReadResults.toString());
566
572
  } else {
567
- save_history(function () {});
573
+ save_history(function() { });
568
574
  assert(historyReadResults.length === 1);
569
575
  dump_historyDataValues(
570
576
  {
@@ -582,16 +588,16 @@ function process_line(line) {
582
588
  break;
583
589
  case "r":
584
590
  case "read":
585
- apply_on_valid_session(cmd, function (the_session, callback) {
591
+ apply_on_valid_session(cmd, function(the_session, callback) {
586
592
  nodes = [args[1]];
587
593
  nodes = nodes.map((n) => coerceNodeId(n));
588
594
 
589
- the_session.readVariableValue(nodes, function (err, dataValues) {
595
+ the_session.readVariableValue(nodes, function(err, dataValues) {
590
596
  if (err) {
591
597
  log(err);
592
598
  log(dataValues);
593
599
  } else {
594
- save_history(function () {});
600
+ save_history(function() { });
595
601
  dump_dataValues(
596
602
  [
597
603
  {
@@ -608,12 +614,12 @@ function process_line(line) {
608
614
  break;
609
615
  case "ra":
610
616
  case "readall":
611
- apply_on_valid_session(cmd, function (the_session, callback) {
617
+ apply_on_valid_session(cmd, function(the_session, callback) {
612
618
  const node = args[1];
613
619
 
614
- the_session.readAllAttributes(node, function (err, result /*,diagnosticInfos*/) {
620
+ the_session.readAllAttributes(node, function(err, result /*,diagnosticInfos*/) {
615
621
  if (!err) {
616
- save_history(function () {});
622
+ save_history(function() { });
617
623
  console.log(result);
618
624
  //xx dump_dataValues(nodesToRead, dataValues);
619
625
  }
@@ -623,9 +629,9 @@ function process_line(line) {
623
629
  break;
624
630
 
625
631
  case "tb":
626
- apply_on_valid_session(cmd, function (the_session, callback) {
632
+ apply_on_valid_session(cmd, function(the_session, callback) {
627
633
  const path = args[1];
628
- the_session.translateBrowsePath(path, function (err, results) {
634
+ the_session.translateBrowsePath(path, function(err, results) {
629
635
  if (err) {
630
636
  log(err.message);
631
637
  }
@@ -657,7 +663,7 @@ function process_line(line) {
657
663
  }
658
664
  }
659
665
 
660
- rl.on("line", function (line) {
666
+ rl.on("line", function(line) {
661
667
  try {
662
668
  process_line(line);
663
669
  rl.prompt();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-samples",
3
- "version": "2.166.0",
3
+ "version": "2.167.0",
4
4
  "description": "pure nodejs OPCUA SDK - module samples",
5
5
  "bin": {
6
6
  "simple_client": "./dist/simple_client_ts.js",
@@ -22,17 +22,17 @@
22
22
  "chalk": "4.1.2",
23
23
  "easy-table": "^1.2.0",
24
24
  "env-paths": "2.2.1",
25
- "node-opcua": "2.166.0",
26
- "node-opcua-address-space": "2.166.0",
27
- "node-opcua-address-space-for-conformance-testing": "2.166.0",
25
+ "node-opcua": "2.167.0",
26
+ "node-opcua-address-space": "2.167.0",
27
+ "node-opcua-address-space-for-conformance-testing": "2.167.0",
28
28
  "node-opcua-assert": "2.164.0",
29
- "node-opcua-client-proxy": "2.166.0",
30
- "node-opcua-crypto": "5.3.0",
31
- "node-opcua-packet-analyzer": "2.165.0",
32
- "node-opcua-pki": "6.11.0",
33
- "node-opcua-server-configuration": "2.166.0",
29
+ "node-opcua-client-proxy": "2.167.0",
30
+ "node-opcua-crypto": "5.3.3",
31
+ "node-opcua-packet-analyzer": "2.167.0",
32
+ "node-opcua-pki": "6.12.0",
33
+ "node-opcua-server-configuration": "2.167.0",
34
34
  "node-opcua-utils": "2.165.0",
35
- "node-opcua-vendor-diagnostic": "2.166.0",
35
+ "node-opcua-vendor-diagnostic": "2.167.0",
36
36
  "sprintf-js": "^1.1.3",
37
37
  "treeify": "^1.1.0",
38
38
  "yargs": "15.4.1"
@@ -52,7 +52,7 @@
52
52
  "internet of things"
53
53
  ],
54
54
  "homepage": "http://node-opcua.github.io/",
55
- "gitHead": "b50d48c0ebd4761670529bf66f39a9c402a07845",
55
+ "gitHead": "5decfa86ee53a36ecd3bb454e7bf6e3dd27c7a4e",
56
56
  "files": [
57
57
  "dist"
58
58
  ]