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.
@@ -8,8 +8,8 @@ export declare class UaDataType extends UaDefintionNode {
8
8
  get nodeClass(): NodeClass;
9
9
  get valueType(): number;
10
10
  get enumValues(): Map<number, UaLocalizedText> | null;
11
- setEnumVariable(node: UaVariable): void;
12
- setEnumValues(value: UaVariant): void;
13
11
  classify(): void;
14
12
  toJson(): any;
13
+ setEnumVariable(node: UaVariable): void;
14
+ setEnumValues(value: UaVariant): void;
15
15
  }
@@ -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
- value: item[0],
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 == 0) ? enumValues : undefined
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
- typeDefinition: this._typeDefinitionId.toString(),
62
+ typeDefinitionId: this._typeDefinitionId.toString(),
63
63
  eventNotifier: this._eventNotifier,
64
64
  children: (children.length != 0) ? children : undefined
65
65
  };
@@ -1,5 +1,5 @@
1
1
  import { NodeClass } from "opcua-webapi";
2
- import { UaLocalizedText, UaNodeId, UaVariant } from "../types";
2
+ import { UaDataValue, UaLocalizedText, UaNodeId, UaVariant } from "../types";
3
3
  import { UaInstanceNode } from ".";
4
4
  export declare class UaVariable extends UaInstanceNode {
5
5
  private _typeDefinitionId;
@@ -8,7 +8,7 @@ export declare class UaVariable extends UaInstanceNode {
8
8
  private _accessLevel;
9
9
  private _userAccessLevel;
10
10
  private _historizing;
11
- private _value;
11
+ private _dataValue;
12
12
  constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, dataType: UaNodeId, valueRank: number, accessLevel: number, userAccessLevel: number, historizing: boolean, typeDefinitionId: UaNodeId);
13
13
  get nodeClass(): NodeClass;
14
14
  get dataType(): UaNodeId;
@@ -16,8 +16,9 @@ export declare class UaVariable extends UaInstanceNode {
16
16
  get accessLevel(): number;
17
17
  get userAccessLevel(): number;
18
18
  get historizing(): boolean;
19
- get value(): UaVariant;
20
- set value(val: UaVariant);
19
+ get value(): UaVariant | null;
20
+ get dataValue(): UaDataValue | null;
21
+ set dataValue(value: UaDataValue);
21
22
  get typeDefinitionId(): UaNodeId;
22
23
  addMember(node: UaVariable): void;
23
24
  get variableMembers(): Array<UaVariable>;
@@ -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._value;
36
+ return (this._dataValue && this._dataValue.statusCode.isGood()) ? this._dataValue.value : null;
38
37
  }
39
- set value(val) {
40
- this._value = val;
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
- typeDefinition: this._typeDefinitionId.toString(),
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,23 @@
1
+ import { UaLocalizedText, UaNodeId } from "../types";
2
+ export declare class UaReference {
3
+ private _nodeId;
4
+ private _nodeClass;
5
+ private _browseName;
6
+ private _displayName;
7
+ private _referenceTypeId;
8
+ private _typeDefinitionId;
9
+ private _description;
10
+ constructor(nodeId: UaNodeId, nodeClass: number, browseName?: string, displayName?: UaLocalizedText, referenceTypeId?: UaNodeId, typeDefinitionId?: UaNodeId);
11
+ get nodeId(): UaNodeId;
12
+ get nodeClass(): number;
13
+ get browseName(): string;
14
+ get displayName(): UaLocalizedText;
15
+ set displayName(value: UaLocalizedText);
16
+ get referenceTypeId(): UaNodeId;
17
+ set referenceTypeId(value: UaNodeId);
18
+ get typeDefinitionId(): UaNodeId;
19
+ set typeDefinitionId(value: UaNodeId);
20
+ get description(): UaLocalizedText;
21
+ set description(value: UaLocalizedText);
22
+ toJson(): any;
23
+ }
@@ -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;
@@ -7,7 +7,6 @@ export * from "./UaHistoryDataResult";
7
7
  export * from "./UaHistoryEventFieldList";
8
8
  export * from "./UaHistoryEventResult";
9
9
  export * from "./UaLocalizedText";
10
- export * from "./UaLink";
11
10
  export * from "./UaNodeId";
12
11
  export * from "./UaQuery";
13
12
  export * from "./UaQueryFilter";
@@ -18,3 +17,4 @@ export * from "./UaAccessLevel";
18
17
  export * from "./UaBrowseMask";
19
18
  export * from "./UaValueRank";
20
19
  export * from "./UaWriteMask";
20
+ export * from "./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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opcua-webapi-ts",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "Provides OPC UA WebAPI wrapper and client based on opcua-webapi-typescript",
5
5
  "author": "DingYan",
6
6
  "main": "./dist/cjs/index.js",