opcua-webapi-ts 1.1.5 → 1.1.6
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/cjs/client/utils/UaNodeReader.js +439 -517
- package/dist/cjs/common/nodes/UaDataType.js +35 -34
- package/dist/cjs/common/nodes/UaMethod.js +2 -2
- package/dist/cjs/common/nodes/UaObject.js +1 -1
- package/dist/cjs/common/nodes/UaVariable.js +10 -6
- package/dist/cjs/common/types/UaReference.js +59 -0
- package/dist/cjs/common/types/index.js +1 -1
- package/dist/client/utils/UaNodeReader.d.ts +45 -73
- package/dist/client/utils/UaNodeReader.js +439 -517
- package/dist/common/nodes/UaDataType.d.ts +2 -2
- package/dist/common/nodes/UaDataType.js +35 -34
- package/dist/common/nodes/UaMethod.js +2 -2
- package/dist/common/nodes/UaObject.js +1 -1
- package/dist/common/nodes/UaVariable.d.ts +5 -4
- package/dist/common/nodes/UaVariable.js +10 -6
- package/dist/common/types/UaReference.d.ts +23 -0
- package/dist/common/types/UaReference.js +59 -0
- package/dist/common/types/index.d.ts +1 -1
- package/dist/common/types/index.js +1 -1
- package/package.json +1 -1
|
@@ -20,38 +20,6 @@ class UaDataType extends _1.UaDefintionNode {
|
|
|
20
20
|
get enumValues() {
|
|
21
21
|
return this._enumValues;
|
|
22
22
|
}
|
|
23
|
-
setEnumVariable(node) {
|
|
24
|
-
if ("EnumStrings" == node.browseName ||
|
|
25
|
-
"EnumValues" == node.browseName) {
|
|
26
|
-
this.setEnumValues(node.value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
setEnumValues(value) {
|
|
30
|
-
if (types_1.UaVariantType.LocalizedText == value.type) {
|
|
31
|
-
let enumStrings = value.toLocalizedTexts();
|
|
32
|
-
if (null == enumStrings)
|
|
33
|
-
return;
|
|
34
|
-
this._enumValues = new Map;
|
|
35
|
-
let index = 0;
|
|
36
|
-
for (let item of enumStrings) {
|
|
37
|
-
this._enumValues.set(index, item);
|
|
38
|
-
index++;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else if (types_1.UaVariantType.ExtensionObject == value.type) {
|
|
42
|
-
let extensionObjects = value.toExtensionObjects();
|
|
43
|
-
if (null == extensionObjects)
|
|
44
|
-
return;
|
|
45
|
-
let enumValues = new Map;
|
|
46
|
-
for (let item of extensionObjects) {
|
|
47
|
-
let enumValue = structure_1.UaEnumValueType.fromExtensionObject(item);
|
|
48
|
-
if (!enumValue)
|
|
49
|
-
return;
|
|
50
|
-
enumValues.set(enumValue.value, enumValue.displayName);
|
|
51
|
-
}
|
|
52
|
-
this._enumValues = enumValues;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
23
|
classify() {
|
|
56
24
|
let isBasicDataType = false;
|
|
57
25
|
if (0 == this._nodeId.nsIndex) {
|
|
@@ -73,7 +41,7 @@ class UaDataType extends _1.UaDefintionNode {
|
|
|
73
41
|
if (this._enumValues) {
|
|
74
42
|
for (let item of this._enumValues) {
|
|
75
43
|
enumValues.push({
|
|
76
|
-
|
|
44
|
+
index: item[0],
|
|
77
45
|
text: item[1].text
|
|
78
46
|
});
|
|
79
47
|
}
|
|
@@ -85,9 +53,42 @@ class UaDataType extends _1.UaDefintionNode {
|
|
|
85
53
|
displayName: this._displayName.text,
|
|
86
54
|
description: (this._description) ? this._description.text : undefined,
|
|
87
55
|
isAbstract: this._isAbstract,
|
|
88
|
-
enumValues: (enumValues.length
|
|
56
|
+
enumValues: (enumValues.length != 0) ? enumValues : undefined
|
|
89
57
|
};
|
|
90
58
|
return ret;
|
|
91
59
|
}
|
|
60
|
+
setEnumVariable(node) {
|
|
61
|
+
if ("EnumStrings" == node.browseName ||
|
|
62
|
+
"EnumValues" == node.browseName) {
|
|
63
|
+
if (node.value)
|
|
64
|
+
this.setEnumValues(node.value);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
setEnumValues(value) {
|
|
68
|
+
if (types_1.UaVariantType.LocalizedText == value.type) {
|
|
69
|
+
let enumStrings = value.toLocalizedTexts();
|
|
70
|
+
if (null == enumStrings)
|
|
71
|
+
return;
|
|
72
|
+
this._enumValues = new Map;
|
|
73
|
+
let index = 0;
|
|
74
|
+
for (let item of enumStrings) {
|
|
75
|
+
this._enumValues.set(index, item);
|
|
76
|
+
index++;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (types_1.UaVariantType.ExtensionObject == value.type) {
|
|
80
|
+
let extensionObjects = value.toExtensionObjects();
|
|
81
|
+
if (null == extensionObjects)
|
|
82
|
+
return;
|
|
83
|
+
let enumValues = new Map;
|
|
84
|
+
for (let item of extensionObjects) {
|
|
85
|
+
let enumValue = structure_1.UaEnumValueType.fromExtensionObject(item);
|
|
86
|
+
if (!enumValue)
|
|
87
|
+
return;
|
|
88
|
+
enumValues.set(enumValue.value, enumValue.displayName);
|
|
89
|
+
}
|
|
90
|
+
this._enumValues = enumValues;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
92
93
|
}
|
|
93
94
|
exports.UaDataType = UaDataType;
|
|
@@ -66,8 +66,8 @@ class UaMethod extends _1.UaInstanceNode {
|
|
|
66
66
|
name: this._browseName,
|
|
67
67
|
displayName: this._displayName.text,
|
|
68
68
|
description: (this._description) ? this._description.text : undefined,
|
|
69
|
-
inputArguments: inputArgs,
|
|
70
|
-
outputArguments: outputArgs
|
|
69
|
+
inputArguments: (inputArgs.length != 0) ? inputArgs : undefined,
|
|
70
|
+
outputArguments: (outputArgs.length != 0) ? outputArgs : undefined
|
|
71
71
|
};
|
|
72
72
|
return ret;
|
|
73
73
|
}
|
|
@@ -59,7 +59,7 @@ class UaObject extends _1.UaInstanceNode {
|
|
|
59
59
|
name: this._browseName,
|
|
60
60
|
displayName: this._displayName.text,
|
|
61
61
|
description: (this._description) ? this._description.text : undefined,
|
|
62
|
-
|
|
62
|
+
typeDefinitionId: this._typeDefinitionId.toString(),
|
|
63
63
|
eventNotifier: this._eventNotifier,
|
|
64
64
|
children: (children.length != 0) ? children : undefined
|
|
65
65
|
};
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UaVariable = void 0;
|
|
4
4
|
const opcua_webapi_1 = require("opcua-webapi");
|
|
5
|
-
const types_1 = require("../types");
|
|
6
5
|
const _1 = require(".");
|
|
7
6
|
class UaVariable extends _1.UaInstanceNode {
|
|
8
7
|
constructor(nodeId, browseName, displayName, dataType, valueRank, accessLevel, userAccessLevel, historizing, typeDefinitionId) {
|
|
@@ -12,8 +11,8 @@ class UaVariable extends _1.UaInstanceNode {
|
|
|
12
11
|
this._accessLevel = accessLevel;
|
|
13
12
|
this._userAccessLevel = userAccessLevel;
|
|
14
13
|
this._historizing = historizing;
|
|
15
|
-
this._value = types_1.UaVariant.null();
|
|
16
14
|
this._typeDefinitionId = typeDefinitionId;
|
|
15
|
+
this._dataValue = null;
|
|
17
16
|
}
|
|
18
17
|
get nodeClass() {
|
|
19
18
|
return opcua_webapi_1.NodeClass.Variable;
|
|
@@ -34,10 +33,13 @@ class UaVariable extends _1.UaInstanceNode {
|
|
|
34
33
|
return this._historizing;
|
|
35
34
|
}
|
|
36
35
|
get value() {
|
|
37
|
-
return this.
|
|
36
|
+
return (this._dataValue && this._dataValue.statusCode.isGood()) ? this._dataValue.value : null;
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
this.
|
|
38
|
+
get dataValue() {
|
|
39
|
+
return this._dataValue;
|
|
40
|
+
}
|
|
41
|
+
set dataValue(value) {
|
|
42
|
+
this._dataValue = value;
|
|
41
43
|
}
|
|
42
44
|
get typeDefinitionId() {
|
|
43
45
|
return this._typeDefinitionId;
|
|
@@ -64,10 +66,12 @@ class UaVariable extends _1.UaInstanceNode {
|
|
|
64
66
|
nodeClass: opcua_webapi_1.NodeClass.Variable,
|
|
65
67
|
name: this._browseName,
|
|
66
68
|
displayName: this._displayName.text,
|
|
67
|
-
|
|
69
|
+
typeDefinitionId: this._typeDefinitionId.toString(),
|
|
68
70
|
dataType: this._dataType.toString(),
|
|
69
71
|
valueRank: this._valueRank,
|
|
70
72
|
accessLevel: this._accessLevel,
|
|
73
|
+
historizing: this._historizing,
|
|
74
|
+
value: this._dataValue ? this._dataValue.value.value : undefined,
|
|
71
75
|
children: (children.length != 0) ? children : undefined
|
|
72
76
|
};
|
|
73
77
|
return ret;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UaReference = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
class UaReference {
|
|
6
|
+
constructor(nodeId, nodeClass, browseName, displayName, referenceTypeId, typeDefinitionId) {
|
|
7
|
+
this._nodeId = nodeId;
|
|
8
|
+
this._nodeClass = nodeClass;
|
|
9
|
+
this._browseName = (browseName) ? browseName : "";
|
|
10
|
+
this._displayName = (displayName) ? displayName : types_1.UaLocalizedText.nullText;
|
|
11
|
+
this._referenceTypeId = (referenceTypeId) ? referenceTypeId : types_1.UaNodeId.nullNodeId;
|
|
12
|
+
this._typeDefinitionId = (typeDefinitionId) ? typeDefinitionId : types_1.UaNodeId.nullNodeId;
|
|
13
|
+
}
|
|
14
|
+
get nodeId() {
|
|
15
|
+
return this._nodeId;
|
|
16
|
+
}
|
|
17
|
+
get nodeClass() {
|
|
18
|
+
return this._nodeClass;
|
|
19
|
+
}
|
|
20
|
+
get browseName() {
|
|
21
|
+
return this._browseName;
|
|
22
|
+
}
|
|
23
|
+
get displayName() {
|
|
24
|
+
return this._displayName;
|
|
25
|
+
}
|
|
26
|
+
set displayName(value) {
|
|
27
|
+
this._displayName = value;
|
|
28
|
+
}
|
|
29
|
+
get referenceTypeId() {
|
|
30
|
+
return this._referenceTypeId;
|
|
31
|
+
}
|
|
32
|
+
set referenceTypeId(value) {
|
|
33
|
+
this._referenceTypeId = value;
|
|
34
|
+
}
|
|
35
|
+
get typeDefinitionId() {
|
|
36
|
+
return this._typeDefinitionId;
|
|
37
|
+
}
|
|
38
|
+
set typeDefinitionId(value) {
|
|
39
|
+
this._typeDefinitionId = value;
|
|
40
|
+
}
|
|
41
|
+
get description() {
|
|
42
|
+
return this._description;
|
|
43
|
+
}
|
|
44
|
+
set description(value) {
|
|
45
|
+
this._description = value;
|
|
46
|
+
}
|
|
47
|
+
toJson() {
|
|
48
|
+
let ret = {
|
|
49
|
+
nodeId: this._nodeId.toString(),
|
|
50
|
+
nodeClass: this._nodeClass,
|
|
51
|
+
name: this._browseName,
|
|
52
|
+
displayName: this._displayName.text,
|
|
53
|
+
description: (this._description) ? this._description.text : undefined,
|
|
54
|
+
typeDefinitionId: (!this._typeDefinitionId.isEmpty()) ? this._typeDefinitionId.toString() : undefined,
|
|
55
|
+
};
|
|
56
|
+
return ret;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.UaReference = UaReference;
|
|
@@ -23,7 +23,6 @@ __exportStar(require("./UaHistoryDataResult"), exports);
|
|
|
23
23
|
__exportStar(require("./UaHistoryEventFieldList"), exports);
|
|
24
24
|
__exportStar(require("./UaHistoryEventResult"), exports);
|
|
25
25
|
__exportStar(require("./UaLocalizedText"), exports);
|
|
26
|
-
__exportStar(require("./UaLink"), exports);
|
|
27
26
|
__exportStar(require("./UaNodeId"), exports);
|
|
28
27
|
__exportStar(require("./UaQuery"), exports);
|
|
29
28
|
__exportStar(require("./UaQueryFilter"), exports);
|
|
@@ -34,3 +33,4 @@ __exportStar(require("./UaAccessLevel"), exports);
|
|
|
34
33
|
__exportStar(require("./UaBrowseMask"), exports);
|
|
35
34
|
__exportStar(require("./UaValueRank"), exports);
|
|
36
35
|
__exportStar(require("./UaWriteMask"), exports);
|
|
36
|
+
__exportStar(require("./UaReference"), exports);
|
|
@@ -1,88 +1,60 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UaNode, UaNodeId, UaReference } from "../../common";
|
|
2
2
|
import { UaWebClient } from "../UaWebClient";
|
|
3
|
-
type
|
|
3
|
+
export type BrowseReferenceResult = {
|
|
4
4
|
nodeId: UaNodeId;
|
|
5
|
-
|
|
5
|
+
references: Array<UaReference>;
|
|
6
6
|
};
|
|
7
|
-
type
|
|
8
|
-
nodeId: UaNodeId;
|
|
9
|
-
continuationPoint: string;
|
|
10
|
-
};
|
|
11
|
-
type BrowseResult = {
|
|
12
|
-
fromNodeId: UaNodeId;
|
|
13
|
-
nodeId: UaNodeId;
|
|
14
|
-
nodeClass: number;
|
|
15
|
-
browseName: string;
|
|
16
|
-
displayName: UaLocalizedText;
|
|
17
|
-
referenceTypeId: UaNodeId;
|
|
18
|
-
isForward?: boolean;
|
|
19
|
-
typeDefinitionId?: UaNodeId;
|
|
20
|
-
};
|
|
21
|
-
type ReadResult = {
|
|
22
|
-
parentId: UaNodeId;
|
|
23
|
-
node: UaNode;
|
|
24
|
-
};
|
|
25
|
-
export type ReadChildResult = {
|
|
7
|
+
export type ReadChildNodeResult = {
|
|
26
8
|
nodeId: UaNodeId;
|
|
27
9
|
children: Array<UaNode>;
|
|
28
10
|
};
|
|
29
|
-
export
|
|
30
|
-
nodeId: UaNodeId;
|
|
31
|
-
links: Array<UaLink>;
|
|
32
|
-
};
|
|
33
|
-
export declare abstract class UaNodeReaderBase {
|
|
34
|
-
protected _finished: boolean;
|
|
35
|
-
protected _nodesToBrowse: Array<NodeToBrowse>;
|
|
36
|
-
protected _continuationPointToBrowse: Array<CpToBrowse>;
|
|
37
|
-
protected _browseResults: Array<BrowseResult>;
|
|
38
|
-
protected _readResults: Map<string, ReadResult>;
|
|
39
|
-
protected _nodeClassToReturn: number;
|
|
40
|
-
protected _returnDescription: boolean;
|
|
41
|
-
private static s_variableTypeWithoutMember;
|
|
42
|
-
private static s_variableNameToReadValue;
|
|
43
|
-
constructor(returnDescription: boolean, returnVariables: boolean, returnMethod: boolean);
|
|
44
|
-
protected _browseNodes(client: UaWebClient): Promise<void>;
|
|
45
|
-
protected _browseContinuationPoints(client: UaWebClient): Promise<void>;
|
|
46
|
-
protected _readNodes(client: UaWebClient): Promise<void>;
|
|
47
|
-
protected _buildNodeTree(): void;
|
|
48
|
-
private _readTypes;
|
|
49
|
-
private _readObjects;
|
|
50
|
-
private _readVariables;
|
|
51
|
-
private _readMethods;
|
|
52
|
-
private _updateNodesToBrowse;
|
|
53
|
-
}
|
|
54
|
-
export declare class UaNodeReader extends UaNodeReaderBase {
|
|
55
|
-
private _nodeIds;
|
|
56
|
-
private _isRootNodeRead;
|
|
57
|
-
constructor(nodeIds: Array<UaNodeId>, returnDescription?: boolean | null, returnVariables?: boolean | null, returnMethod?: boolean | null);
|
|
58
|
-
readAll(client: UaWebClient): Promise<void>;
|
|
59
|
-
read(client: UaWebClient): Promise<void>;
|
|
60
|
-
isFinish(): boolean;
|
|
61
|
-
getResults(): Array<UaNode>;
|
|
62
|
-
private _readRootNodes;
|
|
63
|
-
}
|
|
64
|
-
export declare class UaNodeChildReader extends UaNodeReaderBase {
|
|
65
|
-
private _nodeIds;
|
|
66
|
-
constructor(nodeIds: Array<UaNodeId>, returnDescription?: boolean | null, returnVariables?: boolean | null, returnMethod?: boolean | null);
|
|
67
|
-
readAll(client: UaWebClient): Promise<void>;
|
|
68
|
-
read(client: UaWebClient): Promise<void>;
|
|
69
|
-
isFinish(): boolean;
|
|
70
|
-
getResults(): Array<ReadChildResult>;
|
|
71
|
-
}
|
|
72
|
-
export declare class UaNodeLinkReader {
|
|
11
|
+
export declare class UaNodeReferenceBrowser {
|
|
73
12
|
private _nodesToBrowse;
|
|
74
13
|
private _continuationPointToBrowse;
|
|
75
|
-
private
|
|
14
|
+
private _referenceType;
|
|
15
|
+
private _nodeClassToReturn;
|
|
76
16
|
private _returnDescription;
|
|
17
|
+
private _maxNodesPerBrowse;
|
|
18
|
+
private _maxReferencesPerNode;
|
|
77
19
|
private _readResults;
|
|
78
|
-
constructor(nodeIds: Array<UaNodeId>, returnDescription
|
|
79
|
-
|
|
80
|
-
|
|
20
|
+
constructor(nodeIds: Array<UaNodeId>, referenceType: UaNodeId, nodeClassToReturn: number, returnDescription: boolean, maxNodesPerBrowse?: number | null, maxReferencesPerNode?: number | null);
|
|
21
|
+
browse(client: UaWebClient): Promise<void>;
|
|
22
|
+
browseOnce(client: UaWebClient): Promise<void>;
|
|
23
|
+
results(): Array<BrowseReferenceResult>;
|
|
81
24
|
isFinish(): boolean;
|
|
82
|
-
getResults(): Array<ReadLinkResult>;
|
|
83
25
|
private _browseNodes;
|
|
84
26
|
private _browseContinuationPoints;
|
|
85
|
-
private _buildResults;
|
|
86
27
|
private _readDescriptions;
|
|
87
28
|
}
|
|
88
|
-
export {
|
|
29
|
+
export declare class UaChildBrowser extends UaNodeReferenceBrowser {
|
|
30
|
+
constructor(nodeIds: Array<UaNodeId>, returnDescription?: boolean);
|
|
31
|
+
}
|
|
32
|
+
export declare class UaLinkBrowser extends UaNodeReferenceBrowser {
|
|
33
|
+
constructor(nodeIds: Array<UaNodeId>, returnDescription?: boolean);
|
|
34
|
+
}
|
|
35
|
+
export declare class UaNodeReader {
|
|
36
|
+
private _nodeClassToReturn;
|
|
37
|
+
private _returnDescription;
|
|
38
|
+
private _returnAttributes;
|
|
39
|
+
private _returnValue;
|
|
40
|
+
private static s_variableTypeWithoutMember;
|
|
41
|
+
private static s_variablesNameToRead;
|
|
42
|
+
constructor(returnDescription?: boolean | null, returnVariable?: boolean | null, returnMethod?: boolean | null, returnAttributes?: boolean | null, returnValue?: boolean | null);
|
|
43
|
+
read(nodeIds: Array<UaNodeId>, client: UaWebClient): Promise<Array<UaNode>>;
|
|
44
|
+
readByReferences(references: Array<UaReference>, client: UaWebClient): Promise<Array<UaNode>>;
|
|
45
|
+
private _readRootNodes;
|
|
46
|
+
private _readNodes;
|
|
47
|
+
private _readTypes;
|
|
48
|
+
private _readObjects;
|
|
49
|
+
private _readVariables;
|
|
50
|
+
private _readMethods;
|
|
51
|
+
private _buildNodeTree;
|
|
52
|
+
}
|
|
53
|
+
export declare class UaObjectReader extends UaNodeReader {
|
|
54
|
+
constructor(returnDescription?: boolean | null, returnValue?: boolean | null);
|
|
55
|
+
read(nodeIds: Array<UaNodeId>, client: UaWebClient): Promise<Array<UaNode>>;
|
|
56
|
+
}
|
|
57
|
+
export declare class UaTypeReader extends UaNodeReader {
|
|
58
|
+
constructor();
|
|
59
|
+
read(nodeIds: Array<UaNodeId>, client: UaWebClient): Promise<Array<UaNode>>;
|
|
60
|
+
}
|