Skip to content

Commit

Permalink
Merge pull request #87 from joyja/improvedDBEgress
Browse files Browse the repository at this point in the history
fixed egress publish
  • Loading branch information
joyja committed May 20, 2021
2 parents 3cd7e66 + 64da0e5 commit 54c78bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/relations.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,22 +501,23 @@ MqttSource.prototype.log = async function (scanClassId) {
return {
id: tag.id,
value: tag.prevValue,
timestamp: tag.prevChangeOn,
timestamp: tag.lastChangeOn,
}
})
// The following is to collect realtime history of events to be published without isHistorical
if (tags.length > 0) {
this.rtHistory = [
...this.rtHistory,
...preDeadbandExitPoints,
...tags.map((tag) => {
return {
id: tag.id,
value: tag.value,
timestamp: getUnixTime(new Date()),
}
}),
...preDeadbandExitPoints,
]
console.log(this.rtHistory)
}
// The following is to collect history in the event of a primaryHost going offline
if (tags.length > 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ class Tag extends Model {
async setValue(value, write = true) {
this.checkInit()
const lastValue = this.value
const lastChangeOn = this.lastChangeOn
this.lastChangeOn = this.timestamp
if (!this.prevChangeWithinDeadband) {
this.prevValue = lastValue
this.prevChangeOn = lastChangeOn
this.prevChangeOn = this.lastChangeOn
}
if (this.source && write) {
this.source.write(value)
Expand All @@ -113,7 +113,7 @@ class Tag extends Model {
this._value = result
this.pubsub.publish('tagUpdate', { tagUpdate: this })
})
this.lastChangeOn = getUnixTime(new Date())
this.timestamp = getUnixTime(new Date())
this.prevChangeWithinDeadband =
this.datatype === 'BOOLEAN'
? this.value === this.prevValue
Expand Down

0 comments on commit 54c78bf

Please sign in to comment.