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.

85 lines
2.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
6 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
6 years ago
​
​
5 years ago
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
  1. #include "rgooseNode.h"
  2. #define LOG( X ) m_pLog->Log( "NODE", this, X )
  3. #ifdef DEBUG
  4. #define LOG_ERROR( X ) {\
  5. char _tBfrErrMSG2w34[256];\
  6. sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
  7. m_pLog->Log( "NODE", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
  8. }
  9. #else
  10. #define LOG_ERROR( X ) m_pLog->Log( "NODE", this, _LOG_ERROR, X );
  11. #endif
  12. argusNetNode::argusNetNode( uint32_t id ):basicObject(){
  13. m_nDBID = id;
  14. m_pDBC = argusDBC::getInstance();
  15. m_pLog = basicLogCollection::getInstance();
  16. m_pPosition = NULL;
  17. m_pTargetFilter = NULL;
  18. if( m_pDBC != NULL ) {
  19. DBC_NODE_DATA *tData = NULL;
  20. tData = m_pDBC->getNodeData( m_nDBID );
  21. if( tData != NULL ) {
  22. memcpy( &m_sNodeData , tData, sizeof(DBC_NODE_DATA));
  23. free( tData );
  24. } else {
  25. memset( &m_sNodeData , 0, sizeof(DBC_NODE_DATA));
  26. m_sNodeData.type = ARGUS_UNKNOWN;
  27. m_sNodeData.node_id = id;
  28. };
  29. } else {
  30. memset( &m_sNodeData , 0, sizeof(DBC_NODE_DATA));
  31. m_sNodeData.type = ARGUS_UNKNOWN;
  32. m_sNodeData.node_id = id;
  33. };
  34. LOG("FULL CONSTRUCTOR DONE!");
  35. };
  36. argusNetNode::argusNetNode( DBC_NODE_DATA *Data ):basicObject(){
  37. m_nDBID = Data->node_id;
  38. m_pDBC = argusDBC::getInstance();
  39. memcpy( &m_sNodeData , Data, sizeof(DBC_NODE_DATA));
  40. LOG("DATA CONSTRUCTOR DONE!");
  41. };
  42. argusNetNode::~argusNetNode(){
  43. //if( m_pPosition != NULL ) delete(m_pPosition);
  44. m_mCommandProtector.lock();
  45. if( m_qCommands.size() ) {
  46. NODE_COMMAND *tVal = NULL;
  47. while( tVal = m_qCommands.front() ){
  48. m_qCommands.pop();
  49. if( tVal->data ) {
  50. free( tVal->data );
  51. };
  52. free( tVal );
  53. };
  54. };
  55. m_mCommandProtector.unlock();
  56. };
  57. NODE_COMMAND *argusNetNode::fetchCommand(){
  58. NODE_COMMAND *RetVal = NULL;
  59. m_mCommandProtector.lock();
  60. if( m_qCommands.size() ) {
  61. RetVal = m_qCommands.front();
  62. m_qCommands.pop();
  63. };
  64. m_mCommandProtector.unlock();
  65. return RetVal;
  66. };
  67. void argusNetNode::enqueueCommand( NODE_COMMAND *ptr ){
  68. if( ptr ) {
  69. m_mCommandProtector.lock();
  70. m_qCommands.push( ptr );
  71. m_mCommandProtector.unlock();
  72. };
  73. };
  74. #undef LOG
  75. #undef LOG_ERROR