opcua-webapi-ts 1.1.26 → 1.1.27

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.
@@ -18,7 +18,7 @@ class UaObjectSerializer {
18
18
  let propertyJson = {
19
19
  name: variable.browseName,
20
20
  displayName: variable.displayName.text,
21
- value: (variable.value) ? variable.value.value : null
21
+ value: (variable.value) ? variable.value.jsonValue() : null
22
22
  };
23
23
  properties.push(propertyJson);
24
24
  }
@@ -12,6 +12,7 @@ class UaNode {
12
12
  this._writeMask = null;
13
13
  this._parent = null;
14
14
  this._children = [];
15
+ this._customizedData = null;
15
16
  }
16
17
  get nodeId() {
17
18
  return this._nodeId;
@@ -34,6 +35,12 @@ class UaNode {
34
35
  set description(description) {
35
36
  this._description = description;
36
37
  }
38
+ get customizedData() {
39
+ return this._customizedData;
40
+ }
41
+ set customizedData(customizedData) {
42
+ this._customizedData = customizedData;
43
+ }
37
44
  }
38
45
  exports.UaNode = UaNode;
39
46
  class UaDefinitionNode extends UaNode {
@@ -78,7 +78,7 @@ class UaVariable extends _1.UaInstanceNode {
78
78
  valueRank: (this._valueRank != 0) ? this._valueRank : undefined,
79
79
  accessLevel: this._accessLevel,
80
80
  historizing: (this._historizing) ? true : undefined,
81
- value: this._dataValue ? this._dataValue.value.value : undefined,
81
+ value: this._dataValue ? this._dataValue.value.jsonValue() : undefined,
82
82
  members: (members.length != 0) ? members : undefined
83
83
  };
84
84
  return ret;
@@ -18,6 +18,89 @@ class UaVariant {
18
18
  get arrayType() {
19
19
  return this._arrayType;
20
20
  }
21
+ jsonValue() {
22
+ if (UaVariantType.NodeId == this._type) {
23
+ if (this.isScalar()) {
24
+ return this._value.toString();
25
+ }
26
+ else {
27
+ let nodeIds = this._value;
28
+ let value = [];
29
+ for (let item of nodeIds) {
30
+ value.push(item.toString());
31
+ }
32
+ return value;
33
+ }
34
+ }
35
+ else if (UaVariantType.ExpandedNodeId == this._type) {
36
+ if (this.isScalar()) {
37
+ return this._value.toString();
38
+ }
39
+ else {
40
+ let nodeIds = this._value;
41
+ let value = [];
42
+ for (let item of nodeIds) {
43
+ value.push(item.toString());
44
+ }
45
+ return value;
46
+ }
47
+ }
48
+ else if (UaVariantType.DateTime == this._type) {
49
+ if (this.isScalar()) {
50
+ return this._value.toISOString();
51
+ }
52
+ else {
53
+ let dateTimes = this._value;
54
+ let value = [];
55
+ for (let item of dateTimes) {
56
+ value.push(item.toISOString());
57
+ }
58
+ return value;
59
+ }
60
+ }
61
+ else if (UaVariantType.LocalizedText == this._type) {
62
+ if (this.isScalar()) {
63
+ return this._value.text;
64
+ }
65
+ else {
66
+ let localizedTexts = this._value;
67
+ let value = [];
68
+ for (let item of localizedTexts) {
69
+ value.push(item.text);
70
+ }
71
+ return value;
72
+ }
73
+ }
74
+ else if (UaVariantType.StatusCode == this._type) {
75
+ if (this.isScalar()) {
76
+ return this._value.toString();
77
+ }
78
+ else {
79
+ let statusCodes = this._value;
80
+ let value = [];
81
+ for (let item of statusCodes) {
82
+ value.push(item.toString());
83
+ }
84
+ return value;
85
+ }
86
+ }
87
+ else if (UaVariantType.ExtensionObject == this._type) {
88
+ if (this.isScalar()) {
89
+ return this._value.body;
90
+ }
91
+ else {
92
+ let extensionObjects = this._value;
93
+ let value = [];
94
+ for (let item of extensionObjects) {
95
+ value.push(item.body);
96
+ }
97
+ return value;
98
+ }
99
+ }
100
+ else {
101
+ return this._value;
102
+ }
103
+ }
21
104
  isScalar() {
22
105
  return (UaArrayType.Scalar == this._arrayType) ? true : false;
23
106
  }
@@ -18,7 +18,7 @@ class UaObjectSerializer {
18
18
  let propertyJson = {
19
19
  name: variable.browseName,
20
20
  displayName: variable.displayName.text,
21
- value: (variable.value) ? variable.value.value : null
21
+ value: (variable.value) ? variable.value.jsonValue() : null
22
22
  };
23
23
  properties.push(propertyJson);
24
24
  }
@@ -8,6 +8,7 @@ export declare abstract class UaNode {
8
8
  protected _writeMask: number | null;
9
9
  protected _parent: UaNode | null;
10
10
  protected _children: Array<UaNode>;
11
+ private _customizedData;
11
12
  constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText);
12
13
  abstract get nodeClass(): NodeClass;
13
14
  get nodeId(): UaNodeId;
@@ -17,6 +18,8 @@ export declare abstract class UaNode {
17
18
  set writeMask(writeMask: number);
18
19
  get description(): UaLocalizedText | null;
19
20
  set description(description: UaLocalizedText | null);
21
+ get customizedData(): any | null;
22
+ set customizedData(customizedData: any | null);
20
23
  abstract toJson(): any;
21
24
  }
22
25
  export declare abstract class UaDefinitionNode extends UaNode {
@@ -12,6 +12,7 @@ class UaNode {
12
12
  this._writeMask = null;
13
13
  this._parent = null;
14
14
  this._children = [];
15
+ this._customizedData = null;
15
16
  }
16
17
  get nodeId() {
17
18
  return this._nodeId;
@@ -34,6 +35,12 @@ class UaNode {
34
35
  set description(description) {
35
36
  this._description = description;
36
37
  }
38
+ get customizedData() {
39
+ return this._customizedData;
40
+ }
41
+ set customizedData(customizedData) {
42
+ this._customizedData = customizedData;
43
+ }
37
44
  }
38
45
  exports.UaNode = UaNode;
39
46
  class UaDefinitionNode extends UaNode {
@@ -78,7 +78,7 @@ class UaVariable extends _1.UaInstanceNode {
78
78
  valueRank: (this._valueRank != 0) ? this._valueRank : undefined,
79
79
  accessLevel: this._accessLevel,
80
80
  historizing: (this._historizing) ? true : undefined,
81
- value: this._dataValue ? this._dataValue.value.value : undefined,
81
+ value: this._dataValue ? this._dataValue.value.jsonValue() : undefined,
82
82
  members: (members.length != 0) ? members : undefined
83
83
  };
84
84
  return ret;
@@ -6,6 +6,7 @@ export declare class UaVariant {
6
6
  get value(): any;
7
7
  get type(): UaVariantType;
8
8
  get arrayType(): UaArrayType;
9
+ jsonValue(): any;
9
10
  isScalar(): boolean;
10
11
  isArray(): boolean;
11
12
  isNull(): boolean;
@@ -18,6 +18,89 @@ class UaVariant {
18
18
  get arrayType() {
19
19
  return this._arrayType;
20
20
  }
21
+ jsonValue() {
22
+ if (UaVariantType.NodeId == this._type) {
23
+ if (this.isScalar()) {
24
+ return this._value.toString();
25
+ }
26
+ else {
27
+ let nodeIds = this._value;
28
+ let value = [];
29
+ for (let item of nodeIds) {
30
+ value.push(item.toString());
31
+ }
32
+ return value;
33
+ }
34
+ }
35
+ else if (UaVariantType.ExpandedNodeId == this._type) {
36
+ if (this.isScalar()) {
37
+ return this._value.toString();
38
+ }
39
+ else {
40
+ let nodeIds = this._value;
41
+ let value = [];
42
+ for (let item of nodeIds) {
43
+ value.push(item.toString());
44
+ }
45
+ return value;
46
+ }
47
+ }
48
+ else if (UaVariantType.DateTime == this._type) {
49
+ if (this.isScalar()) {
50
+ return this._value.toISOString();
51
+ }
52
+ else {
53
+ let dateTimes = this._value;
54
+ let value = [];
55
+ for (let item of dateTimes) {
56
+ value.push(item.toISOString());
57
+ }
58
+ return value;
59
+ }
60
+ }
61
+ else if (UaVariantType.LocalizedText == this._type) {
62
+ if (this.isScalar()) {
63
+ return this._value.text;
64
+ }
65
+ else {
66
+ let localizedTexts = this._value;
67
+ let value = [];
68
+ for (let item of localizedTexts) {
69
+ value.push(item.text);
70
+ }
71
+ return value;
72
+ }
73
+ }
74
+ else if (UaVariantType.StatusCode == this._type) {
75
+ if (this.isScalar()) {
76
+ return this._value.toString();
77
+ }
78
+ else {
79
+ let statusCodes = this._value;
80
+ let value = [];
81
+ for (let item of statusCodes) {
82
+ value.push(item.toString());
83
+ }
84
+ return value;
85
+ }
86
+ }
87
+ else if (UaVariantType.ExtensionObject == this._type) {
88
+ if (this.isScalar()) {
89
+ return this._value.body;
90
+ }
91
+ else {
92
+ let extensionObjects = this._value;
93
+ let value = [];
94
+ for (let item of extensionObjects) {
95
+ value.push(item.body);
96
+ }
97
+ return value;
98
+ }
99
+ }
100
+ else {
101
+ return this._value;
102
+ }
103
+ }
21
104
  isScalar() {
22
105
  return (UaArrayType.Scalar == this._arrayType) ? true : false;
23
106
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opcua-webapi-ts",
3
- "version": "1.1.26",
3
+ "version": "1.1.27",
4
4
  "description": "Provides OPC UA WebAPI wrapper and client based on opcua-webapi-typescript",
5
5
  "author": "DingYan",
6
6
  "license": "MIT",