You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

912 lines
31 KiB

/*******************************************************************
*
* DESCRIPTION: ARGUS Kernel source
*
* AUTHOR: gagua
*
* HISTORY:
*
* DATE:5/29/2019
*
*******************************************************************/
#include "rgooseKernel.h"
#include "rgooseFilterAPF.h"
#include <sys/types.h>
#define LOG( X ) m_pLog->Log( "KRNL", 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( "KRNL", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
}
#else
#define LOG_ERROR( X ) m_pLog->Log( "KRNL", this, _LOG_ERROR, X );
#endif
argusKernel *argusKernel::_instance = NULL;
/**
* Returns the single instance of the object.
*/
argusKernel* argusKernel::getInstance( config_setting_t *Settings ) {
// check if the instance has been created yet
if( 0 == _instance ){
// if not, then create it
_instance = new argusKernel( Settings );
};
// return the single instance
return _instance;
};
argusKernel::argusKernel( config_setting_t *Settings ):basicThread(), basicEventHandler(){
m_bExitCause = 0;
m_nServerID = 0;
m_nSiteID = 0;
m_pDBC = NULL;
m_tTimeTSeconds = time( NULL );
m_pLog = basicLogCollection::getInstance();
m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "KERNEL" );
//m_pServiceAnnouncer = NULL;
m_pEventHeap = NULL;
//m_pOnvifMediaObserver = NULL;
m_pNodeFactory = NULL;
m_pModuleFactory = NULL;
#ifdef SIMULATE_KERNEL_TARGETS
sprintf( m_cCurrentMission,"" );
m_bLandingTO = 0;
m_bJamingTO = 0;
#endif
};
argusKernel::~argusKernel(){
#ifdef DEBUG
LOG("Destructor");
#endif
WaitFinish(true);
unloadFilters();
if( m_pDBC != NULL ) m_pDBC->unregisterServer( m_nSiteID, m_nServerNodeID );
#ifdef DEBUG
LOG("Deleting Components");
#endif
LOG(" Module Factory...");
if( m_pModuleFactory != NULL ) delete( m_pModuleFactory );
LOG(" Node Factory...");
if( m_pNodeFactory != NULL ) delete( m_pNodeFactory );
//LOG(" Onvif Observer...");
//if( m_pOnvifMediaObserver != NULL ) delete( m_pOnvifMediaObserver );
//LOG(" Stream Manager...");
//if( m_pStreamManager != NULL ) delete( m_pStreamManager );
//LOG(" SSDP Service Announcer...");
//if( m_pServiceAnnouncer !=NULL ) delete( m_pServiceAnnouncer );
LOG(" DataBase Connection...");
if( m_pDBC != NULL ) delete( m_pDBC );
m_pDBC = NULL;
_instance = NULL;
#ifdef DEBUG
LOG("Destructor Finished");
#endif
};
bool argusKernel::create( void ){
char tBuffer[256];
if( m_pSettings != NULL ) {
config_setting_t * pSetting;
int tVal;
const char * tBuf;
//Connect( CSTR DBName, CSTR DBHost, CSTR DBUser, CSTR DBPassword, uint16_t Port = 3300 );
LOG("Getting Settings ...");
if( !config_setting_lookup_string( m_pSettings, ARGUS_KERNEL_TAG_SERVER_IDENTITY, &tBuf ) ){
char * tVar;
char * tTS;
tTS = getTStr(NULL);
tVar = MD5String(tTS);
free(tTS);
sprintf( m_sIdentity, tVar );
pSetting = config_setting_add( m_pSettings, ARGUS_KERNEL_TAG_SERVER_IDENTITY, CONFIG_TYPE_STRING );
config_setting_set_string( pSetting, tVar );
free( tVar );
basicSettingsProvider::getInstance()->compromise();
LOG("Server Identity not defined - generating new!");
} else {
sprintf( m_sIdentity, tBuf );
sprintf( tBuffer, "Server Identity Read From Settings: %s", tBuf );
LOG( tBuffer );
};
if( !config_setting_lookup_int( m_pSettings, ARGUS_KERNEL_TAG_SITE_ID, &tVal ) ){
tVal = m_nSiteID = 1;
pSetting = config_setting_add( m_pSettings, ARGUS_KERNEL_TAG_SITE_ID, CONFIG_TYPE_INT );
config_setting_set_int( pSetting, tVal );
basicSettingsProvider::getInstance()->compromise();
LOG("Site ID not defined - using [1] as number!");
} else {
m_nSiteID = tVal;
sprintf( tBuffer, "Site ID Read From Settings: %d", m_nSiteID );
LOG( tBuffer );
};
} else {
LOG_ERROR("Failed Read Config Settings!");
return false;
};
if( m_pDBC == NULL ) {
LOG("Explicitly Create DBC Object");
m_pDBC = argusDBC::getInstance( m_pSettings );
};
if( m_pDBC == NULL ){
LOG_ERROR("DBC Object Creation Failure!");
return false;
} else LOG("DBC Object is OK");
if(!m_pDBC->connect()){
LOG_ERROR("DBC Connection Failure!");
SLEEP(5000);
//ToDO: Set Restart Kernel!
return false;
};
#ifdef DEBUG
LOG( "Settings Read Done" );
#endif
m_pDBC->registerServer( m_nSiteID, m_sIdentity );
m_nServerID = m_pDBC->getServerID( m_sIdentity );
m_nServerNodeID = m_pDBC->getServerNode( m_nServerID );
DBC_SITE_DATA *tSiteData = m_pDBC->getSiteData( m_nSiteID );
if( tSiteData ) {
C3D_WGS84_LOC t;
t.lat = tSiteData->lat;
t.lon = tSiteData->lon;
t.alt = tSiteData->alt;
m_pSystemAnchor = systemAnchor::getInstance( tSiteData->SH, &t );
free( tSiteData );
} else {
LOG_ERROR("Error Loading Site DATA!");
};
//Init Subcomponents
m_pHardwareManager = argusHardwareManager::getInstance();
if( m_pHardwareManager!= NULL ) {
m_pHardwareManager->validate();
} else {
LOG_ERROR("Failure to get HardwareManager Instance!");
return false;
};
//m_pServiceAnnouncer = new ssdpAnnouncer( m_pSettings );
if( basicSettingsProvider::getInstance()->isCompromised() ) {
basicSettingsProvider::getInstance()->validate();
};
m_pEventHeap = basicEventHeap::getInstance();
//m_pOnvifMediaObserver = onvifMediaObserver::getInstance();
m_pNodeFactory = argusNodeFactory::getInstance();
m_pModuleFactory = argusModuleFactory::getInstance();
//enumerateHardware();
loadFilters();
//m_pNodeFactory->setDBC( m_pDBC );
m_pNodeFactory->loadNodes( m_nSiteID );
//m_pModuleFactory->setDBC( m_pDBC ); //m_pDBC->getIPCamRecords( m_vCamRecords );
m_pModuleFactory->loadModules( m_nServerID );
#ifdef DEBUG
//LOG( "Start SSDP Beacon" );
#endif
//if( m_pServiceAnnouncer != NULL ) {
// if( !m_pServiceAnnouncer->init() ){
// delete(m_pServiceAnnouncer);
// m_pServiceAnnouncer = NULL;
// };
//};
//m_pStreamManager = NULL;//mediaNginxManager::getInstance();
//if( m_pStreamManager != NULL ) {
// m_pStreamManager->attachStream("rtsp://gagua:4GetMyID@192.168.0.104:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1", true, 12, "12918" );
//};
/*
#ifdef DEBUG
LOG("Init IP Cameras");
#endif
if( m_vCamRecords.size() ) {
ARGUS_Camera *tPtr = NULL;
for( int i=0; i < m_vCamRecords.size(); i++ ) {
tPtr = new ARGUS_Camera();
if( tPtr != NULL ) {
if( tPtr->create( m_vCamRecords.at(i)->ip, m_vCamRecords.at(i)->username, m_vCamRecords.at(i)->password ) ){
#ifdef DEBUG
LOG("Camera Created!");
#endif
m_vCameras.push_back( tPtr );
tPtr = NULL;
} else {
LOG_ERROR("Camera Creation Failure!");
delete( tPtr );
tPtr = NULL;
};
};
};
};
*/
/*
#ifdef DEBUG
LOG("Start OnVIF Discovery");
#endif
if( m_pOnvifMediaObserver!= NULL ) {
m_pOnvifMediaObserver->startDiscovery();
m_bDiscoveryStarted = true;
};
*/
#ifdef DEBUG
LOG( "Kernel Trhead is about to be Created" );
#endif
if( init() == false ){
LOG_ERROR("Error in starting Kernel Thread!");
return false;
};
#ifdef DEBUG
LOG( "Kernel Thread Created" );
#endif
/*
m_pServletWS = new servletWS();
if( m_pServletWS != NULL ) {
LOG("ServletWS Created");
if(m_pServletWS->create(8080)){
LOG("ServletWS Started");
//if( ! m_pServletWS->attachChannel("rtsp://gagua:4GetMyID@192.168.0.109:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1", false ) ){
// LOG("Error Adding Channel!");
//} else {
// LOG("Channel Attached");
//};
};
};
*/
#ifdef DEBUG
sprintf( tBuffer, "Server is registered as id[%d]", m_nServerID );
LOG( tBuffer );
#endif
return true;
};
void argusKernel::loadFilters(){
if( m_pDBC == NULL ) return;
DBC_INT_LIST *tList = m_pDBC->listFilters( m_nSiteID, m_nServerID );
if( tList != NULL ) {
if( tList->size() > 0 ) {
for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ) {
DBC_TARGET_FLITER_DATA *tData = NULL;
tData = m_pDBC->getTargetFilterData( (*idx) );
if( tData != NULL ) {
switch( tData->type ) {
case TF_AUTHORISED_PEOPLE_FILTER: {
ARGUS_APF *tFilter = new ARGUS_APF( tData->aux_id );
if( tFilter != NULL ) {
if( tFilter->initFilter() ){
m_vTargetFilters.push_back( (ARGUS_TARGET_FILTER*) tFilter );
} else {
delete( tFilter );
};
};
break;
};
};
};
};
tList->clear();
};
delete( tList );
};
};
void argusKernel::unloadFilters(){
if( m_vTargetFilters.size() > 0 ) {
for( V_TARGET_FILTERS::iterator idx = m_vTargetFilters.begin(); idx < m_vTargetFilters.end(); idx++ ){
switch( (*idx)->getType() ) {
case TF_AUTHORISED_PEOPLE_FILTER:{
delete( (ARGUS_APF*)(*idx) );
break;
};
};
};
};
};
ARGUS_TARGET_FILTER *argusKernel::getFilter( uint32_t id ){
ARGUS_TARGET_FILTER *RetVal = NULL;
if( m_vTargetFilters.size() > 0 ) {
for( V_TARGET_FILTERS::iterator idx = m_vTargetFilters.begin(); idx < m_vTargetFilters.end(); idx++ ){
if( (*idx)->getID() == id ) {
RetVal = (*idx);
break;
};
};
};
return RetVal;
};
void argusKernel::WaitFinish( bool Force ){
if( Force ){
#ifdef DEBUG
LOG( "Thread End Forced" );
#endif
} else {
// 3 seconds sleep to settle down processes
SLEEP(3000);
};
waitThreadEnd( Force );
#ifdef DEBUG
LOG( "Thread is Detached" );
#endif
};
/* Main Kernel Thread Procedure */
void argusKernel::m_fThreadProc( void ){
char Buffer[CTEXT];
time_t tTimeTSeconds;
int lastTSS = 0;
int lastTMS = 0;
DBC_EVT_DATA * tEvtPtr;
pid_t pid = gettid();
char pidBuf[16];
sprintf(pidBuf,"KERNEL pid:%d", pid);
LOG( pidBuf );
#ifdef SIMULATE_KERNEL_TARGETS
LOG("SIMULATION ENABLED");
#endif
m_bThreadStatus = TH_WORKING;
while( m_bThreadStatus < TH_ENDED ){
m_tTimeTSeconds = time( NULL );
// Network IP OnVif Discovery
/*
if( m_pOnvifMediaObserver!= NULL ){
if( !m_bDiscoveryStarted ) {
if((m_tTimeTSeconds%ONVIF_DISCOVERY_INTERVAL)==0){
#ifdef DEBUG
LOG("Start OnVIF Discovery");
#endif
m_pOnvifMediaObserver->startDiscovery();
m_bDiscoveryStarted = true;
};
} else {
//*
if((m_tTimeTSeconds%ONVIF_DISCOVERY_INTERVAL)==ONVIF_DISCOVERY_RESULT_TIME){
#ifdef DEBUG
LOG("Validate IP Cameras");
#endif
validateCameras();
m_bDiscoveryStarted = false;
};
//* /
};
};
//*/
//*
// Web CTRL Event Processing Loop
// if( !m_pDBC->getLastEvents( m_vEvtRecords, lastTSS, lastTMS ) ){
// // Error In DB Access
// m_bThreadStatus = TH_ENDED;
// m_bExitCause = 1;
// continue;
// };
//*/
if( m_tTimeTSeconds != tTimeTSeconds ){ // Each Second Process
tTimeTSeconds = m_tTimeTSeconds;
DBC_KRNL_CMD *tCMD;
tCMD = m_pDBC->getActiveCommand( m_nSiteID );
if( tCMD != NULL ){
switch( tCMD->cmd ) {
case ARGUS_CMD_KRNL_RELOAD:{
LOG("Reload ARGUS SERVER!");
m_bThreadStatus = TH_ENDED;
m_bExitCause = 1;
m_pDBC->updateCommand( tCMD->id, ARGUS_CMD_STATUS_FINISHED );
break;
};
case ARGUS_CMD_NODES_RELOAD:{
if( m_pNodeFactory != NULL ) {
m_pNodeFactory->reloadNodes( m_nSiteID );
};
m_pDBC->updateCommand( tCMD->id, ARGUS_CMD_STATUS_FINISHED );
break;
};
case ARGUS_CMD_NODE_RELOAD:{
uint32_t tNodeID = atoi( tCMD->param );
if( m_pNodeFactory != NULL ) {
m_pNodeFactory->reloadNode( tNodeID );
};
m_pDBC->updateCommand( tCMD->id, ARGUS_CMD_STATUS_FINISHED );
break;
};
};
free( tCMD );
};
if( m_pModuleFactory != NULL ) {
m_pModuleFactory->validate();
};
if( m_pNodeFactory != NULL ) {
m_pNodeFactory->validate();
};
};
// if( m_vEvtRecords.size() > 0 ){
// validateEvents( lastTSS, lastTMS );
// // SLEEP( 2 ); // short loop if had an events
// } else
SLEEP( SLEEP_KERNEL_INTERVAL );
#ifdef SIMULATE_KERNEL_TARGETS
/*
// Simulate FlyHunter
if( m_tTimeTSeconds!= m_nEachSec ) {
m_nEachSec = m_tTimeTSeconds;
if( m_bLandingTO ) {
m_bLandingTO--;
if( m_bLandingTO == 1 ) {
//Landing
LOG("Simulate Landing");
LOG( m_cCurrentMission );
//Simulate FH Module Event;
EVENT_CONTAINER *ttt;
FH_MISSION_DATA * nnn = (FH_MISSION_DATA *) malloc( sizeof(FH_MISSION_DATA));
if( nnn ){
nnn->location.lat = 0;
nnn->location.lon = 0;
nnn->location.alt = 0;
sprintf( nnn->missionID, m_cCurrentMission );
ttt = createBasicEvent( 0, EVT_CLASS_FLY_HUNTER, EVT_FH_LANDED, NULL, NULL, nnn );
if( ttt ) {
m_pEventHeap->broadcast( ttt );
} else {
free( nnn );
};
};
};
};
if( m_bJamingTO ) {
m_bJamingTO--;
if( m_bJamingTO == 1 ) {
//Jaming Off
//Simulate FH Module Event;
EVENT_CONTAINER *ttt;
FH_MISSION_DATA * nnn = (FH_MISSION_DATA *) malloc( sizeof(FH_MISSION_DATA));
if( nnn ){
nnn->location.lat = 0;
nnn->location.lon = 0;
nnn->location.alt = 0;
sprintf( nnn->missionID, m_cCurrentMission );
ttt = createBasicEvent( 0, EVT_CLASS_FLY_HUNTER, EVT_FH_JAMER_OFF, NULL, NULL, nnn );
if( ttt ) {
m_pEventHeap->broadcast( ttt );
} else {
free( nnn );
};
};
};
};
};
*/
//Target Simulation To Test Events - Database
/*
if(( m_tTimeTSeconds%SIMULATE_KERNEL_INTERVAL)==(SIMULATE_KERNEL_3D_INTERVAL>>1)){
if( m_tTimeTSeconds!= m_nLastSimRun ){
m_nLastSimRun = m_tTimeTSeconds;
if( m_pNodeFactory != NULL ) {
argusNetNode *tNode = m_pNodeFactory->getNode( SIMULATE_KERNEL_3D_ID );
if( tNode!= NULL ) {
tNode->simulateTarget();
};
};
};
};
*/
if(( m_tTimeTSeconds%SIMULATE_KERNEL_PLS_INTERVAL)==(SIMULATE_KERNEL_PLS_INTERVAL>>1)){
if( m_tTimeTSeconds!= m_nLastSimRun ){
m_nLastSimRun = m_tTimeTSeconds;
if( m_pNodeFactory != NULL ) {
argusNetNode *tNode = m_pNodeFactory->getNode( SIMULATE_KERNEL_PLS_ID );
if( tNode!= NULL ) {
tNode->simulateTarget();
};
};
};
};
if(( m_tTimeTSeconds%SIMULATE_KERNEL_MND_INTERVAL)==(SIMULATE_KERNEL_MND_INTERVAL>>1)){
if( m_tTimeTSeconds!= m_nLastSimRun ){
m_nLastSimRun = m_tTimeTSeconds;
if( m_pNodeFactory != NULL ) {
argusNetNode *tNode = m_pNodeFactory->getNode( SIMULATE_KERNEL_MND_ID );
if( tNode!= NULL ) {
tNode->simulateTarget();
};
};
};
};
#endif
};
};
/*
int argusKernel::isCameraListed( CSTR uid ){
if( m_vCamRecords.size() ){
for( int index = 0; index < m_vCamRecords.size(); index++ ){
if(strstr(m_vCamRecords.at(index)->uuid,uid)!=NULL){
m_vCamRecords.at(index)->online = true;
return index;
};
};
} else {
LOG("No Registered Cameras!");
};
return -1;
};
void argusKernel::validateCameras( void ){
vectorWoWoResults *DiscoverResults = m_pOnvifMediaObserver->getResults();
if( DiscoverResults->size() > 0 ) {
for (int index = 0; index < DiscoverResults->size(); index++) {
char tBuffer[256];
sprintf( tBuffer,"Found Camwera [%s] %s", DiscoverResults->at(index)->XAddrs, DiscoverResults->at(index)->RefID );
LOG( tBuffer );
uint32_t cid = m_pDBC->getCamId( DiscoverResults->at(index)->RefID ); //isCameraListed( DiscoverResults->at(index)->RefID );
if( cid ) {
sprintf( tBuffer, "Camera is Listed as %d", cid );
LOG( tBuffer );
//if( strstr(DiscoverResults->at(index)->XAddrs,m_vCamRecords.at(cid)->ip)==NULL ) {
// LOG( DiscoverResults->at(index)->XAddrs );
m_pDBC->updateIPCam( m_nSiteID, cid, DiscoverResults->at(index)->XAddrs );// DiscoverResults->at(index));
//};
} else {
// Uncknown camera - no checking
LOG("Camera is Not Listed");
m_pDBC->addIPCam( m_nSiteID, DiscoverResults->at(index) );
};
};
} else {
LOG("No Online IP Cameras in Network");
};
};
void argusKernel::validateEvents( int &lastTSS, int &lastTMS ){
DBC_EVT_DATA *tPtr = NULL;
EVENT_CONTAINER *tEvt = NULL;
if(m_vEvtRecords.size()) {
lastTSS = m_vEvtRecords.at(m_vEvtRecords.size()-1)->ts_s;
lastTMS = m_vEvtRecords.at(m_vEvtRecords.size()-1)->ts_ms;
#ifndef ONE_EVENT_PER_LOOP
while( m_vEvtRecords.size() ){
#endif
tPtr = *m_vEvtRecords.begin();
if( tPtr != NULL ) {
if( tEvt != NULL ) {
m_pEventHeap->broadcast( tEvt );
};
free( tPtr );
};
m_vEvtRecords.erase( m_vEvtRecords.begin() );
#ifndef ONE_EVENT_PER_LOOP
};
#endif
};
};
*/
bool argusKernel::signalEvent( void ){
//if( m_pDBC->getLastEvents( m_vEvtRecords, 0,0 ) ){
//};
return true;
};
int argusKernel::getNetNodes( ARGUS_NODE_TYPE type, argusNetNode **&RA ){
RA = NULL;
int cnt = 0;
if( m_pNodeFactory != NULL ){
cnt = m_pNodeFactory->getNodesCount( type );
if( cnt ) {
RA = (argusNetNode **) calloc( cnt, sizeof( argusNetNode * ) );
m_pNodeFactory->fetchNodes(type, RA );
};
};
return cnt;
};
argusNetNode *argusKernel::getNetNode( int id ){
if( m_pNodeFactory != NULL ){
return m_pNodeFactory->getNode( id );
};
return NULL;
};
int argusKernel::getModules( ARGUS_MODULE_TYPE type, argusKernelModule **&RA ){
RA = NULL;
int cnt = 0;
if( m_pModuleFactory != NULL ){
cnt = m_pModuleFactory->getModulesCount( type );
if( cnt ) {
RA = (argusKernelModule **) calloc( cnt, sizeof( argusKernelModule * ) );
m_pModuleFactory->fetchModules( type, RA );
};
};
return cnt;
};
argusKernelModule *argusKernel::getModule( int id ){
if( m_pModuleFactory != NULL ){
return m_pModuleFactory->getModule( id );
};
return NULL;
};
void argusKernel::dispatchEvent( EVENT_CONTAINER *Evt ){
// Register all events in Database;
//LOG( "New EVENT!!" );
if( m_pDBC == NULL ) return;
if( Evt == NULL ) return;
switch( Evt->m_eClass ) {
case EVT_CLASS_EXTERNAL_CMD:
switch( Evt->m_eType ){
case EVT_FH_JAMER_ON:{
uint32_t TS_A, TS_B;
TS_A = Evt->m_UMSTS / 1000;
TS_B = Evt->m_UMSTS % 1000;
#ifdef SIMULATE_KERNEL_TARGETS
m_bJamingTO = SIMULATE_JAMER_TO;
#endif
FH_CTRL_DATA * tData = (FH_CTRL_DATA *) Evt->m_pEvtData;
if( tData ) {
if( m_pDBC->addEvent(
0,
Evt->m_UUID,
TS_A,
TS_B,
EVT_FH_JAMER_ON,
0,
0,
0,
0,
0,
0,
0,
0,
0,
tData->evtUUID
) ){
//Simulate FH Module Event;
EVENT_CONTAINER *ttt;
FH_MISSION_DATA * nnn = (FH_MISSION_DATA *) malloc( sizeof(FH_MISSION_DATA));
if( nnn ){
nnn->location.lat = 0;
nnn->location.lon = 0;
nnn->location.alt = 0;
sprintf( nnn->missionID, tData->evtUUID );
ttt = createBasicEvent( 0, EVT_CLASS_FLY_HUNTER, EVT_FH_JAMER_ON, NULL, NULL, nnn );
if( ttt ) {
m_pEventHeap->broadcast( ttt );
} else {
free( nnn );
};
};
};
free(tData);
};
break;
};
case EVT_FH_MISSION_END:{
FH_CTRL_DATA * tData = (FH_CTRL_DATA *) Evt->m_pEvtData;
if( tData ) {
//DBC_EVT_DATA * tEVT = m_pDBC->getEventByUUID( tData->targetUUID );
if( 1 /*tEVT*/ ) {
uint32_t TS_A, TS_B;
TS_A = Evt->m_UMSTS / 1000;
TS_B = Evt->m_UMSTS % 1000;
if( m_pDBC->addEvent(
0,
Evt->m_UUID,
TS_A,
TS_B,
EVT_FH_LANDED ) ){
//Simulate FH Module Event;
EVENT_CONTAINER *ttt;
FH_MISSION_DATA * nnn = (FH_MISSION_DATA *) malloc( sizeof(FH_MISSION_DATA));
if( nnn ){
nnn->location.lat = 0;
nnn->location.lon = 0;
nnn->location.alt = 0;
sprintf( nnn->missionID, tData->evtUUID );
ttt = createBasicEvent( 0, EVT_CLASS_FLY_HUNTER, EVT_FH_LANDED, NULL, NULL, nnn );
if( ttt ) {
m_pEventHeap->broadcast( ttt );
} else {
free( nnn );
};
};
};
//free( tEVT );
} else {
LOG_ERROR("Linked Event Was Not Found!");
};
};
break;
}
case EVT_FH_MISSION_BEGIN:{
FH_CTRL_DATA * tData = (FH_CTRL_DATA *) Evt->m_pEvtData;
#ifdef SIMULATE_KERNEL_TARGETS
m_bLandingTO = SIMULATE_LANDING_TO;
#endif
if( tData ) {
#ifdef SIMULATE_KERNEL_TARGETS
sprintf( m_cCurrentMission, tData->evtUUID );
#endif
DBC_EVT_DATA * tEVT = m_pDBC->getEventByUUID( tData->targetUUID );
if( tEVT ) {
uint32_t TS_A, TS_B;
TS_A = Evt->m_UMSTS / 1000;
TS_B = Evt->m_UMSTS % 1000;
if( Evt->m_db_id = m_pDBC->addEvent(
0,
Evt->m_UUID,
TS_A,
TS_B,
EVT_FH_FLY_TO,
0,
0,
0,
0,
0,
tEVT->lat,
tEVT->lon,
tEVT->alt,
tEVT->id,
tEVT->uuid
) ){
//Simulate FH Module Event;
EVENT_CONTAINER *ttt;
FH_MISSION_DATA * nnn = (FH_MISSION_DATA *) malloc( sizeof(FH_MISSION_DATA));
if( nnn ){
nnn->location.lat = tEVT->lat;
nnn->location.lon = tEVT->lon;
nnn->location.alt = tEVT->alt;
sprintf( nnn->missionID, tData->evtUUID );
ttt = createBasicEvent( 0, EVT_CLASS_FLY_HUNTER, EVT_FH_MISSION_BEGIN, NULL, NULL, nnn );
if( ttt ) {
m_pEventHeap->broadcast( ttt );
} else {
free( nnn );
};
};
};
free( tEVT );
} else {
LOG_ERROR("Linked Event Was Not Found!");
};
};
break;
};
};
break;
case EVT_CLASS_SENSOR_CLD:
case EVT_CLASS_SENSOR_LGS:
case EVT_CLASS_SENSOR_LFS:
case EVT_CLASS_SENSOR_MND:
case EVT_CLASS_SENSOR_PLS_210:
case EVT_CLASS_SENSOR_PLS_360:
case EVT_CLASS_SENSOR_ALS:
case EVT_CLASS_SENSOR_3D:
case EVT_CLASS_SENSOR_ACC:
switch( Evt->m_eType ) {
case EVT_TARGET_1D:{
TARGET_DATA *tDATA =(TARGET_DATA *) Evt->m_pEvtData;
if( tDATA != NULL ) {
uint32_t TS_A, TS_B;
TS_A = Evt->m_UMSTS / 1000;
TS_B = Evt->m_UMSTS % 1000;
Evt->m_db_id = m_pDBC->addEvent(
Evt->m_nSourceUID,
Evt->m_UUID,
TS_A,
TS_B,
Evt->m_eType,
tDATA->digital,
0,
0,
tDATA->local_target.r,
tDATA->area,
tDATA->global_target.lat,
tDATA->global_target.lon,
tDATA->global_target.alt
);
};
break;
};
case EVT_TARGET_2D_BLACK:
case EVT_TARGET_2D_WHITE:{
TARGET_DATA *tDATA = (TARGET_DATA *)Evt->m_pEvtData;
if( tDATA != NULL ) {
uint32_t TS_A, TS_B;
TS_A = Evt->m_UMSTS / 1000;
TS_B = Evt->m_UMSTS % 1000;
Evt->m_db_id = m_pDBC->addEvent(
Evt->m_nSourceUID,
Evt->m_UUID,
TS_A,
TS_B,
Evt->m_eType,
tDATA->digital,
tDATA->local_target.tetta,
tDATA->local_target.fi,
tDATA->local_target.r,
tDATA->area,
tDATA->global_target.lat,
tDATA->global_target.lon,
tDATA->global_target.alt
);
};
break;
};
case EVT_TARGET_3D_BLACK:
case EVT_TARGET_3D_WHITE:{
TARGET_DATA *tDATA = (TARGET_DATA *) Evt->m_pEvtData;
if( tDATA != NULL ) {
uint32_t TS_A, TS_B;
TS_A = Evt->m_UMSTS / 1000;
TS_B = Evt->m_UMSTS % 1000;
Evt->m_db_id = m_pDBC->addEvent(
Evt->m_nSourceUID,
Evt->m_UUID,
TS_A,
TS_B,
Evt->m_eType,
tDATA->digital,
tDATA->local_target.tetta,
tDATA->local_target.fi,
tDATA->local_target.r,
tDATA->area,
tDATA->global_target.lat,
tDATA->global_target.lon,
tDATA->global_target.alt
);
};
break;
};
case EVT_FLIP:{
uint32_t TS_A, TS_B;
TS_A = Evt->m_UMSTS / 1000;
TS_B = Evt->m_UMSTS % 1000;
Evt->m_db_id = m_pDBC->addEvent( Evt->m_nSourceUID, Evt->m_UUID, TS_A, TS_B, Evt->m_eType);
break;
};
};
break;
case EVT_CLASS_VIDEO:{
switch( Evt->m_eType ) {
case EVT_CAPTURE_START:{
break;
};
};
break;
};
};
};
#undef LOG
#undef LOG_ERROR