node-opcua-client 2.97.0 → 2.98.1

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 (78) 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 +72 -72
  11. package/dist/alarms_and_conditions/client_alarm_tools_dump_event.js.map +1 -1
  12. package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.d.ts +3 -3
  13. package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.js +118 -118
  14. package/dist/alarms_and_conditions/client_tools.d.ts +7 -7
  15. package/dist/alarms_and_conditions/client_tools.js +179 -179
  16. package/dist/client_base.d.ts +277 -277
  17. package/dist/client_base.js +14 -14
  18. package/dist/client_base.js.map +1 -1
  19. package/dist/client_monitored_item.d.ts +21 -21
  20. package/dist/client_monitored_item.js +11 -11
  21. package/dist/client_monitored_item_base.d.ts +39 -39
  22. package/dist/client_monitored_item_base.js +2 -2
  23. package/dist/client_monitored_item_group.d.ts +21 -21
  24. package/dist/client_monitored_item_group.js +13 -13
  25. package/dist/client_monitored_item_toolbox.d.ts +15 -15
  26. package/dist/client_monitored_item_toolbox.js +116 -116
  27. package/dist/client_session.d.ts +529 -529
  28. package/dist/client_session.js +10 -10
  29. package/dist/client_session_keepalive_manager.d.ts +34 -34
  30. package/dist/client_session_keepalive_manager.js +149 -149
  31. package/dist/client_subscription.d.ts +241 -241
  32. package/dist/client_subscription.js +14 -14
  33. package/dist/client_subscription.js.map +1 -1
  34. package/dist/client_utils.d.ts +22 -22
  35. package/dist/client_utils.js +87 -87
  36. package/dist/common.d.ts +17 -17
  37. package/dist/common.js +5 -5
  38. package/dist/index.d.ts +56 -56
  39. package/dist/index.js +94 -94
  40. package/dist/opcua_client.d.ts +118 -118
  41. package/dist/opcua_client.js +33 -33
  42. package/dist/private/client_base_impl.d.ts +160 -160
  43. package/dist/private/client_base_impl.js +1348 -1348
  44. package/dist/private/client_monitored_item_base_impl.d.ts +3 -3
  45. package/dist/private/client_monitored_item_base_impl.js +4 -4
  46. package/dist/private/client_monitored_item_group_impl.d.ts +53 -53
  47. package/dist/private/client_monitored_item_group_impl.js +159 -159
  48. package/dist/private/client_monitored_item_impl.d.ts +93 -93
  49. package/dist/private/client_monitored_item_impl.js +304 -304
  50. package/dist/private/client_publish_engine.d.ts +62 -62
  51. package/dist/private/client_publish_engine.js +408 -408
  52. package/dist/private/client_publish_engine.js.map +1 -1
  53. package/dist/private/client_session_impl.d.ts +631 -631
  54. package/dist/private/client_session_impl.js +1348 -1348
  55. package/dist/private/client_subscription_impl.d.ts +93 -93
  56. package/dist/private/client_subscription_impl.js +763 -763
  57. package/dist/private/i_private_client.d.ts +21 -21
  58. package/dist/private/i_private_client.js +2 -2
  59. package/dist/private/opcua_client_impl.d.ts +166 -166
  60. package/dist/private/opcua_client_impl.js +1000 -1000
  61. package/dist/private/opcua_client_impl.js.map +1 -1
  62. package/dist/private/performance.d.ts +1 -1
  63. package/dist/private/performance.js +18 -18
  64. package/dist/reconnection.d.ts +9 -9
  65. package/dist/reconnection.js +381 -381
  66. package/dist/tools/findservers.d.ts +20 -20
  67. package/dist/tools/findservers.js +61 -61
  68. package/dist/tools/read_history_server_capabilities.d.ts +6 -6
  69. package/dist/tools/read_history_server_capabilities.js +98 -98
  70. package/dist/user_identity_info.d.ts +1 -1
  71. package/dist/user_identity_info.js +2 -2
  72. package/dist/verify.d.ts +5 -5
  73. package/dist/verify.js +134 -134
  74. package/package.json +49 -45
  75. package/source/alarms_and_conditions/client_alarm_tools_dump_event.ts +1 -1
  76. package/.nycrc.json +0 -14
  77. package/test_helpers/create_certificates.js +0 -1
  78. package/typedoc.js +0 -20
