node-opcua-factory
Advanced tools
Comparing version 2.4.2 to 2.5.0-alpha.0
@@ -0,0 +0,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=constructor_type.js.map |
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid"; | ||
import { ConstructorFunc, ConstructorFuncWithSchema } from "./constructor_type"; | ||
import { BaseUAObject } from "./factories_baseobject"; | ||
import { EnumerationDefinitionSchema } from "./factories_enumerations"; | ||
import { StructuredTypeSchema } from "./factories_structuredTypeSchema"; | ||
import { BasicTypeDefinition } from "."; | ||
export declare class DataTypeFactory { | ||
@@ -10,6 +12,16 @@ defaultByteOrder: string; | ||
private _structureTypeConstructorByNameMap; | ||
private _structureTypeConstructorByDataTypeMap; | ||
private _structureTypeConstructorByEncodingNodeIdMap; | ||
private _enumerations; | ||
private _simpleTypes; | ||
private readonly baseDataFactories; | ||
constructor(baseDataFactories: DataTypeFactory[]); | ||
registerFactory(typeName: string, constructor: ConstructorFuncWithSchema): void; | ||
registerSimpleType(name: string, dataTypeNodeId: NodeId, def: BasicTypeDefinition): void; | ||
hasSimpleType(name: string): boolean; | ||
getSimpleType(name: string): BasicTypeDefinition; | ||
registerEnumeration(enumeration: EnumerationDefinitionSchema): void; | ||
hasEnumeration(enumName: string): boolean; | ||
getEnumeration(enumName: string): EnumerationDefinitionSchema | null; | ||
findConstructorForDataType(dataTypeNodeId: NodeId): ConstructorFuncWithSchema; | ||
structuredTypesNames(): string[]; | ||
getStructureTypeConstructor(typeName: string): ConstructorFuncWithSchema; | ||
@@ -19,9 +31,9 @@ hasStructuredType(typeName: string): boolean; | ||
dump(): void; | ||
registerClassDefinition(className: string, classConstructor: ConstructorFuncWithSchema): void; | ||
associateWithDataType(className: string, nodeId: NodeId): void; | ||
registerClassDefinition(dataTypeNodeId: NodeId, className: string, classConstructor: ConstructorFuncWithSchema): void; | ||
getConstructor(binaryEncodingNodeId: NodeId): ConstructorFunc | null; | ||
hasConstructor(binaryEncodingNodeId: NodeId): boolean; | ||
constructObject(binaryEncodingNodeId: NodeId): BaseUAObject; | ||
associateWithBinaryEncoding(className: string, expandedNodeId: ExpandedNodeId): void; | ||
getConstructor(expandedNodeId: ExpandedNodeId): ConstructorFunc | null; | ||
hasConstructor(expandedNodeId: ExpandedNodeId): boolean; | ||
constructObject(expandedNodeId: ExpandedNodeId): BaseUAObject; | ||
registerFactory(dataTypeNodeId: NodeId, typeName: string, constructor: ConstructorFuncWithSchema): void; | ||
} | ||
export declare function callConstructor(constructor: ConstructorFunc): BaseUAObject; |
@@ -12,2 +12,4 @@ "use strict"; | ||
const factories_baseobject_1 = require("./factories_baseobject"); | ||
const factories_enumerations_1 = require("./factories_enumerations"); | ||
const factories_builtin_types_1 = require("./factories_builtin_types"); | ||
const debugLog = node_opcua_debug_1.make_debugLog(__filename); | ||
@@ -19,3 +21,6 @@ const doDebug = node_opcua_debug_1.checkDebugFlag(__filename); | ||
this._structureTypeConstructorByNameMap = {}; | ||
this._structureTypeConstructorByDataTypeMap = {}; | ||
this._structureTypeConstructorByEncodingNodeIdMap = {}; | ||
this._enumerations = {}; | ||
this._simpleTypes = {}; | ||
this.defaultByteOrder = "LittleEndian"; | ||
@@ -25,16 +30,89 @@ this.targetNamespace = ""; | ||
} | ||
registerFactory(typeName, constructor) { | ||
/* istanbul ignore next */ | ||
if (this.hasStructuredType(typeName)) { | ||
console.log(this.getStructureTypeConstructor(typeName)); | ||
console.log("target namespace =", this.targetNamespace); | ||
throw new Error(" registerFactory : " + typeName + " already registered"); | ||
// ----------------------------- | ||
registerSimpleType(name, dataTypeNodeId, def) { | ||
if (this._simpleTypes[name]) { | ||
throw new Error("registerSimpleType " + name + " already register"); | ||
} | ||
this._structureTypeConstructorByNameMap[typeName] = constructor; | ||
Object.defineProperty(constructor.schema, "$typeDictionary", { | ||
enumerable: false, | ||
value: this, | ||
writable: false, | ||
}); | ||
this._simpleTypes[name] = { nodeId: dataTypeNodeId, definition: def }; | ||
} | ||
hasSimpleType(name) { | ||
if (this._simpleTypes[name]) { | ||
return true; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
if (factory.hasSimpleType(name)) { | ||
return true; | ||
} | ||
} | ||
const hasSimpleT = factories_builtin_types_1.hasBuiltInType(name); | ||
if (hasSimpleT) { | ||
return hasSimpleT; | ||
} | ||
return factories_builtin_types_1.hasBuiltInType(name); | ||
} | ||
getSimpleType(name) { | ||
if (this._simpleTypes[name]) { | ||
return this._simpleTypes[name].definition; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
if (factory.hasSimpleType(name)) { | ||
return factory.getSimpleType(name); | ||
} | ||
} | ||
return factories_builtin_types_1.getBuildInType(name); | ||
} | ||
// ----------------------------- | ||
// EnumerationDefinitionSchema | ||
registerEnumeration(enumeration) { | ||
node_opcua_assert_1.assert(!this._enumerations[enumeration.name]); | ||
this._enumerations[enumeration.name] = enumeration; | ||
} | ||
hasEnumeration(enumName) { | ||
if (this._enumerations[enumName]) { | ||
return true; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
const e = factory.hasEnumeration(enumName); | ||
if (e) { | ||
return true; | ||
} | ||
} | ||
if (factories_enumerations_1.hasEnumeration(enumName)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
getEnumeration(enumName) { | ||
if (this._enumerations[enumName]) { | ||
return this._enumerations[enumName]; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
const e = factory.getEnumeration(enumName); | ||
if (e !== null) { | ||
return e; | ||
} | ||
} | ||
const ee = factories_enumerations_1.getEnumeration(enumName); | ||
return ee; | ||
} | ||
// ---------------------------- | ||
findConstructorForDataType(dataTypeNodeId) { | ||
const constructor = this._structureTypeConstructorByDataTypeMap[dataTypeNodeId.toString()]; | ||
if (constructor) { | ||
return constructor; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
const constructor2 = factory.findConstructorForDataType(dataTypeNodeId); | ||
if (constructor2) { | ||
return constructor2; | ||
} | ||
} | ||
throw new Error("Cannot find StructureType constructor for dataType " + dataTypeNodeId.toString()); | ||
} | ||
// ---------------------------------------------------------------------------------------------------- | ||
// Acces by typeName | ||
// ---------------------------------------------------------------------------------------------------- | ||
structuredTypesNames() { | ||
return Object.keys(this._structureTypeConstructorByNameMap); | ||
} | ||
getStructureTypeConstructor(typeName) { | ||
@@ -51,3 +129,3 @@ const constructor = this._structureTypeConstructorByNameMap[typeName]; | ||
} | ||
throw new Error("Cannot find StructureType constructor for " + typeName); | ||
throw new Error("Cannot find StructureType constructor for " + typeName + " - it may be abstract, or it could be a basic type"); | ||
} | ||
@@ -77,38 +155,12 @@ hasStructuredType(typeName) { | ||
} | ||
registerClassDefinition(className, classConstructor) { | ||
this.registerFactory(className, classConstructor); | ||
const expandedNodeId = classConstructor.encodingDefaultBinary; | ||
this.associateWithBinaryEncoding(className, expandedNodeId); | ||
registerClassDefinition(dataTypeNodeId, className, classConstructor) { | ||
this.registerFactory(dataTypeNodeId, className, classConstructor); | ||
node_opcua_assert_1.assert(classConstructor.encodingDefaultBinary.value !== 0); | ||
this.associateWithBinaryEncoding(className, classConstructor.encodingDefaultBinary); | ||
} | ||
associateWithDataType(className, nodeId) { | ||
return; | ||
/* | ||
const schema = this.structuredTypes[className]; | ||
if (doDebug) { | ||
debugLog(" associateWithDataType ", className, nodeId.toString()); | ||
} | ||
assert(schema.id.toString() === "ns=0;i=0", "already associated"); | ||
schema.id = nodeId; | ||
*/ | ||
} | ||
associateWithBinaryEncoding(className, expandedNodeId) { | ||
const classConstructor = this.getStructureTypeConstructor(className); | ||
if (doDebug) { | ||
debugLog(" associateWithBinaryEncoding ", className, expandedNodeId.toString()); | ||
} | ||
/* istanbul ignore next */ | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
console.log(); | ||
throw new Error("Invalid expandedNodeId " + expandedNodeId.toString() + " className = " + className); | ||
} | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
/* istanbul ignore next */ | ||
if (expandedNodeIdKey in this._structureTypeConstructorByEncodingNodeIdMap) { | ||
throw new Error(" Class " + className + " with ID " + expandedNodeId + | ||
" already in constructorMap for " + this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey].name); | ||
} | ||
this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey] = classConstructor; | ||
} | ||
getConstructor(expandedNodeId) { | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
// ---------------------------------------------------------------------------------------------------- | ||
// Acces by binaryEncodingNodeId | ||
// ---------------------------------------------------------------------------------------------------- | ||
getConstructor(binaryEncodingNodeId) { | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(binaryEncodingNodeId); | ||
const constructor = this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey]; | ||
@@ -119,3 +171,3 @@ if (constructor) { | ||
for (const factory of this.baseDataFactories) { | ||
const constructor2 = factory.getConstructor(expandedNodeId); | ||
const constructor2 = factory.getConstructor(binaryEncodingNodeId); | ||
if (constructor2) { | ||
@@ -125,15 +177,15 @@ return constructor2; | ||
} | ||
debugLog(chalk.red("#getConstructor : cannot find constructor for expandedId "), expandedNodeId.toString()); | ||
debugLog(chalk.red("#getConstructor : cannot find constructor for expandedId "), binaryEncodingNodeId.toString()); | ||
return null; | ||
} | ||
hasConstructor(expandedNodeId) { | ||
if (!expandedNodeId) { | ||
hasConstructor(binaryEncodingNodeId) { | ||
if (!binaryEncodingNodeId) { | ||
return false; | ||
} | ||
/* istanbul ignore next */ | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
if (!verifyExpandedNodeId(binaryEncodingNodeId)) { | ||
console.log("Invalid expandedNodeId"); | ||
return false; | ||
} | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(binaryEncodingNodeId); | ||
const constructor = this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey]; | ||
@@ -144,3 +196,3 @@ if (constructor) { | ||
for (const factory of this.baseDataFactories) { | ||
const constructor2 = factory.getConstructor(expandedNodeId); | ||
const constructor2 = factory.getConstructor(binaryEncodingNodeId); | ||
if (constructor2) { | ||
@@ -152,9 +204,9 @@ return true; | ||
} | ||
constructObject(expandedNodeId) { | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
throw new Error(" constructObject : invalid expandedNodeId provided " + expandedNodeId.toString()); | ||
constructObject(binaryEncodingNodeId) { | ||
if (!verifyExpandedNodeId(binaryEncodingNodeId)) { | ||
throw new Error(" constructObject : invalid expandedNodeId provided " + binaryEncodingNodeId.toString()); | ||
} | ||
const constructor = this.getConstructor(expandedNodeId); | ||
const constructor = this.getConstructor(binaryEncodingNodeId); | ||
if (!constructor) { | ||
debugLog("Cannot find constructor for " + expandedNodeId.toString()); | ||
debugLog("Cannot find constructor for " + binaryEncodingNodeId.toString()); | ||
return new factories_baseobject_1.BaseUAObject(); | ||
@@ -165,2 +217,36 @@ // throw new Error("Cannot find constructor for " + expandedNodeId.toString()); | ||
} | ||
associateWithBinaryEncoding(className, expandedNodeId) { | ||
const classConstructor = this.getStructureTypeConstructor(className); | ||
if (doDebug) { | ||
debugLog(" associateWithBinaryEncoding ", className, expandedNodeId.toString()); | ||
} | ||
/* istanbul ignore next */ | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
throw new Error("Invalid expandedNodeId " + expandedNodeId.toString() + " className = " + className); | ||
} | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
/* istanbul ignore next */ | ||
if (expandedNodeIdKey in this._structureTypeConstructorByEncodingNodeIdMap) { | ||
throw new Error(" Class " + className + " with ID " + expandedNodeId + | ||
" already in constructorMap for " + this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey].name); | ||
} | ||
this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey] = classConstructor; | ||
} | ||
registerFactory(dataTypeNodeId, typeName, constructor) { | ||
node_opcua_assert_1.assert(dataTypeNodeId.value !== 0, "dataTypeNodeId cannot be null"); | ||
/* istanbul ignore next */ | ||
if (this.hasStructuredType(typeName)) { | ||
console.log(this.getStructureTypeConstructor(typeName)); | ||
console.log("target namespace =", this.targetNamespace); | ||
throw new Error(" registerFactory : " + typeName + " already registered"); | ||
} | ||
debugLog("registerning typeName ", typeName, dataTypeNodeId.toString()); | ||
this._structureTypeConstructorByNameMap[typeName] = constructor; | ||
this._structureTypeConstructorByDataTypeMap[dataTypeNodeId.toString()] = constructor; | ||
Object.defineProperty(constructor.schema, "$$factory", { | ||
enumerable: false, | ||
value: this, | ||
writable: false, | ||
}); | ||
} | ||
} | ||
@@ -173,20 +259,6 @@ exports.DataTypeFactory = DataTypeFactory; | ||
} | ||
if (expandedNodeId.namespace === 0) { | ||
if (expandedNodeId.namespaceUri === "http://opcfoundation.org/UA/" || !expandedNodeId.namespaceUri) { | ||
return true; | ||
} | ||
// When namespace is ZERO, namepaceUri must be "http://opcfoundation.org/UA/" or nothing | ||
return false; | ||
} | ||
else { | ||
// expandedNodeId.namespace !==0 | ||
// in this case a valid expandedNodeId.namespaceUri must be provided | ||
return !!expandedNodeId.namespaceUri && expandedNodeId.namespaceUri.length > 2; | ||
} | ||
return true; | ||
} | ||
function makeExpandedNodeIdKey(expandedNodeId) { | ||
if (expandedNodeId.namespace === 0) { | ||
return expandedNodeId.value.toString(); | ||
} | ||
return expandedNodeId.namespaceUri + "@" + expandedNodeId.value.toString(); | ||
return expandedNodeId.toString(); | ||
} | ||
@@ -193,0 +265,0 @@ function callConstructor(constructor) { |
@@ -0,0 +0,0 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; |
@@ -166,3 +166,3 @@ "use strict"; | ||
else { | ||
const typeDictionary = self.schema.$typeDictionary; | ||
const typeDictionary = self.schema.$$factory; | ||
if (!typeDictionary) { | ||
@@ -169,0 +169,0 @@ console.log(" No typeDictionary for ", self.schema); |
@@ -0,0 +0,0 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; |
@@ -40,5 +40,6 @@ "use strict"; | ||
const exists = factories_builtin_types_1.hasBuiltInType(schema.name); | ||
/* istanbul ignore next */ | ||
if (exists) { | ||
// tslint:disable-next-line: no-console | ||
console.log(schema); | ||
console.log("registerBasicType:", schema); | ||
throw new Error(`Basic Type ${schema.name} already registered`); | ||
@@ -92,3 +93,4 @@ } | ||
// string in the form "en-US" or "de-DE" or "fr" etc... | ||
registerBasicType({ name: "LocaleId", | ||
registerBasicType({ | ||
name: "LocaleId", | ||
subType: "String", | ||
@@ -95,0 +97,0 @@ defaultValue: null, |
import { ConstructorFunc } from "./constructor_type"; | ||
export declare function registerSpecialVariantEncoder(constructor: ConstructorFunc): void; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -29,2 +29,2 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; | ||
export declare function hasEnumeration(enumerationName: string): boolean; | ||
export declare function getEnumeration(enumerationName: string): EnumerationDefinition; | ||
export declare function getEnumeration(enumerationName: string): EnumerationDefinitionSchema; |
@@ -10,3 +10,2 @@ "use strict"; | ||
const types_1 = require("./types"); | ||
const _enumerations = new Map(); | ||
function _encode_enumeration(typedEnum, value, stream) { | ||
@@ -43,2 +42,3 @@ node_opcua_assert_1.assert(typeof value === "number", "Expecting a number here"); | ||
exports.EnumerationDefinitionSchema = EnumerationDefinitionSchema; | ||
const _enumerations = new Map(); | ||
/** | ||
@@ -72,3 +72,5 @@ * @method registerEnumeration | ||
function getEnumeration(enumerationName) { | ||
node_opcua_assert_1.assert(exports.hasEnumeration(enumerationName)); | ||
if (!exports.hasEnumeration(enumerationName)) { | ||
throw new Error("Cannot find enumeration with type " + enumerationName); | ||
} | ||
return _enumerations.get(enumerationName); | ||
@@ -75,0 +77,0 @@ } |
/** | ||
* @module node-opcua-factory | ||
*/ | ||
import { ExpandedNodeId } from "node-opcua-nodeid"; | ||
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid"; | ||
import { DataTypeFactory } from "./datatype_factory"; | ||
@@ -13,7 +13,6 @@ import { ConstructorFuncWithSchema, ConstructorFunc } from "./constructor_type"; | ||
export declare function getStructuredTypeSchema(typeName: string): StructuredTypeSchema; | ||
export declare function registerFactory(typeName: string, constructor: ConstructorFuncWithSchema): void; | ||
export declare function getConstructor(expandedNodeId: ExpandedNodeId): ConstructorFunc | null; | ||
export declare function hasConstructor(expandedNodeId: ExpandedNodeId): boolean; | ||
export declare function constructObject(expandedNodeId: ExpandedNodeId): BaseUAObject; | ||
export declare function registerClassDefinition(className: string, classConstructor: ConstructorFuncWithSchema): void; | ||
export declare function getConstructor(binaryEncodingNodeId: ExpandedNodeId): ConstructorFunc | null; | ||
export declare function hasConstructor(binaryEncodingNodeId: ExpandedNodeId): boolean; | ||
export declare function constructObject(binaryEncodingNodeId: ExpandedNodeId): BaseUAObject; | ||
export declare function registerClassDefinition(dataTypeNodeId: NodeId, className: string, classConstructor: ConstructorFuncWithSchema): void; | ||
export declare function dump(): void; |
@@ -32,20 +32,16 @@ "use strict"; | ||
exports.getStructuredTypeSchema = getStructuredTypeSchema; | ||
function registerFactory(typeName, constructor) { | ||
return getStandartDataTypeFactory().registerFactory(typeName, constructor); | ||
function getConstructor(binaryEncodingNodeId) { | ||
return getStandartDataTypeFactory().getConstructor(binaryEncodingNodeId); | ||
} | ||
exports.registerFactory = registerFactory; | ||
function getConstructor(expandedNodeId) { | ||
return getStandartDataTypeFactory().getConstructor(expandedNodeId); | ||
} | ||
exports.getConstructor = getConstructor; | ||
function hasConstructor(expandedNodeId) { | ||
return getStandartDataTypeFactory().hasConstructor(expandedNodeId); | ||
function hasConstructor(binaryEncodingNodeId) { | ||
return getStandartDataTypeFactory().hasConstructor(binaryEncodingNodeId); | ||
} | ||
exports.hasConstructor = hasConstructor; | ||
function constructObject(expandedNodeId) { | ||
return getStandartDataTypeFactory().constructObject(expandedNodeId); | ||
function constructObject(binaryEncodingNodeId) { | ||
return getStandartDataTypeFactory().constructObject(binaryEncodingNodeId); | ||
} | ||
exports.constructObject = constructObject; | ||
function registerClassDefinition(className, classConstructor) { | ||
return getStandartDataTypeFactory().registerClassDefinition(className, classConstructor); | ||
function registerClassDefinition(dataTypeNodeId, className, classConstructor) { | ||
return getStandartDataTypeFactory().registerClassDefinition(dataTypeNodeId, className, classConstructor); | ||
} | ||
@@ -52,0 +48,0 @@ exports.registerClassDefinition = registerClassDefinition; |
export declare function generate_new_id(): number; | ||
export declare function next_available_id(): number; | ||
export declare function is_internal_id(value: number): boolean; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { FieldType, StructuredTypeField } from "./types"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -7,2 +7,3 @@ import { FieldType, StructuredTypeOptions, TypeSchemaBase } from "./types"; | ||
id: NodeId; | ||
dataTypeNodeId: NodeId; | ||
baseType: string; | ||
@@ -17,2 +18,3 @@ _possibleFields: string[]; | ||
encodingDefaultXml?: ExpandedNodeId; | ||
encodingDefaultJson?: ExpandedNodeId; | ||
bitFields?: any[]; | ||
@@ -19,0 +21,0 @@ constructor(options: StructuredTypeOptions); |
@@ -95,2 +95,3 @@ "use strict"; | ||
this.id = node_opcua_nodeid_1.NodeId.nullNodeId; | ||
this.dataTypeNodeId = node_opcua_nodeid_1.NodeId.nullNodeId; | ||
this._possibleFields = this.fields.map((field) => field.name); | ||
@@ -113,3 +114,3 @@ this._baseSchema = null; | ||
} | ||
if (schema.baseType === "ExtensionObject") { | ||
if (schema.baseType === "ExtensionObject" || schema.baseType === "DataTypeDefinition") { | ||
return null; | ||
@@ -116,0 +117,0 @@ } |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "node-opcua-factory", | ||
"version": "2.4.2", | ||
"description": "pure nodejs OPCUA SDK - module -factory", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc", | ||
"lint": "tslint source/**/*.ts", | ||
"test": "echo no test" | ||
}, | ||
"dependencies": { | ||
"chalk": "^3.0.0", | ||
"node-opcua-assert": "^2.3.0", | ||
"node-opcua-basic-types": "^2.4.2", | ||
"node-opcua-binary-stream": "^2.4.2", | ||
"node-opcua-enum": "^2.4.2", | ||
"node-opcua-guid": "^2.3.0", | ||
"node-opcua-nodeid": "^2.4.2", | ||
"node-opcua-status-code": "^2.4.2", | ||
"node-opcua-utils": "^2.4.2", | ||
"underscore": "^1.9.2" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-debug": "^2.4.2" | ||
}, | ||
"author": "Etienne Rossignon", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/node-opcua/node-opcua.git" | ||
}, | ||
"keywords": [ | ||
"OPCUA", | ||
"opcua", | ||
"m2m", | ||
"iot", | ||
"opc ua", | ||
"internet of things" | ||
], | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "6e4967fd20a09317ddd00098bcfe93e92c1df510" | ||
"name": "node-opcua-factory", | ||
"version": "2.5.0-alpha.0", | ||
"description": "pure nodejs OPCUA SDK - module -factory", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"scripts": { | ||
"build": "tsc -b", | ||
"lint": "tslint source/**/*.ts", | ||
"test": "echo no test" | ||
}, | ||
"dependencies": { | ||
"chalk": "^3.0.0", | ||
"node-opcua-assert": "^2.5.0-alpha.0", | ||
"node-opcua-basic-types": "^2.5.0-alpha.0", | ||
"node-opcua-binary-stream": "^2.5.0-alpha.0", | ||
"node-opcua-debug": "^2.5.0-alpha.0", | ||
"node-opcua-enum": "^2.5.0-alpha.0", | ||
"node-opcua-guid": "^2.5.0-alpha.0", | ||
"node-opcua-nodeid": "^2.5.0-alpha.0", | ||
"node-opcua-status-code": "^2.5.0-alpha.0", | ||
"node-opcua-utils": "^2.5.0-alpha.0", | ||
"underscore": "^1.9.2" | ||
}, | ||
"author": "Etienne Rossignon", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/node-opcua/node-opcua.git" | ||
}, | ||
"keywords": [ | ||
"OPCUA", | ||
"opcua", | ||
"m2m", | ||
"iot", | ||
"opc ua", | ||
"internet of things" | ||
], | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "341ac6292b30304bb028ab10971dc8552ff1a35a" | ||
} |
@@ -0,0 +0,0 @@ /** |
@@ -10,7 +10,10 @@ /** | ||
import { checkDebugFlag, make_debugLog } from "node-opcua-debug"; | ||
import {ExpandedNodeId, NodeId} from "node-opcua-nodeid"; | ||
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid"; | ||
import { ConstructorFunc, ConstructorFuncWithSchema } from "./constructor_type"; | ||
import { BaseUAObject } from "./factories_baseobject"; | ||
import { EnumerationDefinitionSchema, hasEnumeration, getEnumeration } from "./factories_enumerations"; | ||
import { StructuredTypeSchema } from "./factories_structuredTypeSchema"; | ||
import { hasBuiltInType, getBuildInType } from "./factories_builtin_types"; | ||
import { BasicTypeDefinition } from "."; | ||
@@ -27,3 +30,12 @@ const debugLog = make_debugLog(__filename); | ||
private _structureTypeConstructorByNameMap: { [key: string]: ConstructorFuncWithSchema } = {}; | ||
private _structureTypeConstructorByDataTypeMap: { [key: string]: ConstructorFuncWithSchema } = {}; | ||
private _structureTypeConstructorByEncodingNodeIdMap: any = {}; | ||
private _enumerations: { | ||
[key: string]: EnumerationDefinitionSchema | ||
} = {}; | ||
private _simpleTypes: { | ||
[key: string]: { nodeId: NodeId, definition: BasicTypeDefinition } | ||
} = {}; | ||
private readonly baseDataFactories: DataTypeFactory[]; | ||
@@ -37,18 +49,92 @@ | ||
public registerFactory(typeName: string, constructor: ConstructorFuncWithSchema): void { | ||
/* istanbul ignore next */ | ||
if (this.hasStructuredType(typeName)) { | ||
console.log(this.getStructureTypeConstructor(typeName)); | ||
console.log("target namespace =", this.targetNamespace); | ||
throw new Error(" registerFactory : " + typeName + " already registered"); | ||
// ----------------------------- | ||
public registerSimpleType(name: string, dataTypeNodeId: NodeId, def: BasicTypeDefinition) { | ||
if (this._simpleTypes[name]) { | ||
throw new Error("registerSimpleType " + name + " already register"); | ||
} | ||
this._structureTypeConstructorByNameMap[typeName] = constructor; | ||
Object.defineProperty(constructor.schema, "$typeDictionary", { | ||
enumerable: false, | ||
value: this, | ||
writable: false, | ||
}); | ||
this._simpleTypes[name] = { nodeId: dataTypeNodeId, definition: def }; | ||
} | ||
public hasSimpleType(name: string): boolean { | ||
if (this._simpleTypes[name]) { | ||
return true; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
if (factory.hasSimpleType(name)) { | ||
return true; | ||
} | ||
} | ||
const hasSimpleT = hasBuiltInType(name); | ||
if (hasSimpleT) { | ||
return hasSimpleT; | ||
} | ||
return hasBuiltInType(name); | ||
} | ||
public getSimpleType(name: string): BasicTypeDefinition { | ||
if (this._simpleTypes[name]) { | ||
return this._simpleTypes[name].definition; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
if (factory.hasSimpleType(name)) { | ||
return factory.getSimpleType(name); | ||
} | ||
} | ||
return getBuildInType(name); | ||
} | ||
// ----------------------------- | ||
// EnumerationDefinitionSchema | ||
public registerEnumeration(enumeration: EnumerationDefinitionSchema): void { | ||
assert(!this._enumerations[enumeration.name]); | ||
this._enumerations[enumeration.name] = enumeration; | ||
} | ||
public hasEnumeration(enumName: string): boolean { | ||
if (this._enumerations[enumName]) { | ||
return true; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
const e = factory.hasEnumeration(enumName); | ||
if (e) { | ||
return true; | ||
} | ||
} | ||
if (hasEnumeration(enumName)) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
public getEnumeration(enumName: string): EnumerationDefinitionSchema | null { | ||
if (this._enumerations[enumName]) { | ||
return this._enumerations[enumName]; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
const e = factory.getEnumeration(enumName); | ||
if (e !== null) { | ||
return e; | ||
} | ||
} | ||
const ee = getEnumeration(enumName); | ||
return ee; | ||
} | ||
// ---------------------------- | ||
public findConstructorForDataType(dataTypeNodeId: NodeId): ConstructorFuncWithSchema { | ||
const constructor = this._structureTypeConstructorByDataTypeMap[dataTypeNodeId.toString()]; | ||
if (constructor) { | ||
return constructor; | ||
} | ||
for (const factory of this.baseDataFactories) { | ||
const constructor2 = factory.findConstructorForDataType(dataTypeNodeId); | ||
if (constructor2) { | ||
return constructor2; | ||
} | ||
} | ||
throw new Error("Cannot find StructureType constructor for dataType " + dataTypeNodeId.toString()); | ||
} | ||
// ---------------------------------------------------------------------------------------------------- | ||
// Acces by typeName | ||
// ---------------------------------------------------------------------------------------------------- | ||
public structuredTypesNames(): string[] { | ||
return Object.keys(this._structureTypeConstructorByNameMap); | ||
} | ||
public getStructureTypeConstructor(typeName: string): ConstructorFuncWithSchema { | ||
@@ -65,3 +151,3 @@ const constructor = this._structureTypeConstructorByNameMap[typeName]; | ||
} | ||
throw new Error("Cannot find StructureType constructor for " + typeName); | ||
throw new Error("Cannot find StructureType constructor for " + typeName + " - it may be abstract, or it could be a basic type"); | ||
} | ||
@@ -93,45 +179,13 @@ | ||
public registerClassDefinition(className: string, classConstructor: ConstructorFuncWithSchema): void { | ||
this.registerFactory(className, classConstructor); | ||
const expandedNodeId = classConstructor.encodingDefaultBinary; | ||
this.associateWithBinaryEncoding(className, expandedNodeId); | ||
public registerClassDefinition(dataTypeNodeId: NodeId, className: string, classConstructor: ConstructorFuncWithSchema): void { | ||
this.registerFactory(dataTypeNodeId, className, classConstructor); | ||
assert(classConstructor.encodingDefaultBinary.value !== 0); | ||
this.associateWithBinaryEncoding(className, classConstructor.encodingDefaultBinary); | ||
} | ||
public associateWithDataType(className: string, nodeId: NodeId) { | ||
return; | ||
/* | ||
const schema = this.structuredTypes[className]; | ||
if (doDebug) { | ||
debugLog(" associateWithDataType ", className, nodeId.toString()); | ||
} | ||
assert(schema.id.toString() === "ns=0;i=0", "already associated"); | ||
schema.id = nodeId; | ||
*/ | ||
} | ||
public associateWithBinaryEncoding(className: string, expandedNodeId: ExpandedNodeId) { | ||
const classConstructor = this.getStructureTypeConstructor(className); | ||
if (doDebug) { | ||
debugLog(" associateWithBinaryEncoding ", className, expandedNodeId.toString()); | ||
} | ||
/* istanbul ignore next */ | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
console.log() | ||
throw new Error("Invalid expandedNodeId " + expandedNodeId.toString() + " className = " + className); | ||
} | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
/* istanbul ignore next */ | ||
if (expandedNodeIdKey in this._structureTypeConstructorByEncodingNodeIdMap) { | ||
throw new Error(" Class " + className + " with ID " + expandedNodeId + | ||
" already in constructorMap for " + this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey].name); | ||
} | ||
this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey] = classConstructor; | ||
} | ||
public getConstructor(expandedNodeId: ExpandedNodeId): ConstructorFunc | null { | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
// ---------------------------------------------------------------------------------------------------- | ||
// Acces by binaryEncodingNodeId | ||
// ---------------------------------------------------------------------------------------------------- | ||
public getConstructor(binaryEncodingNodeId: NodeId): ConstructorFunc | null { | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(binaryEncodingNodeId); | ||
const constructor = this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey]; | ||
@@ -142,3 +196,3 @@ if (constructor) { | ||
for (const factory of this.baseDataFactories) { | ||
const constructor2 = factory.getConstructor(expandedNodeId); | ||
const constructor2 = factory.getConstructor(binaryEncodingNodeId); | ||
if (constructor2) { | ||
@@ -148,16 +202,16 @@ return constructor2; | ||
} | ||
debugLog(chalk.red("#getConstructor : cannot find constructor for expandedId "), expandedNodeId.toString()); | ||
debugLog(chalk.red("#getConstructor : cannot find constructor for expandedId "), binaryEncodingNodeId.toString()); | ||
return null; | ||
} | ||
public hasConstructor(expandedNodeId: ExpandedNodeId): boolean { | ||
if (!expandedNodeId) { | ||
public hasConstructor(binaryEncodingNodeId: NodeId): boolean { | ||
if (!binaryEncodingNodeId) { | ||
return false; | ||
} | ||
/* istanbul ignore next */ | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
if (!verifyExpandedNodeId(binaryEncodingNodeId)) { | ||
console.log("Invalid expandedNodeId"); | ||
return false; | ||
} | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(binaryEncodingNodeId); | ||
const constructor = this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey]; | ||
@@ -168,3 +222,3 @@ if (constructor) { | ||
for (const factory of this.baseDataFactories) { | ||
const constructor2 = factory.getConstructor(expandedNodeId); | ||
const constructor2 = factory.getConstructor(binaryEncodingNodeId); | ||
if (constructor2) { | ||
@@ -177,10 +231,10 @@ return true; | ||
public constructObject(expandedNodeId: ExpandedNodeId): BaseUAObject { | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
throw new Error(" constructObject : invalid expandedNodeId provided " + expandedNodeId.toString()); | ||
public constructObject(binaryEncodingNodeId: NodeId): BaseUAObject { | ||
if (!verifyExpandedNodeId(binaryEncodingNodeId)) { | ||
throw new Error(" constructObject : invalid expandedNodeId provided " + binaryEncodingNodeId.toString()); | ||
} | ||
const constructor = this.getConstructor(expandedNodeId); | ||
const constructor = this.getConstructor(binaryEncodingNodeId); | ||
if (!constructor) { | ||
debugLog("Cannot find constructor for " + expandedNodeId.toString()); | ||
debugLog("Cannot find constructor for " + binaryEncodingNodeId.toString()); | ||
return new BaseUAObject(); | ||
@@ -192,5 +246,45 @@ // throw new Error("Cannot find constructor for " + expandedNodeId.toString()); | ||
} | ||
public associateWithBinaryEncoding(className: string, expandedNodeId: ExpandedNodeId) { | ||
const classConstructor = this.getStructureTypeConstructor(className); | ||
if (doDebug) { | ||
debugLog(" associateWithBinaryEncoding ", className, expandedNodeId.toString()); | ||
} | ||
/* istanbul ignore next */ | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
throw new Error("Invalid expandedNodeId " + expandedNodeId.toString() + " className = " + className); | ||
} | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
/* istanbul ignore next */ | ||
if (expandedNodeIdKey in this._structureTypeConstructorByEncodingNodeIdMap) { | ||
throw new Error(" Class " + className + " with ID " + expandedNodeId + | ||
" already in constructorMap for " + this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey].name); | ||
} | ||
this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey] = classConstructor; | ||
} | ||
public registerFactory(dataTypeNodeId: NodeId, typeName: string, constructor: ConstructorFuncWithSchema): void { | ||
assert(dataTypeNodeId.value !== 0, "dataTypeNodeId cannot be null"); | ||
/* istanbul ignore next */ | ||
if (this.hasStructuredType(typeName)) { | ||
console.log(this.getStructureTypeConstructor(typeName)); | ||
console.log("target namespace =", this.targetNamespace); | ||
throw new Error(" registerFactory : " + typeName + " already registered"); | ||
} | ||
debugLog("registerning typeName ", typeName, dataTypeNodeId.toString()); | ||
this._structureTypeConstructorByNameMap[typeName] = constructor; | ||
this._structureTypeConstructorByDataTypeMap[dataTypeNodeId.toString()] = constructor; | ||
Object.defineProperty(constructor.schema, "$$factory", { | ||
enumerable: false, | ||
value: this, | ||
writable: false, | ||
}); | ||
} | ||
} | ||
function verifyExpandedNodeId(expandedNodeId: ExpandedNodeId): boolean { | ||
function verifyExpandedNodeId(expandedNodeId: NodeId): boolean { | ||
/* istanbul ignore next */ | ||
@@ -200,20 +294,7 @@ if (expandedNodeId.value instanceof Buffer) { | ||
} | ||
if (expandedNodeId.namespace === 0) { | ||
if (expandedNodeId.namespaceUri === "http://opcfoundation.org/UA/" || !expandedNodeId.namespaceUri) { | ||
return true; | ||
} | ||
// When namespace is ZERO, namepaceUri must be "http://opcfoundation.org/UA/" or nothing | ||
return false; | ||
} else { | ||
// expandedNodeId.namespace !==0 | ||
// in this case a valid expandedNodeId.namespaceUri must be provided | ||
return !!expandedNodeId.namespaceUri && expandedNodeId.namespaceUri.length > 2; | ||
} | ||
return true; | ||
} | ||
function makeExpandedNodeIdKey(expandedNodeId: ExpandedNodeId): string { | ||
if (expandedNodeId.namespace === 0) { | ||
return expandedNodeId.value.toString(); | ||
} | ||
return expandedNodeId.namespaceUri + "@" + expandedNodeId.value.toString(); | ||
function makeExpandedNodeIdKey(expandedNodeId: NodeId): string { | ||
return expandedNodeId.toString(); | ||
} | ||
@@ -227,2 +308,1 @@ | ||
@@ -70,3 +70,3 @@ /** | ||
) { | ||
const baseSchema = get_base_schema(schema); | ||
@@ -179,3 +179,3 @@ if (baseSchema) { | ||
if (fieldType === "IntegerId" || fieldType === "UInt32") { | ||
value = "" + value + " " + ((value !== undefined ) ? "0x"+value.toString(16) : "undefined"); | ||
value = "" + value + " " + ((value !== undefined) ? "0x" + value.toString(16) : "undefined"); | ||
} else if (fieldType === "DateTime" || fieldType === "UtcTime") { | ||
@@ -201,7 +201,7 @@ value = (value && value.toISOString) ? value.toISOString() : value; | ||
const typeDictionary = (self.schema as any).$typeDictionary as DataTypeFactory; | ||
const typeDictionary = (self.schema as any).$$factory as DataTypeFactory; | ||
if (!typeDictionary) { | ||
console.log(" No typeDictionary for ", self.schema); | ||
} | ||
field.fieldTypeConstructor = field.fieldTypeConstructor || | ||
field.fieldTypeConstructor = field.fieldTypeConstructor || | ||
(typeDictionary.getStructureTypeConstructor(fieldType)); | ||
@@ -208,0 +208,0 @@ const fieldTypeConstructor = field.fieldTypeConstructor; |
@@ -55,5 +55,7 @@ /** | ||
const exists: boolean = hasBuiltInType(schema.name); | ||
/* istanbul ignore next */ | ||
if (exists) { | ||
// tslint:disable-next-line: no-console | ||
console.log(schema); | ||
console.log("registerBasicType:", schema); | ||
throw new Error(`Basic Type ${schema.name} already registered`); | ||
@@ -69,3 +71,3 @@ } | ||
// tslint:disable-next-line:no-console | ||
console.log(util.inspect(schema, { colors: true})); | ||
console.log(util.inspect(schema, { colors: true })); | ||
throw new Error(" cannot find subtype " + schema.subType); | ||
@@ -111,16 +113,17 @@ } | ||
registerBasicType({name: "Counter", subType: "UInt32"}); | ||
registerBasicType({ name: "Counter", subType: "UInt32" }); | ||
// OPC Unified Architecture, part 3.0 $8.13 page 65 | ||
registerBasicType({name: "Duration", subType: "Double"}); | ||
registerBasicType({name: "UAString", subType: "String"}); | ||
registerBasicType({name: "UABoolean", subType: "Boolean"}); | ||
registerBasicType({name: "UtcTime", subType: "DateTime"}); | ||
registerBasicType({ name: "Duration", subType: "Double" }); | ||
registerBasicType({ name: "UAString", subType: "String" }); | ||
registerBasicType({ name: "UABoolean", subType: "Boolean" }); | ||
registerBasicType({ name: "UtcTime", subType: "DateTime" }); | ||
// already ? registerBasicType({name: "Int8", subType: "SByte"}); | ||
// already ? registerBasicType({name: "UInt8", subType: "Byte"}); | ||
registerBasicType({name: "Char", subType: "Byte"}); | ||
registerBasicType({ name: "Char", subType: "Byte" }); | ||
// xx registerBasicType({name:"XmlElement" ,subType:"String" }); | ||
registerBasicType({name: "Time", subType: "String"}); | ||
registerBasicType({ name: "Time", subType: "String" }); | ||
// string in the form "en-US" or "de-DE" or "fr" etc... | ||
registerBasicType({name: "LocaleId", | ||
registerBasicType({ | ||
name: "LocaleId", | ||
subType: "String", | ||
@@ -135,5 +138,5 @@ | ||
registerBasicType({name: "ContinuationPoint", subType: "ByteString"}); | ||
registerBasicType({name: "Image", subType: "ByteString"}); | ||
registerBasicType({name: "NodeIdType", subType: "NodeId"}); | ||
registerBasicType({ name: "ContinuationPoint", subType: "ByteString" }); | ||
registerBasicType({ name: "Image", subType: "ByteString" }); | ||
registerBasicType({ name: "NodeIdType", subType: "NodeId" }); | ||
@@ -140,0 +143,0 @@ registerBasicType({ name: "ImageBMP", subType: "Image" }); |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -11,3 +11,2 @@ /** | ||
const _enumerations: Map<string, EnumerationDefinition> = new Map<string, EnumerationDefinition>(); | ||
@@ -65,2 +64,4 @@ function _encode_enumeration(typedEnum: Enum, value: number, stream: OutputBinaryStream): void { | ||
const _enumerations: Map<string, EnumerationDefinitionSchema> = new Map<string, EnumerationDefinitionSchema>(); | ||
/** | ||
@@ -96,5 +97,7 @@ * @method registerEnumeration | ||
export function getEnumeration(enumerationName: string): EnumerationDefinition { | ||
assert(exports.hasEnumeration(enumerationName)); | ||
return _enumerations.get(enumerationName) as EnumerationDefinition; | ||
export function getEnumeration(enumerationName: string): EnumerationDefinitionSchema { | ||
if (!exports.hasEnumeration(enumerationName)) { | ||
throw new Error("Cannot find enumeration with type " + enumerationName); | ||
} | ||
return _enumerations.get(enumerationName) as EnumerationDefinitionSchema; | ||
} |
@@ -11,10 +11,10 @@ /** | ||
import { checkDebugFlag, make_debugLog } from "node-opcua-debug"; | ||
import { ExpandedNodeId } from "node-opcua-nodeid"; | ||
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid"; | ||
import { | ||
DataTypeFactory, | ||
import { | ||
DataTypeFactory, | ||
} from "./datatype_factory"; | ||
import { | ||
import { | ||
ConstructorFuncWithSchema, | ||
ConstructorFunc | ||
ConstructorFunc | ||
} from "./constructor_type"; | ||
@@ -45,17 +45,15 @@ | ||
} | ||
export function registerFactory(typeName: string, constructor: ConstructorFuncWithSchema): void { | ||
return getStandartDataTypeFactory().registerFactory(typeName, constructor); | ||
export function getConstructor(binaryEncodingNodeId: ExpandedNodeId): ConstructorFunc | null { | ||
return getStandartDataTypeFactory().getConstructor(binaryEncodingNodeId); | ||
} | ||
export function getConstructor(expandedNodeId: ExpandedNodeId): ConstructorFunc | null { | ||
return getStandartDataTypeFactory().getConstructor(expandedNodeId); | ||
export function hasConstructor(binaryEncodingNodeId: ExpandedNodeId): boolean { | ||
return getStandartDataTypeFactory().hasConstructor(binaryEncodingNodeId); | ||
} | ||
export function hasConstructor(expandedNodeId: ExpandedNodeId): boolean { | ||
return getStandartDataTypeFactory().hasConstructor(expandedNodeId); | ||
export function constructObject(binaryEncodingNodeId: ExpandedNodeId): BaseUAObject { | ||
return getStandartDataTypeFactory().constructObject(binaryEncodingNodeId); | ||
} | ||
export function constructObject(expandedNodeId: ExpandedNodeId): BaseUAObject { | ||
return getStandartDataTypeFactory().constructObject(expandedNodeId); | ||
export function registerClassDefinition(dataTypeNodeId: NodeId, className: string, classConstructor: ConstructorFuncWithSchema): void { | ||
return getStandartDataTypeFactory().registerClassDefinition(dataTypeNodeId, className, classConstructor); | ||
} | ||
export function registerClassDefinition(className: string, classConstructor: ConstructorFuncWithSchema): void { | ||
return getStandartDataTypeFactory().registerClassDefinition(className,classConstructor); | ||
} | ||
/* istanbul ignore next */ | ||
@@ -62,0 +60,0 @@ export function dump(): void { |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -103,3 +103,3 @@ /** | ||
switchValue: fieldLight.switchValue, | ||
schema | ||
@@ -113,2 +113,4 @@ }; | ||
public id: NodeId; | ||
public dataTypeNodeId: NodeId; | ||
public baseType: string; | ||
@@ -127,2 +129,4 @@ public _possibleFields: string[]; | ||
public encodingDefaultXml?: ExpandedNodeId; | ||
public encodingDefaultJson?: ExpandedNodeId; | ||
public bitFields?: any[]; | ||
@@ -143,2 +147,3 @@ | ||
this.id = NodeId.nullNodeId; | ||
this.dataTypeNodeId = NodeId.nullNodeId; | ||
@@ -164,3 +169,3 @@ this._possibleFields = this.fields.map((field) => field.name); | ||
if (schema.baseType === "ExtensionObject") { | ||
if (schema.baseType === "ExtensionObject" || schema.baseType === "DataTypeDefinition") { | ||
return null; | ||
@@ -167,0 +172,0 @@ } |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
{ | ||
"extends" : "../tsconfig.json", | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "source", | ||
"outDir": "dist" | ||
"outDir": "dist", | ||
"composite": true | ||
}, | ||
"files": [ "source/index.ts"] | ||
"include": [ | ||
"source/**/*.ts" | ||
], | ||
"exclude": [ | ||
"node_modules", | ||
"dist" | ||
], | ||
"references": [ | ||
{ | ||
"path": "../node-opcua-assert" | ||
}, | ||
{ | ||
"path": "../node-opcua-basic-types" | ||
}, | ||
{ | ||
"path": "../node-opcua-binary-stream" | ||
}, | ||
{ | ||
"path": "../node-opcua-debug" | ||
}, | ||
{ | ||
"path": "../node-opcua-enum" | ||
}, | ||
{ | ||
"path": "../node-opcua-guid" | ||
}, | ||
{ | ||
"path": "../node-opcua-nodeid" | ||
}, | ||
{ | ||
"path": "../node-opcua-status-code" | ||
}, | ||
{ | ||
"path": "../node-opcua-utils" | ||
} | ||
] | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
371119
0
3990
11
2
+ Addedhexy@0.3.5(transitive)
+ Addednode-opcua-debug@2.139.0(transitive)