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.

611 lines
20 KiB

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