@@ -1,157 +1,157 @@
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.installAlarmMonitoring = exports.uninstallAlarmMonitoring = void 0;
13
- const node_opcua_data_model_1 = require("node-opcua-data-model");
14
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
15
- const node_opcua_service_filter_1 = require("node-opcua-service-filter");
16
- const node_opcua_service_read_1 = require("node-opcua-service-read");
17
- const node_opcua_variant_1 = require("node-opcua-variant");
18
- const node_opcua_debug_1 = require("node-opcua-debug");
19
- const client_alarm_1 = require("./client_alarm");
20
- const client_alarm_list_1 = require("./client_alarm_list");
21
- const client_alarm_tools_extractConditionFields_1 = require("./client_alarm_tools_extractConditionFields");
22
- const client_tools_1 = require("./client_tools");
23
- const doDebug = (0, node_opcua_debug_1.checkDebugFlag)("A&E");
24
- const debugLog = (0, node_opcua_debug_1.make_debugLog)("A&E");
25
- const warningLog = (0, node_opcua_debug_1.make_warningLog)("A&E");
26
- function r(_key, o) {
27
- if (o && o.dataType === "Null") {
28
- return undefined;
29
- }
30
- return o;
31
- }
32
- // ------------------------------------------------------------------------------------------------------------------------------
33
- function uninstallAlarmMonitoring(session) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const _sessionPriv = session;
36
- if (!_sessionPriv.$clientAlarmList) {
37
- return;
38
- }
39
- const mi = _sessionPriv.$monitoredItemForAlarmList;
40
- mi.removeAllListeners();
41
- _sessionPriv.$monitoredItemForAlarmList = null;
42
- yield _sessionPriv.$subscriptionforAlarmList.terminate();
43
- _sessionPriv.$clientAlarmList = null;
44
- return;
45
- });
46
- }
47
- exports.uninstallAlarmMonitoring = uninstallAlarmMonitoring;
48
- // Release 1.04 8 OPC Unified Architecture, Part 9
49
- // 4.5 Condition state synchronization
50
- //
51
- // A Client that wishes to display the current status of Alarms and Conditions (known as a
52
- // “current Alarm display”) would use the following logic to process Refresh Event Notifications.
53
- // The Client flags all Retained Conditions as suspect on reception of the Event of the
54
- // RefreshStartEventType. The Client adds any new Events that are received during the Refresh
55
- // without flagging them as suspect. The Client also removes the suspect flag from any Retained
56
- // Conditions that are returned as part of the Refresh. When the Client receives a
57
- // RefreshEndEvent, the Client removes any remaining suspect Events, since they no longer
58
- // apply.
59
- // ------------------------------------------------------------------------------------------------------------------------------
60
- function installAlarmMonitoring(session) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const _sessionPriv = session;
63
- // create
64
- if (_sessionPriv.$clientAlarmList) {
65
- return _sessionPriv.$clientAlarmList;
66
- }
67
- const clientAlarmList = new client_alarm_list_1.ClientAlarmList();
68
- _sessionPriv.$clientAlarmList = clientAlarmList;
69
- const request = {
70
- maxNotificationsPerPublish: 100,
71
- priority: 6,
72
- publishingEnabled: true,
73
- requestedLifetimeCount: 10000,
74
- requestedMaxKeepAliveCount: 10,
75
- requestedPublishingInterval: 500
76
- };
77
- const subscription = yield session.createSubscription2(request);
78
- _sessionPriv.$subscriptionforAlarmList = subscription;
79
- const itemToMonitor = {
80
- attributeId: node_opcua_data_model_1.AttributeIds.EventNotifier,
81
- nodeId: (0, node_opcua_nodeid_1.resolveNodeId)("Server") // i=2253
82
- };
83
- const fields = yield (0, client_alarm_tools_extractConditionFields_1.extractConditionFields)(session, "AlarmConditionType");
84
- const AcknowledgeableConditionType = (0, node_opcua_nodeid_1.resolveNodeId)("AcknowledgeableConditionType");
85
- const eventFilter = (0, node_opcua_service_filter_1.constructEventFilter)(fields, (0, node_opcua_service_filter_1.ofType)(AcknowledgeableConditionType));
86
- const monitoringParameters = {
87
- discardOldest: false,
88
- filter: eventFilter,
89
- queueSize: 1000,
90
- samplingInterval: 0
91
- };
92
- // now create a event monitored Item
93
- const eventMonitoringItem = yield subscription.monitor(itemToMonitor, monitoringParameters, node_opcua_service_read_1.TimestampsToReturn.Both);
94
- const queueEvent = [];
95
- function flushQueue() {
96
- const q = [...queueEvent];
97
- queueEvent.length = 0;
98
- for (const pojo of q) {
99
- clientAlarmList.update(pojo);
100
- }
101
- }
102
- let inInit = true;
103
- eventMonitoringItem.on("changed", (eventFields) => {
104
- var _a, _b;
105
- const pojo = (0, client_alarm_1.fieldsToJson)(fields, eventFields);
106
- const { eventType, eventId, conditionId, conditionName } = pojo;
107
- debugLog("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---- ALARM RECEIVED " +
108
- eventType.value.toString() +
109
- " " +
110
- ((_a = eventId.value) === null || _a === void 0 ? void 0 : _a.toString("hex")));
111
- try {
112
- if (!conditionId || !conditionId.value || conditionId.dataType === node_opcua_variant_1.DataType.Null) {
113
- // not a acknowledgeable condition
114
- warningLog(" not acknowledgeable condition ---- " + eventType.value.toString() + " ", conditionId, conditionName === null || conditionName === void 0 ? void 0 : conditionName.value, " " + ((_b = eventId.value) === null || _b === void 0 ? void 0 : _b.toString("hex")));
115
- return;
116
- }
117
- queueEvent.push(pojo);
118
- if (queueEvent.length === 1 && !inInit) {
119
- setTimeout(() => flushQueue(), 10);
120
- }
121
- }
122
- catch (err) {
123
- warningLog(JSON.stringify(pojo, r, " "));
124
- warningLog("Error !!", err);
125
- }
126
- // Release 1.04 8 OPC Unified Architecture, Part 9
127
- // 4.5 Condition state synchronization
128
- // RefreshRequiredEventType
129
- // Under some circumstances a Server may not be capable of ensuring the Client is fully
130
- // in sync with the current state of Condition instances. For example, if the underlying
131
- // system represented by the Server is reset or communications are lost for some period
132
- // of time the Server may need to resynchronize itself with the underlying system. In
133
- // these cases, the Server shall send an Event of the RefreshRequiredEventType to
134
- // advise the Client that a Refresh may be necessary. A Client receiving this special
135
- // Event should initiate a ConditionRefresh as noted in this clause.
136
- // TODO
137
- });
138
- try {
139
- yield (0, client_tools_1.callConditionRefresh)(subscription);
140
- }
141
- catch (err) {
142
- if (err.message.match(/BadNothingToDo/)) {
143
- /** fine! nothing to do */
144
- }
145
- else {
146
- warningLog("Server may not implement condition refresh", err.message);
147
- }
148
- }
149
- _sessionPriv.$monitoredItemForAlarmList = eventMonitoringItem;
150
- setTimeout(() => flushQueue(), 10);
151
- inInit = false;
152
- // also request updates
153
- return clientAlarmList;
154
- });
155
- }
156
- exports.installAlarmMonitoring = installAlarmMonitoring;
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.installAlarmMonitoring = exports.uninstallAlarmMonitoring = void 0;
13
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
14
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
15
+ const node_opcua_service_filter_1 = require("node-opcua-service-filter");
16
+ const node_opcua_service_read_1 = require("node-opcua-service-read");
17
+ const node_opcua_variant_1 = require("node-opcua-variant");
18
+ const node_opcua_debug_1 = require("node-opcua-debug");
19
+ const client_alarm_1 = require("./client_alarm");
20
+ const client_alarm_list_1 = require("./client_alarm_list");
21
+ const client_alarm_tools_extractConditionFields_1 = require("./client_alarm_tools_extractConditionFields");
22
+ const client_tools_1 = require("./client_tools");
23
+ const doDebug = (0, node_opcua_debug_1.checkDebugFlag)("A&E");
24
+ const debugLog = (0, node_opcua_debug_1.make_debugLog)("A&E");
25
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)("A&E");
26
+ function r(_key, o) {
27
+ if (o && o.dataType === "Null") {
28
+ return undefined;
29
+ }
30
+ return o;
31
+ }
32
+ // ------------------------------------------------------------------------------------------------------------------------------
33
+ function uninstallAlarmMonitoring(session) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const _sessionPriv = session;
36
+ if (!_sessionPriv.$clientAlarmList) {
37
+ return;
38
+ }
39
+ const mi = _sessionPriv.$monitoredItemForAlarmList;
40
+ mi.removeAllListeners();
41
+ _sessionPriv.$monitoredItemForAlarmList = null;
42
+ yield _sessionPriv.$subscriptionforAlarmList.terminate();
43
+ _sessionPriv.$clientAlarmList = null;
44
+ return;
45
+ });
46
+ }
47
+ exports.uninstallAlarmMonitoring = uninstallAlarmMonitoring;
48
+ // Release 1.04 8 OPC Unified Architecture, Part 9
49
+ // 4.5 Condition state synchronization
50
+ //
51
+ // A Client that wishes to display the current status of Alarms and Conditions (known as a
52
+ // “current Alarm display”) would use the following logic to process Refresh Event Notifications.
53
+ // The Client flags all Retained Conditions as suspect on reception of the Event of the
54
+ // RefreshStartEventType. The Client adds any new Events that are received during the Refresh
55
+ // without flagging them as suspect. The Client also removes the suspect flag from any Retained
56
+ // Conditions that are returned as part of the Refresh. When the Client receives a
57
+ // RefreshEndEvent, the Client removes any remaining suspect Events, since they no longer
58
+ // apply.
59
+ // ------------------------------------------------------------------------------------------------------------------------------
60
+ function installAlarmMonitoring(session) {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const _sessionPriv = session;
63
+ // create
64
+ if (_sessionPriv.$clientAlarmList) {
65
+ return _sessionPriv.$clientAlarmList;
66
+ }
67
+ const clientAlarmList = new client_alarm_list_1.ClientAlarmList();
68
+ _sessionPriv.$clientAlarmList = clientAlarmList;
69
+ const request = {
70
+ maxNotificationsPerPublish: 100,
71
+ priority: 6,
72
+ publishingEnabled: true,
73
+ requestedLifetimeCount: 10000,
74
+ requestedMaxKeepAliveCount: 10,
75
+ requestedPublishingInterval: 500
76
+ };
77
+ const subscription = yield session.createSubscription2(request);
78
+ _sessionPriv.$subscriptionforAlarmList = subscription;
79
+ const itemToMonitor = {
80
+ attributeId: node_opcua_data_model_1.AttributeIds.EventNotifier,
81
+ nodeId: (0, node_opcua_nodeid_1.resolveNodeId)("Server") // i=2253
82
+ };
83
+ const fields = yield (0, client_alarm_tools_extractConditionFields_1.extractConditionFields)(session, "AlarmConditionType");
84
+ const AcknowledgeableConditionType = (0, node_opcua_nodeid_1.resolveNodeId)("AcknowledgeableConditionType");
85
+ const eventFilter = (0, node_opcua_service_filter_1.constructEventFilter)(fields, (0, node_opcua_service_filter_1.ofType)(AcknowledgeableConditionType));
86
+ const monitoringParameters = {
87
+ discardOldest: false,
88
+ filter: eventFilter,
89
+ queueSize: 1000,
90
+ samplingInterval: 0
91
+ };
92
+ // now create a event monitored Item
93
+ const eventMonitoringItem = yield subscription.monitor(itemToMonitor, monitoringParameters, node_opcua_service_read_1.TimestampsToReturn.Both);
94
+ const queueEvent = [];
95
+ function flushQueue() {
96
+ const q = [...queueEvent];
97
+ queueEvent.length = 0;
98
+ for (const pojo of q) {
99
+ clientAlarmList.update(pojo);
100
+ }
101
+ }
102
+ let inInit = true;
103
+ eventMonitoringItem.on("changed", (eventFields) => {
104
+ var _a, _b;
105
+ const pojo = (0, client_alarm_1.fieldsToJson)(fields, eventFields);
106
+ const { eventType, eventId, conditionId, conditionName } = pojo;
107
+ debugLog("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---- ALARM RECEIVED " +
108
+ eventType.value.toString() +
109
+ " " +
110
+ ((_a = eventId.value) === null || _a === void 0 ? void 0 : _a.toString("hex")));
111
+ try {
112
+ if (!conditionId || !conditionId.value || conditionId.dataType === node_opcua_variant_1.DataType.Null) {
113
+ // not a acknowledgeable condition
114
+ warningLog(" not acknowledgeable condition ---- " + eventType.value.toString() + " ", conditionId, conditionName === null || conditionName === void 0 ? void 0 : conditionName.value, " " + ((_b = eventId.value) === null || _b === void 0 ? void 0 : _b.toString("hex")));
115
+ return;
116
+ }
117
+ queueEvent.push(pojo);
118
+ if (queueEvent.length === 1 && !inInit) {
119
+ setTimeout(() => flushQueue(), 10);
120
+ }
121
+ }
122
+ catch (err) {
123
+ warningLog(JSON.stringify(pojo, r, " "));
124
+ warningLog("Error !!", err);
125
+ }
126
+ // Release 1.04 8 OPC Unified Architecture, Part 9
127
+ // 4.5 Condition state synchronization
128
+ // RefreshRequiredEventType
129
+ // Under some circumstances a Server may not be capable of ensuring the Client is fully
130
+ // in sync with the current state of Condition instances. For example, if the underlying
131
+ // system represented by the Server is reset or communications are lost for some period
132
+ // of time the Server may need to resynchronize itself with the underlying system. In
133
+ // these cases, the Server shall send an Event of the RefreshRequiredEventType to
134
+ // advise the Client that a Refresh may be necessary. A Client receiving this special
135
+ // Event should initiate a ConditionRefresh as noted in this clause.
136
+ // TODO
137
+ });
138
+ try {
139
+ yield (0, client_tools_1.callConditionRefresh)(subscription);
140
+ }
141
+ catch (err) {
142
+ if (err.message.match(/BadNothingToDo/)) {
143
+ /** fine! nothing to do */
144
+ }
145
+ else {
146
+ warningLog("Server may not implement condition refresh", err.message);
147
+ }
148
+ }
149
+ _sessionPriv.$monitoredItemForAlarmList = eventMonitoringItem;
150
+ setTimeout(() => flushQueue(), 10);
151
+ inInit = false;
152
+ // also request updates
153
+ return clientAlarmList;
154
+ });
155
+ }
156
+ exports.installAlarmMonitoring = installAlarmMonitoring;
157
157
  //# sourceMappingURL=client_alarm_tools.js.map
