node-opcua-factory
Advanced tools
Comparing version 2.4.0 to 2.4.2
@@ -0,0 +0,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
//# sourceMappingURL=constructor_type.js.map |
@@ -1,4 +0,4 @@ | ||
import { ExpandedNodeId } from "node-opcua-nodeid"; | ||
import { ExpandedNodeId, NodeId } from "node-opcua-nodeid"; | ||
import { ConstructorFunc, ConstructorFuncWithSchema } from "./constructor_type"; | ||
import { BaseUAObject } from "./factories_baseobject"; | ||
import { ConstructorFuncWithSchema, ConstructorFunc } from "./constructor_type"; | ||
import { StructuredTypeSchema } from "./factories_structuredTypeSchema"; | ||
@@ -11,3 +11,3 @@ export declare class DataTypeFactory { | ||
private _structureTypeConstructorByEncodingNodeIdMap; | ||
private baseDataFactories; | ||
private readonly baseDataFactories; | ||
constructor(baseDataFactories: DataTypeFactory[]); | ||
@@ -20,2 +20,3 @@ registerFactory(typeName: string, constructor: ConstructorFuncWithSchema): void; | ||
registerClassDefinition(className: string, classConstructor: ConstructorFuncWithSchema): void; | ||
associateWithDataType(className: string, nodeId: NodeId): void; | ||
associateWithBinaryEncoding(className: string, expandedNodeId: ExpandedNodeId): void; | ||
@@ -22,0 +23,0 @@ getConstructor(expandedNodeId: ExpandedNodeId): ConstructorFunc | null; |
@@ -33,4 +33,4 @@ "use strict"; | ||
enumerable: false, | ||
value: this, | ||
writable: false, | ||
value: this | ||
}); | ||
@@ -79,2 +79,13 @@ } | ||
} | ||
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) { | ||
@@ -87,3 +98,4 @@ const classConstructor = this.getStructureTypeConstructor(className); | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
throw new Error("Invalid expandedNodeId " + expandedNodeId.toString()); | ||
console.log(); | ||
throw new Error("Invalid expandedNodeId " + expandedNodeId.toString() + " className = " + className); | ||
} | ||
@@ -90,0 +102,0 @@ const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); |
@@ -0,0 +0,0 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; |
@@ -0,0 +0,0 @@ "use strict"; |
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"; |
@@ -0,0 +0,0 @@ import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
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"; |
@@ -0,0 +0,0 @@ import { FieldType, StructuredTypeOptions, TypeSchemaBase } from "./types"; |
@@ -118,3 +118,3 @@ "use strict"; | ||
} | ||
if (schema.baseType && schema.baseType !== "BaseUAObject") { | ||
if (schema.baseType && schema.baseType !== "BaseUAObject" && schema.baseType !== "DataTypeDefinition") { | ||
const baseType = factories_factories_1.getStructureTypeConstructor(schema.baseType); | ||
@@ -121,0 +121,0 @@ // istanbul ignore next |
@@ -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.0", | ||
"version": "2.4.2", | ||
"description": "pure nodejs OPCUA SDK - module -factory", | ||
@@ -15,13 +15,13 @@ "main": "./dist/index.js", | ||
"node-opcua-assert": "^2.3.0", | ||
"node-opcua-basic-types": "^2.4.0", | ||
"node-opcua-binary-stream": "^2.3.0", | ||
"node-opcua-enum": "^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.3.0", | ||
"node-opcua-status-code": "^2.3.0", | ||
"node-opcua-utils": "^2.4.0", | ||
"underscore": "^1.9.1" | ||
"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.3.0" | ||
"node-opcua-debug": "^2.4.2" | ||
}, | ||
@@ -43,3 +43,3 @@ "author": "Etienne Rossignon", | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "21f5967e799ef2b4d6491b8fc670964127c11431" | ||
"gitHead": "6e4967fd20a09317ddd00098bcfe93e92c1df510" | ||
} |
@@ -0,0 +0,0 @@ /** |
@@ -10,24 +10,22 @@ /** | ||
import { checkDebugFlag, make_debugLog } from "node-opcua-debug"; | ||
import { ExpandedNodeId } from "node-opcua-nodeid"; | ||
import {ExpandedNodeId, NodeId} from "node-opcua-nodeid"; | ||
import { ConstructorFunc, ConstructorFuncWithSchema } from "./constructor_type"; | ||
import { BaseUAObject } from "./factories_baseobject"; | ||
import { ConstructorFuncWithSchema, ConstructorFunc } from "./constructor_type"; | ||
import { StructuredTypeSchema } from "./factories_structuredTypeSchema"; | ||
const debugLog = make_debugLog(__filename); | ||
const doDebug = checkDebugFlag(__filename); | ||
export class DataTypeFactory { | ||
export class DataTypeFactory { | ||
public defaultByteOrder: string; | ||
public defaultByteOrder: string; | ||
public targetNamespace: string; | ||
public imports: string[] = []; | ||
private _structureTypeConstructorByNameMap: { [ key: string ]: ConstructorFuncWithSchema } = {}; | ||
private _structureTypeConstructorByNameMap: { [key: string]: ConstructorFuncWithSchema } = {}; | ||
private _structureTypeConstructorByEncodingNodeIdMap: any = {}; | ||
private baseDataFactories: DataTypeFactory[]; | ||
private readonly baseDataFactories: DataTypeFactory[]; | ||
public constructor(baseDataFactories: DataTypeFactory[]){ | ||
public constructor(baseDataFactories: DataTypeFactory[]) { | ||
this.defaultByteOrder = "LittleEndian"; | ||
@@ -38,4 +36,3 @@ this.targetNamespace = ""; | ||
public registerFactory(typeName: string, constructor: ConstructorFuncWithSchema): void | ||
{ | ||
public registerFactory(typeName: string, constructor: ConstructorFuncWithSchema): void { | ||
/* istanbul ignore next */ | ||
@@ -48,12 +45,12 @@ if (this.hasStructuredType(typeName)) { | ||
this._structureTypeConstructorByNameMap[typeName] = constructor; | ||
Object.defineProperty(constructor.schema , "$typeDictionary", { | ||
Object.defineProperty(constructor.schema, "$typeDictionary", { | ||
enumerable: false, | ||
value: this, | ||
writable: false, | ||
value: this | ||
}); | ||
} | ||
public getStructureTypeConstructor(typeName: string): ConstructorFuncWithSchema { | ||
const constructor = this._structureTypeConstructorByNameMap[typeName]; | ||
const constructor = this._structureTypeConstructorByNameMap[typeName]; | ||
if (constructor) { | ||
@@ -70,5 +67,5 @@ return constructor; | ||
} | ||
public hasStructuredType(typeName: string): boolean | ||
{ | ||
const flag = !!this._structureTypeConstructorByNameMap[typeName]; | ||
public hasStructuredType(typeName: string): boolean { | ||
const flag = !!this._structureTypeConstructorByNameMap[typeName]; | ||
if (flag) { return true; } | ||
@@ -83,24 +80,35 @@ for (const factory of this.baseDataFactories) { | ||
} | ||
public getStructuredTypeSchema(typeName: string): StructuredTypeSchema { | ||
const constructor = this.getStructureTypeConstructor(typeName); | ||
return constructor.schema; | ||
} | ||
} | ||
public dump(): void { | ||
console.log(" dumping registered factories"); | ||
console.log(" Factory ", Object.keys(this._structureTypeConstructorByNameMap) | ||
.sort().forEach((e) => e)); | ||
public dump(): void { | ||
console.log(" dumping registered factories"); | ||
console.log(" Factory ", Object.keys(this._structureTypeConstructorByNameMap) | ||
.sort().forEach((e) => e)); | ||
console.log(" done"); | ||
} | ||
public registerClassDefinition(className: string, classConstructor: ConstructorFuncWithSchema): void | ||
{ | ||
public registerClassDefinition(className: string, classConstructor: ConstructorFuncWithSchema): void { | ||
this.registerFactory(className, classConstructor); | ||
const expandedNodeId = classConstructor.encodingDefaultBinary; | ||
this.associateWithBinaryEncoding(className, expandedNodeId); | ||
} | ||
public associateWithBinaryEncoding(className: string, expandedNodeId: ExpandedNodeId) | ||
{ | ||
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); | ||
@@ -110,15 +118,16 @@ if (doDebug) { | ||
} | ||
/* istanbul ignore next */ | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
throw new Error("Invalid expandedNodeId " + expandedNodeId.toString()); | ||
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); | ||
" already in constructorMap for " + this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey].name); | ||
} | ||
this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey] = classConstructor; | ||
@@ -128,3 +137,3 @@ } | ||
public getConstructor(expandedNodeId: ExpandedNodeId): ConstructorFunc | null { | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
const expandedNodeIdKey = makeExpandedNodeIdKey(expandedNodeId); | ||
const constructor = this._structureTypeConstructorByEncodingNodeIdMap[expandedNodeIdKey]; | ||
@@ -167,3 +176,3 @@ if (constructor) { | ||
public constructObject(expandedNodeId: ExpandedNodeId): BaseUAObject { | ||
public constructObject(expandedNodeId: ExpandedNodeId): BaseUAObject { | ||
if (!verifyExpandedNodeId(expandedNodeId)) { | ||
@@ -173,3 +182,3 @@ throw new Error(" constructObject : invalid expandedNodeId provided " + expandedNodeId.toString()); | ||
const constructor = this.getConstructor(expandedNodeId); | ||
if (!constructor) { | ||
@@ -181,3 +190,3 @@ debugLog("Cannot find constructor for " + expandedNodeId.toString()); | ||
return callConstructor(constructor); | ||
} | ||
@@ -192,3 +201,3 @@ } | ||
if (expandedNodeId.namespace === 0) { | ||
if (expandedNodeId.namespaceUri === "http://opcfoundation.org/UA/" || !expandedNodeId.namespaceUri ) { | ||
if (expandedNodeId.namespaceUri === "http://opcfoundation.org/UA/" || !expandedNodeId.namespaceUri) { | ||
return true; | ||
@@ -195,0 +204,0 @@ } |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -167,3 +167,3 @@ /** | ||
if (schema.baseType && schema.baseType !== "BaseUAObject") { | ||
if (schema.baseType && schema.baseType !== "BaseUAObject" && schema.baseType !== "DataTypeDefinition") { | ||
const baseType = getStructureTypeConstructor(schema.baseType); | ||
@@ -170,0 +170,0 @@ |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ { |
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
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
3786
355616
Updatednode-opcua-enum@^2.4.2
Updatednode-opcua-nodeid@^2.4.2
Updatednode-opcua-utils@^2.4.2
Updatedunderscore@^1.9.2