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

#include "rgooseNode.h"
#define LOG( X ) m_pLog->Log( "NODE", 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( "NODE", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
}
#else
#define LOG_ERROR( X ) m_pLog->Log( "NODE", this, _LOG_ERROR, X );
#endif
argusNetNode::argusNetNode( uint32_t id ):basicObject(){
m_nDBID = id;
m_pDBC = argusDBC::getInstance();
m_pLog = basicLogCollection::getInstance();
m_pPosition = NULL;
m_pTargetFilter = NULL;
if( m_pDBC != NULL ) {
DBC_NODE_DATA *tData = NULL;
tData = m_pDBC->getNodeData( m_nDBID );
if( tData != NULL ) {
memcpy( &m_sNodeData , tData, sizeof(DBC_NODE_DATA));
free( tData );
} else {
memset( &m_sNodeData , 0, sizeof(DBC_NODE_DATA));
m_sNodeData.type = ARGUS_UNKNOWN;
m_sNodeData.node_id = id;
};
} else {
memset( &m_sNodeData , 0, sizeof(DBC_NODE_DATA));
m_sNodeData.type = ARGUS_UNKNOWN;
m_sNodeData.node_id = id;
};
LOG("FULL CONSTRUCTOR DONE!");
};
argusNetNode::argusNetNode( DBC_NODE_DATA *Data ):basicObject(){
m_nDBID = Data->node_id;
m_pDBC = argusDBC::getInstance();
memcpy( &m_sNodeData , Data, sizeof(DBC_NODE_DATA));
LOG("DATA CONSTRUCTOR DONE!");
};
argusNetNode::~argusNetNode(){
//if( m_pPosition != NULL ) delete(m_pPosition);
m_mCommandProtector.lock();
if( m_qCommands.size() ) {
NODE_COMMAND *tVal = NULL;
while( tVal = m_qCommands.front() ){
m_qCommands.pop();
if( tVal->data ) {
free( tVal->data );
};
free( tVal );
};
};
m_mCommandProtector.unlock();
};
NODE_COMMAND *argusNetNode::fetchCommand(){
NODE_COMMAND *RetVal = NULL;
m_mCommandProtector.lock();
if( m_qCommands.size() ) {
RetVal = m_qCommands.front();
m_qCommands.pop();
};
m_mCommandProtector.unlock();
return RetVal;
};
void argusNetNode::enqueueCommand( NODE_COMMAND *ptr ){
if( ptr ) {
m_mCommandProtector.lock();
m_qCommands.push( ptr );
m_mCommandProtector.unlock();
};
};
#undef LOG
#undef LOG_ERROR