node-opcua-data-value
Advanced tools
Comparing version 2.0.0-alpha.8 to 2.0.0-alpha.9
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module node-opcua-data-value | ||
*/ | ||
const node_opcua_assert_1 = require("node-opcua-assert"); | ||
@@ -51,2 +54,3 @@ const node_opcua_date_time_1 = require("node-opcua-date-time"); | ||
if (!dataValue.value.encode) { | ||
// tslint:disable-next-line:no-console | ||
console.log(" CANNOT FIND ENCODE METHOD ON VARIANT !!! HELP", dataValue.toString()); | ||
@@ -435,4 +439,5 @@ } | ||
return dataValue.value && ((dataValue.value.arrayType !== node_opcua_variant_1.VariantArrayType.Scalar) || | ||
((dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) && (dataValue.value.dataType === node_opcua_variant_1.DataType.ByteString)) || | ||
((dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) && (dataValue.value.dataType === node_opcua_variant_1.DataType.String))); | ||
((dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) && (dataValue.value.dataType === node_opcua_variant_1.DataType.ByteString)) | ||
|| | ||
((dataValue.value.arrayType === node_opcua_variant_1.VariantArrayType.Scalar) && (dataValue.value.dataType === node_opcua_variant_1.DataType.String))); | ||
} | ||
@@ -493,3 +498,4 @@ /** | ||
case TimestampsToReturn_enum_1.TimestampsToReturn.Both: | ||
return sourceTimestampHasChanged(dataValue1, dataValue2) || serverTimestampHasChanged(dataValue1, dataValue2); | ||
return sourceTimestampHasChanged(dataValue1, dataValue2) || | ||
serverTimestampHasChanged(dataValue1, dataValue2); | ||
case TimestampsToReturn_enum_1.TimestampsToReturn.Source: | ||
@@ -496,0 +502,0 @@ return sourceTimestampHasChanged(dataValue1, dataValue2); |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module node-opcua-data-value | ||
*/ | ||
import { Enum } from "node-opcua-enum"; | ||
@@ -2,0 +5,0 @@ export declare enum DataValueEncodingByte { |
@@ -0,2 +1,5 @@ | ||
/** | ||
* @module node-opcua-data-value | ||
*/ | ||
export * from "./datavalue"; | ||
export * from "./TimestampsToReturn_enum"; |
@@ -6,4 +6,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* @module node-opcua-data-value | ||
*/ | ||
__export(require("./datavalue")); | ||
__export(require("./TimestampsToReturn_enum")); | ||
//# sourceMappingURL=index.js.map |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module node-opcua-data-value | ||
*/ | ||
import { BinaryStream } from "node-opcua-binary-stream"; | ||
@@ -2,0 +5,0 @@ import { Enum } from "node-opcua-enum"; |
@@ -14,3 +14,3 @@ "use strict"; | ||
name: "TimestampsToReturn", | ||
enumValues: TimestampsToReturn, | ||
enumValues: TimestampsToReturn | ||
}; | ||
@@ -17,0 +17,0 @@ function encodeTimestampsToReturn(value, stream) { |
@@ -5,3 +5,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "2.0.0-alpha.8", | ||
"version": "2.0.0-alpha.9", | ||
"description": "pure nodejs OPCUA SDK - module -data-value", | ||
@@ -14,19 +14,19 @@ "scripts": { | ||
"dependencies": { | ||
"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-data-model": "^2.0.0-alpha.8", | ||
"node-opcua-date-time": "^2.0.0-alpha.8", | ||
"node-opcua-enum": "^2.0.0-alpha.8", | ||
"node-opcua-factory": "^2.0.0-alpha.8", | ||
"node-opcua-nodeid": "^2.0.0-alpha.8", | ||
"node-opcua-status-code": "^2.0.0-alpha.8", | ||
"node-opcua-utils": "^2.0.0-alpha.8", | ||
"node-opcua-variant": "^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-data-model": "^2.0.0-alpha.9", | ||
"node-opcua-date-time": "^2.0.0-alpha.9", | ||
"node-opcua-enum": "^2.0.0-alpha.9", | ||
"node-opcua-factory": "^2.0.0-alpha.9", | ||
"node-opcua-nodeid": "^2.0.0-alpha.9", | ||
"node-opcua-status-code": "^2.0.0-alpha.9", | ||
"node-opcua-utils": "^2.0.0-alpha.9", | ||
"node-opcua-variant": "^2.0.0-alpha.9", | ||
"underscore": "^1.9.1" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-generator": "^2.0.0-alpha.8", | ||
"node-opcua-numeric-range": "^2.0.0-alpha.8", | ||
"node-opcua-packet-analyzer": "^2.0.0-alpha.8", | ||
"node-opcua-generator": "^2.0.0-alpha.9", | ||
"node-opcua-numeric-range": "^2.0.0-alpha.9", | ||
"node-opcua-packet-analyzer": "^2.0.0-alpha.9", | ||
"should": "13.2.3" | ||
@@ -49,3 +49,3 @@ }, | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "7bbf38d5a3cd29cb6aed6ca38078f4d89d3f956a" | ||
"gitHead": "cd7120d1840593757f0f3c9e53be4e85883dc0e6" | ||
} |
@@ -0,1 +1,4 @@ | ||
/** | ||
* @module node-opcua-data-value | ||
*/ | ||
import { assert } from "node-opcua-assert"; | ||
@@ -24,3 +27,3 @@ import { BinaryStream } from "node-opcua-binary-stream"; | ||
encodeStatusCode, encodeUInt16, | ||
encodeUInt8, UInt16, | ||
encodeUInt8, UInt16 | ||
} from "node-opcua-basic-types"; | ||
@@ -71,2 +74,3 @@ import { AttributeIds } from "node-opcua-data-model"; | ||
if (!dataValue.value.encode) { | ||
// tslint:disable-next-line:no-console | ||
console.log(" CANNOT FIND ENCODE METHOD ON VARIANT !!! HELP", dataValue.toString()); | ||
@@ -214,9 +218,10 @@ } | ||
name: "DataValue", | ||
fields: [ | ||
{name: "value", fieldType: "Variant", defaultValue: null}, | ||
{name: "statusCode", fieldType: "StatusCode", defaultValue: StatusCodes.Good}, | ||
{name: "sourceTimestamp", fieldType: "DateTime", defaultValue: null}, | ||
{name: "sourcePicoseconds", fieldType: "UInt16", defaultValue: 0}, | ||
{name: "serverTimestamp", fieldType: "DateTime", defaultValue: null}, | ||
{name: "serverPicoseconds", fieldType: "UInt16", defaultValue: 0} | ||
{ name: "value", fieldType: "Variant", defaultValue: null }, | ||
{ name: "statusCode", fieldType: "StatusCode", defaultValue: StatusCodes.Good }, | ||
{ name: "sourceTimestamp", fieldType: "DateTime", defaultValue: null }, | ||
{ name: "sourcePicoseconds", fieldType: "UInt16", defaultValue: 0 }, | ||
{ name: "serverTimestamp", fieldType: "DateTime", defaultValue: null }, | ||
{ name: "serverPicoseconds", fieldType: "UInt16", defaultValue: 0 } | ||
] | ||
@@ -271,3 +276,3 @@ }); | ||
if (options === null) { | ||
this.value = new Variant({dataType: DataType.Null}); | ||
this.value = new Variant({ dataType: DataType.Null }); | ||
} | ||
@@ -281,5 +286,5 @@ | ||
if (options.value === undefined || options.value === null) { | ||
this.value = new Variant({dataType: DataType.Null}); | ||
this.value = new Variant({ dataType: DataType.Null }); | ||
} else { | ||
this.value = (options.value) ? new Variant(options.value) : new Variant({dataType: DataType.Null}); | ||
this.value = (options.value) ? new Variant(options.value) : new Variant({ dataType: DataType.Null }); | ||
} | ||
@@ -343,7 +348,7 @@ | ||
return "" | ||
+ w((picoseconds / 1000000) >> 0) | ||
+ "." | ||
+ w(((picoseconds % 1000000) / 1000) >> 0) | ||
+ "." | ||
+ w((picoseconds % 1000) >> 0); | ||
+ w((picoseconds / 1000000) >> 0) | ||
+ "." | ||
+ w(((picoseconds % 1000000) / 1000) >> 0) | ||
+ "." | ||
+ w((picoseconds % 1000) >> 0); | ||
// + " (" + picoseconds+ ")"; | ||
@@ -360,7 +365,7 @@ } | ||
str += "\n serverTimestamp: " + (this.serverTimestamp ? this.serverTimestamp.toISOString() | ||
+ " $ " + toMicroNanoPico(this.serverPicoseconds) | ||
: "null"); // + " " + (this.serverTimestamp ? this.serverTimestamp.getTime() :"-"); | ||
+ " $ " + toMicroNanoPico(this.serverPicoseconds) | ||
: "null"); // + " " + (this.serverTimestamp ? this.serverTimestamp.getTime() :"-"); | ||
str += "\n sourceTimestamp: " + (this.sourceTimestamp ? this.sourceTimestamp.toISOString() | ||
+ " $ " + toMicroNanoPico(this.sourcePicoseconds) | ||
: "null"); // + " " + (this.sourceTimestamp ? this.sourceTimestamp.getTime() :"-"); | ||
+ " $ " + toMicroNanoPico(this.sourcePicoseconds) | ||
: "null"); // + " " + (this.sourceTimestamp ? this.sourceTimestamp.getTime() :"-"); | ||
return str; | ||
@@ -397,3 +402,7 @@ } | ||
export function apply_timestamps(dataValue: DataValue, timestampsToReturn: TimestampsToReturn, attributeId: AttributeIds) { | ||
export function apply_timestamps( | ||
dataValue: DataValue, | ||
timestampsToReturn: TimestampsToReturn, | ||
attributeId: AttributeIds | ||
): DataValue { | ||
@@ -448,3 +457,7 @@ assert(attributeId > 0); | ||
function apply_timestamps2(dataValue: DataValue, timestampsToReturn: TimestampsToReturn, attributeId: AttributeIds): DataValue { | ||
function apply_timestamps2( | ||
dataValue: DataValue, | ||
timestampsToReturn: TimestampsToReturn, | ||
attributeId: AttributeIds | ||
): DataValue { | ||
@@ -500,6 +513,11 @@ assert(attributeId > 0); | ||
statusCode: result.statusCode, | ||
serverTimestamp: dataValue.serverTimestamp, | ||
serverPicoseconds: dataValue.serverPicoseconds, | ||
sourceTimestamp: dataValue.sourceTimestamp, | ||
sourcePicoseconds: dataValue.sourcePicoseconds, | ||
value: { | ||
@@ -518,4 +536,5 @@ dataType: DataType.Null | ||
return dataValue.value && ((dataValue.value.arrayType !== VariantArrayType.Scalar) || | ||
((dataValue.value.arrayType === VariantArrayType.Scalar) && (dataValue.value.dataType === DataType.ByteString)) || | ||
((dataValue.value.arrayType === VariantArrayType.Scalar) && (dataValue.value.dataType === DataType.String))); | ||
((dataValue.value.arrayType === VariantArrayType.Scalar) && (dataValue.value.dataType === DataType.ByteString)) | ||
|| | ||
((dataValue.value.arrayType === VariantArrayType.Scalar) && (dataValue.value.dataType === DataType.String))); | ||
} | ||
@@ -562,3 +581,3 @@ | ||
return !sameDate(dataValue1.sourceTimestamp, dataValue2.sourceTimestamp) | ||
|| (dataValue1.sourcePicoseconds !== dataValue2.sourcePicoseconds); | ||
|| (dataValue1.sourcePicoseconds !== dataValue2.sourcePicoseconds); | ||
} | ||
@@ -568,6 +587,10 @@ | ||
return !sameDate(dataValue1.serverTimestamp, dataValue2.serverTimestamp) | ||
|| (dataValue1.serverPicoseconds !== dataValue2.serverPicoseconds); | ||
|| (dataValue1.serverPicoseconds !== dataValue2.serverPicoseconds); | ||
} | ||
export function timestampHasChanged(dataValue1: DataValue, dataValue2: DataValue, timestampsToReturn?: TimestampsToReturn): boolean { | ||
export function timestampHasChanged( | ||
dataValue1: DataValue, | ||
dataValue2: DataValue, | ||
timestampsToReturn?: TimestampsToReturn | ||
): boolean { | ||
// TODO: timestampsToReturn = timestampsToReturn || { key: "Neither"}; | ||
@@ -581,3 +604,4 @@ if (timestampsToReturn === undefined) { | ||
case TimestampsToReturn.Both: | ||
return sourceTimestampHasChanged(dataValue1, dataValue2) || serverTimestampHasChanged(dataValue1, dataValue2); | ||
return sourceTimestampHasChanged(dataValue1, dataValue2) || | ||
serverTimestampHasChanged(dataValue1, dataValue2); | ||
case TimestampsToReturn.Source: | ||
@@ -584,0 +608,0 @@ return sourceTimestampHasChanged(dataValue1, dataValue2); |
@@ -0,3 +1,6 @@ | ||
/** | ||
* @module node-opcua-data-value | ||
*/ | ||
import { Enum } from "node-opcua-enum"; | ||
import { registerEnumeration } from "node-opcua-factory"; | ||
import { Enum } from "node-opcua-enum"; | ||
@@ -14,4 +17,5 @@ export enum DataValueEncodingByte { | ||
name: "DataValue_EncodingByte", | ||
enumValues: DataValueEncodingByte | ||
}; | ||
export const _enumerationDataValueEncodingByte: Enum = registerEnumeration(schemaDataValueEncodingByte); |
@@ -0,2 +1,5 @@ | ||
/** | ||
* @module node-opcua-data-value | ||
*/ | ||
export * from "./datavalue"; | ||
export * from "./TimestampsToReturn_enum"; |
@@ -1,4 +0,7 @@ | ||
import { registerEnumeration } from "node-opcua-factory"; | ||
/** | ||
* @module node-opcua-data-value | ||
*/ | ||
import { BinaryStream } from "node-opcua-binary-stream"; | ||
import { Enum } from "node-opcua-enum"; | ||
import { registerEnumeration } from "node-opcua-factory"; | ||
@@ -15,3 +18,4 @@ export enum TimestampsToReturn { | ||
name: "TimestampsToReturn", | ||
enumValues: TimestampsToReturn, | ||
enumValues: TimestampsToReturn | ||
}; | ||
@@ -23,3 +27,3 @@ | ||
function clamp(min: number, a: number, max: number) { | ||
function clamp(min: number, a: number, max: number) { | ||
return Math.max(Math.min(a, max), min); | ||
@@ -32,2 +36,2 @@ } | ||
export const _enumerationTimestampsToReturn : Enum = registerEnumeration(schemaTimestampsToReturn); | ||
export const _enumerationTimestampsToReturn: Enum = registerEnumeration(schemaTimestampsToReturn); |
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
79024
19
1328