node-opcua-client-proxy 2.177.0 → 2.179.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/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/object_explorer.d.ts +11 -8
- package/dist/object_explorer.js +37 -31
- package/dist/object_explorer.js.map +1 -1
- package/dist/proxy.d.ts +1 -1
- package/dist/proxy.js +3 -3
- package/dist/proxy.js.map +1 -1
- package/dist/proxy_base_node.d.ts +19 -14
- package/dist/proxy_base_node.js +8 -8
- package/dist/proxy_base_node.js.map +1 -1
- package/dist/proxy_manager.d.ts +9 -10
- package/dist/proxy_manager.js +17 -15
- package/dist/proxy_manager.js.map +1 -1
- package/dist/proxy_object.d.ts +2 -2
- package/dist/proxy_state.d.ts +2 -2
- package/dist/proxy_state.js +2 -2
- package/dist/proxy_state.js.map +1 -1
- package/dist/proxy_state_machine.d.ts +3 -3
- package/dist/proxy_state_machine.js +2 -2
- package/dist/proxy_state_machine.js.map +1 -1
- package/dist/proxy_transition.d.ts +2 -2
- package/dist/proxy_variable.d.ts +4 -4
- package/dist/proxy_variable.js +1 -1
- package/dist/proxy_variable.js.map +1 -1
- package/dist/state_machine_proxy.d.ts +1 -1
- package/dist/state_machine_proxy.js.map +1 -1
- package/package.json +19 -19
- package/source/index.ts +2 -1
- package/source/object_explorer.ts +102 -63
- package/source/proxy.ts +6 -4
- package/source/proxy_base_node.ts +25 -23
- package/source/proxy_manager.ts +40 -34
- package/source/proxy_object.ts +2 -2
- package/source/proxy_state.ts +5 -5
- package/source/proxy_state_machine.ts +3 -3
- package/source/proxy_transition.ts +2 -2
- package/source/proxy_variable.ts +4 -4
- package/source/state_machine_proxy.ts +3 -4
package/dist/proxy_state.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-client-proxy
|
|
3
3
|
*/
|
|
4
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
5
|
-
import { ProxyNode } from "./proxy_transition";
|
|
4
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
5
|
+
import type { ProxyNode } from "./proxy_transition";
|
|
6
6
|
export declare class ProxyState {
|
|
7
7
|
private _node;
|
|
8
8
|
constructor(proxyNode: ProxyNode);
|
package/dist/proxy_state.js
CHANGED
|
@@ -12,14 +12,14 @@ class ProxyState {
|
|
|
12
12
|
}
|
|
13
13
|
get stateNumber() {
|
|
14
14
|
// note stateNumber has no real dataValue
|
|
15
|
-
return this._node.stateNumber
|
|
15
|
+
return this._node.stateNumber?.nodeId.value.toString() || "";
|
|
16
16
|
}
|
|
17
17
|
get nodeId() {
|
|
18
18
|
// note stateNumber has no real dataValue
|
|
19
19
|
return this._node.nodeId;
|
|
20
20
|
}
|
|
21
21
|
toString() {
|
|
22
|
-
return
|
|
22
|
+
return `state ${this.browseName} stateNumber :${this.stateNumber.toString()}`;
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
exports.ProxyState = ProxyState;
|
package/dist/proxy_state.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy_state.js","sourceRoot":"","sources":["../source/proxy_state.ts"],"names":[],"mappings":";;;AAgCA,wCAEC;AA5BD,MAAa,UAAU;IACX,KAAK,
|
|
1
|
+
{"version":3,"file":"proxy_state.js","sourceRoot":"","sources":["../source/proxy_state.ts"],"names":[],"mappings":";;;AAgCA,wCAEC;AA5BD,MAAa,UAAU;IACX,KAAK,CAA0C;IAEvD,YAAY,SAAoB;QAC5B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IAC3B,CAAC;IAED,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC5C,CAAC;IAED,IAAW,WAAW;QAClB,yCAAyC;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACjE,CAAC;IAED,IAAW,MAAM;QACb,yCAAyC;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC7B,CAAC;IAEM,QAAQ;QACX,OAAO,SAAS,IAAI,CAAC,UAAU,iBAAiB,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC;IAClF,CAAC;CACJ;AAxBD,gCAwBC;AAED,SAAgB,cAAc,CAAC,IAAe;IAC1C,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-client-proxy
|
|
3
3
|
*/
|
|
4
|
-
import { EventEmitter } from "events";
|
|
5
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
6
|
-
import { UAProxyManager } from "./proxy_manager";
|
|
4
|
+
import { EventEmitter } from "node:events";
|
|
5
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
6
|
+
import type { UAProxyManager } from "./proxy_manager";
|
|
7
7
|
export declare class StateMachineProxy extends EventEmitter {
|
|
8
8
|
nodeId: NodeId;
|
|
9
9
|
private proxyManager;
|
|
@@ -4,9 +4,9 @@ exports.StateMachineProxy = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* @module node-opcua-client-proxy
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
7
|
+
const node_events_1 = require("node:events");
|
|
8
8
|
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
9
|
-
class StateMachineProxy extends
|
|
9
|
+
class StateMachineProxy extends node_events_1.EventEmitter {
|
|
10
10
|
nodeId;
|
|
11
11
|
proxyManager;
|
|
12
12
|
constructor(proxyManager, nodeId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy_state_machine.js","sourceRoot":"","sources":["../source/proxy_state_machine.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"proxy_state_machine.js","sourceRoot":"","sources":["../source/proxy_state_machine.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,6CAA2C;AAC3C,yDAA2C;AAI3C,MAAa,iBAAkB,SAAQ,0BAAY;IACxC,MAAM,CAAS;IACd,YAAY,CAAiB;IAErC,YAAY,YAA4B,EAAE,MAAc;QACpD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAA,0BAAM,EAAC,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,yBAAyB,CAAC,CAAC;QAC7D,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,EAAE;YACxC,UAAU,EAAE,KAAK;YACjB,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;IACP,CAAC;CACJ;AAdD,8CAcC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { QualifiedName } from "node-opcua-data-model";
|
|
2
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
1
|
+
import type { QualifiedName } from "node-opcua-data-model";
|
|
2
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
3
3
|
export interface ProxyNode {
|
|
4
4
|
nodeId: NodeId;
|
|
5
5
|
browseName: QualifiedName;
|
package/dist/proxy_variable.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
2
|
-
import { ReferenceDescription } from "node-opcua-service-browse";
|
|
1
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
2
|
+
import type { ReferenceDescription } from "node-opcua-service-browse";
|
|
3
3
|
import { ProxyBaseNode } from "./proxy_base_node";
|
|
4
|
-
import { UAProxyManager } from "./proxy_manager";
|
|
4
|
+
import type { UAProxyManager } from "./proxy_manager";
|
|
5
5
|
export declare class ProxyVariable extends ProxyBaseNode {
|
|
6
|
-
constructor(proxyManager: UAProxyManager, nodeId: NodeId,
|
|
6
|
+
constructor(proxyManager: UAProxyManager, nodeId: NodeId, _reference: ReferenceDescription);
|
|
7
7
|
}
|
package/dist/proxy_variable.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.ProxyVariable = void 0;
|
|
|
7
7
|
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
8
8
|
const proxy_base_node_1 = require("./proxy_base_node");
|
|
9
9
|
class ProxyVariable extends proxy_base_node_1.ProxyBaseNode {
|
|
10
|
-
constructor(proxyManager, nodeId,
|
|
10
|
+
constructor(proxyManager, nodeId, _reference) {
|
|
11
11
|
super(proxyManager, nodeId, node_opcua_data_model_1.NodeClass.Variable);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy_variable.js","sourceRoot":"","sources":["../source/proxy_variable.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,iEAAkD;AAGlD,uDAAkD;AAGlD,MAAa,aAAc,SAAQ,+BAAa;IAC5C,YAAY,YAA4B,EAAE,MAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"proxy_variable.js","sourceRoot":"","sources":["../source/proxy_variable.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,iEAAkD;AAGlD,uDAAkD;AAGlD,MAAa,aAAc,SAAQ,+BAAa;IAC5C,YAAY,YAA4B,EAAE,MAAc,EAAE,UAAgC;QACtF,KAAK,CAAC,YAAY,EAAE,MAAM,EAAE,iCAAS,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC;CACJ;AAJD,sCAIC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProxyState } from "./proxy_state";
|
|
2
|
-
import { ProxyNode, ProxyTransition } from "./proxy_transition";
|
|
2
|
+
import { type ProxyNode, type ProxyTransition } from "./proxy_transition";
|
|
3
3
|
export declare class ProxyStateMachineType {
|
|
4
4
|
initialState: ProxyState | undefined;
|
|
5
5
|
states: ProxyState[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"state_machine_proxy.js","sourceRoot":"","sources":["../source/state_machine_proxy.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAC3C,+CAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"state_machine_proxy.js","sourceRoot":"","sources":["../source/state_machine_proxy.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAC3C,+CAA2D;AAC3D,yDAA+F;AAE/F,MAAa,qBAAqB;IACvB,YAAY,CAAyB;IACrC,MAAM,CAAe;IACrB,WAAW,CAAoB;IAEtC,YAAY,GAAc;QACtB,MAAM,iBAAiB,GAAG,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,SAAoB,EAAE,EAAE;YACtE,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;gBAC5B,OAAO,KAAK,CAAC;YACjB,CAAC;YACD,OAAO,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,kBAAkB,CAAC;QACtE,CAAC,CAAC,CAAC;QAEH,IAAI,iBAAiB,CAAC,MAAM,EAAE,CAAC;YAC3B,IAAA,0BAAM,EAAC,iBAAiB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;YACvC,IAAI,CAAC,YAAY,GAAG,IAAI,wBAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,WAAW;aACxB,MAAM,CAAC,CAAC,SAAoB,EAAE,EAAE;YAC7B,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;gBAC5B,OAAO,KAAK,CAAC;YACjB,CAAC;YACD,OAAO,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,WAAW,CAAC;QAC/D,CAAC,CAAC;aACD,GAAG,CAAC,4BAAc,CAAC,CAAC;QAEzB,IAAI,CAAC,WAAW,GAAG,GAAG,CAAC,WAAW;aAC7B,MAAM,CAAC,CAAC,SAAoB,EAAE,EAAE;YAC7B,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;gBAC5B,OAAO,KAAK,CAAC;YACjB,CAAC;YACD,OAAO,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,gBAAgB,CAAC;QACpE,CAAC,CAAC;aACD,GAAG,CAAC,sCAAmB,CAAC,CAAC;IAClC,CAAC;CAcJ;AAnDD,sDAmDC"}
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-client-proxy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.179.0",
|
|
4
4
|
"description": "pure nodejs OPCUA SDK - module client-proxy",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"clean": "npx rimraf -g node_modules dist *.tsbuildinfo",
|
|
7
7
|
"build": "tsc -b",
|
|
8
|
-
"lint": "
|
|
9
|
-
"format": "
|
|
8
|
+
"lint": "biome check --no-errors-on-unmatched .",
|
|
9
|
+
"format": "biome check --write --no-errors-on-unmatched .",
|
|
10
10
|
"test": "mocha"
|
|
11
11
|
},
|
|
12
12
|
"main": "./dist/index.js",
|
|
13
13
|
"types": "./dist/index.d.ts",
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"node-opcua-assert": "2.
|
|
16
|
-
"node-opcua-constants": "2.
|
|
17
|
-
"node-opcua-data-model": "2.
|
|
18
|
-
"node-opcua-data-value": "2.
|
|
19
|
-
"node-opcua-debug": "2.
|
|
20
|
-
"node-opcua-nodeid": "2.
|
|
21
|
-
"node-opcua-pseudo-session": "2.
|
|
22
|
-
"node-opcua-service-browse": "2.
|
|
23
|
-
"node-opcua-service-call": "2.
|
|
24
|
-
"node-opcua-service-read": "2.
|
|
25
|
-
"node-opcua-service-subscription": "2.
|
|
26
|
-
"node-opcua-service-write": "2.
|
|
27
|
-
"node-opcua-status-code": "2.
|
|
28
|
-
"node-opcua-utils": "2.
|
|
29
|
-
"node-opcua-variant": "2.
|
|
15
|
+
"node-opcua-assert": "2.179.0",
|
|
16
|
+
"node-opcua-constants": "2.179.0",
|
|
17
|
+
"node-opcua-data-model": "2.179.0",
|
|
18
|
+
"node-opcua-data-value": "2.179.0",
|
|
19
|
+
"node-opcua-debug": "2.179.0",
|
|
20
|
+
"node-opcua-nodeid": "2.179.0",
|
|
21
|
+
"node-opcua-pseudo-session": "2.179.0",
|
|
22
|
+
"node-opcua-service-browse": "2.179.0",
|
|
23
|
+
"node-opcua-service-call": "2.179.0",
|
|
24
|
+
"node-opcua-service-read": "2.179.0",
|
|
25
|
+
"node-opcua-service-subscription": "2.179.0",
|
|
26
|
+
"node-opcua-service-write": "2.179.0",
|
|
27
|
+
"node-opcua-status-code": "2.179.0",
|
|
28
|
+
"node-opcua-utils": "2.179.0",
|
|
29
|
+
"node-opcua-variant": "2.179.0"
|
|
30
30
|
},
|
|
31
31
|
"author": "Etienne Rossignon",
|
|
32
32
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"internet of things"
|
|
44
44
|
],
|
|
45
45
|
"homepage": "http://node-opcua.github.io/",
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "c78c6ee424bae3c6e851fabd8e144390e2941f8a",
|
|
47
47
|
"files": [
|
|
48
48
|
"dist",
|
|
49
49
|
"source"
|
package/source/index.ts
CHANGED
|
@@ -3,32 +3,34 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { assert } from "node-opcua-assert";
|
|
6
|
+
import { DataTypeIds } from "node-opcua-constants";
|
|
6
7
|
import { AttributeIds, BrowseDirection, makeNodeClassMask, makeResultMask } from "node-opcua-data-model";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "node-opcua-
|
|
12
|
-
import { ReferenceDescription } from "node-opcua-service-browse";
|
|
13
|
-
import { CallMethodRequest, Argument } from "node-opcua-service-call";
|
|
8
|
+
import { make_debugLog } from "node-opcua-debug";
|
|
9
|
+
import type { NodeId } from "node-opcua-nodeid";
|
|
10
|
+
import type { IBasicSessionBrowseAsyncSimple, IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
|
|
11
|
+
import type { ReferenceDescription } from "node-opcua-service-browse";
|
|
12
|
+
import { type Argument, CallMethodRequest } from "node-opcua-service-call";
|
|
14
13
|
import { lowerFirstLetter } from "node-opcua-utils";
|
|
15
14
|
import { DataType, Variant, VariantArrayType } from "node-opcua-variant";
|
|
16
|
-
import { make_errorLog, make_debugLog } from "node-opcua-debug";
|
|
17
|
-
import { DataTypeIds } from "node-opcua-constants";
|
|
18
15
|
|
|
19
16
|
import { makeRefId } from "./proxy";
|
|
20
|
-
import {
|
|
17
|
+
import type { ArgumentEx, MethodDescription, ProxyBaseNode } from "./proxy_base_node";
|
|
18
|
+
import type { UAProxyManager } from "./proxy_manager";
|
|
21
19
|
import { ProxyVariable } from "./proxy_variable";
|
|
22
|
-
import { MethodDescription, ArgumentEx } from "./proxy_base_node";
|
|
23
20
|
|
|
24
21
|
const doDebug = false;
|
|
25
22
|
const debugLog = make_debugLog("Proxy");
|
|
26
23
|
|
|
24
|
+
// ProxyBaseNode plus the dynamically-named child properties (obj[browseName] = childNode)
|
|
25
|
+
// that add_component/add_property/addFolderElement/add_method install as they walk the
|
|
26
|
+
// address space; there is no way to know those names statically.
|
|
27
|
+
type ProxyNodeUnderConstruction = ProxyBaseNode & { [dynamicChildName: string]: unknown };
|
|
28
|
+
|
|
27
29
|
export interface ObjectExplorerOptions {
|
|
28
30
|
proxyManager: UAProxyManager;
|
|
29
31
|
name: string;
|
|
30
32
|
nodeId: NodeId;
|
|
31
|
-
parent:
|
|
33
|
+
parent: ProxyNodeUnderConstruction;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
const resultMask = makeResultMask("ReferenceType | IsForward | BrowseName | NodeClass | TypeDefinition");
|
|
@@ -82,7 +84,7 @@ async function convertNodeIdToDataTypeAsync(
|
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
if (dataTypeId.namespace === 0 && DataType[dataTypeId.value as number]) {
|
|
85
|
-
dataType = (DataType as
|
|
87
|
+
dataType = (DataType as unknown as Record<number, DataType>)[dataTypeId.value as number];
|
|
86
88
|
return dataType;
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -97,19 +99,18 @@ async function convertNodeIdToDataTypeAsync(
|
|
|
97
99
|
// xx nodeClassMask: makeNodeClassMask("ObjectType"),
|
|
98
100
|
resultMask
|
|
99
101
|
};
|
|
100
|
-
// tslint:disable:no-shadowed-variable
|
|
101
102
|
const browseResult = await session.browse(nodeToBrowse);
|
|
102
103
|
|
|
103
|
-
const references = browseResult
|
|
104
|
+
const references = browseResult?.references;
|
|
104
105
|
|
|
105
|
-
if (
|
|
106
|
-
throw new Error(
|
|
106
|
+
if (references?.length !== 1) {
|
|
107
|
+
throw new Error(`cannot find SuperType of ${dataTypeName.toString()}`);
|
|
107
108
|
}
|
|
108
109
|
const nodeId = references[0].nodeId;
|
|
109
110
|
return convertNodeIdToDataTypeAsync(session, nodeId);
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
function convertToVariant(value: unknown, arg: ArgumentEx,
|
|
113
|
+
function convertToVariant(value: unknown, arg: ArgumentEx, _propName: string): Variant {
|
|
113
114
|
const dataType = arg._basicDataType || DataType.Null;
|
|
114
115
|
const arrayType =
|
|
115
116
|
arg.valueRank === 1 ? VariantArrayType.Array : arg.valueRank === -1 ? VariantArrayType.Scalar : VariantArrayType.Matrix;
|
|
@@ -134,12 +135,19 @@ function convertToVariantArray(inputArgsDef: ArgumentEx[], inputArgs: Record<str
|
|
|
134
135
|
return inputArguments;
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
import {
|
|
138
|
-
import {
|
|
138
|
+
import type { StatusCode } from "node-opcua-status-code";
|
|
139
|
+
import type { ProxyNode } from "./proxy_transition";
|
|
139
140
|
|
|
140
|
-
function makeFunction(obj:
|
|
141
|
-
return async function functionCaller(
|
|
142
|
-
|
|
141
|
+
function makeFunction(obj: ProxyNodeUnderConstruction, methodName: string) {
|
|
142
|
+
return async function functionCaller(
|
|
143
|
+
this: ProxyNodeUnderConstruction,
|
|
144
|
+
inputArgs: Record<string, unknown>
|
|
145
|
+
): Promise<{ statusCode: StatusCode; output?: Record<string, unknown> }> {
|
|
146
|
+
// proxyManager is a private field of ProxyBaseNode, not part of its public shape;
|
|
147
|
+
// functionCaller is installed onto instances as a dynamic method (obj[methodName] =
|
|
148
|
+
// methodObj.func) and needs it at the call site regardless.
|
|
149
|
+
const proxyManager = (this as unknown as { proxyManager: UAProxyManager }).proxyManager;
|
|
150
|
+
const session = proxyManager.session;
|
|
143
151
|
|
|
144
152
|
const methodDef = this.$methods[methodName];
|
|
145
153
|
// convert input arguments into Variants
|
|
@@ -166,14 +174,14 @@ function makeFunction(obj: any, methodName: string) {
|
|
|
166
174
|
"Internal error callResult.outputArguments.length " +
|
|
167
175
|
callResult.outputArguments.length +
|
|
168
176
|
" " +
|
|
169
|
-
|
|
177
|
+
methodDef.outputArguments.length
|
|
170
178
|
);
|
|
171
179
|
}
|
|
172
180
|
const output: Record<string, unknown> = {};
|
|
173
|
-
methodDef.outputArguments.
|
|
174
|
-
const variant = callResult
|
|
175
|
-
const propName = lowerFirstLetter(arg.name
|
|
176
|
-
output[propName] = variant
|
|
181
|
+
methodDef.outputArguments.forEach((arg: Argument, index: number) => {
|
|
182
|
+
const variant = callResult?.outputArguments?.[index];
|
|
183
|
+
const propName = lowerFirstLetter(arg.name || "");
|
|
184
|
+
output[propName] = variant?.value;
|
|
177
185
|
});
|
|
178
186
|
|
|
179
187
|
return { statusCode: callResult.statusCode, output };
|
|
@@ -188,21 +196,24 @@ async function extractDataType(
|
|
|
188
196
|
return;
|
|
189
197
|
}
|
|
190
198
|
const dataType = await convertNodeIdToDataTypeAsync(session, arg.dataType);
|
|
191
|
-
arg._basicDataType = dataType
|
|
199
|
+
arg._basicDataType = dataType;
|
|
192
200
|
}
|
|
193
201
|
/**
|
|
194
202
|
|
|
195
203
|
* @private
|
|
196
204
|
*/
|
|
197
|
-
async function add_method(
|
|
205
|
+
async function add_method(
|
|
206
|
+
proxyManager: UAProxyManager,
|
|
207
|
+
obj: ProxyNodeUnderConstruction,
|
|
208
|
+
reference: ReferenceDescription
|
|
209
|
+
): Promise<void> {
|
|
198
210
|
const session = proxyManager.session;
|
|
199
211
|
|
|
200
|
-
const methodName = lowerFirstLetter(reference.browseName.name
|
|
212
|
+
const methodName = lowerFirstLetter(reference.browseName.name || "");
|
|
201
213
|
|
|
202
214
|
let inputArguments: ArgumentEx[] = [];
|
|
203
215
|
let outputArguments: ArgumentEx[] = [];
|
|
204
216
|
|
|
205
|
-
// tslint:disable:no-shadowed-variable
|
|
206
217
|
const argumentDefinition = await session.getArgumentDefinition(reference.nodeId);
|
|
207
218
|
inputArguments = (argumentDefinition.inputArguments as ArgumentEx[]) || [];
|
|
208
219
|
outputArguments = (argumentDefinition.outputArguments as ArgumentEx[]) || [];
|
|
@@ -219,22 +230,31 @@ async function add_method(proxyManager: UAProxyManager, obj: any, reference: Ref
|
|
|
219
230
|
const methodObj: MethodDescription = {
|
|
220
231
|
browseName: methodName,
|
|
221
232
|
executableFlag: false,
|
|
222
|
-
func: makeFunction(obj, methodName)
|
|
233
|
+
func: makeFunction(obj, methodName),
|
|
223
234
|
nodeId: reference.nodeId,
|
|
224
235
|
inputArguments,
|
|
225
236
|
outputArguments
|
|
226
237
|
};
|
|
227
238
|
obj.$methods[methodName] = methodObj;
|
|
228
|
-
obj[methodName]
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
239
|
+
// the callable is also exposed directly as obj[methodName](...), decorated with the
|
|
240
|
+
// same input/output argument metadata carried by methodObj, for convenience.
|
|
241
|
+
const callableMethod = methodObj.func as MethodDescription["func"] & {
|
|
242
|
+
inputArguments: ArgumentEx[];
|
|
243
|
+
outputArguments: ArgumentEx[];
|
|
244
|
+
};
|
|
245
|
+
callableMethod.inputArguments = inputArguments;
|
|
246
|
+
callableMethod.outputArguments = outputArguments;
|
|
247
|
+
obj[methodName] = callableMethod;
|
|
232
248
|
|
|
233
249
|
doDebug && debugLog("installing method name", methodName);
|
|
234
250
|
await proxyManager._monitor_execution_flag(methodObj);
|
|
235
251
|
}
|
|
236
252
|
|
|
237
|
-
async function add_component(
|
|
253
|
+
async function add_component(
|
|
254
|
+
proxyManager: UAProxyManager,
|
|
255
|
+
obj: ProxyNodeUnderConstruction,
|
|
256
|
+
reference: ReferenceDescription
|
|
257
|
+
): Promise<void> {
|
|
238
258
|
const name = lowerFirstLetter(reference.browseName.name || "");
|
|
239
259
|
await proxyManager.getObject(reference.nodeId);
|
|
240
260
|
const childObj = new ObjectExplorer({
|
|
@@ -244,12 +264,17 @@ async function add_component(proxyManager: UAProxyManager, obj: any, reference:
|
|
|
244
264
|
proxyManager
|
|
245
265
|
});
|
|
246
266
|
obj[name] = childObj;
|
|
247
|
-
|
|
267
|
+
// childObj is an unresolved placeholder here; $resolve() below pushes the real,
|
|
268
|
+
// fully-typed ProxyNode once the child has been fetched.
|
|
269
|
+
obj.$components.push(childObj as unknown as ProxyNode);
|
|
248
270
|
await childObj.$resolve();
|
|
249
271
|
}
|
|
250
272
|
|
|
251
|
-
async function addFolderElement(
|
|
252
|
-
|
|
273
|
+
async function addFolderElement(
|
|
274
|
+
proxyManager: UAProxyManager,
|
|
275
|
+
obj: ProxyNodeUnderConstruction,
|
|
276
|
+
reference: ReferenceDescription
|
|
277
|
+
): Promise<void> {
|
|
253
278
|
const name = lowerFirstLetter(reference.browseName.name || "");
|
|
254
279
|
|
|
255
280
|
const childObj = new ObjectExplorer({
|
|
@@ -260,19 +285,29 @@ async function addFolderElement(proxyManager: UAProxyManager, obj: any, referenc
|
|
|
260
285
|
});
|
|
261
286
|
|
|
262
287
|
obj[name] = childObj;
|
|
263
|
-
|
|
288
|
+
// childObj is an unresolved placeholder here; $resolve() below pushes the real,
|
|
289
|
+
// fully-typed ProxyNode once the child has been fetched.
|
|
290
|
+
obj.$organizes.push(childObj as unknown as ProxyNode);
|
|
264
291
|
await childObj.$resolve();
|
|
265
292
|
}
|
|
266
293
|
|
|
267
|
-
async function add_property(
|
|
268
|
-
|
|
294
|
+
async function add_property(
|
|
295
|
+
proxyManager: UAProxyManager,
|
|
296
|
+
obj: ProxyNodeUnderConstruction,
|
|
297
|
+
reference: ReferenceDescription
|
|
298
|
+
): Promise<void> {
|
|
269
299
|
const name = lowerFirstLetter(reference.browseName.name || "");
|
|
270
300
|
|
|
271
|
-
|
|
272
|
-
obj
|
|
301
|
+
const propertyNode = new ProxyVariable(proxyManager, reference.nodeId, reference);
|
|
302
|
+
obj[name] = propertyNode;
|
|
303
|
+
obj.$properties[name] = propertyNode;
|
|
273
304
|
}
|
|
274
305
|
|
|
275
|
-
async function add_typeDefinition(
|
|
306
|
+
async function add_typeDefinition(
|
|
307
|
+
_proxyManager: UAProxyManager,
|
|
308
|
+
obj: ProxyNodeUnderConstruction,
|
|
309
|
+
references: ReferenceDescription[]
|
|
310
|
+
): Promise<void> {
|
|
276
311
|
references = references || [];
|
|
277
312
|
if (references.length !== 1) {
|
|
278
313
|
return;
|
|
@@ -282,20 +317,28 @@ async function add_typeDefinition(proxyManager: UAProxyManager, obj: any, refere
|
|
|
282
317
|
obj.typeDefinition = reference.browseName.name || "";
|
|
283
318
|
}
|
|
284
319
|
|
|
285
|
-
async function addFromState(
|
|
320
|
+
async function addFromState(
|
|
321
|
+
proxyManager: UAProxyManager,
|
|
322
|
+
obj: ProxyNodeUnderConstruction,
|
|
323
|
+
reference: ReferenceDescription
|
|
324
|
+
): Promise<void> {
|
|
286
325
|
const childObj = await proxyManager.getObject(reference.nodeId);
|
|
287
326
|
obj.$fromState = childObj;
|
|
288
327
|
}
|
|
289
328
|
|
|
290
|
-
async function addToState(
|
|
329
|
+
async function addToState(
|
|
330
|
+
proxyManager: UAProxyManager,
|
|
331
|
+
obj: ProxyNodeUnderConstruction,
|
|
332
|
+
reference: ReferenceDescription
|
|
333
|
+
): Promise<void> {
|
|
291
334
|
const childObj = await proxyManager.getObject(reference.nodeId);
|
|
292
335
|
obj.$toState = childObj;
|
|
293
336
|
}
|
|
294
|
-
export class ObjectExplorer
|
|
337
|
+
export class ObjectExplorer {
|
|
295
338
|
public proxyManager: UAProxyManager;
|
|
296
339
|
public name: string;
|
|
297
340
|
public nodeId: NodeId;
|
|
298
|
-
public parent:
|
|
341
|
+
public parent: ProxyNodeUnderConstruction;
|
|
299
342
|
|
|
300
343
|
constructor(options: ObjectExplorerOptions) {
|
|
301
344
|
this.proxyManager = options.proxyManager;
|
|
@@ -313,10 +356,10 @@ export class ObjectExplorer {
|
|
|
313
356
|
|
|
314
357
|
function t(references: ReferenceDescription[] | null) {
|
|
315
358
|
if (!references) return "";
|
|
316
|
-
return references.map((r: ReferenceDescription) => r.browseName.name
|
|
359
|
+
return references.map((r: ReferenceDescription) => `${r.browseName.name} ${r.nodeId.toString()}`);
|
|
317
360
|
}
|
|
318
361
|
|
|
319
|
-
export async function readUAStructure(proxyManager: UAProxyManager, obj:
|
|
362
|
+
export async function readUAStructure(proxyManager: UAProxyManager, obj: ProxyNodeUnderConstruction): Promise<ProxyNode> {
|
|
320
363
|
const session = proxyManager.session;
|
|
321
364
|
|
|
322
365
|
// 0 Object
|
|
@@ -411,19 +454,15 @@ export async function readUAStructure(proxyManager: UAProxyManager, obj: { nodeI
|
|
|
411
454
|
for (const reference of browseResults[2].references || []) {
|
|
412
455
|
promises.push(add_method(proxyManager, obj, reference));
|
|
413
456
|
}
|
|
414
|
-
browseResults[3].references &&
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
browseResults[4].references &&
|
|
418
|
-
browseResults[4].references.length &&
|
|
419
|
-
promises.push(addFromState(proxyManager, obj, browseResults[4].references[0]));
|
|
420
|
-
browseResults[5].references &&
|
|
421
|
-
browseResults[5].references.length &&
|
|
422
|
-
promises.push(addToState(proxyManager, obj, browseResults[5].references[0]));
|
|
457
|
+
browseResults[3].references?.length && promises.push(add_typeDefinition(proxyManager, obj, browseResults[3].references || []));
|
|
458
|
+
browseResults[4].references?.length && promises.push(addFromState(proxyManager, obj, browseResults[4].references[0]));
|
|
459
|
+
browseResults[5].references?.length && promises.push(addToState(proxyManager, obj, browseResults[5].references[0]));
|
|
423
460
|
for (const reference of browseResults[6].references || []) {
|
|
424
461
|
promises.push(addFolderElement(proxyManager, obj, reference));
|
|
425
462
|
}
|
|
426
463
|
|
|
427
464
|
await Promise.all(promises);
|
|
428
|
-
|
|
465
|
+
// $fromState/$toState are only ever set dynamically (addFromState/addToState above), so
|
|
466
|
+
// ProxyNodeUnderConstruction's index signature can't statically prove they're present.
|
|
467
|
+
return obj as unknown as ProxyNode;
|
|
429
468
|
}
|
package/source/proxy.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-client-proxy
|
|
3
3
|
*/
|
|
4
|
-
// tslint:disable:no-shadowed-variable
|
|
5
4
|
import { ObjectTypeIds, ReferenceTypeIds } from "node-opcua-constants";
|
|
6
|
-
import { makeNodeId, NodeId } from "node-opcua-nodeid";
|
|
5
|
+
import { makeNodeId, type NodeId } from "node-opcua-nodeid";
|
|
7
6
|
|
|
8
7
|
export function makeRefId(referenceTypeName: string): NodeId {
|
|
9
|
-
const nodeId = makeNodeId(
|
|
8
|
+
const nodeId = makeNodeId(
|
|
9
|
+
(ReferenceTypeIds as unknown as Record<string, number>)[referenceTypeName] ||
|
|
10
|
+
(ObjectTypeIds as unknown as Record<string, number>)[referenceTypeName]
|
|
11
|
+
);
|
|
10
12
|
|
|
11
13
|
// c8 ignore next
|
|
12
14
|
if (nodeId.isEmpty()) {
|
|
13
|
-
throw new Error(
|
|
15
|
+
throw new Error(`makeRefId: cannot find ReferenceTypeName + ${referenceTypeName}`);
|
|
14
16
|
}
|
|
15
17
|
return nodeId;
|
|
16
18
|
}
|