node-opcua-factory 2.98.0 → 2.99.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/base_ua_object.d.ts +53 -0
- package/dist/base_ua_object.js +548 -0
- package/dist/base_ua_object.js.map +1 -0
- package/dist/basic_type.d.ts +40 -0
- package/dist/basic_type.js +119 -0
- package/dist/basic_type.js.map +1 -0
- package/dist/builtin_types.d.ts +46 -0
- package/dist/builtin_types.js +284 -0
- package/dist/builtin_types.js.map +1 -0
- package/dist/builtin_types_special.d.ts +5 -0
- package/dist/builtin_types_special.js +46 -0
- package/dist/builtin_types_special.js.map +1 -0
- package/dist/datatype_factory.d.ts +43 -0
- package/dist/datatype_factory.js +308 -0
- package/dist/datatype_factory.js.map +1 -0
- package/dist/encode_decode.d.ts +9 -0
- package/dist/encode_decode.js +40 -0
- package/dist/encode_decode.js.map +1 -0
- package/dist/enumerations.d.ts +34 -0
- package/dist/enumerations.js +82 -0
- package/dist/enumerations.js.map +1 -0
- package/dist/get_built_in_type.d.ts +0 -0
- package/dist/get_built_in_type.js +2 -0
- package/dist/get_built_in_type.js.map +1 -0
- package/dist/get_standard_data_type_factory.d.ts +5 -0
- package/dist/get_standard_data_type_factory.js +30 -0
- package/dist/get_standard_data_type_factory.js.map +1 -0
- package/dist/get_structured_type_schema.d.ts +1 -0
- package/dist/get_structured_type_schema.js +9 -0
- package/dist/get_structured_type_schema.js.map +1 -0
- package/dist/id_generator.d.ts +3 -0
- package/dist/id_generator.js +22 -0
- package/dist/id_generator.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/nodeid_type.d.ts +13 -0
- package/dist/nodeid_type.js +19 -0
- package/dist/nodeid_type.js.map +1 -0
- package/dist/parameters.d.ts +3 -0
- package/dist/parameters.js +7 -0
- package/dist/parameters.js.map +1 -0
- package/dist/register_class_definition.d.ts +3 -0
- package/dist/register_class_definition.js +9 -0
- package/dist/register_class_definition.js.map +1 -0
- package/dist/schema_helpers.d.ts +24 -0
- package/dist/schema_helpers.js +100 -0
- package/dist/schema_helpers.js.map +1 -0
- package/dist/structured_type_schema.d.ts +39 -0
- package/dist/structured_type_schema.js +284 -0
- package/dist/structured_type_schema.js.map +1 -0
- package/dist/types.d.ts +160 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +17 -13
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerBasicType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-factory
|
|
6
|
+
*/
|
|
7
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
8
|
+
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
9
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
10
|
+
const builtin_types_1 = require("./builtin_types");
|
|
11
|
+
const errorLog = (0, node_opcua_debug_1.make_errorLog)("Factory");
|
|
12
|
+
/**
|
|
13
|
+
* register a Basic Type ,
|
|
14
|
+
* A basic type is new entity type that resolved to a SubType
|
|
15
|
+
* @example:
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* registerBasicType({name:"Duration" ,subType:"Double"});
|
|
19
|
+
*
|
|
20
|
+
* @method registerBasicType
|
|
21
|
+
* @param schema
|
|
22
|
+
* @param schema.name {String}
|
|
23
|
+
* @param schema.subType {String} mandatory, the basic type from which the new type derives.
|
|
24
|
+
*
|
|
25
|
+
* @param [schema.encode] {Function} optional,a specific encoder function to encode an instance of this type.
|
|
26
|
+
* @param schema.encode.value {*}
|
|
27
|
+
* @param schema.encode.stream {BinaryStream}
|
|
28
|
+
*
|
|
29
|
+
* @param [schema.decode] optional,a specific decoder function that returns the decode value out of the stream.
|
|
30
|
+
* @param [schema.decode.stream] {BinaryStream}
|
|
31
|
+
*
|
|
32
|
+
* @param [schema.coerce] optional, a method to convert a value into the request type.
|
|
33
|
+
* @param schema.coerce.value {*} the value to coerce.
|
|
34
|
+
*
|
|
35
|
+
* @param [schema.random] optional, a method to construct a random object of this type
|
|
36
|
+
*
|
|
37
|
+
* @param [schema.toJSON]optional, a method to convert a value into the request type.
|
|
38
|
+
*/
|
|
39
|
+
function registerBasicType(schema) {
|
|
40
|
+
const exists = (0, builtin_types_1.hasBuiltInType)(schema.name);
|
|
41
|
+
/* istanbul ignore next */
|
|
42
|
+
if (exists) {
|
|
43
|
+
errorLog("registerBasicType:", schema);
|
|
44
|
+
throw new Error(`Basic Type ${schema.name} already registered`);
|
|
45
|
+
}
|
|
46
|
+
const name = schema.name;
|
|
47
|
+
const t = (0, builtin_types_1.getBuiltInType)(schema.subType);
|
|
48
|
+
/* istanbul ignore next */
|
|
49
|
+
if (!t) {
|
|
50
|
+
// tslint:disable-next-line:no-console
|
|
51
|
+
throw new Error(" cannot find subtype " + schema.subType);
|
|
52
|
+
}
|
|
53
|
+
(0, node_opcua_assert_1.assert)(typeof t.decode === "function");
|
|
54
|
+
const encodeFunc = schema.encode || t.encode;
|
|
55
|
+
(0, node_opcua_assert_1.assert)(typeof encodeFunc === "function");
|
|
56
|
+
const decodeFunc = schema.decode || t.decode;
|
|
57
|
+
(0, node_opcua_assert_1.assert)(typeof decodeFunc === "function");
|
|
58
|
+
const defaultValue = schema.defaultValue === undefined ? t.defaultValue : schema.defaultValue;
|
|
59
|
+
// assert(typeof defaultValue === "function");
|
|
60
|
+
const coerceFunc = schema.coerce || t.coerce;
|
|
61
|
+
const toJSONFunc = schema.toJSON || t.toJSON;
|
|
62
|
+
const random = schema.random || defaultValue;
|
|
63
|
+
const newSchema = {
|
|
64
|
+
name,
|
|
65
|
+
subType: schema.subType,
|
|
66
|
+
coerce: coerceFunc,
|
|
67
|
+
decode: decodeFunc,
|
|
68
|
+
encode: encodeFunc,
|
|
69
|
+
random,
|
|
70
|
+
defaultValue,
|
|
71
|
+
toJSON: toJSONFunc
|
|
72
|
+
};
|
|
73
|
+
(0, builtin_types_1.registerType)(newSchema);
|
|
74
|
+
}
|
|
75
|
+
exports.registerBasicType = registerBasicType;
|
|
76
|
+
// =============================================================================================
|
|
77
|
+
// Registering the Basic Type already defined int the OPC-UA Specification
|
|
78
|
+
// =============================================================================================
|
|
79
|
+
registerBasicType({ name: "Counter", subType: "UInt32" });
|
|
80
|
+
// OPC Unified Architecture, part 3.0 $8.13 page 65
|
|
81
|
+
registerBasicType({ name: "Duration", subType: "Double" });
|
|
82
|
+
registerBasicType({ name: "UtcTime", subType: "DateTime" });
|
|
83
|
+
registerBasicType({
|
|
84
|
+
name: "LocaleId",
|
|
85
|
+
subType: "String",
|
|
86
|
+
defaultValue: null,
|
|
87
|
+
decode: node_opcua_basic_types_1.decodeLocaleId,
|
|
88
|
+
encode: node_opcua_basic_types_1.encodeLocaleId,
|
|
89
|
+
validate: node_opcua_basic_types_1.validateLocaleId
|
|
90
|
+
});
|
|
91
|
+
registerBasicType({ name: "ContinuationPoint", subType: "ByteString" });
|
|
92
|
+
registerBasicType({ name: "Image", subType: "ByteString" });
|
|
93
|
+
registerBasicType({ name: "ImageBMP", subType: "Image" });
|
|
94
|
+
registerBasicType({ name: "ImageGIF", subType: "Image" });
|
|
95
|
+
registerBasicType({ name: "ImageJPG", subType: "Image" });
|
|
96
|
+
registerBasicType({ name: "ImagePNG", subType: "Image" });
|
|
97
|
+
registerBasicType({ name: "AudioDataType", subType: "ByteString" });
|
|
98
|
+
registerBasicType({ name: "BitFieldMaskDataType", subType: "UInt64" });
|
|
99
|
+
registerBasicType({ name: "DataSetFieldFlags", subType: "UInt16" });
|
|
100
|
+
registerBasicType({ name: "DataSetFieldContentMask", subType: "UInt32" });
|
|
101
|
+
registerBasicType({ name: "UadpNetworkMessageContentMask", subType: "UInt32" });
|
|
102
|
+
registerBasicType({ name: "UadpDataSetMessageContentMask", subType: "UInt32" });
|
|
103
|
+
registerBasicType({ name: "JsonNetworkMessageContentMask", subType: "UInt32" });
|
|
104
|
+
registerBasicType({ name: "JsonDataSetMessageContentMask", subType: "UInt32" });
|
|
105
|
+
registerBasicType({ name: "PermissionType", subType: "UInt32" });
|
|
106
|
+
registerBasicType({ name: "AccessLevelType", subType: "Byte" });
|
|
107
|
+
registerBasicType({ name: "AccessLevelExType", subType: "UInt32" });
|
|
108
|
+
registerBasicType({ name: "EventNotifierType", subType: "Byte" });
|
|
109
|
+
registerBasicType({ name: "AccessRestrictionType", subType: "UInt32" });
|
|
110
|
+
registerBasicType({ name: "NormalizedString", subType: "String" });
|
|
111
|
+
registerBasicType({ name: "DecimalString", subType: "String" });
|
|
112
|
+
registerBasicType({ name: "DurationString", subType: "String" });
|
|
113
|
+
registerBasicType({ name: "TimeString", subType: "String" });
|
|
114
|
+
registerBasicType({ name: "DateString", subType: "String" });
|
|
115
|
+
registerBasicType({ name: "Index", subType: "UInt32" });
|
|
116
|
+
registerBasicType({ name: "VersionTime", subType: "UInt32" });
|
|
117
|
+
registerBasicType({ name: "ApplicationInstanceCertificate", subType: "ByteString" });
|
|
118
|
+
registerBasicType({ name: "AttributeWriteMask", subType: "UInt32" });
|
|
119
|
+
//# sourceMappingURL=basic_type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic_type.js","sourceRoot":"","sources":["../source/basic_type.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAC3C,mEAA0F;AAE1F,uDAAiD;AACjD,mDAA+E;AAE/E,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,SAAS,CAAC,CAAC;AAY1C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAgB,iBAAiB,CAAC,MAAwB;IACtD,MAAM,MAAM,GAAY,IAAA,8BAAc,EAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAEpD,0BAA0B;IAC1B,IAAI,MAAM,EAAE;QACR,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QACvC,MAAM,I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C,CAAC;AAChE,iBAAiB,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AACjE,iBAAiB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC7D,iBAAiB,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC7D,iBAAiB,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AACxD,iBAAiB,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC9D,iBAAiB,CAAC,EAAE,IAAI,EAAE,gCAAgC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAC;AACrF,iBAAiB,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
2
|
+
import { BasicTypeDefinition, BasicTypeDefinitionOptions, BasicTypeDefinitionOptionsBase, CommonInterface, FieldCategory, TypeSchemaConstructorOptions } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* @class TypeSchemaBase
|
|
5
|
+
* @param options {Object}
|
|
6
|
+
* @constructor
|
|
7
|
+
* create a new type Schema
|
|
8
|
+
*/
|
|
9
|
+
export declare class TypeSchemaBase implements CommonInterface {
|
|
10
|
+
name: string;
|
|
11
|
+
defaultValue: any;
|
|
12
|
+
encode?: (value: any, stream: OutputBinaryStream) => void;
|
|
13
|
+
decode?: (stream: BinaryStream) => any;
|
|
14
|
+
coerce?: (value: any) => any;
|
|
15
|
+
toJSON?: () => string;
|
|
16
|
+
category: FieldCategory;
|
|
17
|
+
subType: string;
|
|
18
|
+
isAbstract: boolean;
|
|
19
|
+
constructor(options: TypeSchemaConstructorOptions);
|
|
20
|
+
/**
|
|
21
|
+
* @method computer_default_value
|
|
22
|
+
* @param defaultValue {*} the default value
|
|
23
|
+
* @return {*}
|
|
24
|
+
*/
|
|
25
|
+
computer_default_value(defaultValue: unknown): any;
|
|
26
|
+
getBaseType(): CommonInterface | null;
|
|
27
|
+
isSubTypeOf(type: CommonInterface): boolean;
|
|
28
|
+
}
|
|
29
|
+
export declare class BasicTypeSchema extends TypeSchemaBase implements BasicTypeDefinition {
|
|
30
|
+
subType: string;
|
|
31
|
+
isAbstract: boolean;
|
|
32
|
+
encode: (value: any, stream: OutputBinaryStream) => void;
|
|
33
|
+
decode: (stream: BinaryStream) => any;
|
|
34
|
+
constructor(options: BasicTypeDefinitionOptions);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @method registerType
|
|
38
|
+
* @param schema {TypeSchemaBase}
|
|
39
|
+
*/
|
|
40
|
+
export declare function registerType(schema: BasicTypeDefinitionOptionsBase): void;
|
|
41
|
+
export declare const registerBuiltInType: typeof registerType;
|
|
42
|
+
export declare function unregisterType(typeName: string): void;
|
|
43
|
+
export declare function getBuiltInType(name: string): TypeSchemaBase;
|
|
44
|
+
export declare function hasBuiltInType(name: string): boolean;
|
|
45
|
+
/** */
|
|
46
|
+
export declare function findBuiltInType(dataTypeName: string): BasicTypeDefinition;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findBuiltInType = exports.hasBuiltInType = exports.getBuiltInType = exports.unregisterType = exports.registerBuiltInType = exports.registerType = exports.BasicTypeSchema = exports.TypeSchemaBase = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-factory
|
|
6
|
+
*/
|
|
7
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
8
|
+
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
9
|
+
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
10
|
+
const node_opcua_guid_1 = require("node-opcua-guid");
|
|
11
|
+
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
12
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
13
|
+
const encode_decode_1 = require("./encode_decode");
|
|
14
|
+
const types_1 = require("./types");
|
|
15
|
+
/**
|
|
16
|
+
* @class TypeSchemaBase
|
|
17
|
+
* @param options {Object}
|
|
18
|
+
* @constructor
|
|
19
|
+
* create a new type Schema
|
|
20
|
+
*/
|
|
21
|
+
class TypeSchemaBase {
|
|
22
|
+
constructor(options) {
|
|
23
|
+
(0, node_opcua_assert_1.assert)(options.category !== null);
|
|
24
|
+
this.encode = options.encode || undefined;
|
|
25
|
+
this.decode = options.decode || undefined;
|
|
26
|
+
this.coerce = options.coerce;
|
|
27
|
+
this.category = options.category || types_1.FieldCategory.basic;
|
|
28
|
+
this.name = options.name;
|
|
29
|
+
for (const prop in options) {
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(options, prop)) {
|
|
31
|
+
this[prop] = options[prop];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
this.subType = options.subType || "";
|
|
35
|
+
this.isAbstract = options.isAbstract || false;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* @method computer_default_value
|
|
39
|
+
* @param defaultValue {*} the default value
|
|
40
|
+
* @return {*}
|
|
41
|
+
*/
|
|
42
|
+
computer_default_value(defaultValue) {
|
|
43
|
+
if (defaultValue === undefined) {
|
|
44
|
+
defaultValue = this.defaultValue;
|
|
45
|
+
}
|
|
46
|
+
if (typeof defaultValue === "function") {
|
|
47
|
+
// be careful not to cache this value , it must be call each time to make sure
|
|
48
|
+
// we do not end up with the same value/instance twice.
|
|
49
|
+
defaultValue = defaultValue();
|
|
50
|
+
}
|
|
51
|
+
return defaultValue;
|
|
52
|
+
}
|
|
53
|
+
getBaseType() {
|
|
54
|
+
if (!this.subType)
|
|
55
|
+
return null;
|
|
56
|
+
return getBuiltInType(this.subType);
|
|
57
|
+
}
|
|
58
|
+
isSubTypeOf(type) {
|
|
59
|
+
if (this.name === type.name) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
const baseType = this.getBaseType();
|
|
63
|
+
if (!baseType) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return baseType.isSubTypeOf(type);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.TypeSchemaBase = TypeSchemaBase;
|
|
70
|
+
class BasicTypeSchema extends TypeSchemaBase {
|
|
71
|
+
constructor(options) {
|
|
72
|
+
super(options);
|
|
73
|
+
this.subType = options.subType;
|
|
74
|
+
this.isAbstract = options.isAbstract || false;
|
|
75
|
+
this.encode = options.encode || encode_decode_1.defaultEncode;
|
|
76
|
+
this.decode = options.decode || encode_decode_1.defaultDecode;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.BasicTypeSchema = BasicTypeSchema;
|
|
80
|
+
// there are 4 types of DataTypes in opcua:
|
|
81
|
+
// Built-In DataType
|
|
82
|
+
// Simple DataType
|
|
83
|
+
// Complex DataType
|
|
84
|
+
// Enumeration
|
|
85
|
+
const defaultXmlElement = "";
|
|
86
|
+
// Built-In Type
|
|
87
|
+
const _defaultType = [
|
|
88
|
+
// Built-in DataTypes ( see OPCUA Part III v1.02 - $5.8.2 )
|
|
89
|
+
{
|
|
90
|
+
name: "Null",
|
|
91
|
+
decode: encode_decode_1.decodeNull,
|
|
92
|
+
encode: encode_decode_1.encodeNull,
|
|
93
|
+
defaultValue: null
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
// special case
|
|
97
|
+
name: "Any",
|
|
98
|
+
decode: encode_decode_1.decodeAny,
|
|
99
|
+
encode: encode_decode_1.encodeAny
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: "Boolean",
|
|
103
|
+
decode: node_opcua_basic_types_1.decodeBoolean,
|
|
104
|
+
encode: node_opcua_basic_types_1.encodeBoolean,
|
|
105
|
+
coerce: node_opcua_basic_types_1.coerceBoolean,
|
|
106
|
+
defaultValue: false
|
|
107
|
+
},
|
|
108
|
+
{ name: "Number", isAbstract: true },
|
|
109
|
+
{ name: "Integer", subType: "Number", isAbstract: true },
|
|
110
|
+
{ name: "UInteger", subType: "Number", isAbstract: true },
|
|
111
|
+
{ name: "SByte", subType: "Integer", encode: node_opcua_basic_types_1.encodeSByte, decode: node_opcua_basic_types_1.decodeSByte, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceSByte },
|
|
112
|
+
{ name: "Byte", subType: "UInteger", encode: node_opcua_basic_types_1.encodeByte, decode: node_opcua_basic_types_1.decodeByte, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceByte },
|
|
113
|
+
{ name: "Int16", subType: "Integer", encode: node_opcua_basic_types_1.encodeInt16, decode: node_opcua_basic_types_1.decodeInt16, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceInt16 },
|
|
114
|
+
{ name: "UInt16", subType: "UInteger", encode: node_opcua_basic_types_1.encodeUInt16, decode: node_opcua_basic_types_1.decodeUInt16, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceUInt16 },
|
|
115
|
+
{ name: "Int32", subType: "Integer", encode: node_opcua_basic_types_1.encodeInt32, decode: node_opcua_basic_types_1.decodeInt32, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceInt32 },
|
|
116
|
+
{ name: "UInt32", subType: "UInteger", encode: node_opcua_basic_types_1.encodeUInt32, decode: node_opcua_basic_types_1.decodeUInt32, defaultValue: 0, coerce: node_opcua_basic_types_1.coerceUInt32 },
|
|
117
|
+
{
|
|
118
|
+
name: "Int64",
|
|
119
|
+
subType: "Integer",
|
|
120
|
+
decode: node_opcua_basic_types_1.decodeInt64,
|
|
121
|
+
encode: node_opcua_basic_types_1.encodeInt64,
|
|
122
|
+
coerce: node_opcua_basic_types_1.coerceInt64,
|
|
123
|
+
defaultValue: (0, node_opcua_basic_types_1.coerceInt64)(0)
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
name: "UInt64",
|
|
127
|
+
subType: "UInteger",
|
|
128
|
+
decode: node_opcua_basic_types_1.decodeUInt64,
|
|
129
|
+
encode: node_opcua_basic_types_1.encodeUInt64,
|
|
130
|
+
coerce: node_opcua_basic_types_1.coerceUInt64,
|
|
131
|
+
defaultValue: (0, node_opcua_basic_types_1.coerceUInt64)(0)
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "Float",
|
|
135
|
+
subType: "Number",
|
|
136
|
+
decode: node_opcua_basic_types_1.decodeFloat,
|
|
137
|
+
encode: node_opcua_basic_types_1.encodeFloat,
|
|
138
|
+
coerce: node_opcua_basic_types_1.coerceFloat,
|
|
139
|
+
defaultValue: 0.0
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "Double",
|
|
143
|
+
subType: "Number",
|
|
144
|
+
decode: node_opcua_basic_types_1.decodeDouble,
|
|
145
|
+
encode: node_opcua_basic_types_1.encodeDouble,
|
|
146
|
+
coerce: node_opcua_basic_types_1.coerceDouble,
|
|
147
|
+
defaultValue: 0.0
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "String",
|
|
151
|
+
decode: node_opcua_basic_types_1.decodeString,
|
|
152
|
+
encode: node_opcua_basic_types_1.encodeString,
|
|
153
|
+
defaultValue: ""
|
|
154
|
+
},
|
|
155
|
+
// OPC Unified Architecture, part 3.0 $8.26 page 67
|
|
156
|
+
{
|
|
157
|
+
name: "DateTime",
|
|
158
|
+
decode: node_opcua_basic_types_1.decodeDateTime,
|
|
159
|
+
encode: node_opcua_basic_types_1.encodeDateTime,
|
|
160
|
+
coerce: node_opcua_basic_types_1.coerceDateTime,
|
|
161
|
+
defaultValue: () => node_opcua_basic_types_1.minDate
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
name: "Guid",
|
|
165
|
+
decode: node_opcua_basic_types_1.decodeGuid,
|
|
166
|
+
encode: node_opcua_basic_types_1.encodeGuid,
|
|
167
|
+
defaultValue: node_opcua_guid_1.emptyGuid
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "ByteString",
|
|
171
|
+
decode: node_opcua_basic_types_1.decodeByteString,
|
|
172
|
+
encode: node_opcua_basic_types_1.encodeByteString,
|
|
173
|
+
coerce: node_opcua_basic_types_1.coerceByteString,
|
|
174
|
+
defaultValue: null,
|
|
175
|
+
toJSON: encode_decode_1.toJSONGuid
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "XmlElement",
|
|
179
|
+
decode: node_opcua_basic_types_1.decodeString,
|
|
180
|
+
encode: node_opcua_basic_types_1.encodeString,
|
|
181
|
+
defaultValue: defaultXmlElement
|
|
182
|
+
},
|
|
183
|
+
// see OPCUA Part 3 - V1.02 $8.2.1
|
|
184
|
+
{
|
|
185
|
+
name: "NodeId",
|
|
186
|
+
decode: node_opcua_basic_types_1.decodeNodeId,
|
|
187
|
+
encode: node_opcua_basic_types_1.encodeNodeId,
|
|
188
|
+
coerce: node_opcua_basic_types_1.coerceNodeId,
|
|
189
|
+
defaultValue: node_opcua_nodeid_1.makeNodeId
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
name: "ExpandedNodeId",
|
|
193
|
+
decode: node_opcua_basic_types_1.decodeExpandedNodeId,
|
|
194
|
+
encode: node_opcua_basic_types_1.encodeExpandedNodeId,
|
|
195
|
+
coerce: node_opcua_basic_types_1.coerceExpandedNodeId,
|
|
196
|
+
defaultValue: node_opcua_nodeid_1.makeExpandedNodeId
|
|
197
|
+
},
|
|
198
|
+
// ----------------------------------------------------------------------------------------
|
|
199
|
+
// Simple DataTypes
|
|
200
|
+
// ( see OPCUA Part III v1.02 - $5.8.2 )
|
|
201
|
+
// Simple DataTypes are subtypes of the Built-in DataTypes. They are handled on the wire like the
|
|
202
|
+
// Built-in DataType, i.e. they cannot be distinguished on the wire from their Built-in super types.
|
|
203
|
+
// Since they are handled like Built-in DataTypes regarding the encoding they cannot have encodings
|
|
204
|
+
// defined in the AddressSpace. Clients can read the DataType Attribute of a Variable or VariableType to
|
|
205
|
+
// identify the Simple DataType of the Value Attribute. An example of a Simple DataType is Duration. It
|
|
206
|
+
// is handled on the wire as a Double but the Client can read the DataType Attribute and thus interpret
|
|
207
|
+
// the value as defined by Duration
|
|
208
|
+
//
|
|
209
|
+
// OPC Unified Architecture, part 4.0 $7.13
|
|
210
|
+
// IntegerID: This primitive data type is an UInt32 that is used as an identifier, such as a handle. All values,
|
|
211
|
+
// except for 0, are valid.
|
|
212
|
+
{
|
|
213
|
+
name: "IntegerId",
|
|
214
|
+
decode: node_opcua_basic_types_1.decodeUInt32,
|
|
215
|
+
encode: node_opcua_basic_types_1.encodeUInt32,
|
|
216
|
+
defaultValue: 0xffffffff
|
|
217
|
+
},
|
|
218
|
+
// The StatusCode is a 32-bit unsigned integer. The top 16 bits represent the numeric value of the
|
|
219
|
+
// code that shall be used for detecting specific errors or conditions. The bottom 16 bits are bit flags
|
|
220
|
+
// that contain additional information but do not affect the meaning of the StatusCode.
|
|
221
|
+
// 7.33 Part 4 - P 143
|
|
222
|
+
{
|
|
223
|
+
name: "StatusCode",
|
|
224
|
+
decode: node_opcua_status_code_1.decodeStatusCode,
|
|
225
|
+
encode: node_opcua_status_code_1.encodeStatusCode,
|
|
226
|
+
coerce: node_opcua_status_code_1.coerceStatusCode,
|
|
227
|
+
defaultValue: node_opcua_status_code_1.StatusCodes.Good
|
|
228
|
+
}
|
|
229
|
+
];
|
|
230
|
+
// populate the default type map
|
|
231
|
+
const _defaultTypeMap = new Map();
|
|
232
|
+
_defaultType.forEach(registerType);
|
|
233
|
+
/**
|
|
234
|
+
* @method registerType
|
|
235
|
+
* @param schema {TypeSchemaBase}
|
|
236
|
+
*/
|
|
237
|
+
function registerType(schema) {
|
|
238
|
+
if (!schema.isAbstract) {
|
|
239
|
+
(0, node_opcua_assert_1.assert)(schema.encode);
|
|
240
|
+
(0, node_opcua_assert_1.assert)(schema.decode);
|
|
241
|
+
}
|
|
242
|
+
schema.category = types_1.FieldCategory.basic;
|
|
243
|
+
schema.subType = schema.subType || "";
|
|
244
|
+
if (schema.name !== "Null" && schema.name !== "Any" && schema.name !== "Variant" && schema.name !== "ExtensionObject") {
|
|
245
|
+
const dataType = node_opcua_constants_1.DataTypeIds[schema.name];
|
|
246
|
+
if (!dataType) {
|
|
247
|
+
throw new Error("registerType : dataType " + schema.name + " is not defined");
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
const definition = new BasicTypeSchema(schema);
|
|
251
|
+
_defaultTypeMap.set(schema.name, definition);
|
|
252
|
+
}
|
|
253
|
+
exports.registerType = registerType;
|
|
254
|
+
exports.registerBuiltInType = registerType;
|
|
255
|
+
function unregisterType(typeName) {
|
|
256
|
+
_defaultTypeMap.delete(typeName);
|
|
257
|
+
}
|
|
258
|
+
exports.unregisterType = unregisterType;
|
|
259
|
+
function getBuiltInType(name) {
|
|
260
|
+
const typeSchema = _defaultTypeMap.get(name);
|
|
261
|
+
if (!typeSchema) {
|
|
262
|
+
throw new Error("Cannot find schema for simple type " + name);
|
|
263
|
+
}
|
|
264
|
+
return typeSchema;
|
|
265
|
+
}
|
|
266
|
+
exports.getBuiltInType = getBuiltInType;
|
|
267
|
+
function hasBuiltInType(name) {
|
|
268
|
+
return _defaultTypeMap.has(name);
|
|
269
|
+
}
|
|
270
|
+
exports.hasBuiltInType = hasBuiltInType;
|
|
271
|
+
/** */
|
|
272
|
+
function findBuiltInType(dataTypeName) {
|
|
273
|
+
(0, node_opcua_assert_1.assert)(typeof dataTypeName === "string", "findBuiltInType : expecting a string " + dataTypeName);
|
|
274
|
+
const t = getBuiltInType(dataTypeName);
|
|
275
|
+
if (t.subType && t.subType !== t.name /* avoid infinite recursion */) {
|
|
276
|
+
const st = getBuiltInType(t.subType);
|
|
277
|
+
if (!st.isAbstract) {
|
|
278
|
+
return findBuiltInType(t.subType);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return t;
|
|
282
|
+
}
|
|
283
|
+
exports.findBuiltInType = findBuiltInType;
|
|
284
|
+
//# sourceMappingURL=builtin_types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin_types.js","sourceRoot":"","sources":["../source/builtin_types.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,yDAA2C;AAC3C,mEAmDgC;AAEhC,+DAAmD;AAEnD,qDAA4C;AAC5C,yDAAmE;AACnE,mEAA2G;AAC3G,mDAAyH;AACzH,mCAAwK;AAGxK;;;;;GAKG;AACF,MAAa,cAAc;IAWxB,YAAY,OAAqC;QAC7C,IAAA,0BAAM,EAAC,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,qBAAa,CAAC,KAAK,CAAC;QACxD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YACxB,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE;gBACpD,IAAY,CAAC,IAAI,CAAC,GAAI,OAAe,CAAC,IAAI,CAAC,CAAC;aAChD;SACJ;QACD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,KAAK,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACI,sBAAsB,CAAC,YAAqB;QAC/C,IAAI,YAAY,KAAK,SAAS,EAAE;YAC5B,Y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b,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,IAAI,CAAC,CAAC;KACjE;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AAND,wCAMC;AAED,SAAgB,cAAc,CAAC,IAAY;IACvC,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAFD,wCAEC;AAED,MAAM;AACN,SAAgB,eAAe,CAAC,YAAoB;IAChD,IAAA,0BAAM,EAAC,OAAO,YAAY,KAAK,QAAQ,EAAE,uCAAuC,GAAG,YAAY,CAAC,CAAC;IACjG,MAAM,CAAC,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IACvC,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,IAAI,CAAC,8BAA8B,EAAE;QAClE,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,CAAC,EAAE,CAAC,UAAU,EAAE;YAChB,OAAO,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;SACrC;KACJ;IACD,OAAO,CAAC,CAAC;AACb,CAAC;AAVD,0CAUC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @module node-opcua-factory
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerSpecialVariantEncoder = void 0;
|
|
7
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
8
|
+
const builtin_types_1 = require("./builtin_types");
|
|
9
|
+
function _self_encode(constructor) {
|
|
10
|
+
(0, node_opcua_assert_1.assert)(typeof constructor === "function");
|
|
11
|
+
return (value, stream) => {
|
|
12
|
+
if (!value || !value.encode) {
|
|
13
|
+
value = new constructor(value);
|
|
14
|
+
}
|
|
15
|
+
value.encode(stream);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function _self_decode(constructor) {
|
|
19
|
+
(0, node_opcua_assert_1.assert)(typeof constructor === "function");
|
|
20
|
+
return (stream) => {
|
|
21
|
+
const value = new constructor();
|
|
22
|
+
value.decode(stream);
|
|
23
|
+
return value;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function _self_coerce(constructor) {
|
|
27
|
+
(0, node_opcua_assert_1.assert)(typeof constructor === "function");
|
|
28
|
+
return (value) => {
|
|
29
|
+
const obj = new constructor(value);
|
|
30
|
+
return obj;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function registerSpecialVariantEncoder(constructor) {
|
|
34
|
+
(0, node_opcua_assert_1.assert)(typeof constructor === "function");
|
|
35
|
+
const name = constructor.prototype.schema.name;
|
|
36
|
+
(0, builtin_types_1.registerType)({
|
|
37
|
+
name,
|
|
38
|
+
subType: name,
|
|
39
|
+
encode: _self_encode(constructor),
|
|
40
|
+
decode: _self_decode(constructor),
|
|
41
|
+
coerce: _self_coerce(constructor),
|
|
42
|
+
defaultValue: () => new constructor()
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
exports.registerSpecialVariantEncoder = registerSpecialVariantEncoder;
|
|
46
|
+
//# sourceMappingURL=builtin_types_special.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builtin_types_special.js","sourceRoot":"","sources":["../source/builtin_types_special.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,yDAA2C;AAG3C,mDAA+C;AAG/C,SAAS,YAAY,CAAC,WAAgB;IAClC,IAAA,0BAAM,EAAC,OAAO,WAAW,KAAK,UAAU,CAAC,CAAC;IAC1C,OAAO,CAAC,KAAU,EAAE,MAA0B,EAAE,EAAE;QAC9C,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACzB,KAAK,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;SAClC;QACD,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACzB,CAAC,CAAC;AACN,CAAC;AAED,SAAS,YAAY,CAAC,WAAgB;IAClC,IAAA,0BAAM,EAAC,OAAO,WAAW,KAAK,UAAU,CAAC,CAAC;IAC1C,OAAO,CAAC,MAAoB,EAAE,EAAE;QAC5B,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC;QAChC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrB,OAAO,KAAK,CAAC;IACjB,CAAC,CAAC;AACN,CAAC;AAED,SAAS,YAAY,CAAC,WAAgB;IAClC,IAAA,0BAAM,EAAC,OAAO,WAAW,KAAK,UAAU,CAAC,CAAC;IAC1C,OAAO,CAAC,KAAU,EAAE,EAAE;QAClB,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,GAAG,CAAC;IACf,CAAC,CAAC;AACN,CAAC;AAED,SAAgB,6BAA6B,CAAC,WAA4B;IACtE,IAAA,0BAAM,EAAC,OAAO,WAAW,KAAK,UAAU,CAAC,CAAC;IAE1C,MAAM,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;IAE/C,IAAA,4BAAY,EAAC;QACT,IAAI;QACJ,OAAO,EAAE,IAAI;QAEb,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC;QAEjC,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC;QAEjC,MAAM,EAAE,YAAY,CAAC,WAAW,CAAC;QAEjC,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,WAAW,EAAE;KACxC,CAAC,CAAC;AACP,CAAC;AAjBD,sEAiBC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
|
|
2
|
+
import { EnumerationDefinitionSchema } from "./enumerations";
|
|
3
|
+
import { CommonInterface, IStructuredTypeSchema, ConstructorFuncWithSchema, ConstructorFunc, IBaseUAObject } from "./types";
|
|
4
|
+
export interface StructureInfo {
|
|
5
|
+
constructor: ConstructorFuncWithSchema | null;
|
|
6
|
+
schema: IStructuredTypeSchema;
|
|
7
|
+
}
|
|
8
|
+
export declare class DataTypeFactory {
|
|
9
|
+
defaultByteOrder: string;
|
|
10
|
+
targetNamespace: string;
|
|
11
|
+
imports: string[];
|
|
12
|
+
private _structureInfoByName;
|
|
13
|
+
private _structureInfoByDataTypeMap;
|
|
14
|
+
private _structureInfoByEncodingMap;
|
|
15
|
+
private _enumerations;
|
|
16
|
+
private baseDataFactories;
|
|
17
|
+
constructor(baseDataFactories: DataTypeFactory[]);
|
|
18
|
+
getStructureIterator(): IterableIterator<StructureInfo>;
|
|
19
|
+
getEnumIterator(): IterableIterator<EnumerationDefinitionSchema>;
|
|
20
|
+
repairBaseDataFactories(baseDataFactories: DataTypeFactory[]): void;
|
|
21
|
+
hasBuiltInType(name: string): boolean;
|
|
22
|
+
getBuiltInType(name: string): CommonInterface;
|
|
23
|
+
getBuiltInTypeByDataType(nodeId: NodeId): CommonInterface;
|
|
24
|
+
registerEnumeration(enumeration: EnumerationDefinitionSchema): void;
|
|
25
|
+
hasEnumeration(enumName: string): boolean;
|
|
26
|
+
getEnumeration(enumName: string): EnumerationDefinitionSchema | null;
|
|
27
|
+
findStructureInfoForDataType(dataTypeNodeId: NodeId): StructureInfo;
|
|
28
|
+
getStructureInfoForDataType(dataTypeNodeId: NodeId): StructureInfo | null;
|
|
29
|
+
structuredTypesNames(): IterableIterator<string>;
|
|
30
|
+
enumerations(): IterableIterator<string>;
|
|
31
|
+
getStructureInfoByTypeName(typeName: string): StructureInfo;
|
|
32
|
+
hasStructureByTypeName(typeName: string): boolean;
|
|
33
|
+
getStructuredTypeSchema(typeName: string): IStructuredTypeSchema;
|
|
34
|
+
dump(): void;
|
|
35
|
+
registerAbstractStructure(dataTypeNodeId: NodeId, className: string, schema: IStructuredTypeSchema): void;
|
|
36
|
+
registerClassDefinition(dataTypeNodeId: NodeId, className: string, classConstructor: ConstructorFuncWithSchema): void;
|
|
37
|
+
getConstructor(binaryEncodingNodeId: NodeId): ConstructorFunc | null;
|
|
38
|
+
hasConstructor(binaryEncodingNodeId: NodeId): boolean;
|
|
39
|
+
constructObject(binaryEncodingNodeId: NodeId): IBaseUAObject;
|
|
40
|
+
associateWithBinaryEncoding(className: string, expandedNodeId: ExpandedNodeId): void;
|
|
41
|
+
toString(): string;
|
|
42
|
+
private _registerFactory;
|
|
43
|
+
}
|