node-opcua-client-proxy 2.98.0 → 2.98.2
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.
- package/dist/common.d.ts +3 -0
- package/dist/common.js +5 -0
- package/dist/common.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/object_explorer.d.ts +20 -0
- package/dist/object_explorer.js +462 -0
- package/dist/object_explorer.js.map +1 -0
- package/dist/proxy.d.ts +2 -0
- package/dist/proxy.js +19 -0
- package/dist/proxy.js.map +1 -0
- package/dist/proxy_base_node.d.ts +83 -0
- package/dist/proxy_base_node.js +88 -0
- package/dist/proxy_base_node.js.map +1 -0
- package/dist/proxy_manager.d.ts +50 -0
- package/dist/proxy_manager.js +262 -0
- package/dist/proxy_manager.js.map +1 -0
- package/dist/proxy_object.d.ts +6 -0
- package/dist/proxy_object.js +15 -0
- package/dist/proxy_object.js.map +1 -0
- package/dist/proxy_state.d.ts +14 -0
- package/dist/proxy_state.js +28 -0
- package/dist/proxy_state.js.map +1 -0
- package/dist/proxy_state_machine.d.ts +12 -0
- package/dist/proxy_state_machine.js +22 -0
- package/dist/proxy_state_machine.js.map +1 -0
- package/dist/proxy_transition.d.ts +24 -0
- package/dist/proxy_transition.js +30 -0
- package/dist/proxy_transition.js.map +1 -0
- package/dist/proxy_variable.d.ts +7 -0
- package/dist/proxy_variable.js +15 -0
- package/dist/proxy_variable.js.map +1 -0
- package/dist/state_machine_proxy.d.ts +8 -0
- package/dist/state_machine_proxy.js +44 -0
- package/dist/state_machine_proxy.js.map +1 -0
- package/package.json +22 -18
package/dist/common.d.ts
ADDED
package/dist/common.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../source/common.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/**
|
|
18
|
+
* @module node-opcua-client-proxy
|
|
19
|
+
*/
|
|
20
|
+
__exportStar(require("./proxy_manager"), exports);
|
|
21
|
+
__exportStar(require("./proxy"), exports);
|
|
22
|
+
__exportStar(require("./state_machine_proxy"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,kDAAgC;AAChC,0CAAwB;AACxB,wDAAsC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ErrorCallback } from "node-opcua-status-code";
|
|
2
|
+
import { NodeId } from "node-opcua-nodeid";
|
|
3
|
+
import { UAProxyManager } from "./proxy_manager";
|
|
4
|
+
export interface ObjectExplorerOptions {
|
|
5
|
+
proxyManager: UAProxyManager;
|
|
6
|
+
name: string;
|
|
7
|
+
nodeId: NodeId;
|
|
8
|
+
parent: any;
|
|
9
|
+
}
|
|
10
|
+
export declare class ObjectExplorer {
|
|
11
|
+
proxyManager: UAProxyManager;
|
|
12
|
+
name: string;
|
|
13
|
+
nodeId: NodeId;
|
|
14
|
+
parent: any;
|
|
15
|
+
constructor(options: ObjectExplorerOptions);
|
|
16
|
+
$resolve(callback: (err?: Error) => void): void;
|
|
17
|
+
}
|
|
18
|
+
export declare function readUAStructure(proxyManager: UAProxyManager, obj: {
|
|
19
|
+
nodeId: NodeId;
|
|
20
|
+
}, callback: ErrorCallback): void;
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readUAStructure = exports.ObjectExplorer = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-client-proxy
|
|
6
|
+
*/
|
|
7
|
+
const async = require("async");
|
|
8
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
9
|
+
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
10
|
+
const node_opcua_service_call_1 = require("node-opcua-service-call");
|
|
11
|
+
const node_opcua_utils_1 = require("node-opcua-utils");
|
|
12
|
+
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
13
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
14
|
+
const proxy_1 = require("./proxy");
|
|
15
|
+
const proxy_variable_1 = require("./proxy_variable");
|
|
16
|
+
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
17
|
+
const doDebug = false;
|
|
18
|
+
const errorLog = (0, node_opcua_debug_1.make_errorLog)("Proxy");
|
|
19
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)("Proxy");
|
|
20
|
+
const resultMask = (0, node_opcua_data_model_1.makeResultMask)("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition");
|
|
21
|
+
/**
|
|
22
|
+
* @method convertNodeIdToDataTypeAsync
|
|
23
|
+
*
|
|
24
|
+
* @param session
|
|
25
|
+
* @param dataTypeId
|
|
26
|
+
* @param callback
|
|
27
|
+
* @param callback.err
|
|
28
|
+
* @param callback.dataType
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
*
|
|
32
|
+
* const dataTypeId ="ns=0;i=11"; // Double
|
|
33
|
+
* convertNodeIdToDataTypeAsync(session,dataTypeId,function(err,dataType) {
|
|
34
|
+
* assert(!err && dataType === DataType.Double);
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* const dataTypeId ="ns=0;i=290"; // Duration => SubTypeOf Double
|
|
38
|
+
* convertNodeIdToDataTypeAsync(session,dataTypeId,function(err,dataType) {
|
|
39
|
+
* assert(!err && dataType === DataType.Double);
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* see also AddressSpace#findCorrespondingBasicDataType
|
|
43
|
+
*
|
|
44
|
+
* for an enumeration dataType will be DataType.Int32
|
|
45
|
+
*/
|
|
46
|
+
function convertNodeIdToDataTypeAsync(session, dataTypeId, callback) {
|
|
47
|
+
const nodeToRead = {
|
|
48
|
+
attributeId: node_opcua_data_model_1.AttributeIds.BrowseName,
|
|
49
|
+
nodeId: dataTypeId
|
|
50
|
+
};
|
|
51
|
+
session.read(nodeToRead, (err, dataValue) => {
|
|
52
|
+
// istanbul ignore next
|
|
53
|
+
if (err) {
|
|
54
|
+
setImmediate(() => {
|
|
55
|
+
callback(err);
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
dataValue = dataValue;
|
|
60
|
+
let dataType;
|
|
61
|
+
// istanbul ignore next
|
|
62
|
+
if (dataValue.statusCode.isNotGood()) {
|
|
63
|
+
dataType = node_opcua_variant_1.DataType.Null;
|
|
64
|
+
setImmediate(() => {
|
|
65
|
+
callback(null, dataType);
|
|
66
|
+
});
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const dataTypeName = dataValue.value.value;
|
|
70
|
+
if (dataTypeId.namespace === 0 && dataTypeId.value === node_opcua_constants_1.DataTypeIds.Enumeration) {
|
|
71
|
+
dataType = node_opcua_variant_1.DataType.Int32;
|
|
72
|
+
setImmediate(() => {
|
|
73
|
+
callback(null, dataType);
|
|
74
|
+
});
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (dataTypeId.namespace === 0 && node_opcua_variant_1.DataType[dataTypeId.value]) {
|
|
78
|
+
dataType = node_opcua_variant_1.DataType[dataTypeId.value];
|
|
79
|
+
setImmediate(() => {
|
|
80
|
+
callback(null, dataType);
|
|
81
|
+
});
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
/// example => Duration (i=290) => Double (i=11)
|
|
85
|
+
// read subTypeOf
|
|
86
|
+
const nodeToBrowse = {
|
|
87
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Inverse,
|
|
88
|
+
includeSubtypes: false,
|
|
89
|
+
nodeId: dataTypeId,
|
|
90
|
+
// BrowseDescription
|
|
91
|
+
referenceTypeId: (0, proxy_1.makeRefId)("HasSubtype"),
|
|
92
|
+
// xx nodeClassMask: makeNodeClassMask("ObjectType"),
|
|
93
|
+
resultMask
|
|
94
|
+
};
|
|
95
|
+
// tslint:disable:no-shadowed-variable
|
|
96
|
+
session.browse(nodeToBrowse, (err, browseResult) => {
|
|
97
|
+
// istanbul ignore next
|
|
98
|
+
if (err) {
|
|
99
|
+
return callback(err);
|
|
100
|
+
}
|
|
101
|
+
const references = browseResult.references;
|
|
102
|
+
if (!references || references.length !== 1) {
|
|
103
|
+
return callback(new Error("cannot find SuperType of " + dataTypeName.toString()));
|
|
104
|
+
}
|
|
105
|
+
const nodeId = references[0].nodeId;
|
|
106
|
+
return convertNodeIdToDataTypeAsync(session, nodeId, callback);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function convertToVariant(value, arg, propName) {
|
|
111
|
+
const dataType = arg._basicDataType || node_opcua_variant_1.DataType.Null;
|
|
112
|
+
const arrayType = arg.valueRank === 1 ? node_opcua_variant_1.VariantArrayType.Array : arg.valueRank === -1 ? node_opcua_variant_1.VariantArrayType.Scalar : node_opcua_variant_1.VariantArrayType.Matrix;
|
|
113
|
+
if (value === undefined) {
|
|
114
|
+
throw new Error("expecting input argument ");
|
|
115
|
+
}
|
|
116
|
+
if (arrayType === node_opcua_variant_1.VariantArrayType.Array) {
|
|
117
|
+
if (!Array.isArray(value)) {
|
|
118
|
+
throw new Error("expecting value to be an Array or a TypedArray");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return new node_opcua_variant_1.Variant({ arrayType, dataType, value });
|
|
122
|
+
}
|
|
123
|
+
function convertToVariantArray(inputArgsDef, inputArgs) {
|
|
124
|
+
const inputArguments = inputArgsDef.map((arg) => {
|
|
125
|
+
const propName = (0, node_opcua_utils_1.lowerFirstLetter)(arg.name || "");
|
|
126
|
+
const value = inputArgs[propName];
|
|
127
|
+
return convertToVariant(value, arg, propName);
|
|
128
|
+
});
|
|
129
|
+
return inputArguments;
|
|
130
|
+
}
|
|
131
|
+
const thenify = require("thenify");
|
|
132
|
+
function makeFunction(obj, methodName) {
|
|
133
|
+
return thenify.withCallback(function functionCaller(inputArgs, callback) {
|
|
134
|
+
const session = this.proxyManager.session;
|
|
135
|
+
(0, node_opcua_assert_1.assert)(typeof callback === "function");
|
|
136
|
+
const methodDef = this.$methods[methodName];
|
|
137
|
+
// convert input arguments into Variants
|
|
138
|
+
const inputArgsDef = methodDef.inputArguments || [];
|
|
139
|
+
const inputArguments = convertToVariantArray(inputArgsDef, inputArgs);
|
|
140
|
+
const methodToCall = new node_opcua_service_call_1.CallMethodRequest({
|
|
141
|
+
inputArguments,
|
|
142
|
+
methodId: methodDef.nodeId,
|
|
143
|
+
objectId: obj.nodeId
|
|
144
|
+
});
|
|
145
|
+
session.call(methodToCall, (err, callResult) => {
|
|
146
|
+
// istanbul ignore next
|
|
147
|
+
if (err) {
|
|
148
|
+
return callback(err);
|
|
149
|
+
}
|
|
150
|
+
callResult = callResult;
|
|
151
|
+
if (callResult.statusCode.isNotGood()) {
|
|
152
|
+
return callback(new Error("Error " + callResult.statusCode.toString()));
|
|
153
|
+
}
|
|
154
|
+
callResult.outputArguments = callResult.outputArguments || [];
|
|
155
|
+
if (callResult.outputArguments.length !== methodDef.outputArguments.length) {
|
|
156
|
+
return callback(new Error("Internal error callResult.outputArguments.length " +
|
|
157
|
+
callResult.outputArguments.length +
|
|
158
|
+
" " +
|
|
159
|
+
obj[methodName].outputArguments.length));
|
|
160
|
+
}
|
|
161
|
+
const output = {};
|
|
162
|
+
methodDef.outputArguments.map((arg, index) => {
|
|
163
|
+
const variant = callResult.outputArguments[index];
|
|
164
|
+
const propName = (0, node_opcua_utils_1.lowerFirstLetter)(arg.name);
|
|
165
|
+
output[propName] = variant.value;
|
|
166
|
+
});
|
|
167
|
+
callback(err, output);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function extractDataType(session, arg, callback) {
|
|
172
|
+
if (arg.dataType && arg._basicDataType) {
|
|
173
|
+
setImmediate(callback); // already converted
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
convertNodeIdToDataTypeAsync(session, arg.dataType, (err, dataType) => {
|
|
177
|
+
if (!err) {
|
|
178
|
+
arg._basicDataType = dataType;
|
|
179
|
+
}
|
|
180
|
+
callback(err || undefined);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @method add_method
|
|
185
|
+
* @private
|
|
186
|
+
*/
|
|
187
|
+
function add_method(proxyManager, obj, reference, outerCallback) {
|
|
188
|
+
const session = proxyManager.session;
|
|
189
|
+
const methodName = (0, node_opcua_utils_1.lowerFirstLetter)(reference.browseName.name);
|
|
190
|
+
let inputArguments = [];
|
|
191
|
+
let outputArguments = [];
|
|
192
|
+
// tslint:disable:no-shadowed-variable
|
|
193
|
+
async.series([
|
|
194
|
+
(callback) => {
|
|
195
|
+
session.getArgumentDefinition(reference.nodeId, (err, argumentDefinition) => {
|
|
196
|
+
// istanbul ignore next
|
|
197
|
+
if (err) {
|
|
198
|
+
errorLog("getArgumentDefinition failed ", err);
|
|
199
|
+
return callback(err);
|
|
200
|
+
}
|
|
201
|
+
// istanbul ignore next
|
|
202
|
+
if (!argumentDefinition) {
|
|
203
|
+
return callback(new Error("Internal Error"));
|
|
204
|
+
}
|
|
205
|
+
inputArguments = argumentDefinition.inputArguments || [];
|
|
206
|
+
outputArguments = argumentDefinition.outputArguments || [];
|
|
207
|
+
const _extractDataType = extractDataType.bind(null, session);
|
|
208
|
+
async.series([
|
|
209
|
+
(innerCallback) => async.eachSeries(inputArguments, _extractDataType, innerCallback),
|
|
210
|
+
(innerCallback) => async.eachSeries(outputArguments, _extractDataType, innerCallback)
|
|
211
|
+
], (err) => callback(err));
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
(callback) => {
|
|
215
|
+
const methodObj = {
|
|
216
|
+
browseName: methodName,
|
|
217
|
+
executableFlag: false,
|
|
218
|
+
func: makeFunction(obj, methodName),
|
|
219
|
+
nodeId: reference.nodeId,
|
|
220
|
+
inputArguments,
|
|
221
|
+
outputArguments
|
|
222
|
+
};
|
|
223
|
+
obj.$methods[methodName] = methodObj;
|
|
224
|
+
obj[methodName] = methodObj.func;
|
|
225
|
+
obj[methodName].inputArguments = inputArguments;
|
|
226
|
+
obj[methodName].outputArguments = outputArguments;
|
|
227
|
+
doDebug && debugLog("installing method name", methodName);
|
|
228
|
+
proxyManager._monitor_execution_flag(methodObj, () => {
|
|
229
|
+
callback();
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
], (err) => {
|
|
233
|
+
if (err) {
|
|
234
|
+
errorLog("Error =>", err);
|
|
235
|
+
}
|
|
236
|
+
outerCallback(err);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
function add_component(proxyManager, obj, reference, callback) {
|
|
240
|
+
const session = proxyManager.session;
|
|
241
|
+
const name = (0, node_opcua_utils_1.lowerFirstLetter)(reference.browseName.name || "");
|
|
242
|
+
proxyManager.getObject(reference.nodeId, (err, childObj) => {
|
|
243
|
+
// istanbul ignore else
|
|
244
|
+
if (!err) {
|
|
245
|
+
childObj = new ObjectExplorer({
|
|
246
|
+
name,
|
|
247
|
+
nodeId: reference.nodeId,
|
|
248
|
+
parent: obj,
|
|
249
|
+
proxyManager
|
|
250
|
+
});
|
|
251
|
+
obj[name] = childObj;
|
|
252
|
+
obj.$components.push(childObj);
|
|
253
|
+
childObj.$resolve(callback);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
callback(err);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function addFolderElement(proxyManager, obj, reference, callback) {
|
|
261
|
+
const session = proxyManager.session;
|
|
262
|
+
const name = (0, node_opcua_utils_1.lowerFirstLetter)(reference.browseName.name || "");
|
|
263
|
+
const childObj = new ObjectExplorer({
|
|
264
|
+
name,
|
|
265
|
+
nodeId: reference.nodeId,
|
|
266
|
+
parent: obj,
|
|
267
|
+
proxyManager
|
|
268
|
+
});
|
|
269
|
+
obj[name] = childObj;
|
|
270
|
+
obj.$organizes.push(childObj);
|
|
271
|
+
childObj.$resolve(callback);
|
|
272
|
+
}
|
|
273
|
+
function add_property(proxyManager, obj, reference, callback) {
|
|
274
|
+
const session = proxyManager.session;
|
|
275
|
+
const name = (0, node_opcua_utils_1.lowerFirstLetter)(reference.browseName.name || "");
|
|
276
|
+
obj[name] = new proxy_variable_1.ProxyVariable(proxyManager, reference.nodeId, reference);
|
|
277
|
+
obj.$properties[name] = obj[name];
|
|
278
|
+
setImmediate(callback);
|
|
279
|
+
}
|
|
280
|
+
function add_typeDefinition(proxyManager, obj, references, callback) {
|
|
281
|
+
const session = proxyManager.session;
|
|
282
|
+
references = references || [];
|
|
283
|
+
if (references.length !== 1) {
|
|
284
|
+
setImmediate(callback);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const reference = references[0];
|
|
288
|
+
(0, node_opcua_assert_1.assert)(!obj.typeDefinition, "type definition can only be set once");
|
|
289
|
+
obj.typeDefinition = reference.browseName.name || "";
|
|
290
|
+
setImmediate(callback);
|
|
291
|
+
}
|
|
292
|
+
function addFromState(proxyManager, obj, reference, callback) {
|
|
293
|
+
proxyManager.getObject(reference.nodeId, (err, childObj) => {
|
|
294
|
+
if (err) {
|
|
295
|
+
callback(err);
|
|
296
|
+
}
|
|
297
|
+
obj.$fromState = childObj;
|
|
298
|
+
callback();
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
function addToState(proxyManager, obj, reference, callback) {
|
|
302
|
+
proxyManager.getObject(reference.nodeId, (err, childObj) => {
|
|
303
|
+
if (err) {
|
|
304
|
+
callback(err);
|
|
305
|
+
}
|
|
306
|
+
obj.$toState = childObj;
|
|
307
|
+
callback();
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
class ObjectExplorer {
|
|
311
|
+
constructor(options) {
|
|
312
|
+
this.proxyManager = options.proxyManager;
|
|
313
|
+
this.name = options.name;
|
|
314
|
+
this.nodeId = options.nodeId;
|
|
315
|
+
this.parent = options.parent;
|
|
316
|
+
}
|
|
317
|
+
$resolve(callback) {
|
|
318
|
+
this.proxyManager.getObject(this.nodeId, (err, childObj) => {
|
|
319
|
+
// istanbul ignore next
|
|
320
|
+
if (err) {
|
|
321
|
+
return callback(err);
|
|
322
|
+
}
|
|
323
|
+
this.parent[this.name] = childObj;
|
|
324
|
+
this.parent.$components.push(childObj);
|
|
325
|
+
callback();
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
exports.ObjectExplorer = ObjectExplorer;
|
|
330
|
+
function t(references) {
|
|
331
|
+
if (!references)
|
|
332
|
+
return "";
|
|
333
|
+
return references.map((r) => r.browseName.name + " " + r.nodeId.toString());
|
|
334
|
+
}
|
|
335
|
+
function readUAStructure(proxyManager, obj, callback) {
|
|
336
|
+
const session = proxyManager.session;
|
|
337
|
+
// 0 Object
|
|
338
|
+
// 1 Variable
|
|
339
|
+
// 2 Method
|
|
340
|
+
const nodeId = obj.nodeId;
|
|
341
|
+
const nodesToBrowse = [
|
|
342
|
+
// Components (except Methods)
|
|
343
|
+
{
|
|
344
|
+
// BrowseDescription
|
|
345
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
346
|
+
includeSubtypes: true,
|
|
347
|
+
nodeClassMask: (0, node_opcua_data_model_1.makeNodeClassMask)("Object | Variable"),
|
|
348
|
+
nodeId,
|
|
349
|
+
referenceTypeId: (0, proxy_1.makeRefId)("HasComponent"),
|
|
350
|
+
resultMask
|
|
351
|
+
},
|
|
352
|
+
// Properties
|
|
353
|
+
{
|
|
354
|
+
// BrowseDescription
|
|
355
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
356
|
+
includeSubtypes: true,
|
|
357
|
+
// nodeClassMask: makeNodeClassMask("Variable"),
|
|
358
|
+
nodeId,
|
|
359
|
+
referenceTypeId: (0, proxy_1.makeRefId)("HasProperty"),
|
|
360
|
+
resultMask
|
|
361
|
+
},
|
|
362
|
+
// Methods
|
|
363
|
+
{
|
|
364
|
+
// BrowseDescription
|
|
365
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
366
|
+
includeSubtypes: true,
|
|
367
|
+
nodeClassMask: (0, node_opcua_data_model_1.makeNodeClassMask)("Method"),
|
|
368
|
+
nodeId,
|
|
369
|
+
referenceTypeId: (0, proxy_1.makeRefId)("HasComponent"),
|
|
370
|
+
resultMask
|
|
371
|
+
},
|
|
372
|
+
// TypeDefinition
|
|
373
|
+
{
|
|
374
|
+
// BrowseDescription
|
|
375
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Both,
|
|
376
|
+
includeSubtypes: true,
|
|
377
|
+
nodeId,
|
|
378
|
+
referenceTypeId: (0, proxy_1.makeRefId)("HasTypeDefinition"),
|
|
379
|
+
resultMask
|
|
380
|
+
},
|
|
381
|
+
// FromState
|
|
382
|
+
{
|
|
383
|
+
// BrowseDescription
|
|
384
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
385
|
+
includeSubtypes: true,
|
|
386
|
+
nodeId,
|
|
387
|
+
referenceTypeId: (0, proxy_1.makeRefId)("FromState"),
|
|
388
|
+
resultMask
|
|
389
|
+
},
|
|
390
|
+
// ToState
|
|
391
|
+
{
|
|
392
|
+
// BrowseDescription
|
|
393
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
394
|
+
includeSubtypes: true,
|
|
395
|
+
nodeId,
|
|
396
|
+
referenceTypeId: (0, proxy_1.makeRefId)("ToState"),
|
|
397
|
+
resultMask
|
|
398
|
+
},
|
|
399
|
+
// (for folders ) Organizes
|
|
400
|
+
{
|
|
401
|
+
// BrowseDescription
|
|
402
|
+
browseDirection: node_opcua_data_model_1.BrowseDirection.Forward,
|
|
403
|
+
includeSubtypes: true,
|
|
404
|
+
nodeId,
|
|
405
|
+
referenceTypeId: (0, proxy_1.makeRefId)("Organizes"),
|
|
406
|
+
resultMask
|
|
407
|
+
}
|
|
408
|
+
];
|
|
409
|
+
session.browse(nodesToBrowse, (err, browseResults) => {
|
|
410
|
+
browseResults = browseResults || [];
|
|
411
|
+
// istanbul ignore next
|
|
412
|
+
if (err) {
|
|
413
|
+
return callback(err);
|
|
414
|
+
}
|
|
415
|
+
if (doDebug) {
|
|
416
|
+
debugLog("Components", t(browseResults[0].references));
|
|
417
|
+
debugLog("Properties", t(browseResults[1].references));
|
|
418
|
+
debugLog("Methods", t(browseResults[2].references));
|
|
419
|
+
}
|
|
420
|
+
async.series([
|
|
421
|
+
(callback) => {
|
|
422
|
+
async.mapSeries(browseResults[0].references, (reference, innerCallback) => add_component(proxyManager, obj, reference, innerCallback), (err) => callback(err));
|
|
423
|
+
},
|
|
424
|
+
(callback) => {
|
|
425
|
+
async.mapSeries(browseResults[1].references, (reference, innerCallback) => add_property(proxyManager, obj, reference, innerCallback), (err) => callback(err));
|
|
426
|
+
},
|
|
427
|
+
// now enrich our object with nice callable async methods
|
|
428
|
+
(callback) => {
|
|
429
|
+
async.mapSeries(browseResults[2].references, (reference, innerCallback) => add_method(proxyManager, obj, reference, innerCallback), (err) => callback(err));
|
|
430
|
+
},
|
|
431
|
+
// now set typeDefinition
|
|
432
|
+
(callback) => {
|
|
433
|
+
add_typeDefinition(proxyManager, obj, browseResults[3].references, callback);
|
|
434
|
+
},
|
|
435
|
+
// FromState
|
|
436
|
+
(callback) => {
|
|
437
|
+
// fromState
|
|
438
|
+
const reference = browseResults[4].references ? browseResults[4].references[0] : null;
|
|
439
|
+
// fromState
|
|
440
|
+
if (reference) {
|
|
441
|
+
return addFromState(proxyManager, obj, reference, callback);
|
|
442
|
+
}
|
|
443
|
+
callback();
|
|
444
|
+
},
|
|
445
|
+
// ToState
|
|
446
|
+
(callback) => {
|
|
447
|
+
const reference = browseResults[5].references ? browseResults[5].references[0] : null;
|
|
448
|
+
// fromState
|
|
449
|
+
if (reference) {
|
|
450
|
+
return addToState(proxyManager, obj, reference, callback);
|
|
451
|
+
}
|
|
452
|
+
callback();
|
|
453
|
+
},
|
|
454
|
+
// Organizes
|
|
455
|
+
(callback) => {
|
|
456
|
+
async.mapSeries(browseResults[6].references, (reference, callback) => addFolderElement(proxyManager, obj, reference, callback), (err) => callback(err));
|
|
457
|
+
}
|
|
458
|
+
], (err) => callback(err));
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
exports.readUAStructure = readUAStructure;
|
|
462
|
+
//# sourceMappingURL=object_explorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object_explorer.js","sourceRoot":"","sources":["../source/object_explorer.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,+BAA+B;AAE/B,yDAA2C;AAE3C,iEAAyG;AAKzG,qEAAwF;AAExF,uDAAoD;AACpD,2DAAsF;AACtF,uDAAgE;AAEhE,mCAAoC;AAEpC,qDAAiD;AAEjD,+DAAmD;AAEnD,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MA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AAI,CAAC,CAC1B,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC;AA3JD,0CA2JC"}
|
package/dist/proxy.d.ts
ADDED
package/dist/proxy.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeRefId = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-client-proxy
|
|
6
|
+
*/
|
|
7
|
+
// tslint:disable:no-shadowed-variable
|
|
8
|
+
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
9
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
10
|
+
function makeRefId(referenceTypeName) {
|
|
11
|
+
const nodeId = (0, node_opcua_nodeid_1.makeNodeId)(node_opcua_constants_1.ReferenceTypeIds[referenceTypeName] || node_opcua_constants_1.ObjectTypeIds[referenceTypeName]);
|
|
12
|
+
// istanbul ignore next
|
|
13
|
+
if (nodeId.isEmpty()) {
|
|
14
|
+
throw new Error("makeRefId: cannot find ReferenceTypeName + " + referenceTypeName);
|
|
15
|
+
}
|
|
16
|
+
return nodeId;
|
|
17
|
+
}
|
|
18
|
+
exports.makeRefId = makeRefId;
|
|
19
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../source/proxy.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,sCAAsC;AACtC,+DAAuE;AACvE,yDAAuD;AAEvD,SAAgB,SAAS,CAAC,iBAAyB;IAC/C,MAAM,MAAM,GAAG,IAAA,8BAAU,EAAE,uCAAwB,CAAC,iBAAiB,CAAC,IAAK,oCAAqB,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAErH,uBAAuB;IACvB,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,IAAI,KAAK,CAAC,6CAA6C,GAAG,iBAAiB,CAAC,CAAC;KACtF;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AARD,8BAQC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* @module node-opcua-client-proxy
|
|
4
|
+
*/
|
|
5
|
+
import { EventEmitter } from "events";
|
|
6
|
+
import { NodeClass } from "node-opcua-data-model";
|
|
7
|
+
import { DataValue } from "node-opcua-data-value";
|
|
8
|
+
import { NodeId } from "node-opcua-nodeid";
|
|
9
|
+
import { Argument } from "node-opcua-service-call";
|
|
10
|
+
import { DataType, Variant } from "node-opcua-variant";
|
|
11
|
+
import { UAProxyManager } from "./proxy_manager";
|
|
12
|
+
export interface ArgumentEx extends Argument {
|
|
13
|
+
_basicDataType: DataType;
|
|
14
|
+
}
|
|
15
|
+
export interface MethodDescription {
|
|
16
|
+
browseName: string;
|
|
17
|
+
executableFlag: boolean;
|
|
18
|
+
func: (input: Record<string, unknown>, callback: (err: Error | null, output?: Record<string, unknown>) => void) => void;
|
|
19
|
+
nodeId: NodeId;
|
|
20
|
+
inputArguments: ArgumentEx[];
|
|
21
|
+
outputArguments: ArgumentEx[];
|
|
22
|
+
}
|
|
23
|
+
export declare class ProxyBaseNode extends EventEmitter {
|
|
24
|
+
/**
|
|
25
|
+
* the object nodeId
|
|
26
|
+
* @property nodeId
|
|
27
|
+
* @type {NodeId}
|
|
28
|
+
*/
|
|
29
|
+
readonly nodeId: NodeId;
|
|
30
|
+
/**
|
|
31
|
+
* the object's components
|
|
32
|
+
* @property $components
|
|
33
|
+
* @type {Array<ProxyBaseNode>}
|
|
34
|
+
*/
|
|
35
|
+
readonly $components: any[];
|
|
36
|
+
/**
|
|
37
|
+
* the object's properties
|
|
38
|
+
* @property $properties
|
|
39
|
+
* @type {Array<ProxyBaseNode>}
|
|
40
|
+
*/
|
|
41
|
+
$properties: any[];
|
|
42
|
+
/**
|
|
43
|
+
* the object's properties
|
|
44
|
+
* @property $methods
|
|
45
|
+
* @type {Array<ProxyBaseNode>}
|
|
46
|
+
*/
|
|
47
|
+
$methods: MethodDescription[];
|
|
48
|
+
/**
|
|
49
|
+
* the Folder's elements
|
|
50
|
+
* @property $organizes
|
|
51
|
+
* @type {Array<ProxyBaseNode>}
|
|
52
|
+
*/
|
|
53
|
+
$organizes: any[];
|
|
54
|
+
/**
|
|
55
|
+
* the object's description
|
|
56
|
+
* @property description
|
|
57
|
+
* @type {String}
|
|
58
|
+
*/
|
|
59
|
+
description: string;
|
|
60
|
+
/**
|
|
61
|
+
* the object's browseName
|
|
62
|
+
* @property browseName
|
|
63
|
+
* @type {String}
|
|
64
|
+
*/
|
|
65
|
+
browseName: string;
|
|
66
|
+
/**
|
|
67
|
+
* the object's NodeClass
|
|
68
|
+
* @property nodeClass
|
|
69
|
+
* @type {NodeClass}
|
|
70
|
+
*/
|
|
71
|
+
readonly nodeClass: NodeClass;
|
|
72
|
+
private readonly proxyManager;
|
|
73
|
+
constructor(proxyManager: UAProxyManager, nodeId: NodeId, nodeClass: NodeClass);
|
|
74
|
+
/**
|
|
75
|
+
* get a updated Value of the Variable , by using a ReadRequest
|
|
76
|
+
*/
|
|
77
|
+
readValue(callback: (err: Error | null, variant?: Variant) => void): void;
|
|
78
|
+
/**
|
|
79
|
+
* set the Value of the Variable, by using a WriteRequest
|
|
80
|
+
*/
|
|
81
|
+
writeValue(dataValue: DataValue, callback: (err?: Error) => void): void;
|
|
82
|
+
toString(): string;
|
|
83
|
+
}
|