Add new fuctions for plugins

This commit is contained in:
Emmanuel Papin 2015-01-15 16:51:46 +01:00
parent abddb5d916
commit 2227d9c852
5 changed files with 47 additions and 1 deletions

View File

@ -230,3 +230,17 @@ bool Detector::Detect(const Image &zmImage, Zone** zones, Event::StringSet &zone
return alarm; return alarm;
} }
void Detector::_onCreateEvent(const Image &zmImage, Zone** zones)
{
for(std::vector<unsigned int>::iterator it = m_vnPluginZones.begin(); it != m_vnPluginZones.end(); ++it)
onCreateEvent(zones[*it], *it, const Image *zmImage);
}
void Detector::_onCloseEvent(const Image &zmImage, Zone** zones)
{
for(std::vector<unsigned int>::iterator it = m_vnPluginZones.begin(); it != m_vnPluginZones.end(); ++it)
onCloseEvent(zones[*it], *it, const Image *zmImage);
}

View File

@ -78,6 +78,10 @@ public:
//! Detect (in an image later) //! Detect (in an image later)
bool Detect(const Image &image, Zone** zones, Event::StringSet &zoneSet, unsigned int &score); bool Detect(const Image &image, Zone** zones, Event::StringSet &zoneSet, unsigned int &score);
void _onCreateEvent(const Image &zmImage, Zone** zones);
void _onCloseEvent(const Image &zmImage, Zone** zones);
//! Load detector's parameters. //! Load detector's parameters.
virtual int loadConfig(string sConfigFileName, map<unsigned int,map<string,string> > mapPluginConf) = 0; virtual int loadConfig(string sConfigFileName, map<unsigned int,map<string,string> > mapPluginConf) = 0;
@ -98,6 +102,10 @@ protected:
//! Do detection inside one given zone. //! Do detection inside one given zone.
virtual bool checkZone(Zone *zone, unsigned int n_zone, const Image *zmImage) = 0; virtual bool checkZone(Zone *zone, unsigned int n_zone, const Image *zmImage) = 0;
virtual void onCreateEvent(Zone *zone, unsigned int n_zone, const Image *zmImage) = 0;
virtual void onCloseEvent(Zone *zone, unsigned int n_zone, const Image *zmImage) = 0;
//! Log messages to the SYSLOG. //! Log messages to the SYSLOG.
void log(int, string sLevel, string sMessage); void log(int, string sLevel, string sMessage);

View File

@ -41,7 +41,25 @@ ImageAnalyser::~ImageAnalyser()
delete *It; delete *It;
} }
void ImageAnalyser::onCreateEvent(const Image &comp_image, Zone** zones, Event* event)
{
for ( DetectorsList::iterator It = m_Detectors.begin();
It != m_Detectors.end();
++It )
{
(*It)->_onCreateEvent(const comp_image, zones, event);
}
}
void ImageAnalyser::onCloseEvent(const Image &comp_image, Zone** zones, Event* event)
{
for ( DetectorsList::iterator It = m_Detectors.begin();
It != m_Detectors.end();
++It )
{
(*It)->_onCloseEvent(const comp_image, zones, event);
} }
}
/*!\fn ImageAnalyser::DoDetection(const Image &comp_image, Zone** zones, Event::StringSetMap noteSetMap, string& det_cause) /*!\fn ImageAnalyser::DoDetection(const Image &comp_image, Zone** zones, Event::StringSetMap noteSetMap, string& det_cause)
* \param comp_image is the image to analyse * \param comp_image is the image to analyse

View File

@ -75,6 +75,9 @@ class ImageAnalyser {
m_Detectors.push_back(Det.release()); m_Detectors.push_back(Det.release());
} }
void onCreateEvent(const Image &comp_image, Zone** zones);
void onCloseEvent(const Image &comp_image, Zone** zones);
//! Do detection in an image by calling all available detectors. //! Do detection in an image by calling all available detectors.
bool DoDetection(const Image &comp_image, Zone** zones, Event::StringSetMap& noteSetMap, std::string& det_cause, unsigned int& score); bool DoDetection(const Image &comp_image, Zone** zones, Event::StringSetMap& noteSetMap, std::string& det_cause, unsigned int& score);

View File

@ -1520,7 +1520,10 @@ bool Monitor::Analyse()
// Create event // Create event
event = new Event( this, *timestamp, "Continuous", noteSetMap ); event = new Event( this, *timestamp, "Continuous", noteSetMap );
shared_data->last_event = event->Id(); shared_data->last_event = event->Id();
#if ZM_PLUGINS_ON
if (config.load_plugins)
ThePluginManager.getImageAnalyser().onCreateEvent( *snap_image, zones, event );
#endif // ZM_PLUGINS_ON
Info( "%s: %03d - Opening new event %d, section start", name, image_count, event->Id() ); Info( "%s: %03d - Opening new event %d, section start", name, image_count, event->Id() );
/* To prevent cancelling out an existing alert\prealarm\alarm state */ /* To prevent cancelling out an existing alert\prealarm\alarm state */