opcua-webapi-ts 1.1.25 → 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
  }
@@ -5,7 +5,7 @@ const opcua_webapi_1 = require("opcua-webapi");
5
5
  const types_1 = require("../types");
6
6
  const _1 = require(".");
7
7
  const structure_1 = require("../structure");
8
- class UaDataType extends _1.UaDefintionNode {
8
+ class UaDataType extends _1.UaDefinitionNode {
9
9
  constructor(nodeId, browseName, displayName, isAbstract) {
10
10
  super(nodeId, browseName, displayName, isAbstract);
11
11
  this._valueType = 0;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UaInstanceNode = exports.UaDefintionNode = exports.UaNode = void 0;
3
+ exports.UaInstanceNode = exports.UaDefinitionNode = exports.UaNode = void 0;
4
4
  const types_1 = require("../types");
5
5
  const _1 = require(".");
6
6
  class 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,9 +35,15 @@ 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
- class UaDefintionNode extends UaNode {
46
+ class UaDefinitionNode extends UaNode {
40
47
  constructor(nodeId, browseName, displayName, isAbstract) {
41
48
  super(nodeId, browseName, displayName);
42
49
  this._isAbstract = isAbstract;
@@ -70,7 +77,7 @@ class UaDefintionNode extends UaNode {
70
77
  return ret;
71
78
  }
72
79
  }
73
- exports.UaDefintionNode = UaDefintionNode;
80
+ exports.UaDefinitionNode = UaDefinitionNode;
74
81
  class UaInstanceNode extends UaNode {
75
82
  constructor(nodeId, browseName, displayName) {
76
83
  super(nodeId, browseName, displayName);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UaObjectType = void 0;
4
4
  const opcua_webapi_1 = require("opcua-webapi");
5
5
  const _1 = require(".");
6
- class UaObjectType extends _1.UaDefintionNode {
6
+ class UaObjectType extends _1.UaDefinitionNode {
7
7
  constructor(nodeId, browseName, displayName, isAbstract) {
8
8
  super(nodeId, browseName, displayName, isAbstract);
9
9
  this._isObjectMemberRead = false;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UaReferenceType = void 0;
4
4
  const opcua_webapi_1 = require("opcua-webapi");
5
5
  const _1 = require(".");
6
- class UaReferenceType extends _1.UaDefintionNode {
6
+ class UaReferenceType extends _1.UaDefinitionNode {
7
7
  constructor(nodeId, browseName, displayName, isAbstract, inverseName, symmetric) {
8
8
  super(nodeId, browseName, displayName, isAbstract);
9
9
  this._inverseName = inverseName;
@@ -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;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UaVariableType = void 0;
4
4
  const opcua_webapi_1 = require("opcua-webapi");
5
5
  const _1 = require(".");
6
- class UaVariableType extends _1.UaDefintionNode {
6
+ class UaVariableType extends _1.UaDefinitionNode {
7
7
  constructor(nodeId, browseName, displayName, isAbstract, dataType, valueRank) {
8
8
  super(nodeId, browseName, displayName, isAbstract);
9
9
  this._dataType = dataType;
@@ -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
  }
@@ -1,7 +1,7 @@
1
1
  import { NodeClass } from "opcua-webapi";
2
2
  import { UaLocalizedText, UaNodeId, UaVariant } from "../types";
3
- import { UaDefintionNode, UaVariable } from ".";
4
- export declare class UaDataType extends UaDefintionNode {
3
+ import { UaDefinitionNode, UaVariable } from ".";
4
+ export declare class UaDataType extends UaDefinitionNode {
5
5
  private _valueType;
6
6
  private _enumValues;
7
7
  constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, isAbstract: boolean);
@@ -5,7 +5,7 @@ const opcua_webapi_1 = require("opcua-webapi");
5
5
  const types_1 = require("../types");
6
6
  const _1 = require(".");
7
7
  const structure_1 = require("../structure");
8
- class UaDataType extends _1.UaDefintionNode {
8
+ class UaDataType extends _1.UaDefinitionNode {
9
9
  constructor(nodeId, browseName, displayName, isAbstract) {
10
10
  super(nodeId, browseName, displayName, isAbstract);
11
11
  this._valueType = 0;
@@ -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,16 +18,18 @@ 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
- export declare abstract class UaDefintionNode extends UaNode {
25
+ export declare abstract class UaDefinitionNode extends UaNode {
23
26
  protected _isAbstract: boolean;
24
27
  constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, isAbstract: boolean);
25
28
  get isAbstract(): boolean;
26
- setParentType(parentType: UaDefintionNode): void;
29
+ setParentType(parentType: UaDefinitionNode): void;
27
30
  isSubtypeOf(typeId: UaNodeId): boolean;
28
- parentType(): UaDefintionNode | null;
29
- childTypes(): Array<UaDefintionNode>;
31
+ parentType(): UaDefinitionNode | null;
32
+ childTypes(): Array<UaDefinitionNode>;
30
33
  }
31
34
  export declare abstract class UaInstanceNode extends UaNode {
32
35
  private _modellingRule;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UaInstanceNode = exports.UaDefintionNode = exports.UaNode = void 0;
3
+ exports.UaInstanceNode = exports.UaDefinitionNode = exports.UaNode = void 0;
4
4
  const types_1 = require("../types");
5
5
  const _1 = require(".");
6
6
  class 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,9 +35,15 @@ 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
- class UaDefintionNode extends UaNode {
46
+ class UaDefinitionNode extends UaNode {
40
47
  constructor(nodeId, browseName, displayName, isAbstract) {
41
48
  super(nodeId, browseName, displayName);
42
49
  this._isAbstract = isAbstract;
@@ -70,7 +77,7 @@ class UaDefintionNode extends UaNode {
70
77
  return ret;
71
78
  }
72
79
  }
73
- exports.UaDefintionNode = UaDefintionNode;
80
+ exports.UaDefinitionNode = UaDefinitionNode;
74
81
  class UaInstanceNode extends UaNode {
75
82
  constructor(nodeId, browseName, displayName) {
76
83
  super(nodeId, browseName, displayName);
@@ -1,7 +1,7 @@
1
1
  import { NodeClass } from "opcua-webapi";
2
2
  import { UaLocalizedText, UaNodeId } from "../types";
3
- import { UaDefintionNode, UaObject, UaMethod, UaVariable, UaInstanceNode } from ".";
4
- export declare class UaObjectType extends UaDefintionNode {
3
+ import { UaDefinitionNode, UaObject, UaMethod, UaVariable, UaInstanceNode } from ".";
4
+ export declare class UaObjectType extends UaDefinitionNode {
5
5
  private _isObjectMemberRead;
6
6
  constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, isAbstract: boolean);
7
7
  get nodeClass(): NodeClass;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UaObjectType = void 0;
4
4
  const opcua_webapi_1 = require("opcua-webapi");
5
5
  const _1 = require(".");
6
- class UaObjectType extends _1.UaDefintionNode {
6
+ class UaObjectType extends _1.UaDefinitionNode {
7
7
  constructor(nodeId, browseName, displayName, isAbstract) {
8
8
  super(nodeId, browseName, displayName, isAbstract);
9
9
  this._isObjectMemberRead = false;
@@ -1,7 +1,7 @@
1
1
  import { NodeClass } from "opcua-webapi";
2
2
  import { UaLocalizedText, UaNodeId } from "../types";
3
- import { UaDefintionNode } from ".";
4
- export declare class UaReferenceType extends UaDefintionNode {
3
+ import { UaDefinitionNode } from ".";
4
+ export declare class UaReferenceType extends UaDefinitionNode {
5
5
  private _inverseName;
6
6
  private _symmetric;
7
7
  constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, isAbstract: boolean, inverseName: UaLocalizedText, symmetric: boolean);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UaReferenceType = void 0;
4
4
  const opcua_webapi_1 = require("opcua-webapi");
5
5
  const _1 = require(".");
6
- class UaReferenceType extends _1.UaDefintionNode {
6
+ class UaReferenceType extends _1.UaDefinitionNode {
7
7
  constructor(nodeId, browseName, displayName, isAbstract, inverseName, symmetric) {
8
8
  super(nodeId, browseName, displayName, isAbstract);
9
9
  this._inverseName = inverseName;
@@ -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;
@@ -1,7 +1,7 @@
1
1
  import { NodeClass } from "opcua-webapi";
2
2
  import { UaLocalizedText, UaNodeId } from "../types";
3
- import { UaDefintionNode, UaVariable } from ".";
4
- export declare class UaVariableType extends UaDefintionNode {
3
+ import { UaDefinitionNode, UaVariable } from ".";
4
+ export declare class UaVariableType extends UaDefinitionNode {
5
5
  private _dataType;
6
6
  private _valueRank;
7
7
  constructor(nodeId: UaNodeId, browseName: string, displayName: UaLocalizedText, isAbstract: boolean, dataType: UaNodeId, valueRank: number);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UaVariableType = void 0;
4
4
  const opcua_webapi_1 = require("opcua-webapi");
5
5
  const _1 = require(".");
6
- class UaVariableType extends _1.UaDefintionNode {
6
+ class UaVariableType extends _1.UaDefinitionNode {
7
7
  constructor(nodeId, browseName, displayName, isAbstract, dataType, valueRank) {
8
8
  super(nodeId, browseName, displayName, isAbstract);
9
9
  this._dataType = dataType;
@@ -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.25",
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",