node-opcua-samples 2.73.1 → 2.76.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.
@@ -1,82 +1,82 @@
1
- #!/usr/bin/env ts-node
2
- "use strict";
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- /* eslint no-process-exit: 0 */
14
- // tslint:disable:no-console
15
- const path = require("path");
16
- const chalk = require("chalk");
17
- const node_opcua_1 = require("node-opcua");
18
- const yargs = require("yargs");
19
- Error.stackTraceLimit = Infinity;
20
- function constructFilename(filename) {
21
- return path.join(__dirname, "../", filename);
22
- }
23
- const rootFolder = path.join(__dirname, "../../..");
24
- function main() {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const argv = yield yargs.wrap(132).option("port", {
27
- alias: "p",
28
- default: "26543",
29
- describe: "port to listen"
30
- }).argv;
31
- const port = parseInt(argv.port, 10) || 26555;
32
- const server_certificate_file = constructFilename("certificates/server_cert_2048.pem");
33
- const server_certificate_privatekey_file = constructFilename("certificates/server_key_2048.pem");
34
- const server_options = {
35
- certificateFile: server_certificate_file,
36
- privateKeyFile: server_certificate_privatekey_file,
37
- port,
38
- nodeset_filename: [node_opcua_1.nodesets.standard, path.join(rootFolder, "modeling/my_data_type.xml")]
39
- };
40
- process.title = "Node OPCUA Server on port : " + server_options.port;
41
- const server = new node_opcua_1.OPCUAServer(server_options);
42
- console.log(chalk.yellow(" server PID :"), process.pid);
43
- server.on("post_initialize", () => {
44
- const addressSpace = server.engine.addressSpace;
45
- // to do: expose new nodeid here
46
- const ns = addressSpace.getNamespaceIndex("http://yourorganisation.org/my_data_type/");
47
- const myStructureType = addressSpace.findVariableType("MyStructureType", ns);
48
- if (!myStructureType) {
49
- console.log(" ns = ", ns, "cannot find MyStructureDataType ");
50
- return;
51
- }
52
- const namespace = addressSpace.getOwnNamespace();
53
- const someObject = namespace.addObject({
54
- browseName: "SomeObject",
55
- organizedBy: addressSpace.rootFolder.objects
56
- });
57
- myStructureType.instantiate({
58
- browseName: "MyVar",
59
- componentOf: someObject
60
- });
61
- });
62
- try {
63
- yield server.start();
64
- }
65
- catch (err) {
66
- console.log(" Server failed to start ... exiting");
67
- process.exit(-3);
68
- }
69
- const endpointUrl = server.getEndpointUrl();
70
- console.log(chalk.yellow(" server on port :"), chalk.cyan(server.endpoints[0].port.toString()));
71
- console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
72
- console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
73
- process.on("SIGINT", () => __awaiter(this, void 0, void 0, function* () {
74
- // only work on linux apparently
75
- yield server.shutdown(1000);
76
- console.log(chalk.red.bold(" shutting down completed "));
77
- process.exit(-1);
78
- }));
79
- });
80
- }
81
- main();
1
+ #!/usr/bin/env ts-node
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ /* eslint no-process-exit: 0 */
14
+ // tslint:disable:no-console
15
+ const path = require("path");
16
+ const chalk = require("chalk");
17
+ const node_opcua_1 = require("node-opcua");
18
+ const yargs = require("yargs");
19
+ Error.stackTraceLimit = Infinity;
20
+ function constructFilename(filename) {
21
+ return path.join(__dirname, "../", filename);
22
+ }
23
+ const rootFolder = path.join(__dirname, "../../..");
24
+ function main() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const argv = yield yargs.wrap(132).option("port", {
27
+ alias: "p",
28
+ default: "26543",
29
+ describe: "port to listen"
30
+ }).argv;
31
+ const port = parseInt(argv.port, 10) || 26555;
32
+ const server_certificate_file = constructFilename("certificates/server_cert_2048.pem");
33
+ const server_certificate_privatekey_file = constructFilename("certificates/server_key_2048.pem");
34
+ const server_options = {
35
+ certificateFile: server_certificate_file,
36
+ privateKeyFile: server_certificate_privatekey_file,
37
+ port,
38
+ nodeset_filename: [node_opcua_1.nodesets.standard, path.join(rootFolder, "modeling/my_data_type.xml")]
39
+ };
40
+ process.title = "Node OPCUA Server on port : " + server_options.port;
41
+ const server = new node_opcua_1.OPCUAServer(server_options);
42
+ console.log(chalk.yellow(" server PID :"), process.pid);
43
+ server.on("post_initialize", () => {
44
+ const addressSpace = server.engine.addressSpace;
45
+ // to do: expose new nodeid here
46
+ const ns = addressSpace.getNamespaceIndex("http://yourorganisation.org/my_data_type/");
47
+ const myStructureType = addressSpace.findVariableType("MyStructureType", ns);
48
+ if (!myStructureType) {
49
+ console.log(" ns = ", ns, "cannot find MyStructureDataType ");
50
+ return;
51
+ }
52
+ const namespace = addressSpace.getOwnNamespace();
53
+ const someObject = namespace.addObject({
54
+ browseName: "SomeObject",
55
+ organizedBy: addressSpace.rootFolder.objects
56
+ });
57
+ myStructureType.instantiate({
58
+ browseName: "MyVar",
59
+ componentOf: someObject
60
+ });
61
+ });
62
+ try {
63
+ yield server.start();
64
+ }
65
+ catch (err) {
66
+ console.log(" Server failed to start ... exiting");
67
+ process.exit(-3);
68
+ }
69
+ const endpointUrl = server.getEndpointUrl();
70
+ console.log(chalk.yellow(" server on port :"), chalk.cyan(server.endpoints[0].port.toString()));
71
+ console.log(chalk.yellow(" endpointUrl :"), chalk.cyan(endpointUrl));
72
+ console.log(chalk.yellow("\n server now waiting for connections. CTRL+C to stop"));
73
+ process.on("SIGINT", () => __awaiter(this, void 0, void 0, function* () {
74
+ // only work on linux apparently
75
+ yield server.shutdown(1000);
76
+ console.log(chalk.red.bold(" shutting down completed "));
77
+ process.exit(-1);
78
+ }));
79
+ });
80
+ }
81
+ main();
82
82
  //# sourceMappingURL=simple_server_with_custom_extension_objects.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,37 +1,37 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- // tslint:disable:no-console
