node-opcua-client 2.75.0 → 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.
Files changed (65) hide show
  1. package/dist/alarms_and_conditions/client_alarm.d.ts +49 -49
  2. package/dist/alarms_and_conditions/client_alarm.js +109 -109
  3. package/dist/alarms_and_conditions/client_alarm_list.d.ts +25 -25
  4. package/dist/alarms_and_conditions/client_alarm_list.js +97 -97
  5. package/dist/alarms_and_conditions/client_alarm_tools.d.ts +4 -4
  6. package/dist/alarms_and_conditions/client_alarm_tools.js +156 -156
  7. package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.d.ts +18 -18
  8. package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.js +192 -192
  9. package/dist/alarms_and_conditions/client_alarm_tools_dump_event.d.ts +9 -9
  10. package/dist/alarms_and_conditions/client_alarm_tools_dump_event.js +73 -73
  11. package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.d.ts +3 -3
  12. package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.js +118 -118
  13. package/dist/alarms_and_conditions/client_tools.d.ts +7 -7
  14. package/dist/alarms_and_conditions/client_tools.js +180 -180
  15. package/dist/client_base.d.ts +277 -277
  16. package/dist/client_base.js +14 -14
  17. package/dist/client_monitored_item.d.ts +21 -21
  18. package/dist/client_monitored_item.js +11 -11
  19. package/dist/client_monitored_item_base.d.ts +39 -39
  20. package/dist/client_monitored_item_base.js +2 -2
  21. package/dist/client_monitored_item_group.d.ts +18 -18
  22. package/dist/client_monitored_item_group.js +13 -13
  23. package/dist/client_monitored_item_toolbox.d.ts +15 -15
  24. package/dist/client_monitored_item_toolbox.js +117 -117
  25. package/dist/client_session.d.ts +484 -484
  26. package/dist/client_session.js +10 -10
  27. package/dist/client_session_keepalive_manager.d.ts +34 -34
  28. package/dist/client_session_keepalive_manager.js +150 -150
  29. package/dist/client_subscription.d.ts +241 -241
  30. package/dist/client_subscription.js +14 -14
  31. package/dist/client_utils.d.ts +22 -22
  32. package/dist/client_utils.js +88 -88
  33. package/dist/common.d.ts +17 -17
  34. package/dist/common.js +5 -5
  35. package/dist/index.d.ts +55 -55
  36. package/dist/index.js +93 -93
  37. package/dist/opcua_client.d.ts +132 -132
  38. package/dist/opcua_client.js +33 -33
  39. package/dist/private/client_base_impl.d.ts +157 -157
  40. package/dist/private/client_base_impl.js +1337 -1337
  41. package/dist/private/client_monitored_item_base_impl.d.ts +3 -3
  42. package/dist/private/client_monitored_item_base_impl.js +4 -4
  43. package/dist/private/client_monitored_item_group_impl.d.ts +53 -53
  44. package/dist/private/client_monitored_item_group_impl.js +159 -159
  45. package/dist/private/client_monitored_item_impl.d.ts +93 -93
  46. package/dist/private/client_monitored_item_impl.js +305 -305
  47. package/dist/private/client_publish_engine.d.ts +62 -62
  48. package/dist/private/client_publish_engine.js +408 -408
  49. package/dist/private/client_session_impl.d.ts +621 -621
  50. package/dist/private/client_session_impl.js +1302 -1302
  51. package/dist/private/client_subscription_impl.d.ts +93 -93
  52. package/dist/private/client_subscription_impl.js +748 -748
  53. package/dist/private/i_private_client.d.ts +18 -18
  54. package/dist/private/i_private_client.js +2 -2
  55. package/dist/private/opcua_client_impl.d.ts +169 -169
  56. package/dist/private/opcua_client_impl.js +981 -981
  57. package/dist/reconnection.d.ts +9 -9
  58. package/dist/reconnection.js +408 -408
  59. package/dist/tools/findservers.d.ts +20 -20
  60. package/dist/tools/findservers.js +61 -61
  61. package/dist/tools/read_history_server_capabilities.d.ts +6 -6
  62. package/dist/tools/read_history_server_capabilities.js +99 -99
  63. package/dist/verify.d.ts +5 -5
  64. package/dist/verify.js +134 -134
  65. package/package.json +46 -46
