node-opcua-client 2.64.1 → 2.65.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 +42 -42
  2. package/dist/alarms_and_conditions/client_alarm.js +84 -84
  3. package/dist/alarms_and_conditions/client_alarm_list.d.ts +21 -21
  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 +139 -139
  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 +190 -190
  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 +8 -8
  12. package/dist/alarms_and_conditions/client_alarm_tools_extractConditionFields.js +120 -120
  13. package/dist/alarms_and_conditions/client_tools.d.ts +7 -7
  14. package/dist/alarms_and_conditions/client_tools.js +179 -179
  15. package/dist/client_base.d.ts +270 -270
  16. package/dist/client_base.js +13 -13
  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 +483 -483
  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 +89 -89
  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 +169 -169
  40. package/dist/private/client_base_impl.js +1315 -1315
  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 +304 -304
  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 +620 -620
  50. package/dist/private/client_session_impl.js +1298 -1298
  51. package/dist/private/client_subscription_impl.d.ts +93 -93
  52. package/dist/private/client_subscription_impl.js +779 -779
  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 +978 -978
  57. package/dist/reconnection.d.ts +9 -9
  58. package/dist/reconnection.js +362 -362
  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 +24 -24
@@ -1,191 +1,191 @@
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
- const eventFilter = (0, node_opcua_service_filter_1.constructEventFilter)(fields, [(0, node_opcua_nodeid_1.resolveNodeId)("AcknowledgeableConditionType")]);
80
- const monitoringParameters = {
81
- discardOldest: false,
82
- filter: eventFilter,
83
- queueSize: 100,
84
- samplingInterval: 0
85
- };
86
- const event_monitoringItem = yield subscription.monitor(itemToMonitor, monitoringParameters, node_opcua_service_read_1.TimestampsToReturn.Both);
87
- const acknowledgeableConditions = [];
88
- let refreshStartEventHasBeenReceived = false;
89
- let RefreshEndEventHasBeenReceived = false;
90
- const RefreshStartEventType = (0, node_opcua_nodeid_1.resolveNodeId)("RefreshStartEventType").toString();
91
- const RefreshEndEventType = (0, node_opcua_nodeid_1.resolveNodeId)("RefreshEndEventType").toString();
92
- const promise = new Promise((resolve, reject) => {
93
- // now create a event monitored Item
94
- event_monitoringItem.on("changed", (_eventFields) => {
95
- const eventFields = _eventFields;
96
- try {
97
- if (RefreshEndEventHasBeenReceived) {
98
- return;
99
- }
100
- // dumpEvent(session, fields, eventFields);
101
- const pojo = (0, client_alarm_1.fieldsToJson)(fields, eventFields);
102
- // console.log(pojo.eventType.value.toString(), RefreshEndEventType, RefreshStartEventType);
103
- // make sure we only start recording event after the RefreshStartEvent has been received
104
- if (!refreshStartEventHasBeenReceived) {
105
- if (pojo.eventType.value.toString() === RefreshStartEventType) {
106
- refreshStartEventHasBeenReceived = true;
107
- }
108
- return;
109
- }
110
- if (pojo.eventType.value.toString() === RefreshEndEventType) {
111
- RefreshEndEventHasBeenReceived = true;
112
- resolve();
113
- return;
114
- }
115
- if (!pojo.conditionId.value) {
116
- // not a Acknowledgeable condition
117
- return;
118
- }
119
- if (pojo.ackedState.id.dataType === node_opcua_variant_1.DataType.Boolean) {
120
- acknowledgeableConditions.push(pojo);
121
- }
122
- }
123
- catch (err) {
124
- errorLog("Error !!", err);
125
- }
126
- });
127
- // async call without waiting !
128
- try {
129
- (0, client_tools_1.callConditionRefresh)(subscription);
130
- }
131
- catch (err) {
132
- // it is possible that server do not implement conditionRefresh ...
133
- debugLog("Server may not implement conditionRefresh", err);
134
- }
135
- });
136
- yield promise;
137
- // now shut down susbscription
138
- yield subscription.terminate();
139
- return acknowledgeableConditions;
140
- });
141
- }
142
- exports.findActiveConditions = findActiveConditions;
143
- function acknwoledgeAllConditions(session, message) {
144
- return __awaiter(this, void 0, void 0, function* () {
145
- try {
146
- let conditions = yield findActiveConditions(session);
147
- if (conditions.length === 0) {
148
- debugLog("Warning: cannot find conditions ");
149
- }
150
- // filter acknowledgable conditions (no acked yet)
151
- conditions = conditions.filter((pojo) => pojo.ackedState.id.value === false);
152
- const promises = [];
153
- for (const eventStuff of conditions) {
154
- promises.push(acknowledgeCondition(session, eventStuff, message));
155
- }
156
- const result = yield Promise.all(promises);
157
- if (doDebug) {
158
- debugLog("Acked all results: ", result.map((e) => e.toString()).join(" "));
159
- }
160
- }
161
- catch (err) {
162
- errorLog("Error", err);
163
- }
164
- });
165
- }
166
- exports.acknwoledgeAllConditions = acknwoledgeAllConditions;
167
- function confirmAllConditions(session, message) {
168
- return __awaiter(this, void 0, void 0, function* () {
169
- try {
170
- let conditions = yield findActiveConditions(session);
171
- if (conditions.length === 0) {
172
- debugLog("Warning: cannot find conditions ");
173
- }
174
- // filter acknowledgable conditions (no acked yet)
175
- conditions = conditions.filter((pojo) => pojo.confirmedState.id.value === false);
176
- const promises = [];
177
- for (const eventStuff of conditions) {
178
- promises.push(confirmCondition(session, eventStuff, message));
179
- }
180
- const result = yield Promise.all(promises);
181
- if (doDebug) {
182
- debugLog("Confirm all results: ", result.map((e) => e.toString()).join(" "));
183
- }
184
- }
185
- catch (err) {
186
- errorLog("Error", err);
187
- }
188
- });
189
- }
190
- 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
+ const eventFilter = (0, node_opcua_service_filter_1.constructEventFilter)(fields, [(0, node_opcua_nodeid_1.resolveNodeId)("AcknowledgeableConditionType")]);
80
+ const monitoringParameters = {
81
+ discardOldest: false,
82
+ filter: eventFilter,
83
+ queueSize: 100,
84
+ samplingInterval: 0
85
+ };
86
+ const event_monitoringItem = yield subscription.monitor(itemToMonitor, monitoringParameters, node_opcua_service_read_1.TimestampsToReturn.Both);
87
+ const acknowledgeableConditions = [];
88
+ let refreshStartEventHasBeenReceived = false;
89
+ let RefreshEndEventHasBeenReceived = false;
90
+ const RefreshStartEventType = (0, node_opcua_nodeid_1.resolveNodeId)("RefreshStartEventType").toString();
91
+ const RefreshEndEventType = (0, node_opcua_nodeid_1.resolveNodeId)("RefreshEndEventType").toString();
92
+ const promise = new Promise((resolve, reject) => {
93
+ // now create a event monitored Item
94
+ event_monitoringItem.on("changed", (_eventFields) => {
95
+ const eventFields = _eventFields;
96
+ try {
97
+ if (RefreshEndEventHasBeenReceived) {
98
+ return;
99
+ }
100
+ // dumpEvent(session, fields, eventFields);
101
+ const pojo = (0, client_alarm_1.fieldsToJson)(fields, eventFields);
102
+ // console.log(pojo.eventType.value.toString(), RefreshEndEventType, RefreshStartEventType);
103
+ // make sure we only start recording event after the RefreshStartEvent has been received
104
+ if (!refreshStartEventHasBeenReceived) {
105
+ if (pojo.eventType.value.toString() === RefreshStartEventType) {
106
+ refreshStartEventHasBeenReceived = true;
107
+ }
108
+ return;
109
+ }
110
+ if (pojo.eventType.value.toString() === RefreshEndEventType) {
111
+ RefreshEndEventHasBeenReceived = true;
112
+ resolve();
113
+ return;
114
+ }
115
+ if (!pojo.conditionId.value) {
116
+ // not a Acknowledgeable condition
117
+ return;
118
+ }
119
+ if (pojo.ackedState.id.dataType === node_opcua_variant_1.DataType.Boolean) {
120
+ acknowledgeableConditions.push(pojo);
121
+ }
122
+ }
123
+ catch (err) {
124
+ errorLog("Error !!", err);
125
+ }
126
+ });
127
+ // async call without waiting !
128
+ try {
129
+ (0, client_tools_1.callConditionRefresh)(subscription);
130
+ }
131
+ catch (err) {
132
+ // it is possible that server do not implement conditionRefresh ...
133
+ debugLog("Server may not implement conditionRefresh", err);
134
+ }
135
+ });
136
+ yield promise;
137
+ // now shut down susbscription
138
+ yield subscription.terminate();
139
+ return acknowledgeableConditions;
140
+ });
141
+ }
142
+ exports.findActiveConditions = findActiveConditions;
143
+ function acknwoledgeAllConditions(session, message) {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ try {
146
+ let conditions = yield findActiveConditions(session);
147
+ if (conditions.length === 0) {
148
+ debugLog("Warning: cannot find conditions ");
149
+ }
150
+ // filter acknowledgable conditions (no acked yet)
151
+ conditions = conditions.filter((pojo) => pojo.ackedState.id.value === false);
152
+ const promises = [];
153
+ for (const eventStuff of conditions) {
154
+ promises.push(acknowledgeCondition(session, eventStuff, message));
155
+ }
156
+ const result = yield Promise.all(promises);
157
+ if (doDebug) {
158
+ debugLog("Acked all results: ", result.map((e) => e.toString()).join(" "));
159
+ }
160
+ }
161
+ catch (err) {
162
+ errorLog("Error", err);
163
+ }
164
+ });
165
+ }
166
+ exports.acknwoledgeAllConditions = acknwoledgeAllConditions;
167
+ function confirmAllConditions(session, message) {
168
+ return __awaiter(this, void 0, void 0, function* () {
169
+ try {
170
+ let conditions = yield findActiveConditions(session);
171
+ if (conditions.length === 0) {
172
+ debugLog("Warning: cannot find conditions ");
173
+ }
174
+ // filter acknowledgable conditions (no acked yet)
175
+ conditions = conditions.filter((pojo) => pojo.confirmedState.id.value === false);
176
+ const promises = [];
177
+ for (const eventStuff of conditions) {
178
+ promises.push(confirmCondition(session, eventStuff, message));
179
+ }
180
+ const result = yield Promise.all(promises);
181
+ if (doDebug) {
182
+ debugLog("Confirm all results: ", result.map((e) => e.toString()).join(" "));
183
+ }
184
+ }
185
+ catch (err) {
186
+ errorLog("Error", err);
187
+ }
188
+ });
189
+ }
190
+ exports.confirmAllConditions = confirmAllConditions;
191
191
  //# 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 + " ").substr(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 + " ").substr(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,8 +1,8 @@
1
- import { NodeIdLike } from "node-opcua-nodeid";
2
- import { IBasicSession } from "node-opcua-pseudo-session";
3
- /**
4
- *
5
- * @param session
6
- * @param conditionNodeId
7
- */
8
- 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
+ /**
4
+ *
5
+ * @param session
6
+ * @param conditionNodeId
7
+ */
8
+ export declare function extractConditionFields(session: IBasicSession, conditionNodeId: NodeIdLike): Promise<string[]>;