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,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,73 +1,73 @@
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_variant_1 = require("node-opcua-variant");
16
- /**
17
- *
18
- * @param session
19
- * @param fields
20
- * @param eventFields
21
- */
22
- function dumpEvent(session, fields, eventFields) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- function getBrowseName(_session, nodeId) {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const dataValue = yield _session.read({
27
- attributeId: node_opcua_data_model_1.AttributeIds.BrowseName,
28
- nodeId
29
- });
30
- if (dataValue.statusCode.isGood()) {
31
- const browseName = dataValue.value.value.name;
32
- return browseName;
33
- }
34
- else {
35
- return "???";
36
- }
37
- });
38
- }
39
- function w(str, l) {
40
- return str.padEnd(l, " ").substring(0, l);
41
- }
42
- function __dumpEvent1(_session, _fields, variant, index) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- if (variant.dataType === node_opcua_variant_1.DataType.Null) {
45
- return;
46
- }
47
- if (variant.dataType === node_opcua_variant_1.DataType.NodeId) {
48
- const name = yield getBrowseName(_session, variant.value);
49
- // tslint:disable-next-line: no-console
50
- 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), ")");
51
- }
52
- else {
53
- // tslint:disable-next-line: no-console
54
- console.log(chalk.yellow(w("", 30), w(_fields[index], 25)), chalk.cyan(w(node_opcua_variant_1.DataType[variant.dataType], 10).toString()), variant.value);
55
- }
56
- });
57
- }
58
- function __dumpEvent(_session, _fields, _eventFields) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- let index = 0;
61
- const promises = [];
62
- for (const variant of _eventFields) {
63
- promises.push(__dumpEvent1(_session, _fields, variant, index));
64
- index++;
65
- }
66
- yield Promise.all(promises);
67
- });
68
- }
69
- yield __dumpEvent(session, fields, eventFields);
70
- });
71
- }
72
- 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_variant_1 = require("node-opcua-variant");
16
+ /**
17
+ *
18
+ * @param session
19
+ * @param fields
20
+ * @param eventFields
21
+ */
22
+ function dumpEvent(session, fields, eventFields) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ function getBrowseName(_session, nodeId) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const dataValue = yield _session.read({
27
+ attributeId: node_opcua_data_model_1.AttributeIds.BrowseName,
28
+ nodeId
29
+ });
30
+ if (dataValue.statusCode.isGood()) {
31
+ const browseName = dataValue.value.value.name;
32
+ return browseName;
33
+ }
34
+ else {
35
+ return "???";
36
+ }
37
+ });
38
+ }
39
+ function w(str, l) {
40
+ return (str || "").toString().padEnd(l, " ").substring(0, l);
41
+ }
42
+ function __dumpEvent1(_session, _fields, variant, index) {
43
+ return __awaiter(this, void 0, void 0, function* () {
44
+ if (variant.dataType === node_opcua_variant_1.DataType.Null) {
45
+ return;
46
+ }
47
+ if (variant.dataType === node_opcua_variant_1.DataType.NodeId) {
48
+ const name = yield getBrowseName(_session, variant.value);
49
+ // tslint:disable-next-line: no-console
50
+ 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), ")");
51
+ }
52
+ else {
53
+ // tslint:disable-next-line: no-console
54
+ console.log(chalk.yellow(w("", 30), w(_fields[index], 25)), chalk.cyan(w(node_opcua_variant_1.DataType[variant.dataType], 10).toString()), variant.value);
55
+ }
56
+ });
57
+ }
58
+ function __dumpEvent(_session, _fields, _eventFields) {
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ let index = 0;
61
+ const promises = [];
62
+ for (const variant of _eventFields) {
63
+ promises.push(__dumpEvent1(_session, _fields, variant, index));
64
+ index++;
65
+ }
66
+ yield Promise.all(promises);
67
+ });
68
+ }
69
+ yield __dumpEvent(session, fields, eventFields);
70
+ });
71
+ }
72
+ exports.dumpEvent = dumpEvent;
73
73
  //# sourceMappingURL=client_alarm_tools_dump_event.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client_alarm_tools_dump_event.js","sourceRoot":"","sources":["../../source/alarms_and_conditions/client_alarm_tools_dump_event.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,iEAAqD;AAGrD,2DAAoE;AAEpE;;;;;GAKG;AACH,SAAsB,SAAS,CAAC,OAAsB,EAAE,MAAgB,EAAE,WAAsB;;QAC5F,SAAe,aAAa,CAAC,QAAuB,EAAE,MAAc;;gBAChE,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC;oBAClC,WAAW,EAAE,oCAAY,CAAC,UAAU;oBACpC,MAAM;iBACT,CAAC,CAAC;gBACH,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE;oBAC/B,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAK,CAAC;oBAC/C,OAAO,UAAU,CAAC;iBACrB;qBAAM;oBACH,OAAO,KAAK,C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,EAAE,CAAC,EAClE,OAAO,CAAC,KAAK,CAChB,CAAC;iBACL;YACL,CAAC;SAAA;QAED,SAAe,WAAW,CAAC,QAAuB,EAAE,OAAiB,EAAE,YAAuB;;gBAC1F,IAAI,KAAK,GAAG,CAAC,CAAC;gBACd,MAAM,QAAQ,GAAG,EAAE,CAAC;gBACpB,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE;oBAChC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;oBAC/D,KAAK,EAAE,CAAC;iBACX;gBACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;SAAA;QACD,MAAM,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACpD,CAAC;CAAA;AAnDD,8BAmDC"}
1
+ {"version":3,"file":"client_alarm_tools_dump_event.js","sourceRoot":"","sources":["../../source/alarms_and_conditions/client_alarm_tools_dump_event.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA+B;AAC/B,iEAAqD;AAGrD,2DAAoE;AAEpE;;;;;GAKG;AACH,SAAsB,SAAS,CAAC,OAAsB,EAAE,MAAgB,EAAE,WAAsB;;QAC5F,SAAe,aAAa,CAAC,QAAuB,EAAE,MAAc;;gBAChE,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC;oBAClC,WAAW,EAAE,oCAAY,CAAC,UAAU;oBACpC,MAAM;iBACT,CAAC,CAAC;gBACH,IAAI,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE;oBAC/B,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAK,CAAC;oBAC/C,OAAO,UAAU,CAAC;iBACrB;qBAAM;oBACH,OAAO,KAAK,CAAC;iBAChB;YACL,CAAC;SAAA;QACD,SAAS,CAAC,CAAC,GAAW,EAAE,CAAS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CAAC,KAAK,CAChB,CAAC;iBACL;YACL,CAAC;SAAA;QAED,SAAe,WAAW,CAAC,QAAuB,EAAE,OAAiB,EAAE,YAAuB;;gBAC1F,IAAI,KAAK,GAAG,CAAC,CAAC;gBACd,MAAM,QAAQ,GAAG,EAAE,CAAC;gBACpB,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE;oBAChC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;oBAC/D,KAAK,EAAE,CAAC;iBACX;gBACD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;SAAA;QACD,MAAM,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACpD,CAAC;CAAA;AAnDD,8BAmDC"}
@@ -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[]>;