node-opcua-address-space 2.139.0 → 2.141.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.
- package/dist/source/helpers/call_helpers.d.ts +1 -2
- package/dist/source/helpers/call_helpers.js +25 -32
- package/dist/source/helpers/call_helpers.js.map +1 -1
- package/dist/source/pseudo_session.js +44 -53
- package/dist/source/pseudo_session.js.map +1 -1
- package/dist/src/ua_method_impl.js +2 -2
- package/dist/src/ua_method_impl.js.map +1 -1
- package/dist/src/ua_variable_impl.js +6 -6
- package/dist/src/ua_variable_impl.js.map +1 -1
- package/dist/tsconfig_common.tsbuildinfo +1 -1
- package/package.json +17 -18
- package/source/helpers/call_helpers.ts +36 -45
- package/source/pseudo_session.ts +45 -69
- package/src/ua_method_impl.ts +2 -2
- package/src/ua_variable_impl.ts +6 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-address-space",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.141.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module address-space",
|
|
5
5
|
"main": "./dist/src/index_current.js",
|
|
6
6
|
"types": "./dist/source/index.d.ts",
|
|
@@ -18,18 +18,17 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@types/lodash": "4.17.13",
|
|
20
20
|
"@types/semver": "^7.5.8",
|
|
21
|
-
"async": "^3.2.6",
|
|
22
21
|
"chalk": "4.1.2",
|
|
23
22
|
"dequeue": "^1.0.5",
|
|
24
23
|
"lodash": "4.17.21",
|
|
25
|
-
"node-opcua-address-space-base": "2.
|
|
24
|
+
"node-opcua-address-space-base": "2.141.0",
|
|
26
25
|
"node-opcua-assert": "2.139.0",
|
|
27
26
|
"node-opcua-basic-types": "2.139.0",
|
|
28
27
|
"node-opcua-binary-stream": "2.139.0",
|
|
29
|
-
"node-opcua-client-dynamic-extension-object": "2.
|
|
28
|
+
"node-opcua-client-dynamic-extension-object": "2.141.0",
|
|
30
29
|
"node-opcua-constants": "2.139.0",
|
|
31
30
|
"node-opcua-crypto": "4.15.0",
|
|
32
|
-
"node-opcua-data-access": "2.
|
|
31
|
+
"node-opcua-data-access": "2.141.0",
|
|
33
32
|
"node-opcua-data-model": "2.139.0",
|
|
34
33
|
"node-opcua-data-value": "2.139.0",
|
|
35
34
|
"node-opcua-date-time": "2.139.0",
|
|
@@ -38,23 +37,23 @@
|
|
|
38
37
|
"node-opcua-extension-object": "2.139.0",
|
|
39
38
|
"node-opcua-factory": "2.139.0",
|
|
40
39
|
"node-opcua-nodeid": "2.139.0",
|
|
41
|
-
"node-opcua-nodeset-ua": "2.
|
|
40
|
+
"node-opcua-nodeset-ua": "2.141.0",
|
|
42
41
|
"node-opcua-numeric-range": "2.139.0",
|
|
43
42
|
"node-opcua-object-registry": "2.139.0",
|
|
44
|
-
"node-opcua-pseudo-session": "2.
|
|
45
|
-
"node-opcua-service-browse": "2.
|
|
46
|
-
"node-opcua-service-call": "2.
|
|
47
|
-
"node-opcua-service-history": "2.
|
|
48
|
-
"node-opcua-service-translate-browse-path": "2.
|
|
49
|
-
"node-opcua-service-write": "2.
|
|
43
|
+
"node-opcua-pseudo-session": "2.141.0",
|
|
44
|
+
"node-opcua-service-browse": "2.141.0",
|
|
45
|
+
"node-opcua-service-call": "2.141.0",
|
|
46
|
+
"node-opcua-service-history": "2.141.0",
|
|
47
|
+
"node-opcua-service-translate-browse-path": "2.141.0",
|
|
48
|
+
"node-opcua-service-write": "2.141.0",
|
|
50
49
|
"node-opcua-status-code": "2.139.0",
|
|
51
|
-
"node-opcua-types": "2.
|
|
50
|
+
"node-opcua-types": "2.141.0",
|
|
52
51
|
"node-opcua-utils": "2.139.0",
|
|
53
52
|
"node-opcua-variant": "2.139.0",
|
|
54
|
-
"node-opcua-xml2json": "2.
|
|
53
|
+
"node-opcua-xml2json": "2.141.0",
|
|
55
54
|
"semver": "^7.6.3",
|
|
56
55
|
"set-prototype-of": "^1.0.0",
|
|
57
|
-
"thenify": "
|
|
56
|
+
"thenify-ex": "4.2.0",
|
|
58
57
|
"xml-writer": "^1.7.0"
|
|
59
58
|
},
|
|
60
59
|
"devDependencies": {
|
|
@@ -62,8 +61,8 @@
|
|
|
62
61
|
"node-opcua-leak-detector": "2.139.0",
|
|
63
62
|
"node-opcua-nodesets": "2.139.0",
|
|
64
63
|
"node-opcua-packet-analyzer": "2.139.0",
|
|
65
|
-
"node-opcua-service-filter": "2.
|
|
66
|
-
"node-opcua-test-fixtures": "2.
|
|
64
|
+
"node-opcua-service-filter": "2.141.0",
|
|
65
|
+
"node-opcua-test-fixtures": "2.141.0",
|
|
67
66
|
"source-map-support": "^0.5.21"
|
|
68
67
|
},
|
|
69
68
|
"author": "Etienne Rossignon",
|
|
@@ -81,7 +80,7 @@
|
|
|
81
80
|
"internet of things"
|
|
82
81
|
],
|
|
83
82
|
"homepage": "http://node-opcua.github.io/",
|
|
84
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "7467e145ce9ebad2c80cabb096189bda7714083d",
|
|
85
84
|
"files": [
|
|
86
85
|
"dist",
|
|
87
86
|
"distHelpers",
|
|
@@ -8,7 +8,6 @@ import { CallMethodRequest } from "node-opcua-service-call";
|
|
|
8
8
|
import { StatusCode, StatusCodes } from "node-opcua-status-code";
|
|
9
9
|
import { CallMethodResultOptions } from "node-opcua-types";
|
|
10
10
|
import { Variant } from "node-opcua-variant";
|
|
11
|
-
import { ResponseCallback } from "node-opcua-pseudo-session";
|
|
12
11
|
import { ISessionContext, IAddressSpace, UAMethod, UAObject } from "node-opcua-address-space-base";
|
|
13
12
|
|
|
14
13
|
import { getMethodDeclaration_ArgumentList, verifyArguments_ArgumentList } from "./argument_list";
|
|
@@ -30,12 +29,11 @@ import { resolveOpaqueOnAddressSpace } from "./resolve_opaque_on_address_space";
|
|
|
30
29
|
// A server shall accept a ByteString if an array of Byte is expected.
|
|
31
30
|
// BadNoCommunication
|
|
32
31
|
|
|
33
|
-
export function callMethodHelper(
|
|
32
|
+
export async function callMethodHelper(
|
|
34
33
|
context: ISessionContext,
|
|
35
34
|
addressSpace: IAddressSpace,
|
|
36
|
-
callMethodRequest: CallMethodRequest
|
|
37
|
-
|
|
38
|
-
): void {
|
|
35
|
+
callMethodRequest: CallMethodRequest
|
|
36
|
+
): Promise<CallMethodResultOptions> {
|
|
39
37
|
const objectId = callMethodRequest.objectId;
|
|
40
38
|
const methodId = callMethodRequest.methodId;
|
|
41
39
|
const inputArguments = callMethodRequest.inputArguments || [];
|
|
@@ -45,24 +43,24 @@ export function callMethodHelper(
|
|
|
45
43
|
|
|
46
44
|
const object = addressSpace.findNode(objectId) as UAObject;
|
|
47
45
|
if (!object) {
|
|
48
|
-
return
|
|
46
|
+
return { statusCode: StatusCodes.BadNodeIdUnknown };
|
|
49
47
|
}
|
|
50
48
|
if (object.nodeClass !== NodeClass.Object && object.nodeClass !== NodeClass.ObjectType) {
|
|
51
|
-
return
|
|
49
|
+
return { statusCode: StatusCodes.BadNodeIdInvalid };
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
const methodObj = addressSpace.findNode(methodId) as UAMethod;
|
|
55
53
|
if (!methodObj) {
|
|
56
|
-
return
|
|
54
|
+
return { statusCode: StatusCodes.BadMethodInvalid };
|
|
57
55
|
}
|
|
58
56
|
if (methodObj.nodeClass !== NodeClass.Method) {
|
|
59
|
-
return
|
|
57
|
+
return { statusCode: StatusCodes.BadMethodInvalid };
|
|
60
58
|
}
|
|
61
59
|
|
|
62
60
|
const response1 = getMethodDeclaration_ArgumentList(addressSpace, objectId, methodId);
|
|
63
61
|
|
|
64
62
|
if (response1.statusCode.isNotGood()) {
|
|
65
|
-
return
|
|
63
|
+
return { statusCode: response1.statusCode };
|
|
66
64
|
}
|
|
67
65
|
const methodDeclaration = response1.methodDeclaration!;
|
|
68
66
|
|
|
@@ -71,41 +69,34 @@ export function callMethodHelper(
|
|
|
71
69
|
|
|
72
70
|
const response = verifyArguments_ArgumentList(addressSpace, methodInputArguments, inputArguments);
|
|
73
71
|
if (response.statusCode.isNotGood()) {
|
|
74
|
-
return
|
|
72
|
+
return response;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
await resolveOpaqueOnAddressSpace(addressSpace, inputArguments);
|
|
78
|
+
|
|
79
|
+
const callMethodResponse = await methodObj.execute(
|
|
80
|
+
object,
|
|
81
|
+
inputArguments,
|
|
82
|
+
context);
|
|
83
|
+
callMethodResponse.inputArgumentResults =
|
|
84
|
+
callMethodResponse.inputArgumentResults || response.inputArgumentResults || [];
|
|
85
|
+
assert(callMethodResponse.statusCode);
|
|
86
|
+
|
|
87
|
+
if (callMethodResponse.statusCode?.isGood()) {
|
|
88
|
+
assert(Array.isArray(callMethodResponse.outputArguments));
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
assert(Array.isArray(callMethodResponse.inputArgumentResults));
|
|
92
|
+
assert(callMethodResponse.inputArgumentResults!.length === methodInputArguments.length);
|
|
93
|
+
|
|
94
|
+
const outputArguments = callMethodResponse.outputArguments || [];
|
|
95
|
+
await resolveOpaqueOnAddressSpace(addressSpace, outputArguments as Variant[]);
|
|
96
|
+
|
|
97
|
+
return callMethodResponse;
|
|
98
|
+
} catch (err) {
|
|
99
|
+
return { statusCode: StatusCodes.BadInternalError };
|
|
75
100
|
}
|
|
76
101
|
|
|
77
|
-
resolveOpaqueOnAddressSpace(addressSpace, inputArguments)
|
|
78
|
-
.then(() => {
|
|
79
|
-
methodObj.execute(
|
|
80
|
-
object,
|
|
81
|
-
inputArguments,
|
|
82
|
-
context,
|
|
83
|
-
(err: Error | null, callMethodResponse?: CallMethodResultOptions) => {
|
|
84
|
-
/* istanbul ignore next */
|
|
85
|
-
if (err) {
|
|
86
|
-
return callback(err);
|
|
87
|
-
}
|
|
88
|
-
if (!callMethodResponse) {
|
|
89
|
-
return callback(new Error("internal Error"));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
callMethodResponse.inputArgumentResults =
|
|
93
|
-
callMethodResponse.inputArgumentResults || response.inputArgumentResults || [];
|
|
94
|
-
assert(callMethodResponse.statusCode);
|
|
95
|
-
|
|
96
|
-
if (callMethodResponse.statusCode?.isGood()) {
|
|
97
|
-
assert(Array.isArray(callMethodResponse.outputArguments));
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
assert(Array.isArray(callMethodResponse.inputArgumentResults));
|
|
101
|
-
assert(callMethodResponse.inputArgumentResults!.length === methodInputArguments.length);
|
|
102
|
-
|
|
103
|
-
const outputArguments = callMethodResponse.outputArguments || [];
|
|
104
|
-
resolveOpaqueOnAddressSpace(addressSpace, outputArguments as Variant[])
|
|
105
|
-
.then(() => callback(null, callMethodResponse))
|
|
106
|
-
.catch(callback);
|
|
107
|
-
}
|
|
108
|
-
);
|
|
109
|
-
})
|
|
110
|
-
.catch((err) => callback(err));
|
|
111
102
|
}
|
package/source/pseudo_session.ts
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
* @module node-opcua-address-space
|
|
3
3
|
*/
|
|
4
4
|
import { promisify } from "util";
|
|
5
|
-
import async from "async";
|
|
6
|
-
|
|
7
5
|
import { assert } from "node-opcua-assert";
|
|
8
6
|
import { DataValue } from "node-opcua-data-value";
|
|
9
7
|
import { make_errorLog } from "node-opcua-debug";
|
|
@@ -198,38 +196,26 @@ export class PseudoSession implements IBasicSession {
|
|
|
198
196
|
const _nodesToRead = nodesToRead as ReadValueIdOptions[];
|
|
199
197
|
const context = this[$context];
|
|
200
198
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if (!obj) {
|
|
222
|
-
return new DataValue({ statusCode: StatusCodes.BadNodeIdUnknown });
|
|
223
|
-
}
|
|
224
|
-
const context = this[$context];
|
|
225
|
-
const dataValue = obj.readAttribute(context, attributeId, indexRange, dataEncoding);
|
|
226
|
-
return dataValue;
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
callback!(null, isArray ? dataValues : dataValues[0]);
|
|
230
|
-
}
|
|
231
|
-
);
|
|
232
|
-
});
|
|
199
|
+
const readV = async (nodeToRead: ReadValueIdOptions): Promise<DataValue> => {
|
|
200
|
+
const obj = this[$addressSpace].findNode(nodeToRead.nodeId!);
|
|
201
|
+
if (!obj) {
|
|
202
|
+
return new DataValue({ statusCode: StatusCodes.BadNodeIdUnknown });
|
|
203
|
+
}
|
|
204
|
+
// refresh the variable value if the attribute to read is the Value attribute
|
|
205
|
+
if (obj.nodeClass === NodeClass.Variable && nodeToRead.attributeId == AttributeIds.Value) {
|
|
206
|
+
(obj as UAVariable).readValueAsync(context);
|
|
207
|
+
}
|
|
208
|
+
assert(!!nodeToRead.nodeId, "expecting a nodeId");
|
|
209
|
+
assert(!!nodeToRead.attributeId, "expecting a attributeId");
|
|
210
|
+
const attributeId = nodeToRead.attributeId!;
|
|
211
|
+
const indexRange = nodeToRead.indexRange;
|
|
212
|
+
const dataEncoding = nodeToRead.dataEncoding;
|
|
213
|
+
const dataValue = obj.readAttribute(context, attributeId, indexRange, dataEncoding);
|
|
214
|
+
return dataValue;
|
|
215
|
+
};
|
|
216
|
+
Promise.all(_nodesToRead.map(async (nodeToRead: ReadValueIdOptions) => await readV(nodeToRead)))
|
|
217
|
+
.then((dataValues) => callback!(null, isArray ? dataValues : dataValues[0]))
|
|
218
|
+
.catch((err) => callback!(err));
|
|
233
219
|
}
|
|
234
220
|
|
|
235
221
|
public browseNext(
|
|
@@ -280,34 +266,24 @@ export class PseudoSession implements IBasicSession {
|
|
|
280
266
|
if (!isArray) {
|
|
281
267
|
methodsToCall = [methodsToCall as CallMethodRequestLike];
|
|
282
268
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
(err: Error | null, result?: CallMethodResultOptions) => {
|
|
294
|
-
let callMethodResult: CallMethodResult;
|
|
295
|
-
if (err) {
|
|
296
|
-
errorLog("Internal Error = ", err);
|
|
297
|
-
callMethodResult = new CallMethodResult({
|
|
298
|
-
statusCode: StatusCodes.BadInternalError
|
|
299
|
-
});
|
|
300
|
-
} else {
|
|
301
|
-
callMethodResult = new CallMethodResult(result);
|
|
302
|
-
}
|
|
303
|
-
innerCallback(null, callMethodResult);
|
|
304
|
-
}
|
|
305
|
-
);
|
|
306
|
-
},
|
|
307
|
-
(err?: Error | null, callMethodResults?: any) => {
|
|
308
|
-
callback!(null, isArray ? callMethodResults! : callMethodResults![0]);
|
|
269
|
+
Promise.all((methodsToCall as CallMethodRequestLike[]).map(async (methodToCall) => {
|
|
270
|
+
const callMethodRequest = new CallMethodRequest(methodToCall);
|
|
271
|
+
try {
|
|
272
|
+
const result = await callMethodHelper(this[$context], this[$addressSpace], callMethodRequest);
|
|
273
|
+
return new CallMethodResult(result);
|
|
274
|
+
} catch (err) {
|
|
275
|
+
errorLog("Internal Error = ", err);
|
|
276
|
+
return new CallMethodResult({
|
|
277
|
+
statusCode: StatusCodes.BadInternalError
|
|
278
|
+
});
|
|
309
279
|
}
|
|
310
|
-
)
|
|
280
|
+
}))
|
|
281
|
+
.then((callMethodResults) => {
|
|
282
|
+
callback!(null, isArray ? callMethodResults : callMethodResults[0]);
|
|
283
|
+
})
|
|
284
|
+
.catch((err) => {
|
|
285
|
+
callback!(err);
|
|
286
|
+
});
|
|
311
287
|
}
|
|
312
288
|
|
|
313
289
|
public getArgumentDefinition(methodId: MethodId): Promise<ArgumentDefinition>;
|
|
@@ -373,11 +349,11 @@ export class PseudoSession implements IBasicSession {
|
|
|
373
349
|
|
|
374
350
|
// tslint:disable:no-var-requires
|
|
375
351
|
// tslint:disable:max-line-length
|
|
376
|
-
|
|
377
|
-
PseudoSession.prototype.read =
|
|
378
|
-
PseudoSession.prototype.write =
|
|
379
|
-
PseudoSession.prototype.browse =
|
|
380
|
-
PseudoSession.prototype.browseNext =
|
|
381
|
-
PseudoSession.prototype.getArgumentDefinition =
|
|
382
|
-
PseudoSession.prototype.call =
|
|
383
|
-
PseudoSession.prototype.translateBrowsePath =
|
|
352
|
+
import { withCallback } from "thenify-ex";
|
|
353
|
+
PseudoSession.prototype.read = withCallback(PseudoSession.prototype.read);
|
|
354
|
+
PseudoSession.prototype.write = withCallback(PseudoSession.prototype.write);
|
|
355
|
+
PseudoSession.prototype.browse = withCallback(PseudoSession.prototype.browse);
|
|
356
|
+
PseudoSession.prototype.browseNext = withCallback(PseudoSession.prototype.browseNext);
|
|
357
|
+
PseudoSession.prototype.getArgumentDefinition = withCallback(PseudoSession.prototype.getArgumentDefinition);
|
|
358
|
+
PseudoSession.prototype.call = withCallback(PseudoSession.prototype.call);
|
|
359
|
+
PseudoSession.prototype.translateBrowsePath = withCallback(PseudoSession.prototype.translateBrowsePath);
|
package/src/ua_method_impl.ts
CHANGED
|
@@ -307,5 +307,5 @@ export class UAMethodImpl extends BaseNodeImpl implements UAMethod {
|
|
|
307
307
|
|
|
308
308
|
// tslint:disable:no-var-requires
|
|
309
309
|
// tslint:disable:max-line-length
|
|
310
|
-
|
|
311
|
-
UAMethodImpl.prototype.execute =
|
|
310
|
+
import { withCallback } from "thenify-ex";
|
|
311
|
+
UAMethodImpl.prototype.execute = withCallback(UAMethodImpl.prototype.execute);
|
package/src/ua_variable_impl.ts
CHANGED
|
@@ -1854,12 +1854,12 @@ export class UAVariableImpl extends BaseNodeImpl implements UAVariable {
|
|
|
1854
1854
|
}
|
|
1855
1855
|
|
|
1856
1856
|
// tslint:disable:no-var-requires
|
|
1857
|
-
|
|
1858
|
-
UAVariableImpl.prototype.asyncRefresh =
|
|
1859
|
-
UAVariableImpl.prototype.writeValue =
|
|
1860
|
-
UAVariableImpl.prototype.writeAttribute =
|
|
1861
|
-
UAVariableImpl.prototype.historyRead =
|
|
1862
|
-
UAVariableImpl.prototype.readValueAsync =
|
|
1857
|
+
import { withCallback } from "thenify-ex";
|
|
1858
|
+
UAVariableImpl.prototype.asyncRefresh = withCallback(UAVariableImpl.prototype.asyncRefresh);
|
|
1859
|
+
UAVariableImpl.prototype.writeValue = withCallback(UAVariableImpl.prototype.writeValue);
|
|
1860
|
+
UAVariableImpl.prototype.writeAttribute = withCallback(UAVariableImpl.prototype.writeAttribute);
|
|
1861
|
+
UAVariableImpl.prototype.historyRead = withCallback(UAVariableImpl.prototype.historyRead);
|
|
1862
|
+
UAVariableImpl.prototype.readValueAsync = withCallback(UAVariableImpl.prototype.readValueAsync);
|
|
1863
1863
|
|
|
1864
1864
|
export interface UAVariableImplExtArray {
|
|
1865
1865
|
$$variableType?: UAVariableType;
|