node-opcua-data-value
Advanced tools
Comparing version 2.11.0 to 2.13.0
@@ -199,124 +199,127 @@ "use strict"; | ||
}); | ||
class DataValue extends node_opcua_factory_1.BaseUAObject { | ||
/** | ||
* | ||
* @class DataValue | ||
* @constructor | ||
* @extends BaseUAObject | ||
* @param options {Object} | ||
*/ | ||
constructor(options) { | ||
super(); | ||
const schema = schemaDataValue; | ||
options = options || {}; | ||
/* istanbul ignore next */ | ||
if (node_opcua_factory_1.parameters.debugSchemaHelper) { | ||
node_opcua_factory_1.check_options_correctness_against_schema(this, schema, options); | ||
} | ||
if (options === null) { | ||
this.value = new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null }); | ||
} | ||
let DataValue = /** @class */ (() => { | ||
class DataValue extends node_opcua_factory_1.BaseUAObject { | ||
/** | ||
* @property value | ||
* @type {Variant} | ||
* @default null | ||
* | ||
* @class DataValue | ||
* @constructor | ||
* @extends BaseUAObject | ||
* @param options {Object} | ||
*/ | ||
if (options.value === undefined || options.value === null) { | ||
this.value = new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null }); | ||
constructor(options) { | ||
super(); | ||
const schema = schemaDataValue; | ||
options = options || {}; | ||
/* istanbul ignore next */ | ||
if (node_opcua_factory_1.parameters.debugSchemaHelper) { | ||
node_opcua_factory_1.check_options_correctness_against_schema(this, schema, options); | ||
} | ||
if (options === null) { | ||
this.value = new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null }); | ||
} | ||
/** | ||
* @property value | ||
* @type {Variant} | ||
* @default null | ||
*/ | ||
if (options.value === undefined || options.value === null) { | ||
this.value = new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null }); | ||
} | ||
else { | ||
this.value = (options.value) ? new node_opcua_variant_1.Variant(options.value) : new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null }); | ||
} | ||
/** | ||
* @property statusCode | ||
* @type {StatusCode} | ||
* @default Good (0x00000) | ||
*/ | ||
this.statusCode = node_opcua_factory_1.initialize_field(schema.fields[1], options.statusCode); | ||
/** | ||
* @property sourceTimestamp | ||
* @type {DateTime} | ||
* @default null | ||
*/ | ||
this.sourceTimestamp = node_opcua_factory_1.initialize_field(schema.fields[2], options.sourceTimestamp); | ||
/** | ||
* @property sourcePicoseconds | ||
* @type {UInt16} | ||
* @default 0 | ||
*/ | ||
this.sourcePicoseconds = node_opcua_factory_1.initialize_field(schema.fields[3], options.sourcePicoseconds); | ||
/** | ||
* @property serverTimestamp | ||
* @type {DateTime} | ||
* @default null | ||
*/ | ||
this.serverTimestamp = node_opcua_factory_1.initialize_field(schema.fields[4], options.serverTimestamp); | ||
/** | ||
* @property serverPicoseconds | ||
* @type {UInt16} | ||
* @default 0 | ||
*/ | ||
this.serverPicoseconds = node_opcua_factory_1.initialize_field(schema.fields[5], options.serverPicoseconds); | ||
} | ||
else { | ||
this.value = (options.value) ? new node_opcua_variant_1.Variant(options.value) : new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.Null }); | ||
encode(stream) { | ||
encodeDataValue(this, stream); | ||
} | ||
/** | ||
* @property statusCode | ||
* @type {StatusCode} | ||
* @default Good (0x00000) | ||
*/ | ||
this.statusCode = node_opcua_factory_1.initialize_field(schema.fields[1], options.statusCode); | ||
/** | ||
* @property sourceTimestamp | ||
* @type {DateTime} | ||
* @default null | ||
*/ | ||
this.sourceTimestamp = node_opcua_factory_1.initialize_field(schema.fields[2], options.sourceTimestamp); | ||
/** | ||
* @property sourcePicoseconds | ||
* @type {UInt16} | ||
* @default 0 | ||
*/ | ||
this.sourcePicoseconds = node_opcua_factory_1.initialize_field(schema.fields[3], options.sourcePicoseconds); | ||
/** | ||
* @property serverTimestamp | ||
* @type {DateTime} | ||
* @default null | ||
*/ | ||
this.serverTimestamp = node_opcua_factory_1.initialize_field(schema.fields[4], options.serverTimestamp); | ||
/** | ||
* @property serverPicoseconds | ||
* @type {UInt16} | ||
* @default 0 | ||
*/ | ||
this.serverPicoseconds = node_opcua_factory_1.initialize_field(schema.fields[5], options.serverPicoseconds); | ||
} | ||
encode(stream) { | ||
encodeDataValue(this, stream); | ||
} | ||
decode(stream) { | ||
decodeDataValueInternal(this, stream); | ||
} | ||
decodeDebug(stream, options) { | ||
decodeDebugDataValue(this, stream, options); | ||
} | ||
isValid() { | ||
return isValidDataValue(this); | ||
} | ||
toString() { | ||
function toMicroNanoPico(picoseconds) { | ||
return "" | ||
+ w((picoseconds / 1000000) >> 0) | ||
+ "." | ||
+ w(((picoseconds % 1000000) / 1000) >> 0) | ||
+ "." | ||
+ w((picoseconds % 1000) >> 0); | ||
// + " (" + picoseconds+ ")"; | ||
decode(stream) { | ||
decodeDataValueInternal(this, stream); | ||
} | ||
function d(timestamp, picoseconds) { | ||
return (timestamp ? timestamp.toISOString() | ||
+ " $ " + toMicroNanoPico(picoseconds) | ||
: "null"); // + " " + (this.serverTimestamp ? this.serverTimestamp.getTime() :"-"); | ||
decodeDebug(stream, options) { | ||
decodeDebugDataValue(this, stream, options); | ||
} | ||
let str = "{ /* DataValue */"; | ||
if (this.value) { | ||
str += "\n" + " value: " + node_opcua_variant_1.Variant.prototype.toString.apply(this.value); // this.value.toString(); | ||
isValid() { | ||
return isValidDataValue(this); | ||
} | ||
else { | ||
str += "\n" + " value: <null>"; | ||
toString() { | ||
function toMicroNanoPico(picoseconds) { | ||
return "" | ||
+ w((picoseconds / 1000000) >> 0) | ||
+ "." | ||
+ w(((picoseconds % 1000000) / 1000) >> 0) | ||
+ "." | ||
+ w((picoseconds % 1000) >> 0); | ||
// + " (" + picoseconds+ ")"; | ||
} | ||
function d(timestamp, picoseconds) { | ||
return (timestamp ? timestamp.toISOString() | ||
+ " $ " + toMicroNanoPico(picoseconds) | ||
: "null"); // + " " + (this.serverTimestamp ? this.serverTimestamp.getTime() :"-"); | ||
} | ||
let str = "{ /* DataValue */"; | ||
if (this.value) { | ||
str += "\n" + " value: " + node_opcua_variant_1.Variant.prototype.toString.apply(this.value); // this.value.toString(); | ||
} | ||
else { | ||
str += "\n" + " value: <null>"; | ||
} | ||
str += "\n" + " statusCode: " + (this.statusCode ? this.statusCode.toString() : "null"); | ||
str += "\n" + " serverTimestamp: " + d(this.serverTimestamp, this.serverPicoseconds); | ||
str += "\n" + " sourceTimestamp: " + d(this.sourceTimestamp, this.sourcePicoseconds); | ||
str += "\n" + "}"; | ||
return str; | ||
} | ||
str += "\n" + " statusCode: " + (this.statusCode ? this.statusCode.toString() : "null"); | ||
str += "\n" + " serverTimestamp: " + d(this.serverTimestamp, this.serverPicoseconds); | ||
str += "\n" + " sourceTimestamp: " + d(this.sourceTimestamp, this.sourcePicoseconds); | ||
str += "\n" + "}"; | ||
return str; | ||
clone() { | ||
return new DataValue({ | ||
serverPicoseconds: this.serverPicoseconds, | ||
serverTimestamp: this.serverTimestamp, | ||
sourcePicoseconds: this.sourcePicoseconds, | ||
sourceTimestamp: this.sourceTimestamp, | ||
statusCode: this.statusCode, | ||
value: this.value ? this.value.clone() : undefined | ||
}); | ||
} | ||
} | ||
clone() { | ||
return new DataValue({ | ||
serverPicoseconds: this.serverPicoseconds, | ||
serverTimestamp: this.serverTimestamp, | ||
sourcePicoseconds: this.sourcePicoseconds, | ||
sourceTimestamp: this.sourceTimestamp, | ||
statusCode: this.statusCode, | ||
value: this.value ? this.value.clone() : undefined | ||
}); | ||
} | ||
} | ||
DataValue.possibleFields = [ | ||
"value", | ||
"statusCode", | ||
"sourceTimestamp", | ||
"sourcePicoseconds", | ||
"serverTimestamp", | ||
"serverPicoseconds" | ||
]; | ||
DataValue.schema = schemaDataValue; | ||
return DataValue; | ||
})(); | ||
exports.DataValue = DataValue; | ||
DataValue.possibleFields = [ | ||
"value", | ||
"statusCode", | ||
"sourceTimestamp", | ||
"sourcePicoseconds", | ||
"serverTimestamp", | ||
"serverPicoseconds" | ||
]; | ||
DataValue.schema = schemaDataValue; | ||
DataValue.prototype.schema = DataValue.schema; | ||
@@ -323,0 +326,0 @@ node_opcua_factory_1.registerSpecialVariantEncoder(DataValue); |
@@ -5,3 +5,3 @@ { | ||
"types": "./dist/index.d.ts", | ||
"version": "2.11.0", | ||
"version": "2.13.0", | ||
"description": "pure nodejs OPCUA SDK - module -data-value", | ||
@@ -15,19 +15,19 @@ "scripts": { | ||
"node-opcua-assert": "2.10.0", | ||
"node-opcua-basic-types": "2.11.0", | ||
"node-opcua-basic-types": "2.13.0", | ||
"node-opcua-binary-stream": "2.11.0", | ||
"node-opcua-data-model": "2.11.0", | ||
"node-opcua-data-model": "2.13.0", | ||
"node-opcua-date-time": "2.11.0", | ||
"node-opcua-enum": "2.10.0", | ||
"node-opcua-extension-object": "2.11.0", | ||
"node-opcua-factory": "2.11.0", | ||
"node-opcua-extension-object": "2.13.0", | ||
"node-opcua-factory": "2.13.0", | ||
"node-opcua-nodeid": "2.11.0", | ||
"node-opcua-status-code": "2.11.0", | ||
"node-opcua-utils": "2.10.0", | ||
"node-opcua-variant": "2.11.0", | ||
"node-opcua-utils": "2.13.0", | ||
"node-opcua-variant": "2.13.0", | ||
"underscore": "^1.10.2" | ||
}, | ||
"devDependencies": { | ||
"node-opcua-generator": "2.11.0", | ||
"node-opcua-numeric-range": "2.11.0", | ||
"node-opcua-packet-analyzer": "2.11.0", | ||
"node-opcua-generator": "2.13.0", | ||
"node-opcua-numeric-range": "2.13.0", | ||
"node-opcua-packet-analyzer": "2.13.0", | ||
"should": "^13.2.3" | ||
@@ -50,3 +50,3 @@ }, | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "1e1c6d63340aa799867af261437a6a0f5a9a2cdd" | ||
"gitHead": "3c8a33e1e9d7923c9434607ad22d51d6d8d58918" | ||
} |
Sorry, the diff of this file is not supported yet
81616
1385
+ Addednode-opcua-basic-types@2.13.0(transitive)
+ Addednode-opcua-data-model@2.13.0(transitive)
+ Addednode-opcua-extension-object@2.13.0(transitive)
+ Addednode-opcua-factory@2.13.0(transitive)
+ Addednode-opcua-utils@2.13.0(transitive)
+ Addednode-opcua-variant@2.13.0(transitive)
- Removednode-opcua-basic-types@2.11.0(transitive)
- Removednode-opcua-data-model@2.11.0(transitive)
- Removednode-opcua-extension-object@2.11.0(transitive)
- Removednode-opcua-factory@2.11.0(transitive)
- Removednode-opcua-utils@2.10.0(transitive)
- Removednode-opcua-variant@2.11.0(transitive)
Updatednode-opcua-data-model@2.13.0
Updatednode-opcua-factory@2.13.0
Updatednode-opcua-utils@2.13.0
Updatednode-opcua-variant@2.13.0