Fix Multi Record Monitor Tags on Event
commitcycling-live-grid57168bd7e9
Author: Moe <github@m03.ca> Date: Wed Mar 15 13:25:00 2023 -0700 clean up UI, rename field to "Trigger Monitors with Tags" commit592a1f6144
Author: Moe <github@m03.ca> Date: Wed Mar 15 13:24:26 2023 -0700 fix bindTagLegendForMonitors commitac68b16bf6
Author: Moe <github@m03.ca> Date: Wed Mar 15 11:47:32 2023 -0700 Fix Triggering Record by Monitor Tags
parent
9bb2f82a7a
commit
5e60c26eeb
|
@ -2784,7 +2784,7 @@ module.exports = function(s,config,lang){
|
||||||
{
|
{
|
||||||
hidden: true,
|
hidden: true,
|
||||||
"name": "detail=det_trigger_tags",
|
"name": "detail=det_trigger_tags",
|
||||||
"field": lang['Trigger Group to Record'],
|
"field": lang['Trigger Monitors with Tags'],
|
||||||
"form-group-class": "h_det_input h_det_1",
|
"form-group-class": "h_det_input h_det_1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4020,25 +4020,6 @@ module.exports = function(s,config,lang){
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"Grouping": {
|
|
||||||
id: "monSectionGrouping",
|
|
||||||
"name": lang.Grouping,
|
|
||||||
"headerTitle": lang['Grouping'] + ' <small>Add groups in <b>Settings</b></small>',
|
|
||||||
"color": "purple",
|
|
||||||
isSection: true,
|
|
||||||
isAdvanced: true,
|
|
||||||
"info": [
|
|
||||||
{
|
|
||||||
"fieldType": 'div',
|
|
||||||
"id": "monitor_groups",
|
|
||||||
"class": "mdl-list"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
hidden: true,
|
|
||||||
"name": "detail=groups",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
"Copy Settings": {
|
"Copy Settings": {
|
||||||
id: "monSectionCopying",
|
id: "monSectionCopying",
|
||||||
"name": lang['Copy Settings'],
|
"name": lang['Copy Settings'],
|
||||||
|
|
|
@ -194,6 +194,7 @@
|
||||||
"Global Detector Settings": "Global Detector Settings",
|
"Global Detector Settings": "Global Detector Settings",
|
||||||
"Detector Settings": "Detector Settings",
|
"Detector Settings": "Detector Settings",
|
||||||
"Trigger Group to Record": "Trigger Group to Record",
|
"Trigger Group to Record": "Trigger Group to Record",
|
||||||
|
"Trigger Monitors with Tags": "Trigger Monitors with Tags",
|
||||||
"triggerGroupRecordFieldText": "Add the names of an existing tag that was added to a Monitor previously or is pending to be added to this monitor that is currently being edited.",
|
"triggerGroupRecordFieldText": "Add the names of an existing tag that was added to a Monitor previously or is pending to be added to this monitor that is currently being edited.",
|
||||||
"Trigger Camera Groups": "Trigger Camera Groups",
|
"Trigger Camera Groups": "Trigger Camera Groups",
|
||||||
"Motion Detection": "Motion Detection",
|
"Motion Detection": "Motion Detection",
|
||||||
|
|
|
@ -1,4 +1,22 @@
|
||||||
module.exports = function(s,config,lang){
|
module.exports = function(s,config,lang){
|
||||||
require('./events/onvif.js')(s,config,lang)
|
require('./events/onvif.js')(s,config,lang)
|
||||||
require('./events/noEventsDetector.js')(s,config,lang)
|
require('./events/noEventsDetector.js')(s,config,lang)
|
||||||
|
const { bindTagLegendForMonitors } = require('./events/utils.js')(s,config,lang)
|
||||||
|
s.onAccountSave(function(theGroup,formDetails,user){
|
||||||
|
const groupKey = user.ke
|
||||||
|
bindTagLegendForMonitors(groupKey)
|
||||||
|
})
|
||||||
|
s.onMonitorSave(function(monitorConfig){
|
||||||
|
const groupKey = monitorConfig.ke
|
||||||
|
bindTagLegendForMonitors(groupKey)
|
||||||
|
})
|
||||||
|
s.onMonitorStop(function(monitorConfig){
|
||||||
|
const groupKey = monitorConfig.ke
|
||||||
|
bindTagLegendForMonitors(groupKey)
|
||||||
|
})
|
||||||
|
s.onProcessReady(function(){
|
||||||
|
Object.keys(s.group).forEach((groupKey) => {
|
||||||
|
bindTagLegendForMonitors(groupKey)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
const movingThings = require('shinobi-node-moving-things-tracker').Tracker
|
const movingThings = require('shinobi-node-moving-things-tracker').Tracker
|
||||||
module.exports = (s,config,lang,app,io) => {
|
module.exports = (s,config,lang) => {
|
||||||
const objectTrackers = {}
|
const objectTrackers = {}
|
||||||
const objectTrackerTimeouts = {}
|
const objectTrackerTimeouts = {}
|
||||||
function resetObjectTracker(trackerId,matrices){
|
function resetObjectTracker(trackerId,matrices){
|
||||||
|
|
|
@ -10,7 +10,7 @@ const V = SAT.Vector;
|
||||||
const P = SAT.Polygon;
|
const P = SAT.Polygon;
|
||||||
const B = SAT.Box;
|
const B = SAT.Box;
|
||||||
// Matrix In Region Libs />
|
// Matrix In Region Libs />
|
||||||
module.exports = (s,config,lang,app,io) => {
|
module.exports = (s,config,lang) => {
|
||||||
// Event Filters >
|
// Event Filters >
|
||||||
const acceptableOperators = ['indexOf','!indexOf','===','!==','>=','>','<','<=']
|
const acceptableOperators = ['indexOf','!indexOf','===','!==','>=','>','<','<=']
|
||||||
// Event Filters />
|
// Event Filters />
|
||||||
|
@ -29,7 +29,7 @@ module.exports = (s,config,lang,app,io) => {
|
||||||
setLastTracked,
|
setLastTracked,
|
||||||
trackObjectWithTimeout,
|
trackObjectWithTimeout,
|
||||||
getAllMatricesThatMoved,
|
getAllMatricesThatMoved,
|
||||||
} = require('./tracking.js')(s,config,lang,app,io)
|
} = require('./tracking.js')(s,config,lang)
|
||||||
const {
|
const {
|
||||||
isEven,
|
isEven,
|
||||||
fetchTimeout,
|
fetchTimeout,
|
||||||
|
@ -330,8 +330,8 @@ module.exports = (s,config,lang,app,io) => {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
const runMultiEventBasedRecord = (monitorConfig, triggerTags, eventTime) => {
|
const runMultiEventBasedRecord = (monitorConfig, monitorIdsToTrigger, eventTime) => {
|
||||||
triggerTags.forEach(function(monitorId){
|
monitorIdsToTrigger.forEach(function(monitorId){
|
||||||
const groupKey = monitorConfig.ke
|
const groupKey = monitorConfig.ke
|
||||||
const monitor = s.group[groupKey].rawMonitorConfigurations[monitorId]
|
const monitor = s.group[groupKey].rawMonitorConfigurations[monitorId]
|
||||||
if(monitorId !== monitorConfig.mid && monitor){
|
if(monitorId !== monitorConfig.mid && monitor){
|
||||||
|
@ -347,7 +347,34 @@ module.exports = (s,config,lang,app,io) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
function bindTagLegendForMonitors(groupKey){
|
||||||
|
const newTagLegend = {}
|
||||||
|
const theGroup = s.group[groupKey]
|
||||||
|
const monitorIds = Object.keys(theGroup.rawMonitorConfigurations)
|
||||||
|
monitorIds.forEach((monitorId) => {
|
||||||
|
const monitorConfig = theGroup.rawMonitorConfigurations[monitorId]
|
||||||
|
const theTags = (monitorConfig.tags || '').split(',')
|
||||||
|
theTags.forEach((tag) => {
|
||||||
|
if(!tag)return;
|
||||||
|
if(!newTagLegend[tag])newTagLegend[tag] = []
|
||||||
|
if(newTagLegend[tag].indexOf(monitorId) === -1)newTagLegend[tag].push(monitorId)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
theGroup.tagLegend = newTagLegend
|
||||||
|
}
|
||||||
|
function findMonitorsAssociatedToTags(groupKey,triggerTags){
|
||||||
|
const monitorsToTrigger = []
|
||||||
|
const theGroup = s.group[groupKey]
|
||||||
|
triggerTags.forEach((tag) => {
|
||||||
|
const monitorIds = theGroup.tagLegend[tag]
|
||||||
|
monitorIds.forEach((monitorId) => {
|
||||||
|
if(monitorsToTrigger.indexOf(monitorId) === -1)monitorsToTrigger.push(monitorId)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return monitorsToTrigger
|
||||||
|
}
|
||||||
const runEventExecutions = async (eventTime,monitorConfig,eventDetails,forceSave,filter,d, triggerEvent) => {
|
const runEventExecutions = async (eventTime,monitorConfig,eventDetails,forceSave,filter,d, triggerEvent) => {
|
||||||
|
const groupKey = monitorConfig.ke
|
||||||
const monitorDetails = monitorConfig.details
|
const monitorDetails = monitorConfig.details
|
||||||
const detailString = JSON.stringify(eventDetails)
|
const detailString = JSON.stringify(eventDetails)
|
||||||
if(monitorDetails.detector_ptz_follow === '1'){
|
if(monitorDetails.detector_ptz_follow === '1'){
|
||||||
|
@ -355,7 +382,8 @@ module.exports = (s,config,lang,app,io) => {
|
||||||
}
|
}
|
||||||
if(monitorDetails.det_trigger_tags){
|
if(monitorDetails.det_trigger_tags){
|
||||||
const triggerTags = monitorDetails.det_trigger_tags.split(',')
|
const triggerTags = monitorDetails.det_trigger_tags.split(',')
|
||||||
runMultiEventBasedRecord(monitorConfig, triggerTags, eventTime)
|
const monitorIds = findMonitorsAssociatedToTags(groupKey, triggerTags)
|
||||||
|
runMultiEventBasedRecord(monitorConfig, monitorIds, eventTime)
|
||||||
}
|
}
|
||||||
//save this detection result in SQL, only coords. not image.
|
//save this detection result in SQL, only coords. not image.
|
||||||
if(d.frame){
|
if(d.frame){
|
||||||
|
@ -779,7 +807,8 @@ module.exports = (s,config,lang,app,io) => {
|
||||||
hasMatrices: hasMatrices,
|
hasMatrices: hasMatrices,
|
||||||
checkEventFilters: checkEventFilters,
|
checkEventFilters: checkEventFilters,
|
||||||
checkMotionLock: checkMotionLock,
|
checkMotionLock: checkMotionLock,
|
||||||
runMultiEventBasedRecord: runMultiEventBasedRecord,
|
bindTagLegendForMonitors,
|
||||||
|
runMultiEventBasedRecord,
|
||||||
runEventExecutions: runEventExecutions,
|
runEventExecutions: runEventExecutions,
|
||||||
createEventBasedRecording: createEventBasedRecording,
|
createEventBasedRecording: createEventBasedRecording,
|
||||||
closeEventBasedRecording: closeEventBasedRecording,
|
closeEventBasedRecording: closeEventBasedRecording,
|
||||||
|
|
Loading…
Reference in New Issue