23 changed files with 763 additions and 236 deletions
-
1Projects/la_mojo/la_mojo.vpj
-
49Projects/la_mojo/makefile
-
42lib/App/common/MySQL_dataBinder.cpp
-
218lib/App/common/SQLite_dataBinder.cpp
-
4lib/App/common/SQLite_dataBinder.h
-
3lib/App/common/dataBinder.h
-
28lib/App/common/dataBinder_structures.h
-
21lib/App/common/deviceNodeCamera.cpp
-
32lib/App/common/deviceNodePTZCamControl.cpp
-
46lib/App/common/hardwareManager.cpp
-
64lib/App/common/kernelEventFilter.cpp
-
22lib/App/common/kernelEventFilter.h
-
16lib/App/common/kernelEventFilterAPF.cpp
-
198lib/App/common/kernelEventFilterTrain.cpp
-
34lib/App/common/kernelEventFilterTrain.h
-
164lib/App/common/kernelModuleEmbedVideo.cpp
-
2lib/App/common/kernelModuleEmbedVideo.h
-
16lib/App/common/kernelModuleOnvifObserver.cpp
-
17lib/components/base/basicEvent.h
-
10lib/components/base/basicFunctionality.cpp
-
5lib/components/base/basicFunctionality.h
-
2lib/data/media/video/videoAVLIBSource.cpp
-
5lib/rgoose/rgooseTypes.h
@ -1,27 +1,51 @@ |
|||
#include "kernelEventFilter.h"
|
|||
|
|||
kernelEventFilter::kernelEventFilter( uint32_t id, TARGET_FILTER_TYPE type ){ |
|||
m_nDBID = id; |
|||
//m_pDBC = argusDBC::getInstance();
|
|||
#ifdef USE_MYSQL
|
|||
#include "MySQL_dataBinder.h"
|
|||
#else
|
|||
#include "SQLite_dataBinder.h"
|
|||
#endif
|
|||
|
|||
kernelEventFilter::kernelEventFilter( uint32_t id, TARGET_FILTER_TYPE type ){ |
|||
m_bActive = false; |
|||
m_bFilterType = type; |
|||
//if( m_pDBC != NULL ) {
|
|||
//DBC_NODE_DATA *tData = NULL;
|
|||
//tData = m_pDBC->getNodeData( m_nDBID );
|
|||
//if( tData != NULL ) {
|
|||
// memcpy( &m_sNodeData , tData, sizeof(DBC_NODE_DATA));
|
|||
// free( tData );
|
|||
//} else {
|
|||
// memset( &m_sNodeData , 0, sizeof(DBC_NODE_DATA));
|
|||
// m_sNodeData.type = ARGUS_UNKNOWN;
|
|||
// m_sNodeData.node_id = id;
|
|||
//};
|
|||
//} else {
|
|||
//memset( &m_sNodeData , 0, sizeof(DBC_NODE_DATA));
|
|||
//m_sNodeData.type = ARGUS_UNKNOWN;
|
|||
//m_sNodeData.node_id = id;
|
|||
//};
|
|||
#ifdef USE_MYSQL
|
|||
m_pDBC = mysqlDBC::getInstance(); |
|||
#else
|
|||
m_pDBC = sqliteDBC::getInstance(); |
|||
#endif
|
|||
m_pEventHeap = basicEventHeap::getInstance(); |
|||
if( m_pDBC != NULL ) { |
|||
DBC_TARGET_FLITER_DATA *tData = NULL; |
|||
tData = m_pDBC->getTargetFilterData( id ); |
|||
if( tData != NULL ) { |
|||
memcpy( &m_sFilterData , tData, sizeof(DBC_TARGET_FLITER_DATA)); |
|||
free( tData ); |
|||
} else { |
|||
memset( &m_sFilterData , 0, sizeof(DBC_TARGET_FLITER_DATA)); |
|||
m_sFilterData.type = type; |
|||
m_sFilterData.id = id; |
|||
}; |
|||
} else { |
|||
memset( &m_sFilterData , 0, sizeof(DBC_TARGET_FLITER_DATA)); |
|||
m_sFilterData.type = type; |
|||
m_sFilterData.id = id; |
|||
}; |
|||
}; |
|||
|
|||
kernelEventFilter::~kernelEventFilter(){ |
|||
}; |
|||
|
|||
void kernelEventFilter::createFilterEvent( basicEventTypeID typ, CSTR msg ){ |
|||
if ( m_pEventHeap!= NULL ) { |
|||
EVENT_CONTAINER *tEvt = NULL; |
|||
switch ( m_sFilterData.type ) { |
|||
case TF_LA_METRO_TRAIN_FILTER:{ |
|||
tEvt = createBasicEvent( m_sFilterData.id, EVT_CLASS_KRNL_FILTER_LATF, typ, NULL, msg ); |
|||
break; |
|||
}; |
|||
}; |
|||
if( tEvt ){ |
|||
m_pEventHeap->broadcast( tEvt ); |
|||
}; |
|||
}; |
|||
}; |
|||
@ -1,31 +1,29 @@ |
|||
#ifndef __KERNEL_EVENT_FILTER_HEADER__ |
|||
#define __KERNEL_EVENT_FILTER_HEADER__ |
|||
|
|||
#include "../../components/base/basicEvent.h" |
|||
//#include "../../components/base/basicEvent.h" |
|||
#include "../../components/base/basicEventHeap.h" |
|||
#include "../../components/base/basicPosition.h" |
|||
#include "dataBinder.h" |
|||
|
|||
typedef enum E_TARGET_FILTER_TYPE{ |
|||
TF_UDEFINED_FILTER = 0, |
|||
TF_AUTHORISED_PEOPLE_FILTER = 1, |
|||
TF_LA_METRO_TRAIN_FILTER = 2 |
|||
}TARGET_FILTER_TYPE; |
|||
|
|||
class kernelEventFilter{ |
|||
protected: |
|||
uint32_t m_nDBID; |
|||
uint8_t m_bFilterType; |
|||
bool m_bActive; |
|||
DBC_TARGET_FLITER_DATA m_sFilterData; |
|||
dataBinder * m_pDBC; |
|||
basicEventHeap * m_pEventHeap; |
|||
bool m_bActive; |
|||
void createFilterEvent( basicEventTypeID typ, CSTR msg = NULL ); |
|||
public: |
|||
explicit kernelEventFilter( uint32_t id, TARGET_FILTER_TYPE type = TF_UDEFINED_FILTER ); |
|||
virtual ~kernelEventFilter(); |
|||
virtual bool validateTarget( uint32_t DevID, TARGET_DATA *ptr ){ return true; }; |
|||
virtual bool initFilter(){ return true; }; |
|||
virtual bool stopFilter(){ return true; }; |
|||
uint32_t getID(){ return m_nDBID; }; |
|||
uint8_t getType(){ return m_bFilterType; }; |
|||
uint32_t getID(){ return m_sFilterData.id; }; |
|||
uint8_t getType(){ return m_sFilterData.type; }; |
|||
bool pause(); |
|||
bool resume(); |
|||
bool isActive(){ return m_bActive; }; |
|||
}; |
|||
|
|||
typedef vector<kernelEventFilter *> vectorKernelEventFilters; |
|||
|
|||
@ -0,0 +1,198 @@ |
|||
#include "kernelEventFilterTrain.h"
|
|||
#include "../../components/base/basicFunctionality.h"
|
|||
|
|||
#define LOG( X ) m_pLog->Log( "TTF", this, X )
|
|||
#ifdef DEBUG
|
|||
#define LOG_ERROR( X ) {\
|
|||
char _tBfrErrMSG2w34[256];\ |
|||
sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ |
|||
m_pLog->Log( "TTF", this, _LOG_ERROR, _tBfrErrMSG2w34 );\ |
|||
} |
|||
#else
|
|||
#define LOG_ERROR( X ) m_pLog->Log( "TTF", this, _LOG_ERROR, X );
|
|||
#endif
|
|||
|
|||
|
|||
kernelEventFilterTrain::kernelEventFilterTrain( uint32_t id ): kernelEventFilter( id, TF_LA_METRO_TRAIN_FILTER ){ |
|||
m_pLog = basicLogCollection::getInstance(); |
|||
memset( &m_sTrainFilterData, 0, sizeof(TRAIN_FILTER_DATA)); |
|||
}; |
|||
|
|||
kernelEventFilterTrain::~kernelEventFilterTrain(){ |
|||
|
|||
}; |
|||
|
|||
bool kernelEventFilterTrain::validateTarget( uint32_t DevID, TARGET_DATA *ptr ){ |
|||
if( m_bActive && ( ptr != NULL ) ){ |
|||
if( m_sTrainFilterData.bDebugMode ){ |
|||
createFilterEvent( EVT_FLT_LATF_CHK ); |
|||
char tmpC[CTEXT]; |
|||
// Mark Event Message
|
|||
sprintf( tmpC, "A:%0.3f R:%0.3f W:%d", ptr->local_target.fi, ptr->local_target.r, ptr->area ); |
|||
LOG( tmpC ); |
|||
}; |
|||
// Validate Zones and statuses (EXP)
|
|||
uint64_t cts = getMilliseconds(); |
|||
//Upper Sensor Zone
|
|||
if( m_sUpperZone.TrainOnTheField ){ |
|||
if( ( cts - m_sUpperZone.ts ) > m_sTrainFilterData.nDecisionTime ){ |
|||
// Clear Expired Suspicious
|
|||
m_sUpperZone.TrainOnTheField = false; |
|||
m_sUpperZone.startAngle = 0; |
|||
m_sUpperZone.endAngle = 0; |
|||
}; |
|||
}; |
|||
if( m_sUpperZone.SuspiciousUnconfirmed ){ |
|||
if( ( cts - m_sUpperZone.ts ) > ( m_sTrainFilterData.nSuspectTime << 1 ) ){ |
|||
m_sUpperZone.SuspiciousUnconfirmed = false; |
|||
}; |
|||
}; |
|||
if( m_sUpperZone.SuspiciousObject ){ |
|||
if( ( cts - m_sUpperZone.ts ) > m_sTrainFilterData.nSuspectTime ){ |
|||
m_sUpperZone.SuspiciousObject = false; |
|||
if( !m_sUpperZone.TrainOnTheField ) m_sUpperZone.SuspiciousUnconfirmed = true; |
|||
}; |
|||
}; |
|||
//Bottom Sensor Zone
|
|||
if( m_sBottomZone.TrainOnTheField ){ |
|||
if( ( cts - m_sBottomZone.ts ) > m_sTrainFilterData.nDecisionTime ){ |
|||
// Clear Expired Suspicious
|
|||
m_sBottomZone.TrainOnTheField = false; |
|||
m_sBottomZone.startAngle = 0; |
|||
m_sBottomZone.endAngle = 0; |
|||
}; |
|||
}; |
|||
if( m_sBottomZone.SuspiciousUnconfirmed ){ |
|||
if( ( cts - m_sBottomZone.ts ) > ( m_sTrainFilterData.nSuspectTime << 1 ) ){ |
|||
m_sBottomZone.SuspiciousUnconfirmed = false; |
|||
}; |
|||
}; |
|||
if( m_sBottomZone.SuspiciousObject ){ |
|||
if( ( cts - m_sBottomZone.ts ) > m_sTrainFilterData.nSuspectTime ){ |
|||
m_sBottomZone.SuspiciousObject = false; |
|||
if( !m_sBottomZone.TrainOnTheField ) m_sBottomZone.SuspiciousUnconfirmed = true; |
|||
}; |
|||
}; |
|||
|
|||
// Check Current Target
|
|||
float tAngleWidth; |
|||
if( ptr->digital > 0 ) { |
|||
tAngleWidth = ( 360.0f * ( ptr->area / (float)ptr->digital) ) / 12000.0f; |
|||
} else { |
|||
tAngleWidth = ( 360.0f * ptr->area ) / 12000.0f; |
|||
}; |
|||
|
|||
if( DevID == m_sTrainFilterData.nUpperSensorID ){ //If Upper Sensor
|
|||
// Train is detected;
|
|||
if( m_sUpperZone.TrainOnTheField ){ |
|||
// Already was Train Detection
|
|||
m_sUpperZone.ts = cts; // Update TS
|
|||
if( ( ptr->local_target.fi - tAngleWidth ) < m_sUpperZone.startAngle ) m_sUpperZone.startAngle = ptr->local_target.fi - tAngleWidth; |
|||
if( ( ptr->local_target.fi + tAngleWidth ) > m_sUpperZone.endAngle ) m_sUpperZone.endAngle = ptr->local_target.fi + tAngleWidth; |
|||
if( m_sTrainFilterData.bDebugMode ){ |
|||
//Train Position Update Event
|
|||
createFilterEvent( EVT_FLT_LATF_TRP_UPDT ); |
|||
// Proceed Event as normal
|
|||
return false; |
|||
}; |
|||
// Block Event
|
|||
return true; |
|||
} else { |
|||
// Newly Detected Train
|
|||
m_sUpperZone.TrainOnTheField = true; |
|||
// Clear Suspicies - Train Detected!
|
|||
m_sUpperZone.SuspiciousObject = false; |
|||
m_sUpperZone.SuspiciousUnconfirmed = false; |
|||
m_sUpperZone.ts = cts; |
|||
m_sUpperZone.startAngle = ptr->local_target.fi - tAngleWidth; |
|||
m_sUpperZone.endAngle = ptr->local_target.fi + tAngleWidth; |
|||
if( m_sTrainFilterData.bDetectTrain || m_sTrainFilterData.bDebugMode ){ |
|||
//Train Detection Event
|
|||
createFilterEvent( EVT_FLT_LATF_TRP_DET ); |
|||
// Proceed Event as normal
|
|||
return false; |
|||
}; |
|||
// Block Event
|
|||
return true; |
|||
}; |
|||
} else { |
|||
// check pedestrians detection as Train
|
|||
if( m_sBottomZone.SuspiciousObject == false ){ |
|||
// No Train is detected by Upper Sensor Yet
|
|||
if( m_sBottomZone.TrainOnTheField == false ){ |
|||
// If the object is suspicious
|
|||
if( m_sBottomZone.SuspiciousUnconfirmed == false ){ |
|||
// Check New Suspicious
|
|||
if( ptr->area > m_sTrainFilterData.nTrainWidth ){ |
|||
m_sBottomZone.SuspiciousObject = true; |
|||
m_sBottomZone.ts = cts; |
|||
if( m_sTrainFilterData.bDebugMode ){ |
|||
// Suspisious Detection
|
|||
createFilterEvent( EVT_FLT_LATF_SUSP_START ); |
|||
// Proceed Event as normal
|
|||
return false; |
|||
}; |
|||
return true; |
|||
}; |
|||
// Regular Target
|
|||
if( m_sTrainFilterData.bDebugMode ){ |
|||
createFilterEvent( EVT_FLT_LATF_REGULAR ); |
|||
}; |
|||
} else { |
|||
// Unconfirmed Suspicious
|
|||
if( m_sTrainFilterData.bDebugMode ){ |
|||
createFilterEvent( EVT_FLT_LATF_SUSP_NAK ); |
|||
}; |
|||
}; |
|||
} else { |
|||
// Disable Targets while Train is present
|
|||
|
|||
// Detect Targets from others than train angles
|
|||
//if( m_bTrackTrainDetection ){
|
|||
// if( ( event.target.dAngle < ( m_sGroupZone[cGID].startAngle - tAngleWidth ) )
|
|||
// ||
|
|||
// ( event.target.dAngle > ( m_sGroupZone[cGID].endAngle + tAngleWidth ) ) ) {
|
|||
// EVT_FLT_LATF_DIFF_DET
|
|||
// return false;
|
|||
// };
|
|||
//};
|
|||
|
|||
if( m_sTrainFilterData.bDebugMode ){ |
|||
createFilterEvent( EVT_FLT_LATF_DISABLED ); |
|||
}; |
|||
return true; |
|||
}; |
|||
} else { |
|||
// Suspicious Mode Target
|
|||
if( m_sTrainFilterData.bDebugMode ){ |
|||
createFilterEvent( EVT_FLT_LATF_SUSP_DET ); |
|||
return false; |
|||
}; |
|||
return true; |
|||
}; |
|||
}; |
|||
}; |
|||
return false; |
|||
}; |
|||
|
|||
bool kernelEventFilterTrain::initFilter(){ |
|||
m_bActive = false; |
|||
if( m_pDBC != NULL ){ |
|||
if( m_sFilterData.aux_id != 0 ){ |
|||
TRAIN_FILTER_DATA *tData = m_pDBC->getTrainFilterData( m_sFilterData.aux_id ); |
|||
if( tData != NULL ){ |
|||
memcpy( &m_sTrainFilterData, tData, sizeof( TRAIN_FILTER_DATA )); |
|||
free( tData ); |
|||
if( m_sTrainFilterData.nUpperSensorID && m_sTrainFilterData.nBottomSensorID ) { |
|||
m_bActive = true; |
|||
}; |
|||
}; |
|||
}; |
|||
}; |
|||
return m_bActive; |
|||
}; |
|||
|
|||
bool kernelEventFilterTrain::stopFilter(){ |
|||
m_bActive = false; |
|||
return true; |
|||
}; |
|||
@ -0,0 +1,34 @@ |
|||
#ifndef __KERNEL_EVENT_FILTER_TRAIN__ |
|||
#define __KERNEL_EVENT_FILTER_TRAIN__ |
|||
|
|||
#include "kernelEventFilter.h" |
|||
|
|||
typedef std::vector<TARGET_DATA *> groupArray; |
|||
|
|||
typedef struct S_EFT_ZONE { |
|||
bool TrainOnTheField; |
|||
bool SuspiciousObject; |
|||
bool SuspiciousUnconfirmed; |
|||
uint64_t ts; |
|||
float startAngle; |
|||
float endAngle; |
|||
} EFT_ZONE; |
|||
|
|||
|
|||
class kernelEventFilterTrain: public kernelEventFilter{ |
|||
private: |
|||
basicLogCollection * m_pLog; |
|||
TRAIN_FILTER_DATA m_sTrainFilterData; |
|||
EFT_ZONE m_sUpperZone; |
|||
EFT_ZONE m_sBottomZone; |
|||
groupArray m_aUpperFIFO; |
|||
groupArray m_aBottomFIFO; |
|||
public: |
|||
explicit kernelEventFilterTrain( uint32_t id ); |
|||
virtual ~kernelEventFilterTrain(); |
|||
virtual bool validateTarget( uint32_t DevID, TARGET_DATA *ptr ); |
|||
virtual bool initFilter(); |
|||
virtual bool stopFilter(); |
|||
}; |
|||
|
|||
#endif |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue