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,119 +1,119 @@
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.extractConditionFields = 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_types_1 = require("node-opcua-types");
16
- function extractConditionFields(session, conditionNodeId) {
17
- return __awaiter(this, void 0, void 0, function* () {
18
- // conditionNodeId could be a Object of type ConditionType
19
- // or it could be directly a ObjectType which is a subType of ConditionType
20
- const _duplicateMap = {};
21
- const fields1 = [];
22
- function addField(name) {
23
- if (!_duplicateMap[name]) {
24
- fields1.push(name);
25
- _duplicateMap[name] = name;
26
- }
27
- }
28
- const stack = [];
29
- function deferObjectOrVariableInvestigation(objectId, browseName) {
30
- stack.push({
31
- browseName,
32
- nodeId: objectId
33
- });
34
- }
35
- function _investigateObjectOrVariable() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- if (stack.length === 0) {
38
- return;
39
- }
40
- const extracted = stack.splice(0);
41
- const nodesToBrowse = extracted.map((e) => {
42
- const b = {
43
- browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
44
- includeSubtypes: true,
45
- // tslint:disable-next-line: no-bitwise
46
- nodeClassMask: node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClassMask.Variable,
47
- nodeId: e.nodeId,
48
- referenceTypeId: "HasChild",
49
- resultMask: 63
50
- };
51
- return b;
52
- });
53
- const results = yield session.browse(nodesToBrowse);
54
- let i = 0;
55
- for (const result of results) {
56
- const name = extracted[i].browseName.toString();
57
- i++;
58
- if (!result.references) {
59
- continue;
60
- }
61
- for (const ref of result.references) {
62
- const n = name + "." + ref.browseName.toString();
63
- if (ref.nodeClass === node_opcua_types_1.NodeClass.Variable) {
64
- addField(n);
65
- }
66
- deferObjectOrVariableInvestigation(ref.nodeId, n);
67
- }
68
- }
69
- yield _investigateObjectOrVariable();
70
- });
71
- }
72
- // tslint:disable-next-line: no-shadowed-variable
73
- function _investigateLevel(conditionNodeId) {
74
- return __awaiter(this, void 0, void 0, function* () {
75
- const nodeToBrowse1 = {
76
- browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
77
- includeSubtypes: true,
78
- nodeClassMask: node_opcua_data_model_1.NodeClassMask.ObjectType,
79
- nodeId: conditionNodeId,
80
- referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
81
- resultMask: 63
82
- };
83
- const nodeToBrowse2 = {
84
- browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
85
- includeSubtypes: true,
86
- // tslint:disable-next-line: no-bitwise
87
- nodeClassMask: node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClassMask.Variable,
88
- nodeId: conditionNodeId,
89
- referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasChild"),
90
- resultMask: 63
91
- };
92
- const nodesToBrowse = [nodeToBrowse1, nodeToBrowse2];
93
- const browseResults = yield session.browse(nodesToBrowse);
94
- if (browseResults[1] && browseResults[1].references) {
95
- for (const ref of browseResults[1].references) {
96
- if (ref.nodeClass === node_opcua_types_1.NodeClass.Variable) {
97
- addField(ref.browseName.toString());
98
- }
99
- deferObjectOrVariableInvestigation(ref.nodeId, ref.browseName.toString());
100
- }
101
- }
102
- if (browseResults[0] && browseResults[0].references) {
103
- const promises = [];
104
- for (const reference of browseResults[0].references) {
105
- promises.push(_investigateLevel(reference.nodeId));
106
- }
107
- yield Promise.all(promises);
108
- }
109
- yield _investigateObjectOrVariable();
110
- });
111
- }
112
- yield _investigateLevel(conditionNodeId);
113
- // add this field which will always be added
114
- addField("ConditionId");
115
- return fields1;
116
- });
117
- }
118
- exports.extractConditionFields = extractConditionFields;
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.extractConditionFields = 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_types_1 = require("node-opcua-types");
16
+ function extractConditionFields(session, conditionNodeId) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ // conditionNodeId could be a Object of type ConditionType
19
+ // or it could be directly a ObjectType which is a subType of ConditionType
20
+ const _duplicateMap = {};
21
+ const fields1 = [];
22
+ function addField(name) {
23
+ if (!_duplicateMap[name]) {
24
+ fields1.push(name);
25
+ _duplicateMap[name] = name;
26
+ }
27
+ }
28
+ const stack = [];
29
+ function deferObjectOrVariableInvestigation(objectId, browseName) {
30
+ stack.push({
31
+ browseName,
32
+ nodeId: objectId
33
+ });
34
+ }
35
+ function _investigateObjectOrVariable() {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ if (stack.length === 0) {
38
+ return;
39
+ }
40
+ const extracted = stack.splice(0);
41
+ const nodesToBrowse = extracted.map((e) => {
42
+ const b = {
43
+ browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
44
+ includeSubtypes: true,
45
+ // tslint:disable-next-line: no-bitwise
46
+ nodeClassMask: node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClassMask.Variable,
47
+ nodeId: e.nodeId,
48
+ referenceTypeId: "HasChild",
49
+ resultMask: 63
50
+ };
51
+ return b;
52
+ });
53
+ const results = yield session.browse(nodesToBrowse);
54
+ let i = 0;
55
+ for (const result of results) {
56
+ const name = extracted[i].browseName.toString();
57
+ i++;
58
+ if (!result.references) {
59
+ continue;
60
+ }
61
+ for (const ref of result.references) {
62
+ const n = name + "." + ref.browseName.toString();
63
+ if (ref.nodeClass === node_opcua_types_1.NodeClass.Variable) {
64
+ addField(n);
65
+ }
66
+ deferObjectOrVariableInvestigation(ref.nodeId, n);
67
+ }
68
+ }
69
+ yield _investigateObjectOrVariable();
70
+ });
71
+ }
72
+ // tslint:disable-next-line: no-shadowed-variable
73
+ function _investigateLevel(conditionNodeId) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const nodeToBrowse1 = {
76
+ browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
77
+ includeSubtypes: true,
78
+ nodeClassMask: node_opcua_data_model_1.NodeClassMask.ObjectType,
79
+ nodeId: conditionNodeId,
80
+ referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasSubtype"),
81
+ resultMask: 63
82
+ };
83
+ const nodeToBrowse2 = {
84
+ browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
85
+ includeSubtypes: true,
86
+ // tslint:disable-next-line: no-bitwise
87
+ nodeClassMask: node_opcua_data_model_1.NodeClassMask.Object | node_opcua_data_model_1.NodeClassMask.Variable,
88
+ nodeId: conditionNodeId,
89
+ referenceTypeId: (0, node_opcua_nodeid_1.resolveNodeId)("HasChild"),
90
+ resultMask: 63
91
+ };
92
+ const nodesToBrowse = [nodeToBrowse1, nodeToBrowse2];
93
+ const browseResults = yield session.browse(nodesToBrowse);
94
+ if (browseResults[1] && browseResults[1].references) {
95
+ for (const ref of browseResults[1].references) {
96
+ if (ref.nodeClass === node_opcua_types_1.NodeClass.Variable) {
97
+ addField(ref.browseName.toString());
98
+ }
99
+ deferObjectOrVariableInvestigation(ref.nodeId, ref.browseName.toString());
100
+ }
101
+ }
102
+ if (browseResults[0] && browseResults[0].references) {
103
+ const promises = [];
104
+ for (const reference of browseResults[0].references) {
105
+ promises.push(_investigateLevel(reference.nodeId));
106
+ }
107
+ yield Promise.all(promises);
108
+ }
109
+ yield _investigateObjectOrVariable();
110
+ });
111
+ }
112
+ yield _investigateLevel(conditionNodeId);
113
+ // add this field which will always be added
114
+ addField("ConditionId");
115
+ return fields1;
116
+ });
117
+ }
118
+ exports.extractConditionFields = extractConditionFields;
119
119
  //# sourceMappingURL=client_alarm_tools_extractConditionFields.js.map
