node-opcua-extension-object
Advanced tools
Comparing version 2.0.0-alpha.8 to 2.0.0-alpha.9
@@ -1,4 +0,1 @@ | ||
/** | ||
* @module opcua.miscellaneous | ||
*/ | ||
import { BinaryStream } from "node-opcua-binary-stream"; | ||
@@ -5,0 +2,0 @@ import { BaseUAObject } from "node-opcua-factory"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module node-opcua-extension-object | ||
*/ | ||
const node_opcua_basic_types_1 = require("node-opcua-basic-types"); | ||
const node_opcua_debug_1 = require("node-opcua-debug"); | ||
const node_opcua_factory_1 = require("node-opcua-factory"); | ||
const node_opcua_nodeid_1 = require("node-opcua-nodeid"); | ||
const node_opcua_basic_types_1 = require("node-opcua-basic-types"); | ||
const debugLog = node_opcua_debug_1.make_debugLog(__filename); | ||
const chalk_1 = require("chalk"); | ||
@@ -53,3 +58,3 @@ /* tslint:disable:no-empty */ | ||
if (!encodingDefaultBinary) { | ||
console.log(chalk_1.default.yellow("xxxxxxxxx encoding ExtObj "), object); | ||
debugLog(chalk_1.default.yellow("xxxxxxxxx encoding ExtObj "), object); | ||
throw new Error("Cannot find encodingDefaultBinary for this object"); | ||
@@ -59,3 +64,3 @@ } | ||
if (encodingDefaultBinary.isEmpty()) { | ||
console.log(chalk_1.default.yellow("xxxxxxxxx encoding ExtObj "), object.encodingDefaultBinary.toString()); | ||
debugLog(chalk_1.default.yellow("xxxxxxxxx encoding ExtObj "), object.encodingDefaultBinary.toString()); | ||
throw new Error("Cannot find encodingDefaultBinary for this object"); | ||
@@ -65,3 +70,3 @@ } | ||
if (node_opcua_factory_1.is_internal_id(encodingDefaultBinary.value)) { | ||
console.log(chalk_1.default.yellow("xxxxxxxxx encoding ExtObj "), object.encodingDefaultBinary.toString(), object.schema.name); | ||
debugLog(chalk_1.default.yellow("xxxxxxxxx encoding ExtObj "), object.encodingDefaultBinary.toString(), object.schema.name); | ||
throw new Error("Cannot find valid OPCUA encodingDefaultBinary for this object"); | ||
@@ -100,3 +105,3 @@ } | ||
catch (err) { | ||
console.log("Cannot decode object ", err.message); | ||
debugLog("Cannot decode object ", err.message); | ||
} | ||
@@ -107,3 +112,4 @@ if (streamLengthBefore + length !== stream.length) { | ||
// causing 2 extra member to be added. | ||
console.log(chalk_1.default.bgWhiteBright.red("=========================================")); | ||
debugLog(chalk_1.default.bgWhiteBright.red("=========================================")); | ||
// tslint:disable-next-line:no-console | ||
console.warn("WARNING => Extension object decoding error on ", object.constructor.name, " expected size was", length, "actual size was ", stream.length - streamLengthBefore); | ||
@@ -110,0 +116,0 @@ stream.length = streamLengthBefore + length; |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module node-opcua-extension-object | ||
*/ | ||
export * from "./extension_object"; |
@@ -6,3 +6,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module node-opcua-extension-object | ||
*/ | ||
__export(require("./extension_object")); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "node-opcua-extension-object", | ||
"version": "2.0.0-alpha.8", | ||
"version": "2.0.0-alpha.9", | ||
"description": "pure nodejs OPCUA SDK - module -extension-object", | ||
@@ -13,7 +13,8 @@ "main": "./dist/index.js", | ||
"chalk": "^2.4.1", | ||
"node-opcua-assert": "^2.0.0-alpha.8", | ||
"node-opcua-basic-types": "^2.0.0-alpha.8", | ||
"node-opcua-binary-stream": "^2.0.0-alpha.8", | ||
"node-opcua-factory": "^2.0.0-alpha.8", | ||
"node-opcua-nodeid": "^2.0.0-alpha.8" | ||
"node-opcua-assert": "^2.0.0-alpha.9", | ||
"node-opcua-basic-types": "^2.0.0-alpha.9", | ||
"node-opcua-binary-stream": "^2.0.0-alpha.9", | ||
"node-opcua-debug": "^2.0.0-alpha.9", | ||
"node-opcua-factory": "^2.0.0-alpha.9", | ||
"node-opcua-nodeid": "^2.0.0-alpha.9" | ||
}, | ||
@@ -35,3 +36,3 @@ "author": "Etienne Rossignon", | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "7bbf38d5a3cd29cb6aed6ca38078f4d89d3f956a" | ||
"gitHead": "cd7120d1840593757f0f3c9e53be4e85883dc0e6" | ||
} |
/** | ||
* @module opcua.miscellaneous | ||
* @module node-opcua-extension-object | ||
*/ | ||
import { decodeNodeId, encodeNodeId } from "node-opcua-basic-types"; | ||
import { BinaryStream } from "node-opcua-binary-stream"; | ||
import { is_internal_id, constructObject, registerBuiltInType, BaseUAObject } from "node-opcua-factory"; | ||
import { makeNodeId, ExpandedNodeId, NodeId } from "node-opcua-nodeid"; | ||
import { encodeNodeId, decodeNodeId } from "node-opcua-basic-types"; | ||
import { checkDebugFlag, make_debugLog } from "node-opcua-debug"; | ||
import { BaseUAObject, constructObject, is_internal_id, registerBuiltInType } from "node-opcua-factory"; | ||
import { ExpandedNodeId, makeNodeId, NodeId } from "node-opcua-nodeid"; | ||
const debugLog = make_debugLog(__filename); | ||
import chalk from "chalk"; | ||
@@ -18,4 +21,5 @@ | ||
} | ||
ExtensionObject.prototype.schema = {name: "ExtensionObject"}; | ||
ExtensionObject.prototype.schema = { name: "ExtensionObject" }; | ||
function constructEmptyExtensionObject(expandedNodeId: NodeId): any { | ||
@@ -25,3 +29,2 @@ return constructObject(expandedNodeId as ExpandedNodeId); | ||
// OPC-UA Part 6 - $5.2.2.15 ExtensionObject | ||
@@ -53,3 +56,2 @@ // An ExtensionObject is encoded as sequence of bytes prefixed by the NodeId of its | ||
export function encodeExtensionObject(object: any, stream: BinaryStream): void { | ||
@@ -67,3 +69,3 @@ | ||
if (!encodingDefaultBinary) { | ||
console.log(chalk.yellow("xxxxxxxxx encoding ExtObj "), object); | ||
debugLog(chalk.yellow("xxxxxxxxx encoding ExtObj "), object); | ||
throw new Error("Cannot find encodingDefaultBinary for this object"); | ||
@@ -73,3 +75,3 @@ } | ||
if (encodingDefaultBinary.isEmpty()) { | ||
console.log(chalk.yellow("xxxxxxxxx encoding ExtObj "), object.encodingDefaultBinary.toString()); | ||
debugLog(chalk.yellow("xxxxxxxxx encoding ExtObj "), object.encodingDefaultBinary.toString()); | ||
throw new Error("Cannot find encodingDefaultBinary for this object"); | ||
@@ -79,3 +81,4 @@ } | ||
if (is_internal_id(encodingDefaultBinary.value)) { | ||
console.log(chalk.yellow("xxxxxxxxx encoding ExtObj "), object.encodingDefaultBinary.toString(), object.schema.name); | ||
debugLog(chalk.yellow("xxxxxxxxx encoding ExtObj "), | ||
object.encodingDefaultBinary.toString(), object.schema.name); | ||
throw new Error("Cannot find valid OPCUA encodingDefaultBinary for this object"); | ||
@@ -91,3 +94,3 @@ } | ||
export function decodeExtensionObject(stream: BinaryStream): ExtensionObject | null { | ||
export function decodeExtensionObject(stream: BinaryStream): ExtensionObject | null { | ||
@@ -105,3 +108,3 @@ const nodeId = decodeNodeId(stream); | ||
if (nodeId.value === 0 || encodingType === 0) { | ||
return {} as ExtensionObject; | ||
return {} as ExtensionObject; | ||
} | ||
@@ -115,3 +118,3 @@ | ||
stream.length += length; | ||
return {} as ExtensionObject; | ||
return {} as ExtensionObject; | ||
} | ||
@@ -123,6 +126,5 @@ // let verify that decode will use the expected number of bytes | ||
object.decode(stream); | ||
} catch (err) { | ||
debugLog("Cannot decode object ", err.message); | ||
} | ||
catch (err) { | ||
console.log("Cannot decode object ", err.message); | ||
} | ||
@@ -133,4 +135,8 @@ if (streamLengthBefore + length !== stream.length) { | ||
// causing 2 extra member to be added. | ||
console.log(chalk.bgWhiteBright.red("=========================================")); | ||
console.warn("WARNING => Extension object decoding error on ", object.constructor.name, " expected size was", length, "actual size was ", stream.length - streamLengthBefore); | ||
debugLog(chalk.bgWhiteBright.red("=========================================")); | ||
// tslint:disable-next-line:no-console | ||
console.warn("WARNING => Extension object decoding error on ", | ||
object.constructor.name, " expected size was", length, | ||
"actual size was ", stream.length - streamLengthBefore); | ||
stream.length = streamLengthBefore + length; | ||
@@ -141,10 +147,11 @@ } | ||
registerBuiltInType({ | ||
name: "ExtensionObject", | ||
subType: "", | ||
encode: encodeExtensionObject, | ||
decode: decodeExtensionObject, | ||
defaultValue: () => null | ||
defaultValue: () => null | ||
}); | ||
@@ -1,1 +0,4 @@ | ||
export * from "./extension_object"; | ||
/** | ||
* @module node-opcua-extension-object | ||
*/ | ||
export * from "./extension_object"; |
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
17794
7
11
274