Skip to content

Commit

Permalink
Fix historical_data store on sourceTimestamp==null
Browse files Browse the repository at this point in the history
Fix a null pointer exeption if sourceTimestamp is NULL on "value_changed" event in historical_data store
  • Loading branch information
tomsoftware authored and erossignon committed Mar 28, 2017
1 parent a8272ef commit 97fa30b
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ exports.install = function (AddressSpace) {
node.on("value_changed", function (newDataValue) {
node._timeline.push(newDataValue);

var sourceTime = newDataValue.sourceTimestamp || new Date();

// ensure that values are set with date increasing
if (newDataValue.sourceTimestamp.getTime() <= lastDate.getTime()) {
console.log("Warning date not increasing ".red,newDataValue.toString()," last known date = ",lastDate);
if (sourceTime.getTime() <= lastDate.getTime()) {
console.log("Warning date not increasing ".red, newDataValue.toString(), " last known date = ", lastDate);
}

lastDate = newDataValue.sourceTimestamp;
lastDate = sourceTime;

// we keep only a limited amount in main memory
if (node._timeline.length > node._maxOnlineValues) {
Expand Down

0 comments on commit 97fa30b

Please sign in to comment.