@@ -1,7 +1,7 @@
1
- /**
2
- * @module node-opcua-client
3
- */
4
- import { ErrorCallback } from "node-opcua-status-code";
5
- import { ClientSubscription } from "../client_subscription";
6
- export declare function callConditionRefresh(subscription: ClientSubscription): Promise<void>;
7
- export declare function callConditionRefresh(subscription: ClientSubscription, callback: ErrorCallback): void;
1
+ /**
2
+ * @module node-opcua-client
3
+ */
4
+ import { ErrorCallback } from "node-opcua-status-code";
5
+ import { ClientSubscription } from "../client_subscription";
6
+ export declare function callConditionRefresh(subscription: ClientSubscription): Promise<void>;
7
+ export declare function callConditionRefresh(subscription: ClientSubscription, callback: ErrorCallback): void;
@@ -1,180 +1,180 @@
1
- "use strict";
2
- /**
3
- * @module node-opcua-client
4
- */
5
- // tslint:disable:no-empty
6
- // tslint:disable: only-arrow-functions
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.callConditionRefresh = void 0;
9
- const async = require("async");
10
- const node_opcua_assert_1 = require("node-opcua-assert");
11
- const node_opcua_data_model_1 = require("node-opcua-data-model");
12
- const node_opcua_debug_1 = require("node-opcua-debug");
13
- const node_opcua_nodeid_1 = require("node-opcua-nodeid");
14
- const node_opcua_service_call_1 = require("node-opcua-service-call");
15
- const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
16
- const node_opcua_variant_1 = require("node-opcua-variant");
17
- const client_session_impl_1 = require("../private/client_session_impl");
18
- const debugLog = (0, node_opcua_debug_1.make_debugLog)("A&E");
19
- const doDebug = (0, node_opcua_debug_1.checkDebugFlag)("A&E");
20
- const warningLog = (0, node_opcua_debug_1.make_warningLog)("A&E");
21
- function callConditionRefresh(subscription, callback) {
22
- const subscriptionI = subscription;
23
- const theSession = subscriptionI.publishEngine.session;
24
- const subscriptionId = subscription.subscriptionId;
25
- (0, node_opcua_assert_1.assert)(isFinite(subscriptionId), "May be subscription is not yet initialized");
26
- (0, node_opcua_assert_1.assert)(typeof callback === "function");
27
- const conditionTypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("ConditionType");
28
- let conditionRefreshId = (0, node_opcua_nodeid_1.resolveNodeId)("ConditionType_ConditionRefresh");
29
- async.series([
30
- // find conditionRefreshId
31
- (innerCallback) => {
32
- const browsePath = (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(conditionTypeNodeId, ".ConditionRefresh");
33
- theSession.translateBrowsePath(browsePath, (err, result) => {
34
- if (!err) {
35
- result = result;
36
- // istanbul ignore else
37
- if (result.targets && result.targets.length > 0) {
38
- conditionRefreshId = result.targets[0].targetId;
39
- }
40
- else {
41
- // cannot find conditionRefreshId
42
- debugLog("cannot find conditionRefreshId", result.toString());
43
- err = new Error(" cannot find conditionRefreshId");
44
- }
45
- }
46
- innerCallback(err ? err : undefined);
47
- });
48
- },
49
- (innerCallback) => {
50
- const methodToCall = {
51
- inputArguments: [new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.UInt32, value: subscriptionId })],
52
- methodId: conditionRefreshId,
53
- objectId: conditionTypeNodeId
54
- };
55
- doDebug && debugLog("Calling method ", new node_opcua_service_call_1.CallMethodRequest(methodToCall).toString());
56
- theSession.call(methodToCall, (err, result) => {
57
- if (err) {
58
- return innerCallback(err);
59
- }
60
- result = result;
61
- // istanbul ignore next
62
- if (result.statusCode.isNotGood()) {
63
- warningLog(new node_opcua_service_call_1.CallMethodRequest(methodToCall).toString());
64
- return innerCallback(new Error("Error " + result.statusCode.toString()));
65
- }
66
- innerCallback();
67
- });
68
- }
69
- ], (err) => {
70
- callback(err || undefined);
71
- });
72
- }
73
- exports.callConditionRefresh = callConditionRefresh;
74
- client_session_impl_1.ClientSessionImpl.prototype.disableCondition = () => {
75
- /** */
76
- };
77
- client_session_impl_1.ClientSessionImpl.prototype.enableCondition = () => {
78
- /** */
79
- };
80
- client_session_impl_1.ClientSessionImpl.prototype.addCommentCondition = function (conditionId, eventId, comment, callback) {
81
- this._callMethodCondition("AddComment", conditionId, eventId, comment, callback);
82
- };
83
- client_session_impl_1.ClientSessionImpl.prototype.findMethodId = function (nodeId, methodName, callback) {
84
- const browsePath = (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(nodeId, "/" + methodName);
85
- let methodId;
86
- this.translateBrowsePath(browsePath, (err, result) => {
87
- if (err) {
88
- return callback(err);
89
- }
90
- /* istanbul ignore next */
91
- if (!result) {
92
- return callback(new Error("Internal Error"));
93
- }
94
- result.targets = result.targets || [];
95
- // istanbul ignore else
96
- if (result.targets.length > 0) {
97
- methodId = result.targets[0].targetId;
98
- return callback(null, methodId);
99
- }
100
- else {
101
- // cannot find objectWithMethodNodeId
102
- debugLog("cannot find " + methodName + " Method", result.toString());
103
- err = new Error(" cannot find " + methodName + " Method");
104
- }
105
- callback(err);
106
- });
107
- };
108
- /**
109
- *
110
- * @param methodName
111
- * @param conditionId
112
- * @param eventId
113
- * @param comment
114
- * @param callback
115
- * @private
116
- */
117
- client_session_impl_1.ClientSessionImpl.prototype._callMethodCondition = function (methodName, conditionId, eventId, comment, callback) {
118
- conditionId = (0, node_opcua_nodeid_1.coerceNodeId)(conditionId);
119
- (0, node_opcua_assert_1.assert)(conditionId instanceof node_opcua_nodeid_1.NodeId);
120
- (0, node_opcua_assert_1.assert)(eventId instanceof Buffer);
121
- (0, node_opcua_assert_1.assert)(typeof comment === "string" || comment instanceof node_opcua_data_model_1.LocalizedText);
122
- comment = node_opcua_data_model_1.LocalizedText.coerce(comment) || new node_opcua_data_model_1.LocalizedText();
123
- let methodId;
124
- let statusCode;
125
- async.series([
126
- (innerCallback) => {
127
- this.findMethodId(conditionId, methodName, (err, _methodId) => {
128
- if (err) {
129
- return innerCallback(err);
130
- }
131
- if (_methodId) {
132
- methodId = _methodId;
133
- }
134
- innerCallback();
135
- });
136
- },
137
- (innerCallback) => {
138
- const methodToCalls = [];
139
- methodToCalls.push(new node_opcua_service_call_1.CallMethodRequest({
140
- inputArguments: [
141
- /* eventId */ new node_opcua_variant_1.Variant({ dataType: "ByteString", value: eventId }),
142
- /* comment */ new node_opcua_variant_1.Variant({ dataType: "LocalizedText", value: comment })
143
- ],
144
- methodId,
145
- objectId: conditionId
146
- }));
147
- this.call(methodToCalls, (err, results) => {
148
- if (err) {
149
- return innerCallback(err);
150
- }
151
- statusCode = results[0].statusCode;
152
- innerCallback();
153
- });
154
- }
155
- ], (err) => {
156
- if (err) {
157
- return callback(err);
158
- }
159
- callback(null, statusCode);
160
- });
161
- };
162
- client_session_impl_1.ClientSessionImpl.prototype.confirmCondition = function (conditionId, eventId, comment, callback) {
163
- // ns=0;i=9113 AcknowledgeableConditionType#Confirm
164
- // note that confirm method is Optionals on condition
165
- this._callMethodCondition("Confirm", conditionId, eventId, comment, callback);
166
- };
167
- client_session_impl_1.ClientSessionImpl.prototype.acknowledgeCondition = function (conditionId, eventId, comment, callback) {
168
- // ns=0;i=9111 AcknowledgeableConditionType#Acknowledge
169
- this._callMethodCondition("Acknowledge", conditionId, eventId, comment, callback);
170
- };
171
- // tslint:disable:no-var-requires
172
- // tslint:disable:max-line-length
173
- const thenify = require("thenify");
174
- const opts = { multiArgs: false };
175
- client_session_impl_1.ClientSessionImpl.prototype.addCommentCondition = thenify.withCallback(client_session_impl_1.ClientSessionImpl.prototype.addCommentCondition, opts);
176
- client_session_impl_1.ClientSessionImpl.prototype.findMethodId = thenify.withCallback(client_session_impl_1.ClientSessionImpl.prototype.findMethodId, opts);
177
- client_session_impl_1.ClientSessionImpl.prototype.confirmCondition = thenify.withCallback(client_session_impl_1.ClientSessionImpl.prototype.confirmCondition, opts);
178
- client_session_impl_1.ClientSessionImpl.prototype.acknowledgeCondition = thenify.withCallback(client_session_impl_1.ClientSessionImpl.prototype.acknowledgeCondition, opts);
179
- module.exports.callConditionRefresh = thenify.withCallback(module.exports.callConditionRefresh, opts);
1
+ "use strict";
2
+ /**
3
+ * @module node-opcua-client
4
+ */
5
+ // tslint:disable:no-empty
6
+ // tslint:disable: only-arrow-functions
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.callConditionRefresh = void 0;
9
+ const async = require("async");
10
+ const node_opcua_assert_1 = require("node-opcua-assert");
11
+ const node_opcua_data_model_1 = require("node-opcua-data-model");
12
+ const node_opcua_debug_1 = require("node-opcua-debug");
13
+ const node_opcua_nodeid_1 = require("node-opcua-nodeid");
14
+ const node_opcua_service_call_1 = require("node-opcua-service-call");
15
+ const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
16
+ const node_opcua_variant_1 = require("node-opcua-variant");
17
+ const client_session_impl_1 = require("../private/client_session_impl");
18
+ const debugLog = (0, node_opcua_debug_1.make_debugLog)("A&E");
19
+ const doDebug = (0, node_opcua_debug_1.checkDebugFlag)("A&E");
20
+ const warningLog = (0, node_opcua_debug_1.make_warningLog)("A&E");
21
+ function callConditionRefresh(subscription, callback) {
22
+ const subscriptionI = subscription;
23
+ const theSession = subscriptionI.publishEngine.session;
24
+ const subscriptionId = subscription.subscriptionId;
25
+ (0, node_opcua_assert_1.assert)(isFinite(subscriptionId), "May be subscription is not yet initialized");
26
+ (0, node_opcua_assert_1.assert)(typeof callback === "function");
27
+ const conditionTypeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)("ConditionType");
28
+ let conditionRefreshId = (0, node_opcua_nodeid_1.resolveNodeId)("ConditionType_ConditionRefresh");
29
+ async.series([
30
+ // find conditionRefreshId
31
+ (innerCallback) => {
32
+ const browsePath = (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(conditionTypeNodeId, ".ConditionRefresh");
33
+ theSession.translateBrowsePath(browsePath, (err, result) => {
34
+ if (!err) {
35
+ result = result;
36
+ // istanbul ignore else
37
+ if (result.targets && result.targets.length > 0) {
38
+ conditionRefreshId = result.targets[0].targetId;
39
+ }
40
+ else {
41
+ // cannot find conditionRefreshId
42
+ debugLog("cannot find conditionRefreshId", result.toString());
43
+ err = new Error(" cannot find conditionRefreshId");
44
+ }
45
+ }
46
+ innerCallback(err ? err : undefined);
47
+ });
48
+ },
49
+ (innerCallback) => {
50
+ const methodToCall = {
51
+ inputArguments: [new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.UInt32, value: subscriptionId })],
52
+ methodId: conditionRefreshId,
53
+ objectId: conditionTypeNodeId
54
+ };
55
+ doDebug && debugLog("Calling method ", new node_opcua_service_call_1.CallMethodRequest(methodToCall).toString());
56
+ theSession.call(methodToCall, (err, result) => {
57
+ if (err) {
58
+ return innerCallback(err);
59
+ }
60
+ result = result;
61
+ // istanbul ignore next
62
+ if (result.statusCode.isNotGood()) {
63
+ warningLog(new node_opcua_service_call_1.CallMethodRequest(methodToCall).toString());
64
+ return innerCallback(new Error("Error " + result.statusCode.toString()));
65
+ }
66
+ innerCallback();
67
+ });
68
+ }
69
+ ], (err) => {
70
+ callback(err || undefined);
71
+ });
72
+ }
73
+ exports.callConditionRefresh = callConditionRefresh;
74
+ client_session_impl_1.ClientSessionImpl.prototype.disableCondition = () => {
75
+ /** */
76
+ };
77
+ client_session_impl_1.ClientSessionImpl.prototype.enableCondition = () => {
78
+ /** */
79
+ };
80
+ client_session_impl_1.ClientSessionImpl.prototype.addCommentCondition = function (conditionId, eventId, comment, callback) {
81
+ this._callMethodCondition("AddComment", conditionId, eventId, comment, callback);
82
+ };
83
+ client_session_impl_1.ClientSessionImpl.prototype.findMethodId = function (nodeId, methodName, callback) {
84
+ const browsePath = (0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(nodeId, "/" + methodName);
85
+ let methodId;
86
+ this.translateBrowsePath(browsePath, (err, result) => {
87
+ if (err) {
88
+ return callback(err);
89
+ }
90
+ /* istanbul ignore next */
91
+ if (!result) {
92
+ return callback(new Error("Internal Error"));
93
+ }
94
+ result.targets = result.targets || [];
95
+ // istanbul ignore else
96
+ if (result.targets.length > 0) {
97
+ methodId = result.targets[0].targetId;
98
+ return callback(null, methodId);
99
+ }
100
+ else {
101
+ // cannot find objectWithMethodNodeId
102
+ debugLog("cannot find " + methodName + " Method", result.toString());
103
+ err = new Error(" cannot find " + methodName + " Method");
104
+ }
105
+ callback(err);
106
+ });
107
+ };
108
+ /**
109
+ *
110
+ * @param methodName
111
+ * @param conditionId
112
+ * @param eventId
113
+ * @param comment
114
+ * @param callback
115
+ * @private
116
+ */
117
+ client_session_impl_1.ClientSessionImpl.prototype._callMethodCondition = function (methodName, conditionId, eventId, comment, callback) {
118
+ conditionId = (0, node_opcua_nodeid_1.coerceNodeId)(conditionId);
119
+ (0, node_opcua_assert_1.assert)(conditionId instanceof node_opcua_nodeid_1.NodeId);
120
+ (0, node_opcua_assert_1.assert)(eventId instanceof Buffer);
121
+ (0, node_opcua_assert_1.assert)(typeof comment === "string" || comment instanceof node_opcua_data_model_1.LocalizedText);
122
+ comment = node_opcua_data_model_1.LocalizedText.coerce(comment) || new node_opcua_data_model_1.LocalizedText();
123
+ let methodId;
124
+ let statusCode;
125
+ async.series([
126
+ (innerCallback) => {
127
+ this.findMethodId(conditionId, methodName, (err, _methodId) => {
128
+ if (err) {
129
+ return innerCallback(err);
130
+ }
131
+ if (_methodId) {
132
+ methodId = _methodId;
133
+ }
134
+ innerCallback();
135
+ });
136
+ },
137
+ (innerCallback) => {
138
+ const methodToCalls = [];
139
+ methodToCalls.push(new node_opcua_service_call_1.CallMethodRequest({
140
+ inputArguments: [
141
+ /* eventId */ new node_opcua_variant_1.Variant({ dataType: "ByteString", value: eventId }),
142
+ /* comment */ new node_opcua_variant_1.Variant({ dataType: "LocalizedText", value: comment })
143
+ ],
144
+ methodId,
145
+ objectId: conditionId
146
+ }));
147
+ this.call(methodToCalls, (err, results) => {
148
+ if (err) {
149
+ return innerCallback(err);
150
+ }
151
+ statusCode = results[0].statusCode;
152
+ innerCallback();
153
+ });
154
+ }
155
+ ], (err) => {
156
+ if (err) {
157
+ return callback(err);
158
+ }
159
+ callback(null, statusCode);
160
+ });
161
+ };
162
+ client_session_impl_1.ClientSessionImpl.prototype.confirmCondition = function (conditionId, eventId, comment, callback) {
163
+ // ns=0;i=9113 AcknowledgeableConditionType#Confirm
164
+ // note that confirm method is Optionals on condition
165
+ this._callMethodCondition("Confirm", conditionId, eventId, comment, callback);
166
+ };
167
+ client_session_impl_1.ClientSessionImpl.prototype.acknowledgeCondition = function (conditionId, eventId, comment, callback) {
168
+ // ns=0;i=9111 AcknowledgeableConditionType#Acknowledge
169
+ this._callMethodCondition("Acknowledge", conditionId, eventId, comment, callback);
170
+ };
171
+ // tslint:disable:no-var-requires
172
+ // tslint:disable:max-line-length
173
+ const thenify = require("thenify");
174
+ const opts = { multiArgs: false };
175
+ client_session_impl_1.ClientSessionImpl.prototype.addCommentCondition = thenify.withCallback(client_session_impl_1.ClientSessionImpl.prototype.addCommentCondition, opts);
176
+ client_session_impl_1.ClientSessionImpl.prototype.findMethodId = thenify.withCallback(client_session_impl_1.ClientSessionImpl.prototype.findMethodId, opts);
177
+ client_session_impl_1.ClientSessionImpl.prototype.confirmCondition = thenify.withCallback(client_session_impl_1.ClientSessionImpl.prototype.confirmCondition, opts);
178
+ client_session_impl_1.ClientSessionImpl.prototype.acknowledgeCondition = thenify.withCallback(client_session_impl_1.ClientSessionImpl.prototype.acknowledgeCondition, opts);
179
+ module.exports.callConditionRefresh = thenify.withCallback(module.exports.callConditionRefresh, opts);
180
180
  //# sourceMappingURL=client_tools.js.map