13
- const node_opcua_1 = require("node-opcua");
14
- const endpointUrl = "opc.tcp://localhost:26543";
15
- function main() {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- let counter = 1;
18
- while (true) {
19
- const client = node_opcua_1.OPCUAClient.create({ endpointMustExist: false });
20
- client.on("backoff", (retryCount, delay) => console.log(" backoff", retryCount, delay));
21
- try {
22
- yield client.connect(endpointUrl);
23
- const session = yield client.createSession();
24
- yield session.close();
25
- yield client.disconnect();
26
- }
27
- catch (err) {
28
- if (err instanceof Error) {
29
- console.log("err", err.message);
30
- }
31
- }
32
- console.log(" Connected = ", counter++);
33
- }
34
- });
35
- }
36
- main();
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ // tslint:disable:no-console
13
+ const node_opcua_1 = require("node-opcua");
14
+ const endpointUrl = "opc.tcp://localhost:26543";
15
+ function main() {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ let counter = 1;
18
+ while (true) {
19
+ const client = node_opcua_1.OPCUAClient.create({ endpointMustExist: false });
20
+ client.on("backoff", (retryCount, delay) => console.log(" backoff", retryCount, delay));
21
+ try {
22
+ yield client.connect(endpointUrl);
23
+ const session = yield client.createSession();
24
+ yield session.close();
25
+ yield client.disconnect();
26
+ }
27
+ catch (err) {
28
+ if (err instanceof Error) {
29
+ console.log("err", err.message);
30
+ }
31
+ }
32
+ console.log(" Connected = ", counter++);
33
+ }
34
+ });
35
+ }
36
+ main();
37
37
  //# sourceMappingURL=stressing_client.js.map
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,33 +1,33 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- process.env.NODEOPCUADEBUG = "CLIENT{TRACE};TRANSPORT{CHUNK-HELACK}";
13
- const node_opcua_1 = require("node-opcua");
14
- (() => __awaiter(void 0, void 0, void 0, function* () {
15
- const client = node_opcua_1.OPCUAClient.create({
16
- requestedSessionTimeout: 1000,
17
- transportSettings: {
18
- maxChunkCount: 1,
19
- maxMessageSize: 1 * 8192,
20
- receiveBufferSize: 8 * 1024,
21
- sendBufferSize: 8 * 1024
22
- },
23
- connectionStrategy: {
24
- initialDelay: 10,
25
- maxDelay: 100,
26
- maxRetry: 2
27
- }
28
- });
29
- yield client.connect("opc.tcp://localhost:48010");
30
- // await client.connect("opc.tcp://localhost:53530");
31
- yield client.disconnect();
32
- }))();
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ process.env.NODEOPCUADEBUG = "CLIENT{TRACE};TRANSPORT{CHUNK-HELACK}";
13
+ const node_opcua_1 = require("node-opcua");
14
+ (() => __awaiter(void 0, void 0, void 0, function* () {
15
+ const client = node_opcua_1.OPCUAClient.create({
16
+ requestedSessionTimeout: 1000,
17
+ transportSettings: {
18
+ maxChunkCount: 1,
19
+ maxMessageSize: 1 * 8192,
20
+ receiveBufferSize: 8 * 1024,
21
+ sendBufferSize: 8 * 1024
22
+ },
23
+ connectionStrategy: {
24
+ initialDelay: 10,
25
+ maxDelay: 100,
26
+ maxRetry: 2
27
+ }
28
+ });
29
+ yield client.connect("opc.tcp://localhost:48010");
30
+ // await client.connect("opc.tcp://localhost:53530");
31
+ yield client.disconnect();
32
+ }))();
33
33
  //# sourceMappingURL=tiny_client.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-samples",
3
- "version": "2.73.1",
3
+ "version": "2.76.0",
4
4
  "description": "pure nodejs OPCUA SDK - module -samples",
5
5
  "bin": {
6
6
  "simple_client": "./dist/simple_client_ts.js",
@@ -20,10 +20,10 @@
20
20
  "@types/yargs": "17.0.10",
21
21
  "easy-table": "^1.2.0",
22
22
  "exit": "^0.1.2",
23
- "node-opcua": "2.73.1",
24
- "node-opcua-assert": "2.66.0",
23
+ "node-opcua": "2.76.0",
24
+ "node-opcua-assert": "2.76.0",
25
25
  "node-opcua-pki": "^2.17.0",
26
- "node-opcua-server-configuration": "2.73.1",
26
+ "node-opcua-server-configuration": "2.76.0",
27
27
  "sprintf-js": "^1.1.2",
28
28
  "treeify": "^1.1.0",
29
29
  "underscore": "^1.13.4",
@@ -44,5 +44,5 @@
44
44
  "internet of things"
45
45
  ],
46
46
  "homepage": "http://node-opcua.github.io/",
47
- "gitHead": "684a796e88e1732f418f2ada6aca2808e0115de8"
47
+ "gitHead": "75d9b8cf894c8fbadf77d2c4a48a730d055465e7"
48
48
  }