@@ -1,11 +1,11 @@
1
- "use strict";
2
- /**
3
- * @module node-opcua-client
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ExtensionObject = exports.ExtraDataTypeManager = void 0;
7
- var node_opcua_client_dynamic_extension_object_1 = require("node-opcua-client-dynamic-extension-object");
8
- Object.defineProperty(exports, "ExtraDataTypeManager", { enumerable: true, get: function () { return node_opcua_client_dynamic_extension_object_1.ExtraDataTypeManager; } });
9
- var node_opcua_extension_object_1 = require("node-opcua-extension-object");
10
- Object.defineProperty(exports, "ExtensionObject", { enumerable: true, get: function () { return node_opcua_extension_object_1.ExtensionObject; } });
1
+ "use strict";
2
+ /**
3
+ * @module node-opcua-client
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ExtensionObject = exports.ExtraDataTypeManager = void 0;
7
+ var node_opcua_client_dynamic_extension_object_1 = require("node-opcua-client-dynamic-extension-object");
8
+ Object.defineProperty(exports, "ExtraDataTypeManager", { enumerable: true, get: function () { return node_opcua_client_dynamic_extension_object_1.ExtraDataTypeManager; } });
9
+ var node_opcua_extension_object_1 = require("node-opcua-extension-object");
10
+ Object.defineProperty(exports, "ExtensionObject", { enumerable: true, get: function () { return node_opcua_extension_object_1.ExtensionObject; } });
11
11
  //# sourceMappingURL=client_session.js.map
@@ -1,34 +1,34 @@
1
- /// <reference types="node" />
2
- /**
3
- * @module node-opcua-client
4
- */
5
- import { EventEmitter } from "events";
6
- import { ServerState } from "node-opcua-common";
7
- import { ClientSessionImpl } from "./private/client_session_impl";
8
- export interface ClientSessionKeepAliveManagerEvents {
9
- on(event: "keepalive", eventHandler: (lastKnownServerState: ServerState, count: number) => void): this;
10
- on(event: "failure", eventHandler: () => void): this;
11
- }
12
- export declare class ClientSessionKeepAliveManager extends EventEmitter implements ClientSessionKeepAliveManagerEvents {
13
- private readonly session;
14
- private timerId?;
15
- private pingTimeout;
16
- private lastKnownState?;
17
- private checkInterval;
18
- private transactionInProgress;
19
- count: number;
20
- constructor(session: ClientSessionImpl);
21
- start(): void;
22
- stop(): void;
23
- private ping_server;
24
- /**
25
- * @method ping_server
26
- * @internal
27
- * when a session is opened on a server, the client shall send request on a regular basis otherwise the server
28
- * session object might time out.
29
- * start_ping make sure that ping_server is called on a regular basis to prevent session to timeout.
30
- *
31
- * @param callback
32
- */
33
- private _ping_server;
34
- }
1
+ /// <reference types="node" />
2
+ /**
3
+ * @module node-opcua-client
4
+ */
5
+ import { EventEmitter } from "events";
6
+ import { ServerState } from "node-opcua-common";
7
+ import { ClientSessionImpl } from "./private/client_session_impl";
8
+ export interface ClientSessionKeepAliveManagerEvents {
9
+ on(event: "keepalive", eventHandler: (lastKnownServerState: ServerState, count: number) => void): this;
10
+ on(event: "failure", eventHandler: () => void): this;
11
+ }
12
+ export declare class ClientSessionKeepAliveManager extends EventEmitter implements ClientSessionKeepAliveManagerEvents {
13
+ private readonly session;
14
+ private timerId?;
15
+ private pingTimeout;
16
+ private lastKnownState?;
17
+ private checkInterval;
18
+ private transactionInProgress;
19
+ count: number;
20
+ constructor(session: ClientSessionImpl);
21
+ start(): void;
22
+ stop(): void;
23
+ private ping_server;
24
+ /**
25
+ * @method ping_server
26
+ * @internal
27
+ * when a session is opened on a server, the client shall send request on a regular basis otherwise the server
28
+ * session object might time out.
29
+ * start_ping make sure that ping_server is called on a regular basis to prevent session to timeout.
30
+ *
31
+ * @param callback
32
+ */
33
+ private _ping_server;
34
+ }
@@ -1,151 +1,151 @@
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
- exports.ClientSessionKeepAliveManager = void 0;
13
- /**
14
- * @module node-opcua-client
15
- */
16
- const events_1 = require("events");
17
- const chalk = require("chalk");
18
- const node_opcua_assert_1 = require("node-opcua-assert");
19
- const node_opcua_common_1 = require("node-opcua-common");
20
- const node_opcua_constants_1 = require("node-opcua-constants");
21
- const node_opcua_debug_1 = require("node-opcua-debug");
22
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
23
- const node_opcua_status_code_1 = require("node-opcua-status-code");
24
- const serverStatusStateNodeId = (0, node_opcua_nodeid_1.coerceNodeId)(node_opcua_constants_1.VariableIds.Server_ServerStatus_State);
25
- const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
26
- const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
27
- const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
28
- class ClientSessionKeepAliveManager extends events_1.EventEmitter {
29
- constructor(session) {
30
- super();
31
- this.transactionInProgress = false;
32
- this.count = 0;
33
- this.session = session;
34
- this.timerId = undefined;
35
- this.pingTimeout = 0;
36
- this.checkInterval = 0;
37
- this.count = 0;
38
- }
39
- start() {
40
- (0, node_opcua_assert_1.assert)(!this.timerId);
41
- /* istanbul ignore next*/
42
- if (this.session.timeout < 600) {
43
- warningLog(`[NODE-OPCUA-W13] ClientSessionKeepAliveManager detected that the session timeout (${this.session.timeout} ms) is really too small: please adjust it to a greater value ( at least 1000))`);
44
- }
45
- /* istanbul ignore next*/
46
- if (this.session.timeout < 100) {
47
- throw new Error(`ClientSessionKeepAliveManager detected that the session timeout (${this.session.timeout} ms) is really too small: please adjust it to a greater value ( at least 1000))`);
48
- }
49
- this.pingTimeout = Math.min(this.session.timeout / 3, 20000);
50
- this.checkInterval = Math.max(50, Math.min((this.session.timeout * 2) / 3, 20000));
51
- // make sure first one is almost immediate
52
- this.timerId = setTimeout(() => this.ping_server(), this.pingTimeout);
53
- }
54
- stop() {
55
- if (this.timerId) {
56
- debugLog("ClientSessionKeepAliveManager#stop");
57
- clearTimeout(this.timerId);
58
- this.timerId = undefined;
59
- }
60
- else {
61
- debugLog("warning ClientSessionKeepAliveManager#stop ignore (already stopped)");
62
- }
63
- }
64
- ping_server() {
65
- this._ping_server().then((delta) => {
66
- if (!this.session || this.session.hasBeenClosed()) {
67
- return; // stop here
68
- }
69
- if (this.timerId) {
70
- const timeout = Math.max(1, this.checkInterval - delta);
71
- this.timerId = setTimeout(() => this.ping_server(), timeout);
72
- }
73
- });
74
- }
75
- /**
76
- * @method ping_server
77
- * @internal
78
- * when a session is opened on a server, the client shall send request on a regular basis otherwise the server
79
- * session object might time out.
80
- * start_ping make sure that ping_server is called on a regular basis to prevent session to timeout.
81
- *
82
- * @param callback
83
- */
84
- _ping_server() {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- const session = this.session;
87
- if (!session || session.isReconnecting) {
88
- debugLog("ClientSessionKeepAliveManager#ping_server => no session available");
89
- return 0;
90
- }
91
- if (!this.timerId) {
92
- return 0; // keep-alive has been canceled ....
93
- }
94
- const now = Date.now(); // getCurrentClock().timestamp.getTime();
95
- const timeSinceLastServerContact = now - session.lastResponseReceivedTime.getTime();
96
- if (timeSinceLastServerContact < this.pingTimeout) {
97
- debugLog("ClientSessionKeepAliveManager#ping_server skipped because last communication with server was not that long ago ping timeout=", Math.round(this.pingTimeout), "timeSinceLastServerContact = ", timeSinceLastServerContact);
98
- // no need to send a ping yet
99
- // console.log("Skipping ",timeSinceLastServerContact,this.session.timeout);
100
- return timeSinceLastServerContact - this.pingTimeout;
101
- }
102
- if (session.isReconnecting) {
103
- debugLog("ClientSessionKeepAliveManager#ping_server skipped because client is reconnecting");
104
- return 0;
105
- }
106
- if (session.hasBeenClosed()) {
107
- debugLog("ClientSessionKeepAliveManager#ping_server skipped because client is reconnecting");
108
- return 0;
109
- }
110
- debugLog("ClientSessionKeepAliveManager#ping_server timeSinceLastServerContact=", timeSinceLastServerContact, "timeout", this.session.timeout);
111
- if (this.transactionInProgress) {
112
- // readVariable already taking place ! Ignore
113
- return 0;
114
- }
115
- this.transactionInProgress = true;
116
- // Server_ServerStatus_State
117
- return new Promise((resolve) => {
118
- session.readVariableValue(serverStatusStateNodeId, (err, dataValue) => {
119
- this.transactionInProgress = false;
120
- if (err || !dataValue || !dataValue.value) {
121
- if (err) {
122
- warningLog(chalk.cyan(" warning : ClientSessionKeepAliveManager#ping_server "), chalk.yellow(err.message));
123
- }
124
- /**
125
- * @event failure
126
- * raised when the server is not responding or is responding with en error to
127
- * the keep alive read Variable value transaction
128
- */
129
- this.emit("failure");
130
- resolve(0);
131
- return;
132
- }
133
- if (dataValue.statusCode === node_opcua_status_code_1.StatusCodes.Good) {
134
- const newState = dataValue.value.value;
135
- // istanbul ignore next
136
- if (newState !== this.lastKnownState && this.lastKnownState) {
137
- warningLog("ClientSessionKeepAliveManager#Server state has changed = ", node_opcua_common_1.ServerState[newState], " was ", node_opcua_common_1.ServerState[this.lastKnownState]);
138
- }
139
- this.lastKnownState = newState;
140
- this.count++; // increase successful counter
141
- }
142
- debugLog("emit keepalive");
143
- this.emit("keepalive", this.lastKnownState, this.count);
144
- resolve(0);
145
- });
146
- });
147
- });
148
- }
149
- }
150
- exports.ClientSessionKeepAliveManager = ClientSessionKeepAliveManager;
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
+ exports.ClientSessionKeepAliveManager = void 0;
13
+ /**
14
+ * @module node-opcua-client
15
+ */
16
+ const events_1 = require("events");
17
+ const chalk = require("chalk");
18
+ const node_opcua_assert_1 = require("node-opcua-assert");
19
+ const node_opcua_common_1 = require("node-opcua-common");
20
+ const node_opcua_constants_1 = require("node-opcua-constants");
21
+ const node_opcua_debug_1 = require("node-opcua-debug");
22
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
23
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
24
+ const serverStatusStateNodeId = (0, node_opcua_nodeid_1.coerceNodeId)(node_opcua_constants_1.VariableIds.Server_ServerStatus_State);
25
+ const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
26
+ const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
27
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
28
+ class ClientSessionKeepAliveManager extends events_1.EventEmitter {
29
+ constructor(session) {
30
+ super();
31
+ this.transactionInProgress = false;
32
+ this.count = 0;
33
+ this.session = session;
34
+ this.timerId = undefined;
35
+ this.pingTimeout = 0;
36
+ this.checkInterval = 0;
37
+ this.count = 0;
38
+ }
39
+ start() {
40
+ (0, node_opcua_assert_1.assert)(!this.timerId);
41
+ /* istanbul ignore next*/
42
+ if (this.session.timeout < 600) {
43
+ warningLog(`[NODE-OPCUA-W13] ClientSessionKeepAliveManager detected that the session timeout (${this.session.timeout} ms) is really too small: please adjust it to a greater value ( at least 1000))`);
44
+ }
45
+ /* istanbul ignore next*/
46
+ if (this.session.timeout < 100) {
47
+ throw new Error(`ClientSessionKeepAliveManager detected that the session timeout (${this.session.timeout} ms) is really too small: please adjust it to a greater value ( at least 1000))`);
48
+ }
49
+ this.pingTimeout = Math.min(this.session.timeout / 3, 20000);
50
+ this.checkInterval = Math.max(50, Math.min((this.session.timeout * 2) / 3, 20000));
51
+ // make sure first one is almost immediate
52
+ this.timerId = setTimeout(() => this.ping_server(), this.pingTimeout);
53
+ }
54
+ stop() {
55
+ if (this.timerId) {
56
+ debugLog("ClientSessionKeepAliveManager#stop");
57
+ clearTimeout(this.timerId);
58
+ this.timerId = undefined;
59
+ }
60
+ else {
61
+ debugLog("warning ClientSessionKeepAliveManager#stop ignore (already stopped)");
62
+ }
63
+ }
64
+ ping_server() {
65
+ this._ping_server().then((delta) => {
66
+ if (!this.session || this.session.hasBeenClosed()) {
67
+ return; // stop here
68
+ }
69
+ if (this.timerId) {
70
+ const timeout = Math.max(1, this.checkInterval - delta);
71
+ this.timerId = setTimeout(() => this.ping_server(), timeout);
72
+ }
73
+ });
74
+ }
75
+ /**
76
+ * @method ping_server
77
+ * @internal
78
+ * when a session is opened on a server, the client shall send request on a regular basis otherwise the server
79
+ * session object might time out.
80
+ * start_ping make sure that ping_server is called on a regular basis to prevent session to timeout.
81
+ *
82
+ * @param callback
83
+ */
84
+ _ping_server() {
85
+ return __awaiter(this, void 0, void 0, function* () {
86
+ const session = this.session;
87
+ if (!session || session.isReconnecting) {
88
+ debugLog("ClientSessionKeepAliveManager#ping_server => no session available");
89
+ return 0;
90
+ }
91
+ if (!this.timerId) {
92
+ return 0; // keep-alive has been canceled ....
93
+ }
94
+ const now = Date.now(); // getCurrentClock().timestamp.getTime();
95
+ const timeSinceLastServerContact = now - session.lastResponseReceivedTime.getTime();
96
+ if (timeSinceLastServerContact < this.pingTimeout) {
97
+ debugLog("ClientSessionKeepAliveManager#ping_server skipped because last communication with server was not that long ago ping timeout=", Math.round(this.pingTimeout), "timeSinceLastServerContact = ", timeSinceLastServerContact);
98
+ // no need to send a ping yet
99
+ // console.log("Skipping ",timeSinceLastServerContact,this.session.timeout);
100
+ return timeSinceLastServerContact - this.pingTimeout;
101
+ }
102
+ if (session.isReconnecting) {
103
+ debugLog("ClientSessionKeepAliveManager#ping_server skipped because client is reconnecting");
104
+ return 0;
105
+ }
106
+ if (session.hasBeenClosed()) {
107
+ debugLog("ClientSessionKeepAliveManager#ping_server skipped because client is reconnecting");
108
+ return 0;
109
+ }
110
+ debugLog("ClientSessionKeepAliveManager#ping_server timeSinceLastServerContact=", timeSinceLastServerContact, "timeout", this.session.timeout);
111
+ if (this.transactionInProgress) {
112
+ // readVariable already taking place ! Ignore
113
+ return 0;
114
+ }
115
+ this.transactionInProgress = true;
116
+ // Server_ServerStatus_State
117
+ return new Promise((resolve) => {
118
+ session.readVariableValue(serverStatusStateNodeId, (err, dataValue) => {
119
+ this.transactionInProgress = false;
120
+ if (err || !dataValue || !dataValue.value) {
121
+ if (err) {
122
+ warningLog(chalk.cyan(" warning : ClientSessionKeepAliveManager#ping_server "), chalk.yellow(err.message));
123
+ }
124
+ /**
125
+ * @event failure
126
+ * raised when the server is not responding or is responding with en error to
127
+ * the keep alive read Variable value transaction
128
+ */
129
+ this.emit("failure");
130
+ resolve(0);
131
+ return;
132
+ }
133
+ if (dataValue.statusCode === node_opcua_status_code_1.StatusCodes.Good) {
134
+ const newState = dataValue.value.value;
135
+ // istanbul ignore next
136
+ if (newState !== this.lastKnownState && this.lastKnownState) {
137
+ warningLog("ClientSessionKeepAliveManager#Server state has changed = ", node_opcua_common_1.ServerState[newState], " was ", node_opcua_common_1.ServerState[this.lastKnownState]);
138
+ }
139
+ this.lastKnownState = newState;
140
+ this.count++; // increase successful counter
141
+ }
142
+ debugLog("emit keepalive");
143
+ this.emit("keepalive", this.lastKnownState, this.count);
144
+ resolve(0);
145
+ });
146
+ });
147
+ });
148
+ }
149
+ }
150
+ exports.ClientSessionKeepAliveManager = ClientSessionKeepAliveManager;
151
151
  //# sourceMappingURL=client_session_keepalive_manager.js.map