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.

616 lines
19 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
6 years ago
​
​
​
​
​
​
​
6 years ago
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
  1. /*******************************************************************
  2. *
  3. * DESCRIPTION: ARGUS Kernel source
  4. *
  5. * AUTHOR: gagua
  6. *
  7. * HISTORY:
  8. *
  9. * DATE:5/29/2019
  10. *
  11. *******************************************************************/
  12. #include "rgooseKernel.h"
  13. #include <sys/types.h>
  14. #define LOG( X ) m_pLog->Log( "KRNL", this, X )
  15. #ifdef DEBUG
  16. #define LOG_ERROR( X ) {\
  17. char _tBfrErrMSG2w34[256];\
  18. sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
  19. m_pLog->Log( "KRNL", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
  20. }
  21. #else
  22. #define LOG_ERROR( X ) m_pLog->Log( "KRNL", this, _LOG_ERROR, X );
  23. #endif
  24. argusKernel *argusKernel::_instance = NULL;
  25. /**
  26. * Returns the single instance of the object.
  27. */
  28. argusKernel* argusKernel::getInstance( config_setting_t *Settings ) {
  29. // check if the instance has been created yet
  30. if( 0 == _instance ){
  31. // if not, then create it
  32. _instance = new argusKernel( Settings );
  33. };
  34. // return the single instance
  35. return _instance;
  36. };
  37. argusKernel::argusKernel( config_setting_t *Settings ):basicThread(), basicEventHandler(){
  38. m_bExitCause = 0;
  39. m_nServerID = 0;
  40. m_nSiteID = 0;
  41. m_pDBC = NULL;
  42. m_tTimeTSeconds = time( NULL );
  43. m_pLog = basicLogCollection::getInstance();
  44. m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "KERNEL" );
  45. m_pServiceAnnouncer = NULL;
  46. m_pEventHeap = NULL;
  47. m_pOnvifMediaObserver = NULL;
  48. m_pNodeFactory = NULL;
  49. m_pModuleFactory = NULL;
  50. };
  51. argusKernel::~argusKernel(){
  52. #ifdef DEBUG
  53. LOG("Destructor");
  54. #endif
  55. WaitFinish(true);
  56. if( m_pDBC != NULL ) m_pDBC->unregisterServer( m_nSiteID, m_nServerNodeID );
  57. #ifdef DEBUG
  58. LOG("Deleting Components");
  59. #endif
  60. if( m_pStreamManager != NULL ) delete( m_pStreamManager );
  61. //Last DBC
  62. if( m_pDBC != NULL ) delete( m_pDBC );
  63. #ifdef DEBUG
  64. LOG("Destructor Finished");
  65. #endif
  66. };
  67. bool argusKernel::create( void ){
  68. char tBuffer[256];
  69. if( m_pSettings != NULL ) {
  70. config_setting_t * pSetting;
  71. int tVal;
  72. const char * tBuf;
  73. //Connect( CSTR DBName, CSTR DBHost, CSTR DBUser, CSTR DBPassword, uint16_t Port = 3300 );
  74. LOG("Getting Settings ...");
  75. if( !config_setting_lookup_string( m_pSettings, ARGUS_KERNEL_TAG_SERVER_IDENTITY, &tBuf ) ){
  76. char * tVar;
  77. char * tTS;
  78. tTS = getTStr(NULL);
  79. tVar = MD5String(tTS);
  80. free(tTS);
  81. sprintf( m_sIdentity, tVar );
  82. pSetting = config_setting_add( m_pSettings, ARGUS_KERNEL_TAG_SERVER_IDENTITY, CONFIG_TYPE_STRING );
  83. config_setting_set_string( pSetting, tVar );
  84. free( tVar );
  85. basicSettingsProvider::getInstance()->compromise();
  86. LOG("Server Identity not defined - generating new!");
  87. } else {
  88. sprintf( m_sIdentity, tBuf );
  89. sprintf( tBuffer, "Server Identity Read From Settings: %s", tBuf );
  90. LOG( tBuffer );
  91. };
  92. if( !config_setting_lookup_int( m_pSettings, ARGUS_KERNEL_TAG_SITE_ID, &tVal ) ){
  93. tVal = m_nSiteID = 1;
  94. pSetting = config_setting_add( m_pSettings, ARGUS_KERNEL_TAG_SITE_ID, CONFIG_TYPE_INT );
  95. config_setting_set_int( pSetting, tVal );
  96. basicSettingsProvider::getInstance()->compromise();
  97. LOG("Site ID not defined - using [1] as number!");
  98. } else {
  99. m_nSiteID = tVal;
  100. sprintf( tBuffer, "Site ID Read From Settings: %d", m_nSiteID );
  101. LOG( tBuffer );
  102. };
  103. } else {
  104. LOG_ERROR("Failed Read Config Settings!");
  105. return false;
  106. };
  107. if( m_pDBC == NULL ) {
  108. LOG("Explicitly Create DBC Object");
  109. m_pDBC = argusDBC::getInstance( m_pSettings );
  110. };
  111. if( m_pDBC == NULL ){
  112. LOG_ERROR("DBC Object Creation Failure!");
  113. return false;
  114. };
  115. if(!m_pDBC->connect()){
  116. LOG_ERROR("DBC Connection Failure!");
  117. SLEEP(5000);
  118. //ToDO: Set Restart Kernel!
  119. return false;
  120. };
  121. #ifdef DEBUG
  122. LOG( "Settings Read Done" );
  123. #endif
  124. m_pDBC->registerServer( m_nSiteID, m_sIdentity );
  125. m_nServerID = m_pDBC->getServerID( m_sIdentity );
  126. m_nServerNodeID = m_pDBC->getServerNode( m_nServerID );
  127. DBC_SITE_DATA *tSiteData = m_pDBC->getSiteData( m_nSiteID );
  128. if( tSiteData ) {
  129. C3D_WGS84_LOC t;
  130. t.lat = tSiteData->lat;
  131. t.lon = tSiteData->lon;
  132. t.alt = tSiteData->alt;
  133. m_pSystemAnchor = systemAnchor::getInstance( tSiteData->SH, &t );
  134. free( tSiteData );
  135. } else {
  136. LOG_ERROR("Error Loading Site DATA!");
  137. };
  138. //Init Subcomponents
  139. m_pHardwareManager = argusHardwareManager::getInstance();
  140. if( m_pHardwareManager!= NULL ) {
  141. m_pHardwareManager->validate();
  142. } else {
  143. LOG_ERROR("Failure to get HardwareManager Instance!");
  144. return false;
  145. };
  146. m_pServiceAnnouncer = new ssdpAnnouncer( m_pSettings );
  147. if( basicSettingsProvider::getInstance()->isCompromised() ) {
  148. basicSettingsProvider::getInstance()->validate();
  149. };
  150. m_pEventHeap = basicEventHeap::getInstance();
  151. m_pOnvifMediaObserver = onvifMediaObserver::getInstance();
  152. m_pNodeFactory = argusNodeFactory::getInstance();
  153. m_pModuleFactory = argusModuleFactory::getInstance();
  154. //enumerateHardware();
  155. //m_pNodeFactory->setDBC( m_pDBC );
  156. m_pNodeFactory->loadNodes( m_nSiteID );
  157. //m_pModuleFactory->setDBC( m_pDBC ); //m_pDBC->getIPCamRecords( m_vCamRecords );
  158. m_pModuleFactory->loadModules( m_nSiteID );
  159. #ifdef DEBUG
  160. LOG( "Start SSDP Beacon" );
  161. #endif
  162. if( m_pServiceAnnouncer != NULL ) {
  163. if( !m_pServiceAnnouncer->init() ){
  164. delete(m_pServiceAnnouncer);
  165. m_pServiceAnnouncer = NULL;
  166. };
  167. };
  168. m_pStreamManager = NULL;//mediaNginxManager::getInstance();
  169. //if( m_pStreamManager != NULL ) {
  170. // m_pStreamManager->attachStream("rtsp://gagua:4GetMyID@192.168.0.104:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1", true, 12, "12918" );
  171. //};
  172. /*
  173. #ifdef DEBUG
  174. LOG("Init IP Cameras");
  175. #endif
  176. if( m_vCamRecords.size() ) {
  177. ARGUS_Camera *tPtr = NULL;
  178. for( int i=0; i < m_vCamRecords.size(); i++ ) {
  179. tPtr = new ARGUS_Camera();
  180. if( tPtr != NULL ) {
  181. if( tPtr->create( m_vCamRecords.at(i)->ip, m_vCamRecords.at(i)->username, m_vCamRecords.at(i)->password ) ){
  182. #ifdef DEBUG
  183. LOG("Camera Created!");
  184. #endif
  185. m_vCameras.push_back( tPtr );
  186. tPtr = NULL;
  187. } else {
  188. LOG_ERROR("Camera Creation Failure!");
  189. delete( tPtr );
  190. tPtr = NULL;
  191. };
  192. };
  193. };
  194. };
  195. */
  196. #ifdef DEBUG
  197. LOG("Start OnVIF Discovery");
  198. #endif
  199. if( m_pOnvifMediaObserver!= NULL ) {
  200. m_pOnvifMediaObserver->startDiscovery();
  201. m_bDiscoveryStarted = true;
  202. };
  203. #ifdef DEBUG
  204. LOG( "Kernel Trhead is about to be Created" );
  205. #endif
  206. if( init() == false ){
  207. LOG_ERROR("Error in starting Kernel Thread!");
  208. return false;
  209. };
  210. #ifdef DEBUG
  211. LOG( "Kernel Thread Created" );
  212. #endif
  213. /*
  214. m_pServletWS = new servletWS();
  215. if( m_pServletWS != NULL ) {
  216. LOG("ServletWS Created");
  217. if(m_pServletWS->create(8080)){
  218. LOG("ServletWS Started");
  219. //if( ! m_pServletWS->attachChannel("rtsp://gagua:4GetMyID@192.168.0.109:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1", false ) ){
  220. // LOG("Error Adding Channel!");
  221. //} else {
  222. // LOG("Channel Attached");
  223. //};
  224. };
  225. };
  226. */
  227. #ifdef DEBUG
  228. sprintf( tBuffer, "Server is registered as id[%d]", m_nServerID );
  229. LOG( tBuffer );
  230. #endif
  231. return true;
  232. };
  233. void argusKernel::WaitFinish( bool Force ){
  234. if( Force ){
  235. #ifdef DEBUG
  236. LOG( "Thread End Forced" );
  237. #endif
  238. } else {
  239. // 3 seconds sleep to settle down processes
  240. SLEEP(3000);
  241. };
  242. waitThreadEnd( Force );
  243. #ifdef DEBUG
  244. LOG( "Thread is Detached" );
  245. #endif
  246. };
  247. /* Main Kernel Thread Procedure */
  248. void argusKernel::m_fThreadProc( void ){
  249. char Buffer[CTEXT];
  250. time_t tTimeTSeconds;
  251. int lastTSS = 0;
  252. int lastTMS = 0;
  253. DBC_EVT_DATA * tEvtPtr;
  254. pid_t pid = gettid();
  255. char pidBuf[16];
  256. sprintf(pidBuf,"KERNEL pid:%d", pid);
  257. LOG( pidBuf );
  258. #ifdef SIMULATE_KERNEL_TARGETS
  259. LOG("SIMULATION ENABLED");
  260. #endif
  261. m_bThreadStatus = TH_WORKING;
  262. while( m_bThreadStatus < TH_ENDED ){
  263. m_tTimeTSeconds = time( NULL );
  264. // Network IP OnVif Discovery
  265. //*
  266. if( m_pOnvifMediaObserver!= NULL ){
  267. if( !m_bDiscoveryStarted ) {
  268. if((m_tTimeTSeconds%ONVIF_DISCOVERY_INTERVAL)==0){
  269. #ifdef DEBUG
  270. LOG("Start OnVIF Discovery");
  271. #endif
  272. m_pOnvifMediaObserver->startDiscovery();
  273. m_bDiscoveryStarted = true;
  274. };
  275. } else {
  276. //*
  277. if((m_tTimeTSeconds%ONVIF_DISCOVERY_INTERVAL)==ONVIF_DISCOVERY_RESULT_TIME){
  278. #ifdef DEBUG
  279. LOG("Validate IP Cameras");
  280. #endif
  281. validateCameras();
  282. m_bDiscoveryStarted = false;
  283. };
  284. //*/
  285. };
  286. };
  287. //*/
  288. //*
  289. // Web CTRL Event Processing Loop
  290. if( !m_pDBC->getLastEvents( m_vEvtRecords, lastTSS, lastTMS ) ){
  291. // Error In DB Access
  292. m_bThreadStatus = TH_ENDED;
  293. m_bExitCause = 1;
  294. continue;
  295. };
  296. //*/
  297. if( m_tTimeTSeconds != tTimeTSeconds ){ // Each Second Process
  298. tTimeTSeconds = m_tTimeTSeconds;
  299. if( m_pModuleFactory != NULL ) {
  300. m_pModuleFactory->validate();
  301. };
  302. if( m_pNodeFactory != NULL ) {
  303. m_pNodeFactory->validate();
  304. };
  305. };
  306. if( m_vEvtRecords.size() > 0 ){
  307. validateEvents( lastTSS, lastTMS );
  308. // SLEEP( 2 ); // short loop if had an events
  309. } else SLEEP( SLEEP_KERNEL_INTERVAL );
  310. #ifdef SIMULATE_KERNEL_TARGETS
  311. //Target Simulation To Test Events - Database
  312. if(( m_tTimeTSeconds%SIMULATE_KERNEL_INTERVAL)==(SIMULATE_KERNEL_INTERVAL>>1)){
  313. if( m_tTimeTSeconds!= m_nLastSimRun ){
  314. m_nLastSimRun = m_tTimeTSeconds;
  315. if( m_pNodeFactory != NULL ) {
  316. argusNetNode *tNode = m_pNodeFactory->getNode( SIMULATE_KERNEL_NODE_ID );
  317. if( tNode!= NULL ) {
  318. tNode->simulateTarget();
  319. };
  320. };
  321. };
  322. };
  323. #endif
  324. };
  325. };
  326. int argusKernel::isCameraListed( CSTR uid ){
  327. if( m_vCamRecords.size() ){
  328. for( int index = 0; index < m_vCamRecords.size(); index++ ){
  329. if(strstr(m_vCamRecords.at(index)->uuid,uid)!=NULL){
  330. m_vCamRecords.at(index)->online = true;
  331. return index;
  332. };
  333. };
  334. } else {
  335. LOG("No Registered Cameras!");
  336. };
  337. return -1;
  338. };
  339. void argusKernel::validateCameras( void ){
  340. vectorWoWoResults *DiscoverResults = m_pOnvifMediaObserver->getResults();
  341. if( DiscoverResults->size() > 0 ) {
  342. for (int index = 0; index < DiscoverResults->size(); index++) {
  343. char tBuffer[256];
  344. sprintf( tBuffer,"Found Camwera [%s] %s", DiscoverResults->at(index)->XAddrs, DiscoverResults->at(index)->RefID );
  345. LOG( tBuffer );
  346. uint32_t cid = m_pDBC->getCamId( DiscoverResults->at(index)->RefID ); //isCameraListed( DiscoverResults->at(index)->RefID );
  347. if( cid ) {
  348. sprintf( tBuffer, "Camera is Listed as %d", cid );
  349. LOG( tBuffer );
  350. //if( strstr(DiscoverResults->at(index)->XAddrs,m_vCamRecords.at(cid)->ip)==NULL ) {
  351. // LOG( DiscoverResults->at(index)->XAddrs );
  352. m_pDBC->updateIPCam( m_nSiteID, cid, DiscoverResults->at(index)->XAddrs );// DiscoverResults->at(index));
  353. //};
  354. } else {
  355. // Uncknown camera - no checking
  356. LOG("Camera is Not Listed");
  357. m_pDBC->addIPCam( m_nSiteID, DiscoverResults->at(index) );
  358. };
  359. };
  360. } else {
  361. LOG("No Online IP Cameras in Network");
  362. };
  363. };
  364. void argusKernel::validateEvents( int &lastTSS, int &lastTMS ){
  365. DBC_EVT_DATA *tPtr = NULL;
  366. EVENT_CONTAINER *tEvt = NULL;
  367. if(m_vEvtRecords.size()) {
  368. lastTSS = m_vEvtRecords.at(m_vEvtRecords.size()-1)->ts_s;
  369. lastTMS = m_vEvtRecords.at(m_vEvtRecords.size()-1)->ts_ms;
  370. #ifndef ONE_EVENT_PER_LOOP
  371. while( m_vEvtRecords.size() ){
  372. #endif
  373. tPtr = *m_vEvtRecords.begin();
  374. if( tPtr != NULL ) {
  375. if( tEvt != NULL ) {
  376. m_pEventHeap->broadcast( tEvt );
  377. };
  378. free( tPtr );
  379. };
  380. m_vEvtRecords.erase( m_vEvtRecords.begin() );
  381. #ifndef ONE_EVENT_PER_LOOP
  382. };
  383. #endif
  384. };
  385. };
  386. bool argusKernel::signalEvent( void ){
  387. if( m_pDBC->getLastEvents( m_vEvtRecords, 0,0 ) ){
  388. };
  389. return true;
  390. };
  391. int argusKernel::getNetNodes( ARGUS_NODE_TYPE type, argusNetNode **&RA ){
  392. RA = NULL;
  393. int cnt = 0;
  394. if( m_pNodeFactory != NULL ){
  395. cnt = m_pNodeFactory->getNodesCount( type );
  396. if( cnt ) {
  397. RA = (argusNetNode **) calloc( cnt, sizeof( argusNetNode * ) );
  398. m_pNodeFactory->fetchNodes(type, RA );
  399. };
  400. };
  401. return cnt;
  402. };
  403. argusNetNode *argusKernel::getNetNode( int id ){
  404. if( m_pNodeFactory != NULL ){
  405. return m_pNodeFactory->getNode( id );
  406. };
  407. return NULL;
  408. };
  409. int argusKernel::getModules( ARGUS_MODULE_TYPE type, argusKernelModule **&RA ){
  410. RA = NULL;
  411. int cnt = 0;
  412. if( m_pModuleFactory != NULL ){
  413. cnt = m_pModuleFactory->getModulesCount( type );
  414. if( cnt ) {
  415. RA = (argusKernelModule **) calloc( cnt, sizeof( argusKernelModule * ) );
  416. m_pModuleFactory->fetchModules( type, RA );
  417. };
  418. };
  419. return cnt;
  420. };
  421. argusKernelModule *argusKernel::getModule( int id ){
  422. if( m_pModuleFactory != NULL ){
  423. return m_pModuleFactory->getModule( id );
  424. };
  425. return NULL;
  426. };
  427. void argusKernel::dispatchEvent( EVENT_CONTAINER *Evt ){
  428. // Register all events in Database;
  429. LOG( "New EVENT!!" );
  430. if( m_pDBC == NULL ) return;
  431. if( Evt == NULL ) return;
  432. switch( Evt->m_eClass ) {
  433. case EVT_CLASS_EXTERNAL_CMD:
  434. switch( Evt->m_eType ){
  435. case EVT_FH_MISSION_BEGIN:{
  436. FH_CTRL_DATA * tData = (FH_CTRL_DATA *) Evt->m_pEvtData;
  437. if( tData ) {
  438. DBC_EVT_DATA * tEVT = m_pDBC->getEventByUUID( tData->targetUUID );
  439. if( tEVT ) {
  440. uint32_t TS_A, TS_B;
  441. TS_A = Evt->m_UMSTS / 1000;
  442. TS_B = Evt->m_UMSTS % 1000;
  443. if( m_pDBC->addEvent(
  444. 0,
  445. Evt->m_UUID,
  446. TS_A,
  447. TS_B,
  448. EVT_FH_FLY_TO,
  449. 0,
  450. 0,
  451. 0,
  452. 0,
  453. 0,
  454. tEVT->lat,
  455. tEVT->lon,
  456. tEVT->alt,
  457. tEVT->uuid
  458. ) ){
  459. //Simulate FH Module Event;
  460. EVENT_CONTAINER *ttt;
  461. C3D_WGS84_LOC * nnn = (C3D_WGS84_LOC *) malloc( sizeof(C3D_WGS84_LOC));
  462. if( nnn ){
  463. nnn->lat = tEVT->lat;
  464. nnn->lon = tEVT->lon;
  465. nnn->alt = tEVT->alt;
  466. ttt = createBasicEvent( 0, EVT_CLASS_FLY_HUNTER, EVT_FH_MISSION_BEGIN, NULL, nnn );
  467. if( ttt ) {
  468. m_pEventHeap->broadcast( ttt );
  469. } else {
  470. free( nnn );
  471. };
  472. };
  473. };
  474. free( tEVT );
  475. } else {
  476. LOG_ERROR("Linked Event Was Not Found!");
  477. };
  478. };
  479. break;
  480. };
  481. };
  482. break;
  483. case EVT_CLASS_SENSOR_CLD:
  484. case EVT_CLASS_SENSOR_LGS:
  485. case EVT_CLASS_SENSOR_LFS:
  486. case EVT_CLASS_SENSOR_MND:
  487. case EVT_CLASS_SENSOR_PLS_210:
  488. case EVT_CLASS_SENSOR_PLS_360:
  489. case EVT_CLASS_SENSOR_ALS:
  490. case EVT_CLASS_SENSOR_3D:
  491. case EVT_CLASS_SENSOR_ACC:
  492. switch( Evt->m_eType ) {
  493. case EVT_TARGET_1D:{
  494. TARGET_DATA *tDATA =(TARGET_DATA *) Evt->m_pEvtData;
  495. if( tDATA != NULL ) {
  496. uint32_t TS_A, TS_B;
  497. TS_A = Evt->m_UMSTS / 1000;
  498. TS_B = Evt->m_UMSTS % 1000;
  499. m_pDBC->addEvent(
  500. Evt->m_nSourceUID,
  501. Evt->m_UUID,
  502. TS_A,
  503. TS_B,
  504. Evt->m_eType,
  505. 0,
  506. 0,
  507. 0,
  508. tDATA->local_target.r,
  509. tDATA->area,
  510. tDATA->global_target.lat,
  511. tDATA->global_target.lon,
  512. tDATA->global_target.alt
  513. );
  514. };
  515. break;
  516. };
  517. case EVT_TARGET_2D_BLACK:
  518. case EVT_TARGET_2D_WHITE:{
  519. TARGET_DATA *tDATA = (TARGET_DATA *)Evt->m_pEvtData;
  520. if( tDATA != NULL ) {
  521. uint32_t TS_A, TS_B;
  522. TS_A = Evt->m_UMSTS / 1000;
  523. TS_B = Evt->m_UMSTS % 1000;
  524. m_pDBC->addEvent(
  525. Evt->m_nSourceUID,
  526. Evt->m_UUID,
  527. TS_A,
  528. TS_B,
  529. Evt->m_eType,
  530. 0,
  531. tDATA->local_target.fi,
  532. 0,
  533. tDATA->local_target.r,
  534. tDATA->area,
  535. tDATA->global_target.lat,
  536. tDATA->global_target.lon,
  537. tDATA->global_target.alt
  538. );
  539. };
  540. break;
  541. };
  542. case EVT_TARGET_3D_BLACK:
  543. case EVT_TARGET_3D_WHITE:{
  544. TARGET_DATA *tDATA = (TARGET_DATA *) Evt->m_pEvtData;
  545. if( tDATA != NULL ) {
  546. uint32_t TS_A, TS_B;
  547. TS_A = Evt->m_UMSTS / 1000;
  548. TS_B = Evt->m_UMSTS % 1000;
  549. m_pDBC->addEvent(
  550. Evt->m_nSourceUID,
  551. Evt->m_UUID,
  552. TS_A,
  553. TS_B,
  554. Evt->m_eType,
  555. 0,
  556. tDATA->local_target.fi,
  557. tDATA->local_target.tetta,
  558. tDATA->local_target.r,
  559. tDATA->area,
  560. tDATA->global_target.lat,
  561. tDATA->global_target.lon,
  562. tDATA->global_target.alt
  563. );
  564. };
  565. break;
  566. };
  567. };
  568. break;
  569. };
  570. };
  571. #undef LOG
  572. #undef LOG_ERROR