@@ -1,18 +1,18 @@
1
- import { StatusCode } from "node-opcua-status-code";
2
- import { ClientSession } from "../client_session";
3
- import { EventStuff } from "./client_alarm";
4
- /**
5
- *
6
- * @param session
7
- * @param eventStuff
8
- * @param comment
9
- */
10
- export declare function acknowledgeCondition(session: ClientSession, eventStuff: EventStuff, comment: string): Promise<StatusCode>;
11
- export declare function confirmCondition(session: ClientSession, eventStuff: EventStuff, comment: string): Promise<StatusCode>;
12
- /**
13
- * Enumerate all events
14
- * @param session
15
- */
16
- export declare function findActiveConditions(session: ClientSession): Promise<EventStuff[]>;
17
- export declare function acknwoledgeAllConditions(session: ClientSession, message: string): Promise<void>;
18
- export declare function confirmAllConditions(session: ClientSession, message: string): Promise<void>;
1
+ import { StatusCode } from "node-opcua-status-code";
2
+ import { ClientSession } from "../client_session";
3
+ import { EventStuff } from "./client_alarm";
4
+ /**
5
+ *
6
+ * @param session
7
+ * @param eventStuff
8
+ * @param comment
9
+ */
10
+ export declare function acknowledgeCondition(session: ClientSession, eventStuff: EventStuff, comment: string): Promise<StatusCode>;
11
+ export declare function confirmCondition(session: ClientSession, eventStuff: EventStuff, comment: string): Promise<StatusCode>;
12
+ /**
13
+ * Enumerate all events
14
+ * @param session
15
+ */
16
+ export declare function findActiveConditions(session: ClientSession): Promise<EventStuff[]>;
17
+ export declare function acknwoledgeAllConditions(session: ClientSession, message: string): Promise<void>;
18
+ export declare function confirmAllConditions(session: ClientSession, message: string): Promise<void>;