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.

604 lines
19 KiB

5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
5 years ago
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
5 years ago
​
​
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
5 years ago
​
​
​
​
​
​
5 years ago
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
6 years ago
​
​
​
​
6 years ago
​
​
​
​
5 years ago
6 years ago
​
​
​
5 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
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
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
  1. #include "rgooseNodeFactory.h"
  2. #include "rgooseIPCamera.h"
  3. #include "rgooseNode3D.h"
  4. #include "rgooseNode2D.h"
  5. #include "rgooseNodePTZCamControl.h"
  6. #include "rgooseNodeStaticCamControl.h"
  7. #include "rgooseNodeEthernet2Serial.h"
  8. #ifdef MEM_DEBUG
  9. #include "../alg/generic/heapDebug.h"
  10. #endif
  11. #define LOG( X ) m_pLog->Log( "NFAC", this, X )
  12. #define LOG_ERROR( X ) m_pLog->Log( "NFAC", this, _LOG_ERROR, X )
  13. argusNodeFactory * argusNodeFactory::_instance = NULL;
  14. /**
  15. * Returns the single instance of the object.
  16. */
  17. argusNodeFactory* argusNodeFactory::getInstance( uint32_t ServerID ) {
  18. if( NULL == _instance) {
  19. if( ServerID ) {
  20. _instance = new argusNodeFactory( ServerID );
  21. };
  22. };
  23. return _instance;
  24. };
  25. argusNodeFactory::argusNodeFactory( uint32_t ServerID ): basicThread(){
  26. m_nSiteID = ServerID;
  27. m_pLog = basicLogCollection::getInstance();
  28. m_pDBC = argusDBC::getInstance();
  29. init();
  30. };
  31. argusNodeFactory::~argusNodeFactory(){
  32. waitThreadEnd( true );
  33. unloadNodes();
  34. _instance = NULL;
  35. };
  36. bool argusNodeFactory::unloadNodes( void ){
  37. if( m_pDBC != NULL ){
  38. if( m_vNetNodes.size() > 0 ){
  39. for( vectorNetNodes::iterator index = m_vNetNodes.begin(); index < m_vNetNodes.end(); index++ ){
  40. LOG(" Unload Node... BEGIN");
  41. switch( (*index)->getNodeType() ){
  42. case ARGUS_ANALOG_STATIC_CAMERA:
  43. LOG(" Static Analog Cam");
  44. delete( (ARGUS_CAM*) (*index) );
  45. break;
  46. case ARGUS_ANALOG_PTZ_CAMERA:
  47. LOG(" PTZ Analog Cam");
  48. delete( (ARGUS_PTZCAM*) (*index) );
  49. break;
  50. case ARGUS_IP_PTZ_CAMERA:{
  51. LOG(" PTZ IP Cam");
  52. delete( (ARGUS_PTZCAM*) (*index) );
  53. break;
  54. };
  55. case ARGUS_IP_STATIC_CAMERA:{
  56. LOG(" Static IP Cam");
  57. delete( (ARGUS_CAM*) (*index) );
  58. break;
  59. };
  60. case ARGUS_IP_UART_GATEWAY:{
  61. LOG(" UART Gateway");
  62. delete( (ARGUS_ETH2UART*) (*index) );
  63. break;
  64. };
  65. case ARGUS_ALS_SENSOR:
  66. case ARGUS_PLS_200_SENSOR:
  67. case ARGUS_PLS_360_SENSOR:
  68. case ARGUS_LFS_SENSOR:{
  69. LOG(" 2D LRF");
  70. delete( (ARGUS_2DSensor*) (*index) );
  71. LOG(" 2D LRF done");
  72. break;
  73. };
  74. case ARGUS_3D_SENSOR:{
  75. LOG(" 3D LRF");
  76. delete( (argus3DLIDAR*) (*index) );
  77. break;
  78. };
  79. };
  80. LOG(" Unload Node... DONE!");
  81. };
  82. m_vNetNodes.clear();
  83. m_mNetNodesIDS.clear();
  84. };
  85. };
  86. return true;
  87. };
  88. /*
  89. bool argusNodeFactory::loadNodes( uint32_t SiteID ){
  90. LOG("Node Loader");
  91. if(m_pDBC == NULL) return false;
  92. m_nSiteID = SiteID;
  93. DBC_INT_LIST *tList = m_pDBC->listNodes( SiteID );
  94. if( tList != NULL ) {
  95. for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ){
  96. uint32_t id = *idx;
  97. char msg[64];
  98. sprintf( msg, "Creating Node[%d]", id );
  99. createNode( id );
  100. };
  101. tList->clear();
  102. delete( tList );
  103. return true;
  104. };
  105. return false;
  106. };
  107. */
  108. bool argusNodeFactory::loadNodes( uint32_t SiteID ){
  109. if( m_pDBC == NULL ) return false;
  110. m_nSiteID = SiteID;
  111. DBC_INT_LIST *tList = m_pDBC->listNodes( SiteID );
  112. if( tList != NULL ) {
  113. for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ) createNode((*idx));
  114. tList->clear();
  115. delete( tList );
  116. }
  117. #ifdef DEBUG
  118. else {
  119. LOG("No Nodes Defined");
  120. }
  121. #endif
  122. return true;
  123. };
  124. bool argusNodeFactory::reloadNodes( uint32_t SiteID ){
  125. if(!unloadNodes()) return false;
  126. return loadNodes( SiteID );
  127. };
  128. bool argusNodeFactory::reloadNode( uint32_t NodeID ){
  129. deleteNode( NodeID );
  130. argusNetNode *tNode = createNode( NodeID );
  131. if( tNode ) {
  132. return true;
  133. };
  134. return false;
  135. };
  136. argusNetNode *argusNodeFactory::createNode( uint32_t id ){
  137. argusNetNode *tVal = NULL;
  138. if( m_pDBC != NULL ){
  139. DBC_NODE_DATA *tData = NULL;
  140. tData = m_pDBC->getNodeData( id );
  141. if( tData!= NULL ) {
  142. #ifdef DEBUG
  143. char tB[256];
  144. sprintf( tB, "Node id: %d AUX id: %d", id, tData->aux_id );
  145. LOG( tB );
  146. sprintf( tB, "Node type: %d", tData->type );
  147. LOG( tB );
  148. sprintf( tB, "Node Name: %s", tData->name );
  149. LOG( tB );
  150. #endif
  151. switch( tData->type ) {
  152. case ARGUS_ANALOG_STATIC_CAMERA:{
  153. #ifdef DEBUG
  154. LOG("Creating Analog Static Camera");
  155. #endif
  156. ARGUS_CAM *tCamera;
  157. tCamera = new ARGUS_CAM( id );
  158. if( tCamera ) {
  159. LOG("Starting Service");
  160. tCamera->startService();
  161. tVal = ( argusNetNode *) tCamera;
  162. LOG("Success");
  163. };
  164. break;
  165. };
  166. case ARGUS_ANALOG_PTZ_CAMERA:{
  167. #ifdef DEBUG
  168. LOG("Creating Analog PTZ Camera");
  169. #endif
  170. ARGUS_PTZCAM *tCamera;
  171. tCamera = new ARGUS_PTZCAM( id );
  172. if( tCamera ) {
  173. LOG("Starting Service");
  174. tCamera->startService();
  175. tVal = ( argusNetNode *) tCamera;
  176. LOG("Success");
  177. };
  178. break;
  179. };
  180. case ARGUS_IP_STATIC_CAMERA:{
  181. #ifdef DEBUG
  182. LOG("Creating IP Static Camera");
  183. #endif
  184. ARGUS_CAM *tCamera;
  185. tCamera = new ARGUS_CAM( id );
  186. if( tCamera ) {
  187. #ifdef DEBUG
  188. LOG("Starting Service");
  189. #endif
  190. if( tCamera->startService() ){
  191. tVal = ( argusNetNode *) tCamera;
  192. #ifdef DEBUG
  193. LOG("Success");
  194. #endif
  195. } else {
  196. #ifdef DEBUG
  197. LOG_ERROR("Error Sterting Service");
  198. #endif
  199. delete( tCamera );
  200. };
  201. };
  202. break;
  203. };
  204. case ARGUS_IP_PTZ_CAMERA:{
  205. #ifdef DEBUG
  206. LOG("Creating IP PTZ Camera");
  207. #endif
  208. ARGUS_PTZCAM *tCamera;
  209. tCamera = new ARGUS_PTZCAM( id );
  210. if( tCamera ) {
  211. #ifdef DEBUG
  212. LOG("Starting Service");
  213. #endif
  214. if( tCamera->startService() ){
  215. tVal = ( argusNetNode *) tCamera;
  216. #ifdef DEBUG
  217. LOG("Success");
  218. #endif
  219. } else {
  220. #ifdef DEBUG
  221. LOG_ERROR("Error Starting Service!");
  222. #endif
  223. delete( tCamera );
  224. };
  225. };
  226. break;
  227. };
  228. case ARGUS_IP_UART_GATEWAY:{
  229. #ifdef DEBUG
  230. LOG("Creating Ethernet to UART Gateway");
  231. #endif
  232. ARGUS_ETH2UART *tGW;
  233. tGW = new ARGUS_ETH2UART( id );
  234. if ( tGW ) {
  235. if ( tGW->create() ) {
  236. tVal = ( argusNetNode *) tGW;
  237. } else {
  238. delete( tGW );
  239. };
  240. };
  241. break;
  242. };
  243. case ARGUS_IP_VIDEO_SERVER:
  244. #ifdef DEBUG
  245. LOG("Creating Network Video Encoder");
  246. #endif
  247. break;
  248. case ARGUS_LFS_SENSOR:{
  249. #ifdef DEBUG
  250. LOG("Creating LFS Sensor");
  251. #endif
  252. ARGUS_2DSensor *tSensor;
  253. tSensor = new ARGUS_2DSensor( id );
  254. if( tSensor ) {
  255. LOG("Success");
  256. tSensor->startService();
  257. tVal = ( argusNetNode *) tSensor;
  258. };
  259. break;
  260. };
  261. case ARGUS_ALS_SENSOR:{
  262. #ifdef DEBUG
  263. LOG("Creating ALS Sensor");
  264. #endif
  265. ARGUS_2DSensor *tSensor;
  266. tSensor = new ARGUS_2DSensor( id );
  267. if( tSensor ) {
  268. LOG("Success");
  269. tSensor->startService();
  270. tVal = ( argusNetNode *) tSensor;
  271. };
  272. break;
  273. };
  274. case ARGUS_PLS_200_SENSOR:{
  275. #ifdef DEBUG
  276. LOG("Creating PLS200 Sensor");
  277. #endif
  278. ARGUS_2DSensor *tSensor;
  279. tSensor = new ARGUS_2DSensor( id );
  280. if( tSensor ) {
  281. LOG("Success");
  282. tSensor->startService();
  283. tVal = ( argusNetNode *) tSensor;
  284. };
  285. break;
  286. };
  287. case ARGUS_PLS_360_SENSOR:{
  288. #ifdef DEBUG
  289. LOG("Creating PLS360 Sensor");
  290. #endif
  291. ARGUS_2DSensor *tSensor;
  292. tSensor = new ARGUS_2DSensor( id );
  293. if( tSensor ) {
  294. LOG("Success");
  295. tSensor->startService();
  296. tVal = ( argusNetNode *) tSensor;
  297. };
  298. break;
  299. };
  300. case ARGUS_3D_SENSOR:{
  301. #ifdef DEBUG
  302. LOG("Creating 3D Sensor");
  303. #endif
  304. argus3DLIDAR *t3DRadar;
  305. t3DRadar = new argus3DLIDAR( id );
  306. if( t3DRadar ) {
  307. LOG("Success");
  308. t3DRadar->startService();
  309. tVal = ( argusNetNode *) t3DRadar;
  310. };
  311. break;
  312. };
  313. case ARGUS_JAMER:
  314. #ifdef DEBUG
  315. LOG("Creating RF Jamer");
  316. #endif
  317. break;
  318. case ARGUS_NET_PLS_200:
  319. #ifdef DEBUG
  320. LOG("Creating Network-PLS200 Sensor");
  321. #endif
  322. break;
  323. case ARGUS_DRONE_CONTROL:
  324. #ifdef DEBUG
  325. LOG("Creating Drone Controll");
  326. #endif
  327. break;
  328. };
  329. free(tData);
  330. };
  331. };
  332. if( tVal != NULL ){
  333. #ifdef DEBUG
  334. char tB[64];
  335. sprintf( tB, "Node PTR: %p", tVal );
  336. LOG( tB );
  337. #endif
  338. m_vNetNodes.push_back( tVal );
  339. m_mNetNodesIDS[id] = tVal;
  340. };
  341. return tVal;
  342. };
  343. void argusNodeFactory::deleteNode( argusNetNode *ptr ){
  344. if( ptr == NULL ) return;
  345. // if some troubles move this to an end of the function!
  346. for( vectorNetNodes::iterator index = m_vNetNodes.begin() ; index < m_vNetNodes.end(); index++ ){
  347. if( (*index) == ptr ) {
  348. m_mNetNodesIDS.erase( ptr->getNodeID() );
  349. m_vNetNodes.erase( index );
  350. break;
  351. };
  352. };
  353. switch( ptr->getNodeType() ) {
  354. case ARGUS_ANALOG_STATIC_CAMERA:
  355. #ifdef DEBUG
  356. LOG("Destroying Analog Static Camera");
  357. #endif
  358. break;
  359. case ARGUS_ANALOG_PTZ_CAMERA:
  360. #ifdef DEBUG
  361. LOG("Destroying Analog PTZ Camera");
  362. #endif
  363. break;
  364. case ARGUS_IP_STATIC_CAMERA:
  365. #ifdef DEBUG
  366. LOG("Destroying Network Static Camera");
  367. #endif
  368. SLEEP(2000);
  369. LOG("Actual Destroying Network Static Camera");
  370. delete((ARGUS_PTZCAM *) ptr );
  371. break;
  372. case ARGUS_IP_PTZ_CAMERA:
  373. #ifdef DEBUG
  374. LOG("Destroying Network PTZ Camera");
  375. #endif
  376. SLEEP(2000);
  377. delete((ARGUS_PTZCAM *) ptr );
  378. #ifdef DEBUG
  379. LOG("Done Successfuly");
  380. #endif
  381. break;
  382. case ARGUS_IP_UART_GATEWAY:
  383. #ifdef DEBUG
  384. LOG("Destroying Ethernet to UART Gateway");
  385. #endif
  386. break;
  387. case ARGUS_IP_VIDEO_SERVER:
  388. #ifdef DEBUG
  389. LOG("Destroying Network Video Encoder");
  390. #endif
  391. break;
  392. case ARGUS_LFS_SENSOR:
  393. #ifdef DEBUG
  394. LOG("Destroying LFS Sensor");
  395. #endif
  396. break;
  397. case ARGUS_ALS_SENSOR:
  398. #ifdef DEBUG
  399. LOG("Destroying ALS Sensor");
  400. #endif
  401. break;
  402. case ARGUS_PLS_200_SENSOR:
  403. #ifdef DEBUG
  404. LOG("Destroying PLS200 Sensor");
  405. #endif
  406. break;
  407. case ARGUS_PLS_360_SENSOR:
  408. #ifdef DEBUG
  409. LOG("Destroying PLS360 Sensor");
  410. #endif
  411. break;
  412. case ARGUS_3D_SENSOR:
  413. #ifdef DEBUG
  414. LOG("Destroying 3D Sensor");
  415. #endif
  416. break;
  417. case ARGUS_JAMER:
  418. #ifdef DEBUG
  419. LOG("Destroying RF Jamer");
  420. #endif
  421. break;
  422. case ARGUS_NET_PLS_200:
  423. #ifdef DEBUG
  424. LOG("Destroying Network-PLS200 Sensor");
  425. #endif
  426. break;
  427. case ARGUS_DRONE_CONTROL:
  428. #ifdef DEBUG
  429. LOG("Destroying Drone Controll");
  430. #endif
  431. break;
  432. };
  433. };
  434. /*
  435. @id Database ID of Node to be deleted
  436. */
  437. argusNetNode *argusNodeFactory::getNode( uint32_t id ){
  438. mapNode2Id::iterator it;
  439. it = m_mNetNodesIDS.find( id );
  440. if( it != m_mNetNodesIDS.end() ) {
  441. return m_mNetNodesIDS[id];
  442. };
  443. return NULL;
  444. };
  445. /*
  446. @id Database ID of Node to be deleted
  447. */
  448. void argusNodeFactory::deleteNode( uint32_t id ){
  449. argusNetNode *tNode = getNode( id );
  450. deleteNode( tNode );
  451. };
  452. bool argusNodeFactory::validate( void ){
  453. return ( m_bThreadStatus < TH_ENDED );
  454. };
  455. void argusNodeFactory::m_fThreadProc( void ){
  456. if( m_pDBC == NULL ){
  457. m_bThreadStatus = TH_ENDED;
  458. } else {
  459. m_bThreadStatus = TH_WORKING;
  460. while( m_bThreadStatus < TH_ENDED ) {
  461. DBC_INT_LIST *tList = NULL;
  462. #ifdef DEBUG
  463. #ifdef MEM_DEBUG
  464. size_t memStart, memEnd, memDiff;
  465. char MEM_MSG[256];
  466. memStart = getCurrentRSS();
  467. #endif
  468. #endif
  469. if( m_vNetNodes.size() ) {
  470. DBC_INT_LIST tL;
  471. for( vectorNetNodes::iterator idx = m_vNetNodes.begin(); idx < m_vNetNodes.end(); idx++ ) tL.push_back( (*idx)->getNodeID() );
  472. tList = m_pDBC->listNewNodes( m_nSiteID, &tL );
  473. tL.clear();
  474. } else {
  475. tList = m_pDBC->listNewNodes( m_nSiteID, NULL );
  476. };
  477. if( tList != NULL ) {
  478. #ifdef DEBUG
  479. LOG("New Nodes Added!");
  480. #endif
  481. for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ) createNode( *idx );
  482. tList->clear();
  483. delete( tList );
  484. }
  485. #ifdef DEBUG_EXTRA
  486. else {
  487. LOG( "No New Nodes Added");
  488. }
  489. #endif
  490. #ifdef MEM_DEBUG
  491. memEnd = getCurrentRSS();
  492. memDiff = memEnd - memStart;
  493. sprintf(MEM_MSG,"MEM START: %d MEM DIF1: %d", memStart, memDiff );
  494. LOG( MEM_MSG );
  495. #endif
  496. if( m_vNetNodes.size() ) {
  497. //Get Full List
  498. tList = m_pDBC->listNodes( m_nSiteID );
  499. if( tList != NULL ) {
  500. for( vectorNetNodes::iterator idx = m_vNetNodes.begin(); idx < m_vNetNodes.end(); idx++ ){
  501. bool tRemoved = true;
  502. // Check if Removed By changes in DB
  503. for( DBC_INT_LIST::iterator idz = tList->begin(); idz < tList->end(); idz++ ) if( (*idz) == (*idx)->getNodeID() ) tRemoved = false;
  504. // If Not - check validation
  505. if( !tRemoved ){
  506. #ifdef DEBUG_EXTRA
  507. LOG("Node Among Active Nodes.... make Validation");
  508. #endif
  509. tRemoved = !(*idx)->validate();
  510. };
  511. // If Node is Invalid - Removing
  512. if( tRemoved ) {
  513. #ifdef DEBUG
  514. LOG("Node not passed Validation!");
  515. #endif
  516. deleteNode((*idx));
  517. };
  518. };
  519. tList->clear();
  520. delete( tList );
  521. } else {
  522. #ifdef DEUBG
  523. LOG("All Modules Must be Deleted!");
  524. #endif
  525. for( vectorNetNodes::iterator idx = m_vNetNodes.begin(); idx < m_vNetNodes.end(); idx++ ) deleteNode((*idx));
  526. m_vNetNodes.clear();
  527. m_mNetNodesIDS.clear();
  528. };
  529. }
  530. #ifdef DEBUG
  531. #ifdef DEBUG_EXTRA
  532. else {
  533. LOG("No Nodes to Validate");
  534. }
  535. #endif
  536. ;
  537. #ifdef MEM_DEBUG
  538. memEnd = getCurrentRSS();
  539. memDiff = memEnd - memStart;
  540. sprintf(MEM_MSG,"MEM START: %d MEM DIF2: %d", memStart, memDiff );
  541. LOG( MEM_MSG );
  542. #endif
  543. #else
  544. ;
  545. #endif
  546. for( int i = ( 15000 / DEFAULT_THREAD_SLEEP_TIME ); i && ( m_bThreadStatus < TH_ENDED ); i-- ) SLEEP( DEFAULT_THREAD_SLEEP_TIME );
  547. };
  548. };
  549. LOG("EXIT FROM CTRL THREAD");
  550. };
  551. uint32_t argusNodeFactory::getNodesCount( ARGUS_NODE_TYPE type ){
  552. uint32_t RetVal = 0;
  553. if( m_vNetNodes.size() ) for( vectorNetNodes::iterator index = m_vNetNodes.begin(); index < m_vNetNodes.end(); index++ ) if( (*index)->getNodeType() == type ) RetVal++;
  554. return RetVal;
  555. };
  556. uint32_t argusNodeFactory::fetchNodes( ARGUS_NODE_TYPE type, argusNetNode **&RA ){
  557. uint32_t RetVal = 0;
  558. if( RA == NULL ) {
  559. RetVal = getNodesCount( type );
  560. if( RetVal > 0 ) {
  561. RA = (argusNetNode **) calloc( RetVal, sizeof(argusNetNode *));
  562. if( RA == NULL ) return 0;
  563. uint32_t cnt = 0;
  564. for( vectorNetNodes::iterator index = m_vNetNodes.begin(); index < m_vNetNodes.end(); index++ ) {
  565. if( (*index)->getNodeType() == type ) {
  566. RA[cnt] = (*index);
  567. cnt++;
  568. };
  569. };
  570. };
  571. } else {
  572. if( m_vNetNodes.size() ) {
  573. for( vectorNetNodes::iterator index = m_vNetNodes.begin(); index < m_vNetNodes.end(); index++ ) {
  574. if( (*index)->getNodeType() == type ) {
  575. RA[RetVal] = (*index);
  576. RetVal++;
  577. };
  578. };
  579. };
  580. };
  581. return RetVal;
  582. };
  583. #undef LOG
  584. #undef LOG_ERROR