adjust counting methodology for tracking plugins

- tracking plugins are currently not available to public but you may still use the counting feature on a per-frame basis instead of tracked object
build-default-monitor-config-from-definitions
Moe 2020-05-24 22:10:31 -07:00
parent 48e6483550
commit 479efbf228
2 changed files with 10 additions and 8 deletions

View File

@ -14,9 +14,9 @@ module.exports = function(s,config,lang){
const eventsCounted = s.group[event.ke].activeMonitors[event.id].eventsCounted || {} const eventsCounted = s.group[event.ke].activeMonitors[event.id].eventsCounted || {}
if(matrices){ if(matrices){
matrices.forEach((matrix)=>{ matrices.forEach((matrix)=>{
const id = !isNaN(matrix.id) ? matrix.id + '_' + matrix.tag : matrix.tag const id = matrix.tag
if(!eventsCounted[id])eventsCounted[id] = {times: [], count: 0} if(!eventsCounted[id])eventsCounted[id] = {times: [], count: {}, tag: matrix.tag}
++eventsCounted[id].count if(!isNaN(matrix.id))eventsCounted[id].count[matrix.id] = 1
eventsCounted[id].times.push(new Date().getTime()) eventsCounted[id].times.push(new Date().getTime())
}) })
} }

View File

@ -1014,9 +1014,9 @@ module.exports = function(s,config,lang){
if(monitor.details.detector_obj_count === '1'){ if(monitor.details.detector_obj_count === '1'){
const activeMonitor = s.group[monitor.ke].activeMonitors[monitor.id] const activeMonitor = s.group[monitor.ke].activeMonitors[monitor.id]
activeMonitor.eventsCountStartTime = new Date() activeMonitor.eventsCountStartTime = new Date()
const eventsCounted = activeMonitor.eventsCounted || {}
clearInterval(activeMonitor.objectCountIntervals) clearInterval(activeMonitor.objectCountIntervals)
activeMonitor.objectCountIntervals = setInterval(() => { activeMonitor.objectCountIntervals = setInterval(() => {
const eventsCounted = activeMonitor.eventsCounted || {}
const countsToSave = Object.assign(eventsCounted,{}) const countsToSave = Object.assign(eventsCounted,{})
activeMonitor.eventsCounted = {} activeMonitor.eventsCounted = {}
const groupKey = monitor.ke const groupKey = monitor.ke
@ -1027,18 +1027,20 @@ module.exports = function(s,config,lang){
activeMonitor.eventsCountStartTime = new Date() activeMonitor.eventsCountStartTime = new Date()
if(countedKeys.length > 0)countedKeys.forEach((tag) => { if(countedKeys.length > 0)countedKeys.forEach((tag) => {
const tagInfo = countsToSave[tag] const tagInfo = countsToSave[tag]
const count = tagInfo.count const count = Object.keys(tagInfo.count)
const times = tagInfo.times const times = tagInfo.times
const realTag = tagInfo.tag
s.sqlQuery('INSERT INTO `Events Counts` (ke,mid,details,time,end,count,tag) VALUES (?,?,?,?,?,?,?)',[ s.sqlQuery('INSERT INTO `Events Counts` (ke,mid,details,time,end,count,tag) VALUES (?,?,?,?,?,?,?)',[
groupKey, groupKey,
monitorId, monitorId,
JSON.stringify({ JSON.stringify({
times: times times: times,
count: count,
}), }),
startTime, startTime,
endTime, endTime,
count, count.length,
tag realTag
]) ])
}) })
},60000) //every minute },60000) //every minute