better plugin controller
parent
48a0d6be27
commit
df4e07429c
|
@ -2,6 +2,7 @@ module.exports = function(s,config,lang){
|
|||
require('./events/onvif.js')(s,config,lang)
|
||||
require('./events/noEventsDetector.js')(s,config,lang)
|
||||
const { bindTagLegendForMonitors } = require('./events/utils.js')(s,config,lang)
|
||||
const { initMonitorOnPlugin, initAllMonitorsOnPlugins } = require('./plugins/utils.js')(s,config,lang)
|
||||
s.onAccountSave(function(theGroup,formDetails,user){
|
||||
const groupKey = user.ke
|
||||
bindTagLegendForMonitors(groupKey)
|
||||
|
@ -9,14 +10,25 @@ module.exports = function(s,config,lang){
|
|||
s.onMonitorSave(function(monitorConfig){
|
||||
const groupKey = monitorConfig.ke
|
||||
bindTagLegendForMonitors(groupKey)
|
||||
// init in plugins
|
||||
s.ocvTx({
|
||||
f : 'init_monitor',
|
||||
mon : s.group[groupKey].rawMonitorConfigurations[monitorId],
|
||||
ke : groupKey,
|
||||
id : monitorId,
|
||||
time : s.formattedTime(),
|
||||
});
|
||||
})
|
||||
s.onMonitorStop(function(monitorConfig){
|
||||
const groupKey = monitorConfig.ke
|
||||
bindTagLegendForMonitors(groupKey)
|
||||
})
|
||||
});
|
||||
s.onPluginChanged(function(){
|
||||
initAllMonitorsOnPlugins(groupKey)
|
||||
});
|
||||
s.onProcessReady(function(){
|
||||
Object.keys(s.group).forEach((groupKey) => {
|
||||
bindTagLegendForMonitors(groupKey)
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -67,4 +67,6 @@ module.exports = function(s,config){
|
|||
createExtension(`onCloudVideoUploaded`)
|
||||
/////// TIMELAPSE ////////
|
||||
createExtension(`onInsertTimelapseFrame`)
|
||||
/////// PLUGINS ////////
|
||||
createExtension(`onPluginChanged`)
|
||||
}
|
||||
|
|
|
@ -64,6 +64,10 @@ module.exports = function(s,config,lang,app,io){
|
|||
connectionType: d.connectionType
|
||||
}
|
||||
s.resetDetectorPluginArray()
|
||||
for (var i = 0; i < s.onPluginChangedExtensions.length; i++) {
|
||||
const extender = s.onPluginChangedExtensions[i]
|
||||
extender(d,filter)
|
||||
}
|
||||
}
|
||||
s.removeDetectorPlugin = function(name){
|
||||
if(config.oldPluginConnectionMethod === true && s.ocv && s.ocv.plug === name){
|
||||
|
|
|
@ -41,7 +41,30 @@ module.exports = (s,config,lang) => {
|
|||
// s.tx(data,'CPU')
|
||||
// })
|
||||
}
|
||||
function initMonitorOnPlugins(groupKey,monitorId){
|
||||
s.ocvTx({
|
||||
f : 'init_monitor',
|
||||
monitorConfig : s.group[groupKey].rawMonitorConfigurations[monitorId],
|
||||
groupKey,
|
||||
monitorId,
|
||||
time : s.formattedTime(),
|
||||
});
|
||||
}
|
||||
function initMonitorsOnPlugins(groupKey){
|
||||
const monitors = s.group[groupKey].rawMonitorConfigurations;
|
||||
Object.keys(monitors).forEach((monitorId) => {
|
||||
initMonitorOnPlugins(groupKey, monitorId)
|
||||
})
|
||||
}
|
||||
function initAllMonitorsOnPlugins(){
|
||||
Object.keys(s.group).forEach((groupKey) => {
|
||||
initMonitorsOnPlugins(groupKey)
|
||||
})
|
||||
}
|
||||
return {
|
||||
initMonitorOnPlugin,
|
||||
initMonitorsOnPlugins,
|
||||
initAllMonitorsOnPlugins,
|
||||
activateClientPlugin: activateClientPlugin,
|
||||
initializeClientPlugin: initializeClientPlugin,
|
||||
deactivateClientPlugin: deactivateClientPlugin,
|
||||
|
|
Loading…
Reference in New Issue