node-opcua-generator
Advanced tools
Comparing version
@@ -0,0 +0,0 @@ /** |
@@ -310,3 +310,3 @@ "use strict"; | ||
write(" public encode(stream: OutputBinaryStream): void {"); | ||
write(" super.encode(stream);"); | ||
write(" /* NEEDED */ super.encode(stream);"); | ||
const n = schema.fields.length; | ||
@@ -407,3 +407,3 @@ for (let i = 0; i < n; i++) { | ||
write(" // call base class implementation first"); | ||
write(" super.decode(stream);"); | ||
write(" /* NEEDED !!! */ super.decode(stream);"); | ||
const n = schema.fields.length; | ||
@@ -410,0 +410,0 @@ for (let i = 0; i < n; i++) { |
export declare function generate(filename: string, generatedTypescriptFilename: string): Promise<void>; |
@@ -22,2 +22,3 @@ "use strict"; | ||
const fs = require("fs"); | ||
const node_opcua_assert_1 = require("node-opcua-assert"); | ||
const node_opcua_constants_1 = require("node-opcua-constants"); | ||
@@ -40,7 +41,2 @@ const node_opcua_debug_1 = require("node-opcua-debug"); | ||
function writeEnumeratedType(enumerationSchema) { | ||
// make sure there is a Invalid key in the enum => else insert one | ||
const hasInvalid = enumerationSchema.enumValues.hasOwnProperty("Invalid"); | ||
if (!hasInvalid) { | ||
enumerationSchema.enumValues[enumerationSchema.enumValues.Invalid = 0xFFFFFFFF] = "Invalid"; | ||
} | ||
const arrayValues = Object.keys(enumerationSchema.enumValues) | ||
@@ -58,2 +54,7 @@ .filter((a) => a.match("[0-9]+")) | ||
const maxEnumValue = Math.max.apply(null, arrayValues); | ||
// make sure there is a Invalid key in the enum => else insert one (but only if not flaggable) | ||
const hasInvalid = enumerationSchema.enumValues.hasOwnProperty("Invalid"); | ||
if (!hasInvalid && !isFlaggable) { | ||
enumerationSchema.enumValues[enumerationSchema.enumValues.Invalid = 0xFFFFFFFF] = "Invalid"; | ||
} | ||
write(""); | ||
@@ -81,3 +82,9 @@ write(`// --------------------------------------------------------------------------------------------`); | ||
if (!isFlaggable) { | ||
write(` let value = stream.readUInt32() as ${enumerationSchema.name};`); | ||
if (enumerationSchema.lengthInBits === 16) { | ||
write(` let value = stream.readUInt16() as ${enumerationSchema.name};`); | ||
} | ||
else { | ||
node_opcua_assert_1.assert(enumerationSchema.lengthInBits === 32); | ||
write(` let value = stream.readUInt32() as ${enumerationSchema.name};`); | ||
} | ||
write(` value = (value < schema${enumerationSchema.name}.minValue || value > schema${enumerationSchema.name}.maxValue) ? ${enumerationSchema.name}.Invalid : value; `); | ||
@@ -91,3 +98,9 @@ write(` return value;`); | ||
write(`function encode${enumerationSchema.name}(value: ${enumerationSchema.name}, stream: OutputBinaryStream): void {`); | ||
write(` stream.writeUInt32(value);`); | ||
if (enumerationSchema.lengthInBits === 16) { | ||
write(` stream.writeUInt16(value);`); | ||
} | ||
else { | ||
node_opcua_assert_1.assert(enumerationSchema.lengthInBits === 32); | ||
write(` stream.writeUInt32(value);`); | ||
} | ||
write(`}`); | ||
@@ -94,0 +107,0 @@ write(`export const _enumeration${enumerationSchema.name} = registerEnumeration(schema${enumerationSchema.name});`); |
@@ -0,0 +0,0 @@ import { ConstructorFunc } from "node-opcua-factory"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ "use strict"; |
export {}; |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "node-opcua-generator", | ||
"version": "2.7.0", | ||
"version": "2.8.0", | ||
"description": "pure nodejs OPCUA SDK - module -generator", | ||
@@ -15,3 +15,3 @@ "main": "./dist/index.js", | ||
"node-opcua-assert": "^2.6.1", | ||
"node-opcua-basic-types": "^2.7.0", | ||
"node-opcua-basic-types": "^2.8.0", | ||
"node-opcua-buffer-utils": "^2.6.1", | ||
@@ -21,8 +21,8 @@ "node-opcua-constants": "^2.6.1", | ||
"node-opcua-debug": "^2.6.1", | ||
"node-opcua-enum": "^2.6.1", | ||
"node-opcua-factory": "^2.7.0", | ||
"node-opcua-enum": "^2.8.0", | ||
"node-opcua-factory": "^2.8.0", | ||
"node-opcua-guid": "^2.6.1", | ||
"node-opcua-nodeid": "^2.6.1", | ||
"node-opcua-numeric-range": "^2.7.0", | ||
"node-opcua-schemas": "^2.7.0", | ||
"node-opcua-nodeid": "^2.8.0", | ||
"node-opcua-numeric-range": "^2.8.0", | ||
"node-opcua-schemas": "^2.8.0", | ||
"node-opcua-status-code": "^2.6.1", | ||
@@ -38,4 +38,4 @@ "node-opcua-utils": "^2.7.0", | ||
"node-opcua-binary-stream": "^2.6.1", | ||
"node-opcua-extension-object": "^2.7.0", | ||
"node-opcua-packet-analyzer": "^2.7.0", | ||
"node-opcua-extension-object": "^2.8.0", | ||
"node-opcua-packet-analyzer": "^2.8.0", | ||
"should": "^13.2.3", | ||
@@ -59,3 +59,3 @@ "source-map-support": "^0.5.19" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "868b9f5d0bf0411f30476a0947301dc1d487e462" | ||
"gitHead": "e3b0892d751900c13898ca82be84bbfe66997f0c" | ||
} |
@@ -365,3 +365,3 @@ /* istanbul ignore file */ | ||
write(" public encode(stream: OutputBinaryStream): void {"); | ||
write(" super.encode(stream);"); | ||
write(" /* NEEDED */ super.encode(stream);"); | ||
@@ -463,3 +463,3 @@ const n = schema.fields.length; | ||
write(" // call base class implementation first"); | ||
write(" super.decode(stream);"); | ||
write(" /* NEEDED !!! */ super.decode(stream);"); | ||
@@ -466,0 +466,0 @@ const n = schema.fields.length; |
@@ -54,7 +54,2 @@ /* istanbul ignore file */ | ||
// make sure there is a Invalid key in the enum => else insert one | ||
const hasInvalid = enumerationSchema.enumValues.hasOwnProperty("Invalid"); | ||
if (!hasInvalid) { | ||
enumerationSchema.enumValues[enumerationSchema.enumValues.Invalid = 0xFFFFFFFF] = "Invalid"; | ||
} | ||
@@ -76,4 +71,9 @@ const arrayValues = Object.keys(enumerationSchema.enumValues) | ||
// make sure there is a Invalid key in the enum => else insert one (but only if not flaggable) | ||
const hasInvalid = enumerationSchema.enumValues.hasOwnProperty("Invalid"); | ||
if (!hasInvalid && !isFlaggable) { | ||
enumerationSchema.enumValues[enumerationSchema.enumValues.Invalid = 0xFFFFFFFF] = "Invalid"; | ||
} | ||
write(""); | ||
write(`// --------------------------------------------------------------------------------------------`); | ||
@@ -105,3 +105,8 @@ write(`export enum ${enumerationSchema.name} {`); | ||
if (!isFlaggable) { | ||
write(` let value = stream.readUInt32() as ${enumerationSchema.name};`); | ||
if (enumerationSchema.lengthInBits === 16) { | ||
write(` let value = stream.readUInt16() as ${enumerationSchema.name};`); | ||
} else { | ||
assert(enumerationSchema.lengthInBits === 32); | ||
write(` let value = stream.readUInt32() as ${enumerationSchema.name};`); | ||
} | ||
write(` value = (value < schema${enumerationSchema.name}.minValue || value > schema${enumerationSchema.name}.maxValue) ? ${enumerationSchema.name}.Invalid : value; `); | ||
@@ -114,3 +119,8 @@ write(` return value;`); | ||
write(`function encode${enumerationSchema.name}(value: ${enumerationSchema.name}, stream: OutputBinaryStream): void {`); | ||
write(` stream.writeUInt32(value);`); | ||
if (enumerationSchema.lengthInBits === 16) { | ||
write(` stream.writeUInt16(value);`); | ||
} else { | ||
assert(enumerationSchema.lengthInBits === 32); | ||
write(` stream.writeUInt32(value);`); | ||
} | ||
write(`}`); | ||
@@ -117,0 +127,0 @@ |
@@ -0,0 +0,0 @@ /* istanbul ignore file */ |
@@ -0,0 +0,0 @@ /* istanbul ignore file */ |
@@ -0,0 +0,0 @@ /* istanbul ignore file */ |
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
154114
2.77%2492
0.93%Updated
Updated
Updated
Updated