node-opcua-client 2.76.0 → 2.77.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 (68) 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 +485 -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_session_impl.js.map +1 -1
  52. package/dist/private/client_subscription_impl.d.ts +93 -93
  53. package/dist/private/client_subscription_impl.js +748 -748
  54. package/dist/private/i_private_client.d.ts +18 -18
  55. package/dist/private/i_private_client.js +2 -2
  56. package/dist/private/opcua_client_impl.d.ts +169 -169
  57. package/dist/private/opcua_client_impl.js +981 -981
  58. package/dist/reconnection.d.ts +9 -9
  59. package/dist/reconnection.js +408 -408
  60. package/dist/tools/findservers.d.ts +20 -20
  61. package/dist/tools/findservers.js +61 -61
  62. package/dist/tools/read_history_server_capabilities.d.ts +6 -6
  63. package/dist/tools/read_history_server_capabilities.js +99 -99
  64. package/dist/verify.d.ts +5 -5
  65. package/dist/verify.js +134 -134
  66. package/package.json +45 -45
  67. package/source/client_session.ts +1 -1
  68. package/source/private/client_session_impl.ts +1 -1
@@ -1,193 +1,193 @@
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.confirmAllConditions = exports.acknwoledgeAllConditions = exports.findActiveConditions = exports.confirmCondition = exports.acknowledgeCondition = void 0;
13
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
14
- const node_opcua_service_filter_1 = require("node-opcua-service-filter");
15
- const node_opcua_service_read_1 = require("node-opcua-service-read");
16
- const node_opcua_status_code_1 = require("node-opcua-status-code");
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_tools_extractConditionFields_1 = require("./client_alarm_tools_extractConditionFields");
21
- const client_tools_1 = require("./client_tools");
22
- const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
23
- const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
24
- const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
25
- /**
26
- *
27
- * @param session
28
- * @param eventStuff
29
- * @param comment
30
- */
31
- function acknowledgeCondition(session, eventStuff, comment) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- try {
34
- const conditionId = eventStuff.conditionId.value;
35
- const eventId = eventStuff.eventId.value;
36
- return yield session.acknowledgeCondition(conditionId, eventId, comment);
37
- }
38
- catch (err) {
39
- errorLog("Acknowledging alarm has failed !", err);
40
- return node_opcua_status_code_1.StatusCodes.BadInternalError;
41
- }
42
- });
43
- }
44
- exports.acknowledgeCondition = acknowledgeCondition;
45
- function confirmCondition(session, eventStuff, comment) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- try {
48
- const conditionId = eventStuff.conditionId.value;
49
- const eventId = eventStuff.eventId.value;
50
- return yield session.confirmCondition(conditionId, eventId, comment);
51
- }
52
- catch (err) {
53
- errorLog("Acknowledging alarm has failed !", err);
54
- return node_opcua_status_code_1.StatusCodes.BadInternalError;
55
- }
56
- });
57
- }
58
- exports.confirmCondition = confirmCondition;
59
- /**
60
- * Enumerate all events
61
- * @param session
62
- */
63
- function findActiveConditions(session) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- const request = {
66
- maxNotificationsPerPublish: 10000,
67
- priority: 6,
68
- publishingEnabled: true,
69
- requestedLifetimeCount: 1000,
70
- requestedMaxKeepAliveCount: 100,
71
- requestedPublishingInterval: 100
72
- };
73
- const subscription = yield session.createSubscription2(request);
74
- const itemToMonitor = {
75
- attributeId: node_opcua_service_read_1.AttributeIds.EventNotifier,
76
- nodeId: (0, node_opcua_nodeid_1.resolveNodeId)("Server") // i=2253
77
- };
78
- const fields = yield (0, client_alarm_tools_extractConditionFields_1.extractConditionFields)(session, "AcknowledgeableConditionType");
79
- // note: we may want to have this select clause
80
- // Or(OfType("AcknowledgeableConditionType"), OfType("RefreshStartEventType"), OfType("RefreshEndEventType"))
81
- const eventFilter = (0, node_opcua_service_filter_1.constructEventFilter)(fields);
82
- const monitoringParameters = {
83
- discardOldest: false,
84
- filter: eventFilter,
85
- queueSize: 100,
86
- samplingInterval: 0
87
- };
88
- const event_monitoringItem = yield subscription.monitor(itemToMonitor, monitoringParameters, node_opcua_service_read_1.TimestampsToReturn.Both);
89
- const acknowledgeableConditions = [];
90
- let refreshStartEventHasBeenReceived = false;
91
- let RefreshEndEventHasBeenReceived = false;
92
- const RefreshStartEventType = (0, node_opcua_nodeid_1.resolveNodeId)("RefreshStartEventType").toString();
93
- const RefreshEndEventType = (0, node_opcua_nodeid_1.resolveNodeId)("RefreshEndEventType").toString();
94
- const promise = new Promise((resolve, reject) => {
95
- // now create a event monitored Item
96
- event_monitoringItem.on("changed", (_eventFields) => {
97
- const eventFields = _eventFields;
98
- try {
99
- if (RefreshEndEventHasBeenReceived) {
100
- return;
101
- }
102
- // dumpEvent(session, fields, eventFields);
103
- const pojo = (0, client_alarm_1.fieldsToJson)(fields, eventFields);
104
- // console.log(pojo.eventType.value.toString({ addressSpace}), RefreshEndEventType, RefreshStartEventType);
105
- // make sure we only start recording event after the RefreshStartEvent has been received
106
- if (!refreshStartEventHasBeenReceived) {
107
- if (pojo.eventType.value.toString() === RefreshStartEventType) {
108
- refreshStartEventHasBeenReceived = true;
109
- }
110
- return;
111
- }
112
- if (pojo.eventType.value.toString() === RefreshEndEventType) {
113
- RefreshEndEventHasBeenReceived = true;
114
- resolve();
115
- return;
116
- }
117
- if (!pojo.conditionId.value) {
118
- // not a Acknowledgeable condition
119
- return;
120
- }
121
- if (pojo.ackedState.id.dataType === node_opcua_variant_1.DataType.Boolean) {
122
- acknowledgeableConditions.push(pojo);
123
- }
124
- }
125
- catch (err) {
126
- errorLog("Error !!", err);
127
- }
128
- });
129
- // async call without waiting !
130
- try {
131
- (0, client_tools_1.callConditionRefresh)(subscription);
132
- }
133
- catch (err) {
134
- // it is possible that server do not implement conditionRefresh ...
135
- debugLog("Server may not implement conditionRefresh", err);
136
- }
137
- });
138
- yield promise;
139
- // now shut down susbscription
140
- yield subscription.terminate();
141
- return acknowledgeableConditions;
142
- });
143
- }
144
- exports.findActiveConditions = findActiveConditions;
145
- function acknwoledgeAllConditions(session, message) {
146
- return __awaiter(this, void 0, void 0, function* () {
147
- try {
148
- let conditions = yield findActiveConditions(session);
149
- if (conditions.length === 0) {
150
- debugLog("Warning: cannot find conditions ");
151
- }
152
- // filter acknowledgable conditions (no acked yet)
153
- conditions = conditions.filter((pojo) => pojo.ackedState.id.value === false);
154
- const promises = [];
155
- for (const eventStuff of conditions) {
156
- promises.push(acknowledgeCondition(session, eventStuff, message));
157
- }
158
- const result = yield Promise.all(promises);
159
- if (doDebug) {
160
- debugLog("Acked all results: ", result.map((e) => e.toString()).join(" "));
161
- }
162
- }
163
- catch (err) {
164
- errorLog("Error", err);
165
- }
166
- });
167
- }
168
- exports.acknwoledgeAllConditions = acknwoledgeAllConditions;
169
- function confirmAllConditions(session, message) {
170
- return __awaiter(this, void 0, void 0, function* () {
171
- try {
172
- let conditions = yield findActiveConditions(session);
173
- if (conditions.length === 0) {
174
- debugLog("Warning: cannot find conditions ");
175
- }
176
- // filter acknowledgable conditions (no acked yet)
177
- conditions = conditions.filter((pojo) => pojo.confirmedState.id.value === false);
178
- const promises = [];
179
- for (const eventStuff of conditions) {
180
- promises.push(confirmCondition(session, eventStuff, message));
181
- }
182
- const result = yield Promise.all(promises);
183
- if (doDebug) {
184
- debugLog("Confirm all results: ", result.map((e) => e.toString()).join(" "));
185
- }
186
- }
187
- catch (err) {
188
- errorLog("Error", err);
189
- }
190
- });
191
- }
192
- exports.confirmAllConditions = confirmAllConditions;
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.confirmAllConditions = exports.acknwoledgeAllConditions = exports.findActiveConditions = exports.confirmCondition = exports.acknowledgeCondition = void 0;
13
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
14
+ const node_opcua_service_filter_1 = require("node-opcua-service-filter");
15
+ const node_opcua_service_read_1 = require("node-opcua-service-read");
16
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
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_tools_extractConditionFields_1 = require("./client_alarm_tools_extractConditionFields");
21
+ const client_tools_1 = require("./client_tools");
22
+ const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
23
+ const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
24
+ const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
25
+ /**
26
+ *
27
+ * @param session
28
+ * @param eventStuff
29
+ * @param comment
30
+ */
31
+ function acknowledgeCondition(session, eventStuff, comment) {
32
+ return __awaiter(this, void 0, void 0, function* () {
33
+ try {
34
+ const conditionId = eventStuff.conditionId.value;
35
+ const eventId = eventStuff.eventId.value;
36
+ return yield session.acknowledgeCondition(conditionId, eventId, comment);
37
+ }
38
+ catch (err) {
39
+ errorLog("Acknowledging alarm has failed !", err);
40
+ return node_opcua_status_code_1.StatusCodes.BadInternalError;
41
+ }
42
+ });
43
+ }
44
+ exports.acknowledgeCondition = acknowledgeCondition;
45
+ function confirmCondition(session, eventStuff, comment) {
46
+ return __awaiter(this, void 0, void 0, function* () {
47
+ try {
48
+ const conditionId = eventStuff.conditionId.value;
49
+ const eventId = eventStuff.eventId.value;
50
+ return yield session.confirmCondition(conditionId, eventId, comment);
51
+ }
52
+ catch (err) {
53
+ errorLog("Acknowledging alarm has failed !", err);
54
+ return node_opcua_status_code_1.StatusCodes.BadInternalError;
55
+ }
56
+ });
57
+ }
58
+ exports.confirmCondition = confirmCondition;
59
+ /**
60
+ * Enumerate all events
61
+ * @param session
62
+ */
63
+ function findActiveConditions(session) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ const request = {
66
+ maxNotificationsPerPublish: 10000,
67
+ priority: 6,
68
+ publishingEnabled: true,
69
+ requestedLifetimeCount: 1000,
70
+ requestedMaxKeepAliveCount: 100,
71
+ requestedPublishingInterval: 100
72
+ };
73
+ const subscription = yield session.createSubscription2(request);
74
+ const itemToMonitor = {
75
+ attributeId: node_opcua_service_read_1.AttributeIds.EventNotifier,
76
+ nodeId: (0, node_opcua_nodeid_1.resolveNodeId)("Server") // i=2253
77
+ };
78
+ const fields = yield (0, client_alarm_tools_extractConditionFields_1.extractConditionFields)(session, "AcknowledgeableConditionType");
79
+ // note: we may want to have this select clause
80
+ // Or(OfType("AcknowledgeableConditionType"), OfType("RefreshStartEventType"), OfType("RefreshEndEventType"))
81
+ const eventFilter = (0, node_opcua_service_filter_1.constructEventFilter)(fields);
82
+ const monitoringParameters = {
83
+ discardOldest: false,
84
+ filter: eventFilter,
85
+ queueSize: 100,
86
+ samplingInterval: 0
87
+ };
88
+ const event_monitoringItem = yield subscription.monitor(itemToMonitor, monitoringParameters, node_opcua_service_read_1.TimestampsToReturn.Both);
89
+ const acknowledgeableConditions = [];
90
+ let refreshStartEventHasBeenReceived = false;
91
+ let RefreshEndEventHasBeenReceived = false;
92
+ const RefreshStartEventType = (0, node_opcua_nodeid_1.resolveNodeId)("RefreshStartEventType").toString();
93
+ const RefreshEndEventType = (0, node_opcua_nodeid_1.resolveNodeId)("RefreshEndEventType").toString();
94
+ const promise = new Promise((resolve, reject) => {
95
+ // now create a event monitored Item
96
+ event_monitoringItem.on("changed", (_eventFields) => {
97
+ const eventFields = _eventFields;
98
+ try {
99
+ if (RefreshEndEventHasBeenReceived) {
100
+ return;
101
+ }
102
+ // dumpEvent(session, fields, eventFields);
103
+ const pojo = (0, client_alarm_1.fieldsToJson)(fields, eventFields);
104
+ // console.log(pojo.eventType.value.toString({ addressSpace}), RefreshEndEventType, RefreshStartEventType);
105
+ // make sure we only start recording event after the RefreshStartEvent has been received
106
+ if (!refreshStartEventHasBeenReceived) {
107
+ if (pojo.eventType.value.toString() === RefreshStartEventType) {
108
+ refreshStartEventHasBeenReceived = true;
109
+ }
110
+ return;
111
+ }
112
+ if (pojo.eventType.value.toString() === RefreshEndEventType) {
113
+ RefreshEndEventHasBeenReceived = true;
114
+ resolve();
115
+ return;
116
+ }
117
+ if (!pojo.conditionId.value) {
118
+ // not a Acknowledgeable condition
119
+ return;
120
+ }
121
+ if (pojo.ackedState.id.dataType === node_opcua_variant_1.DataType.Boolean) {
122
+ acknowledgeableConditions.push(pojo);
123
+ }
124
+ }
125
+ catch (err) {
126
+ errorLog("Error !!", err);
127
+ }
128
+ });
129
+ // async call without waiting !
130
+ try {
131
+ (0, client_tools_1.callConditionRefresh)(subscription);
132
+ }
133
+ catch (err) {
134
+ // it is possible that server do not implement conditionRefresh ...
135
+ debugLog("Server may not implement conditionRefresh", err);
136
+ }
137
+ });
138
+ yield promise;
139
+ // now shut down susbscription
140
+ yield subscription.terminate();
141
+ return acknowledgeableConditions;
142
+ });
143
+ }
144
+ exports.findActiveConditions = findActiveConditions;
145
+ function acknwoledgeAllConditions(session, message) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ try {
148
+ let conditions = yield findActiveConditions(session);
149
+ if (conditions.length === 0) {
150
+ debugLog("Warning: cannot find conditions ");
151
+ }
152
+ // filter acknowledgable conditions (no acked yet)
153
+ conditions = conditions.filter((pojo) => pojo.ackedState.id.value === false);
154
+ const promises = [];
155
+ for (const eventStuff of conditions) {
156
+ promises.push(acknowledgeCondition(session, eventStuff, message));
157
+ }
158
+ const result = yield Promise.all(promises);
159
+ if (doDebug) {
160
+ debugLog("Acked all results: ", result.map((e) => e.toString()).join(" "));
161
+ }
162
+ }
163
+ catch (err) {
164
+ errorLog("Error", err);
165
+ }
166
+ });
167
+ }
168
+ exports.acknwoledgeAllConditions = acknwoledgeAllConditions;
169
+ function confirmAllConditions(session, message) {
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ try {
172
+ let conditions = yield findActiveConditions(session);
173
+ if (conditions.length === 0) {
174
+ debugLog("Warning: cannot find conditions ");
175
+ }
176
+ // filter acknowledgable conditions (no acked yet)
177
+ conditions = conditions.filter((pojo) => pojo.confirmedState.id.value === false);
178
+ const promises = [];
179
+ for (const eventStuff of conditions) {
180
+ promises.push(confirmCondition(session, eventStuff, message));
181
+ }
182
+ const result = yield Promise.all(promises);
183
+ if (doDebug) {
184
+ debugLog("Confirm all results: ", result.map((e) => e.toString()).join(" "));
185
+ }
186
+ }
187
+ catch (err) {
188
+ errorLog("Error", err);
189
+ }
190
+ });
191
+ }
192
+ exports.confirmAllConditions = confirmAllConditions;
193
193
  //# sourceMappingURL=client_alarm_tools_acknowledge_all_conditions.js.map
