node-opcua-factory 2.51.0 → 2.55.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/LICENSE +20 -20
- package/dist/datatype_factory.d.ts +0 -1
- package/dist/datatype_factory.js +3 -10
- package/dist/datatype_factory.js.map +1 -1
- package/dist/factories_baseobject.js +38 -26
- package/dist/factories_baseobject.js.map +1 -1
- package/dist/factories_builtin_types.js +2 -2
- package/dist/factories_builtin_types.js.map +1 -1
- package/dist/factories_enumerations.js +1 -1
- package/dist/factories_enumerations.js.map +1 -1
- package/dist/factories_structuredTypeSchema.d.ts +1 -2
- package/dist/factories_structuredTypeSchema.js +1 -2
- package/dist/factories_structuredTypeSchema.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.js +0 -4
- package/dist/types.js.map +1 -1
- package/package.json +12 -12
- package/source/constructor_type.ts +18 -18
- package/source/datatype_factory.ts +5 -12
- package/source/factories_baseobject.ts +40 -27
- package/source/factories_basic_type.ts +1 -1
- package/source/factories_builtin_types.ts +3 -3
- package/source/factories_builtin_types_special.ts +1 -1
- package/source/factories_enumerations.ts +4 -4
- package/source/factories_factories.ts +58 -58
- package/source/factories_id_generator.ts +18 -18
- package/source/factories_schema_helpers.ts +125 -125
- package/source/factories_structuredTypeSchema.ts +4 -5
- package/source/index.ts +15 -15
- package/source/types.ts +1 -7
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node-opcua-factory
|
|
3
|
-
*/
|
|
4
|
-
import { ExpandedNodeId } from "node-opcua-nodeid";
|
|
5
|
-
|
|
6
|
-
import { BaseUAObject } from "./factories_baseobject";
|
|
7
|
-
import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
|
|
8
|
-
|
|
9
|
-
type BaseUAObjectConstructable = new (options?: any) => BaseUAObject;
|
|
10
|
-
export type ConstructorFunc = BaseUAObjectConstructable;
|
|
11
|
-
// new (...args: any[]) => BaseUAObjectConstructable;
|
|
12
|
-
|
|
13
|
-
export interface ConstructorFuncWithSchema extends ConstructorFunc {
|
|
14
|
-
schema: StructuredTypeSchema;
|
|
15
|
-
possibleFields: string[];
|
|
16
|
-
encodingDefaultBinary: ExpandedNodeId;
|
|
17
|
-
encodingDefaultXml: ExpandedNodeId;
|
|
18
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-factory
|
|
3
|
+
*/
|
|
4
|
+
import { ExpandedNodeId } from "node-opcua-nodeid";
|
|
5
|
+
|
|
6
|
+
import { BaseUAObject } from "./factories_baseobject";
|
|
7
|
+
import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
|
|
8
|
+
|
|
9
|
+
type BaseUAObjectConstructable = new (options?: any) => BaseUAObject;
|
|
10
|
+
export type ConstructorFunc = BaseUAObjectConstructable;
|
|
11
|
+
// new (...args: any[]) => BaseUAObjectConstructable;
|
|
12
|
+
|
|
13
|
+
export interface ConstructorFuncWithSchema extends ConstructorFunc {
|
|
14
|
+
schema: StructuredTypeSchema;
|
|
15
|
+
possibleFields: string[];
|
|
16
|
+
encodingDefaultBinary: ExpandedNodeId;
|
|
17
|
+
encodingDefaultXml: ExpandedNodeId;
|
|
18
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-factory
|
|
3
3
|
*/
|
|
4
|
-
// tslint:disable:no-console
|
|
5
|
-
import * as chalk from "chalk";
|
|
6
4
|
import * as util from "util";
|
|
5
|
+
import * as chalk from "chalk";
|
|
7
6
|
|
|
8
7
|
import { assert } from "node-opcua-assert";
|
|
9
8
|
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
|
|
@@ -42,7 +41,7 @@ export class DataTypeFactory {
|
|
|
42
41
|
this.baseDataFactories = baseDataFactories;
|
|
43
42
|
}
|
|
44
43
|
// -----------------------------
|
|
45
|
-
public registerSimpleType(name: string, dataTypeNodeId: NodeId, def: BasicTypeDefinition) {
|
|
44
|
+
public registerSimpleType(name: string, dataTypeNodeId: NodeId, def: BasicTypeDefinition): void {
|
|
46
45
|
// istanbul ignore next
|
|
47
46
|
if (this._simpleTypes.has(name)) {
|
|
48
47
|
throw new Error("registerSimpleType " + name + " already register");
|
|
@@ -257,10 +256,10 @@ export class DataTypeFactory {
|
|
|
257
256
|
return new BaseUAObject();
|
|
258
257
|
// throw new Error("Cannot find constructor for " + expandedNodeId.toString());
|
|
259
258
|
}
|
|
260
|
-
return
|
|
259
|
+
return new constructor();
|
|
261
260
|
}
|
|
262
261
|
|
|
263
|
-
public associateWithBinaryEncoding(className: string, expandedNodeId: ExpandedNodeId) {
|
|
262
|
+
public associateWithBinaryEncoding(className: string, expandedNodeId: ExpandedNodeId): void {
|
|
264
263
|
const classConstructor = this.getStructureTypeConstructor(className);
|
|
265
264
|
if (doDebug) {
|
|
266
265
|
debugLog(" associateWithBinaryEncoding ", className, expandedNodeId.toString());
|
|
@@ -359,10 +358,4 @@ function verifyExpandedNodeId(expandedNodeId: NodeId): boolean {
|
|
|
359
358
|
|
|
360
359
|
function makeExpandedNodeIdKey(expandedNodeId: NodeId): string {
|
|
361
360
|
return expandedNodeId.toString();
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
export function callConstructor(constructor: ConstructorFunc): BaseUAObject {
|
|
365
|
-
assert(typeof constructor === "function");
|
|
366
|
-
const constructorFunc: any = constructor.bind.apply(constructor, arguments as any);
|
|
367
|
-
return new constructorFunc();
|
|
368
|
-
}
|
|
361
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
/* eslint-disable prefer-rest-params */
|
|
2
|
+
/* eslint-disable complexity */
|
|
1
3
|
/**
|
|
2
4
|
* @module node-opcua-factory
|
|
3
5
|
*/
|
|
4
6
|
// tslint:disable:no-shadowed-variable
|
|
5
7
|
import * as chalk from "chalk";
|
|
6
8
|
import { assert } from "node-opcua-assert";
|
|
9
|
+
import { AttributeIds } from "node-opcua-basic-types";
|
|
7
10
|
import { BinaryStream, BinaryStreamSizeCalculator, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
8
11
|
import { hexDump } from "node-opcua-debug";
|
|
9
12
|
import { NodeId } from "node-opcua-nodeid";
|
|
@@ -11,11 +14,10 @@ import * as utils from "node-opcua-utils";
|
|
|
11
14
|
|
|
12
15
|
import { getBuildInType } from "./factories_builtin_types";
|
|
13
16
|
import { getEnumeration, hasEnumeration } from "./factories_enumerations";
|
|
14
|
-
import {
|
|
17
|
+
import { DataTypeFactory } from "./datatype_factory";
|
|
15
18
|
import { getStructureTypeConstructor } from "./factories_factories";
|
|
16
19
|
import { get_base_schema, StructuredTypeSchema } from "./factories_structuredTypeSchema";
|
|
17
20
|
import { EnumerationDefinition, FieldCategory, StructuredTypeField, BuiltInTypeDefinition, FieldType } from "./types";
|
|
18
|
-
import { AttributeIds } from "node-opcua-basic-types";
|
|
19
21
|
|
|
20
22
|
function r(str: string, length = 30) {
|
|
21
23
|
return (str + " ").substr(0, length);
|
|
@@ -50,7 +52,7 @@ function _decode_member_(value: any, field: StructuredTypeField, stream: BinaryS
|
|
|
50
52
|
}
|
|
51
53
|
// assert(typeof field.fieldTypeConstructor === "function");
|
|
52
54
|
const constructor = field.fieldTypeConstructor;
|
|
53
|
-
value =
|
|
55
|
+
value = new constructor();
|
|
54
56
|
value.decodeDebug(stream, options);
|
|
55
57
|
}
|
|
56
58
|
}
|
|
@@ -122,7 +124,9 @@ interface ExploreParams {
|
|
|
122
124
|
padding: string;
|
|
123
125
|
lines: string[];
|
|
124
126
|
}
|
|
125
|
-
|
|
127
|
+
// eslint-disable-next-line complexity
|
|
128
|
+
// eslint-disable-next-line max-statements
|
|
129
|
+
function _exploreObject(self: BaseUAObject, field: StructuredTypeField, data: ExploreParams, args: any): void {
|
|
126
130
|
if (!self) {
|
|
127
131
|
return;
|
|
128
132
|
}
|
|
@@ -217,6 +221,7 @@ function _exploreObject(self: BaseUAObject, field: StructuredTypeField, data: Ex
|
|
|
217
221
|
} else if (fieldType === "DateTime" || fieldType === "UtcTime") {
|
|
218
222
|
value = value && value.toISOString ? value.toISOString() : value;
|
|
219
223
|
} else if (typeof value === "object" && value !== null && value !== undefined) {
|
|
224
|
+
// eslint-disable-next-line prefer-spread
|
|
220
225
|
value = value.toString.apply(value, args);
|
|
221
226
|
}
|
|
222
227
|
str =
|
|
@@ -298,23 +303,25 @@ function _exploreObject(self: BaseUAObject, field: StructuredTypeField, data: Ex
|
|
|
298
303
|
|
|
299
304
|
switch (category) {
|
|
300
305
|
case FieldCategory.enumeration:
|
|
301
|
-
|
|
306
|
+
{
|
|
307
|
+
const s = field.schema as EnumerationDefinition;
|
|
302
308
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
309
|
+
// istanbul ignore next
|
|
310
|
+
if (!s.typedEnum) {
|
|
311
|
+
// tslint:disable:no-console
|
|
312
|
+
console.log("xxxx cannot find typeEnum", s);
|
|
313
|
+
}
|
|
314
|
+
// istanbul ignore next
|
|
315
|
+
if (!s.typedEnum.get(value)) {
|
|
316
|
+
// tslint:disable:no-console
|
|
317
|
+
(s.typedEnum as any)._isFlaggable = true;
|
|
318
|
+
console.log("xxxx cannot find typeEnum value ", value);
|
|
319
|
+
str = fieldNameF + " " + fieldTypeF + ": " + s.name + "." + s.typedEnum.get(value) + " ( " + value + ")";
|
|
320
|
+
data.lines.push(str);
|
|
321
|
+
} else {
|
|
322
|
+
str = fieldNameF + " " + fieldTypeF + ": " + s.name + "." + s.typedEnum.get(value)!.key + " ( " + value + ")";
|
|
323
|
+
data.lines.push(str);
|
|
324
|
+
}
|
|
318
325
|
}
|
|
319
326
|
break;
|
|
320
327
|
case FieldCategory.basic:
|
|
@@ -390,7 +397,9 @@ export interface BaseUAObject {
|
|
|
390
397
|
* @constructor
|
|
391
398
|
*/
|
|
392
399
|
export class BaseUAObject {
|
|
393
|
-
constructor() {
|
|
400
|
+
constructor() {
|
|
401
|
+
/** */
|
|
402
|
+
}
|
|
394
403
|
|
|
395
404
|
/**
|
|
396
405
|
* Encode the object to the binary stream.
|
|
@@ -398,7 +407,9 @@ export class BaseUAObject {
|
|
|
398
407
|
* @method encode
|
|
399
408
|
* @param stream {BinaryStream}
|
|
400
409
|
*/
|
|
401
|
-
public encode(stream: OutputBinaryStream): void {
|
|
410
|
+
public encode(stream: OutputBinaryStream): void {
|
|
411
|
+
/** */
|
|
412
|
+
}
|
|
402
413
|
|
|
403
414
|
/**
|
|
404
415
|
* Decode the object from the binary stream.
|
|
@@ -406,7 +417,9 @@ export class BaseUAObject {
|
|
|
406
417
|
* @method decode
|
|
407
418
|
* @param stream {BinaryStream}
|
|
408
419
|
*/
|
|
409
|
-
public decode(stream: BinaryStream): void {
|
|
420
|
+
public decode(stream: BinaryStream): void {
|
|
421
|
+
/** */
|
|
422
|
+
}
|
|
410
423
|
|
|
411
424
|
/**
|
|
412
425
|
* Calculate the required size to store this object in a binary stream.
|
|
@@ -424,14 +437,14 @@ export class BaseUAObject {
|
|
|
424
437
|
* @return {String}
|
|
425
438
|
*/
|
|
426
439
|
public toString(...args: any[]): string {
|
|
427
|
-
if (this.schema &&
|
|
440
|
+
if (this.schema && Object.prototype.hasOwnProperty.call(this.schema, "toString")) {
|
|
428
441
|
return this.schema.toString.apply(this, arguments as any);
|
|
429
442
|
} else {
|
|
430
443
|
if (!this.explore) {
|
|
431
444
|
// xx console.log(util.inspect(this));
|
|
432
445
|
return Object.prototype.toString.apply(this, arguments as any);
|
|
433
446
|
}
|
|
434
|
-
return this.explore
|
|
447
|
+
return this.explore();
|
|
435
448
|
}
|
|
436
449
|
}
|
|
437
450
|
|
|
@@ -464,8 +477,8 @@ export class BaseUAObject {
|
|
|
464
477
|
for (const field of schema.fields) {
|
|
465
478
|
const value = self[field.name];
|
|
466
479
|
|
|
467
|
-
if (typeof field.switchValue === "number"
|
|
468
|
-
// skip
|
|
480
|
+
if (typeof field.switchValue === "number") {
|
|
481
|
+
// skip
|
|
469
482
|
if (self["switchField"] !== field.switchValue) {
|
|
470
483
|
continue;
|
|
471
484
|
}
|
|
@@ -46,7 +46,7 @@ export interface BasicTypeOptions {
|
|
|
46
46
|
*
|
|
47
47
|
* @param [schema.toJSON]optional, a method to convert a value into the request type.
|
|
48
48
|
*/
|
|
49
|
-
export function registerBasicType(schema: BasicTypeOptions) {
|
|
49
|
+
export function registerBasicType(schema: BasicTypeOptions): void {
|
|
50
50
|
const exists: boolean = hasBuiltInType(schema.name);
|
|
51
51
|
|
|
52
52
|
/* istanbul ignore next */
|
|
@@ -65,8 +65,7 @@ import { makeExpandedNodeId, makeNodeId } from "node-opcua-nodeid";
|
|
|
65
65
|
import { coerceStatusCode, decodeStatusCode, encodeStatusCode, StatusCodes } from "node-opcua-status-code";
|
|
66
66
|
import { BasicTypeDefinition, BasicTypeDefinitionOptions, FieldCategory, TypeSchemaBase } from "./types";
|
|
67
67
|
|
|
68
|
-
//
|
|
69
|
-
// tslint:enable:no-unused-variable
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
70
69
|
function defaultEncode(value: any, stream: OutputBinaryStream): void {}
|
|
71
70
|
|
|
72
71
|
function defaultDecode(stream: BinaryStream): any {
|
|
@@ -109,6 +108,7 @@ function decodeAny(stream: BinaryStream) {
|
|
|
109
108
|
assert(false, "type 'Any' cannot be decoded");
|
|
110
109
|
}
|
|
111
110
|
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
112
112
|
function encodeNull(value: any, stream: OutputBinaryStream): void {}
|
|
113
113
|
|
|
114
114
|
function decodeNull(stream: BinaryStream): any {
|
|
@@ -376,6 +376,6 @@ export function findBuiltInType(dataTypeName: string): BasicTypeDefinition {
|
|
|
376
376
|
return t;
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
-
export function getTypeMap() {
|
|
379
|
+
export function getTypeMap(): Map<string, BasicTypeSchema> {
|
|
380
380
|
return _defaultTypeMap;
|
|
381
381
|
}
|
|
@@ -35,7 +35,7 @@ function _self_coerce(constructor: any) {
|
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export function registerSpecialVariantEncoder(constructor: ConstructorFunc) {
|
|
38
|
+
export function registerSpecialVariantEncoder(constructor: ConstructorFunc): void {
|
|
39
39
|
assert(typeof constructor === "function");
|
|
40
40
|
|
|
41
41
|
const name = constructor.prototype.schema.name;
|
|
@@ -15,7 +15,7 @@ function _encode_enumeration(typedEnum: Enum, value: number, stream: OutputBinar
|
|
|
15
15
|
|
|
16
16
|
function _decode_enumeration(typedEnum: Enum, stream: BinaryStream): number {
|
|
17
17
|
const value = stream.readInteger();
|
|
18
|
-
const e =
|
|
18
|
+
const e = typedEnum.get(value) as any as string;
|
|
19
19
|
// istanbul ignore next
|
|
20
20
|
if (!e) {
|
|
21
21
|
throw new Error("cannot coerce value=" + value + " to " + typedEnum.constructor.name);
|
|
@@ -72,11 +72,11 @@ const _enumerations: Map<string, EnumerationDefinitionSchema> = new Map<string,
|
|
|
72
72
|
* @return {Enum}
|
|
73
73
|
*/
|
|
74
74
|
export function registerEnumeration(options: EnumerationDefinitionOptions): Enum {
|
|
75
|
-
assert(Object.prototype.hasOwnProperty.call(options,"name"));
|
|
76
|
-
assert(Object.prototype.hasOwnProperty.call(options,"enumValues"));
|
|
75
|
+
assert(Object.prototype.hasOwnProperty.call(options, "name"));
|
|
76
|
+
assert(Object.prototype.hasOwnProperty.call(options, "enumValues"));
|
|
77
77
|
const name = options.name;
|
|
78
78
|
|
|
79
|
-
if (
|
|
79
|
+
if (Object.prototype.hasOwnProperty.call(_enumerations, name)) {
|
|
80
80
|
throw new Error("factories.registerEnumeration : Enumeration " + options.name + " has been already inserted");
|
|
81
81
|
}
|
|
82
82
|
const enumerationDefinition = new EnumerationDefinitionSchema(options);
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node-opcua-factory
|
|
3
|
-
*/
|
|
4
|
-
// tslint:disable:no-console
|
|
5
|
-
|
|
6
|
-
import * as chalk from "chalk";
|
|
7
|
-
|
|
8
|
-
import { assert } from "node-opcua-assert";
|
|
9
|
-
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
|
|
10
|
-
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
|
|
11
|
-
|
|
12
|
-
import { DataTypeFactory } from "./datatype_factory";
|
|
13
|
-
import { ConstructorFuncWithSchema, ConstructorFunc } from "./constructor_type";
|
|
14
|
-
|
|
15
|
-
import { BaseUAObject } from "./factories_baseobject";
|
|
16
|
-
import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
|
|
17
|
-
|
|
18
|
-
const debugLog = make_debugLog(__filename);
|
|
19
|
-
const doDebug = checkDebugFlag(__filename);
|
|
20
|
-
|
|
21
|
-
let globalFactory: DataTypeFactory;
|
|
22
|
-
export function getStandardDataTypeFactory(): DataTypeFactory {
|
|
23
|
-
if (!globalFactory) {
|
|
24
|
-
globalFactory = new DataTypeFactory([]);
|
|
25
|
-
globalFactory.targetNamespace = "http://opcfoundation.org/UA/";
|
|
26
|
-
}
|
|
27
|
-
return globalFactory;
|
|
28
|
-
}
|
|
29
|
-
export function getStructureTypeConstructor(typeName: string): ConstructorFuncWithSchema {
|
|
30
|
-
return getStandardDataTypeFactory().getStructureTypeConstructor(typeName);
|
|
31
|
-
}
|
|
32
|
-
export function hasStructuredType(typeName: string): boolean {
|
|
33
|
-
return getStandardDataTypeFactory().hasStructuredType(typeName);
|
|
34
|
-
}
|
|
35
|
-
export function getStructuredTypeSchema(typeName: string): StructuredTypeSchema {
|
|
36
|
-
return getStandardDataTypeFactory().getStructuredTypeSchema(typeName);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function getConstructor(binaryEncodingNodeId: ExpandedNodeId): ConstructorFunc | null {
|
|
40
|
-
return getStandardDataTypeFactory().getConstructor(binaryEncodingNodeId);
|
|
41
|
-
}
|
|
42
|
-
export function hasConstructor(binaryEncodingNodeId: ExpandedNodeId): boolean {
|
|
43
|
-
return getStandardDataTypeFactory().hasConstructor(binaryEncodingNodeId);
|
|
44
|
-
}
|
|
45
|
-
export function constructObject(binaryEncodingNodeId: ExpandedNodeId): BaseUAObject {
|
|
46
|
-
return getStandardDataTypeFactory().constructObject(binaryEncodingNodeId);
|
|
47
|
-
}
|
|
48
|
-
export function registerClassDefinition(
|
|
49
|
-
dataTypeNodeId: NodeId,
|
|
50
|
-
className: string,
|
|
51
|
-
classConstructor: ConstructorFuncWithSchema
|
|
52
|
-
): void {
|
|
53
|
-
return getStandardDataTypeFactory().registerClassDefinition(dataTypeNodeId, className, classConstructor);
|
|
54
|
-
}
|
|
55
|
-
/* istanbul ignore next */
|
|
56
|
-
export function dump(): void {
|
|
57
|
-
getStandardDataTypeFactory().dump();
|
|
58
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-factory
|
|
3
|
+
*/
|
|
4
|
+
// tslint:disable:no-console
|
|
5
|
+
|
|
6
|
+
import * as chalk from "chalk";
|
|
7
|
+
|
|
8
|
+
import { assert } from "node-opcua-assert";
|
|
9
|
+
import { checkDebugFlag, make_debugLog } from "node-opcua-debug";
|
|
10
|
+
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid";
|
|
11
|
+
|
|
12
|
+
import { DataTypeFactory } from "./datatype_factory";
|
|
13
|
+
import { ConstructorFuncWithSchema, ConstructorFunc } from "./constructor_type";
|
|
14
|
+
|
|
15
|
+
import { BaseUAObject } from "./factories_baseobject";
|
|
16
|
+
import { StructuredTypeSchema } from "./factories_structuredTypeSchema";
|
|
17
|
+
|
|
18
|
+
const debugLog = make_debugLog(__filename);
|
|
19
|
+
const doDebug = checkDebugFlag(__filename);
|
|
20
|
+
|
|
21
|
+
let globalFactory: DataTypeFactory;
|
|
22
|
+
export function getStandardDataTypeFactory(): DataTypeFactory {
|
|
23
|
+
if (!globalFactory) {
|
|
24
|
+
globalFactory = new DataTypeFactory([]);
|
|
25
|
+
globalFactory.targetNamespace = "http://opcfoundation.org/UA/";
|
|
26
|
+
}
|
|
27
|
+
return globalFactory;
|
|
28
|
+
}
|
|
29
|
+
export function getStructureTypeConstructor(typeName: string): ConstructorFuncWithSchema {
|
|
30
|
+
return getStandardDataTypeFactory().getStructureTypeConstructor(typeName);
|
|
31
|
+
}
|
|
32
|
+
export function hasStructuredType(typeName: string): boolean {
|
|
33
|
+
return getStandardDataTypeFactory().hasStructuredType(typeName);
|
|
34
|
+
}
|
|
35
|
+
export function getStructuredTypeSchema(typeName: string): StructuredTypeSchema {
|
|
36
|
+
return getStandardDataTypeFactory().getStructuredTypeSchema(typeName);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getConstructor(binaryEncodingNodeId: ExpandedNodeId): ConstructorFunc | null {
|
|
40
|
+
return getStandardDataTypeFactory().getConstructor(binaryEncodingNodeId);
|
|
41
|
+
}
|
|
42
|
+
export function hasConstructor(binaryEncodingNodeId: ExpandedNodeId): boolean {
|
|
43
|
+
return getStandardDataTypeFactory().hasConstructor(binaryEncodingNodeId);
|
|
44
|
+
}
|
|
45
|
+
export function constructObject(binaryEncodingNodeId: ExpandedNodeId): BaseUAObject {
|
|
46
|
+
return getStandardDataTypeFactory().constructObject(binaryEncodingNodeId);
|
|
47
|
+
}
|
|
48
|
+
export function registerClassDefinition(
|
|
49
|
+
dataTypeNodeId: NodeId,
|
|
50
|
+
className: string,
|
|
51
|
+
classConstructor: ConstructorFuncWithSchema
|
|
52
|
+
): void {
|
|
53
|
+
return getStandardDataTypeFactory().registerClassDefinition(dataTypeNodeId, className, classConstructor);
|
|
54
|
+
}
|
|
55
|
+
/* istanbul ignore next */
|
|
56
|
+
export function dump(): void {
|
|
57
|
+
getStandardDataTypeFactory().dump();
|
|
58
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module node-opcua-factory
|
|
3
|
-
*/
|
|
4
|
-
const _FIRST_INTERNAL_ID = 0xFFFE0000;
|
|
5
|
-
|
|
6
|
-
let _nextAvailableId = _FIRST_INTERNAL_ID;
|
|
7
|
-
|
|
8
|
-
export function generate_new_id(): number {
|
|
9
|
-
_nextAvailableId += 1;
|
|
10
|
-
return _nextAvailableId;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function next_available_id(): number {
|
|
14
|
-
return -1;
|
|
15
|
-
}
|
|
16
|
-
export function is_internal_id(value: number): boolean {
|
|
17
|
-
return value >= _FIRST_INTERNAL_ID;
|
|
18
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @module node-opcua-factory
|
|
3
|
+
*/
|
|
4
|
+
const _FIRST_INTERNAL_ID = 0xFFFE0000;
|
|
5
|
+
|
|
6
|
+
let _nextAvailableId = _FIRST_INTERNAL_ID;
|
|
7
|
+
|
|
8
|
+
export function generate_new_id(): number {
|
|
9
|
+
_nextAvailableId += 1;
|
|
10
|
+
return _nextAvailableId;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function next_available_id(): number {
|
|
14
|
+
return -1;
|
|
15
|
+
}
|
|
16
|
+
export function is_internal_id(value: number): boolean {
|
|
17
|
+
return value >= _FIRST_INTERNAL_ID;
|
|
18
|
+
}
|