@@ -1,9 +1,9 @@
1
- import { IBasicSession } from "node-opcua-pseudo-session";
2
- import { Variant } from "node-opcua-variant";
3
- /**
4
- *
5
- * @param session
6
- * @param fields
7
- * @param eventFields
8
- */
9
- export declare function dumpEvent(session: IBasicSession, fields: string[], eventFields: Variant[]): Promise<void>;
1
+ import { IBasicSession } from "node-opcua-pseudo-session";
2
+ import { Variant } from "node-opcua-variant";
3
+ /**
4
+ *
5
+ * @param session
6
+ * @param fields
7
+ * @param eventFields
8
+ */
9
+ export declare function dumpEvent(session: IBasicSession, fields: string[], eventFields: Variant[]): Promise<void>;
@@ -1,74 +1,74 @@
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.dumpEvent = void 0;
13
- const chalk = require("chalk");
14
- const node_opcua_data_model_1 = require("node-opcua-data-model");
15
- const node_opcua_status_code_1 = require("node-opcua-status-code");
16
- const node_opcua_variant_1 = require("node-opcua-variant");
17
- /**
18
- *
19
- * @param session
20
- * @param fields
21
- * @param eventFields
22
- */
23
- function dumpEvent(session, fields, eventFields) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- function getBrowseName(_session, nodeId) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const dataValue = yield _session.read({
28
- attributeId: node_opcua_data_model_1.AttributeIds.BrowseName,
29
- nodeId
30
- });
31
- if (dataValue.statusCode === node_opcua_status_code_1.StatusCodes.Good) {
32
- const browseName = dataValue.value.value.name;
33
- return browseName;
34
- }
35
- else {
36
- return "???";
37
- }
38
- });
39
- }
40
- function w(str, l) {
41
- return str.padEnd(l, " ").substring(0, l);
42
- }
43
- function __dumpEvent1(_session, _fields, variant, index) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- if (variant.dataType === node_opcua_variant_1.DataType.Null) {
46
- return;
47
- }
48
- if (variant.dataType === node_opcua_variant_1.DataType.NodeId) {
49
- const name = yield getBrowseName(_session, variant.value);
50
- // tslint:disable-next-line: no-console
51
- console.log(chalk.yellow(w(name, 30), w(_fields[index], 25)), chalk.cyan(w(node_opcua_variant_1.DataType[variant.dataType], 10).toString()), chalk.cyan.bold(name), "(", w(variant.value, 20), ")");
52
- }
53
- else {
54
- // tslint:disable-next-line: no-console
55
- console.log(chalk.yellow(w("", 30), w(_fields[index], 25)), chalk.cyan(w(node_opcua_variant_1.DataType[variant.dataType], 10).toString()), variant.value);
56
- }
57
- });
58
- }
59
- function __dumpEvent(_session, _fields, _eventFields) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- let index = 0;
62
- const promises = [];
63
- for (const variant of _eventFields) {
64
- promises.push(__dumpEvent1(_session, _fields, variant, index));
65
- index++;
66
- }
67
- yield Promise.all(promises);
68
- });
69
- }
70
- yield __dumpEvent(session, fields, eventFields);
71
- });
72
- }
73
- exports.dumpEvent = dumpEvent;
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.dumpEvent = void 0;
13
+ const chalk = require("chalk");
14
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
15
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
16
+ const node_opcua_variant_1 = require("node-opcua-variant");
17
+ /**
18
+ *
19
+ * @param session
20
+ * @param fields
21
+ * @param eventFields
22
+ */
23
+ function dumpEvent(session, fields, eventFields) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ function getBrowseName(_session, nodeId) {
26
+ return __awaiter(this, void 0, void 0, function* () {
27
+ const dataValue = yield _session.read({
28
+ attributeId: node_opcua_data_model_1.AttributeIds.BrowseName,
29
+ nodeId
30
+ });
31
+ if (dataValue.statusCode === node_opcua_status_code_1.StatusCodes.Good) {
32
+ const browseName = dataValue.value.value.name;
33
+ return browseName;
34
+ }
35
+ else {
36
+ return "???";
37
+ }
38
+ });
39
+ }
40
+ function w(str, l) {
41
+ return str.padEnd(l, " ").substring(0, l);
42
+ }
43
+ function __dumpEvent1(_session, _fields, variant, index) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ if (variant.dataType === node_opcua_variant_1.DataType.Null) {
46
+ return;
47
+ }
48
+ if (variant.dataType === node_opcua_variant_1.DataType.NodeId) {
49
+ const name = yield getBrowseName(_session, variant.value);
50
+ // tslint:disable-next-line: no-console
51
+ console.log(chalk.yellow(w(name, 30), w(_fields[index], 25)), chalk.cyan(w(node_opcua_variant_1.DataType[variant.dataType], 10).toString()), chalk.cyan.bold(name), "(", w(variant.value, 20), ")");
52
+ }
53
+ else {
54
+ // tslint:disable-next-line: no-console
55
+ console.log(chalk.yellow(w("", 30), w(_fields[index], 25)), chalk.cyan(w(node_opcua_variant_1.DataType[variant.dataType], 10).toString()), variant.value);
56
+ }
57
+ });
58
+ }
59
+ function __dumpEvent(_session, _fields, _eventFields) {
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ let index = 0;
62
+ const promises = [];
63
+ for (const variant of _eventFields) {
64
+ promises.push(__dumpEvent1(_session, _fields, variant, index));
65
+ index++;
66
+ }
67
+ yield Promise.all(promises);
68
+ });
69
+ }
70
+ yield __dumpEvent(session, fields, eventFields);
71
+ });
72
+ }
73
+ exports.dumpEvent = dumpEvent;
74
74
  //# sourceMappingURL=client_alarm_tools_dump_event.js.map
@@ -1,3 +1,3 @@
1
- import { NodeIdLike } from "node-opcua-nodeid";
2
- import { IBasicSession } from "node-opcua-pseudo-session";
3
- export declare function extractConditionFields(session: IBasicSession, conditionNodeId: NodeIdLike): Promise<string[]>;
1
+ import { NodeIdLike } from "node-opcua-nodeid";
2
+ import { IBasicSession } from "node-opcua-pseudo-session";
3
+ export declare function extractConditionFields(session: IBasicSession, conditionNodeId: NodeIdLike): Promise<string[]>;