From c011591c70f74e84b2aae3b82ea77e27d44bee11 Mon Sep 17 00:00:00 2001 From: Gagua on MyIR master Date: Tue, 23 Jul 2019 16:16:48 +0000 Subject: [PATCH] Fixed Some issues with BasicTransport object in 3DServer --- Projects/LRF_Server/LRF_Server.vpj | 9 +++--- Projects/LRF_Server/makefile | 8 +++--- lib/components/base/basicTransport.cpp | 4 +-- lib/components/base/basicTransport.h | 4 +-- lib/data/net/clientPort.cpp | 17 ++++++----- lib/data/net/transportSocket.cpp | 8 ------ lib/data/net/transportSocket.h | 3 +- lib/data/protocol/protocolRGoose.cpp | 40 +++++++++++++------------- put_to_git | 2 +- 9 files changed, 42 insertions(+), 53 deletions(-) diff --git a/Projects/LRF_Server/LRF_Server.vpj b/Projects/LRF_Server/LRF_Server.vpj index d18b8f2b..4e52fa02 100644 --- a/Projects/LRF_Server/LRF_Server.vpj +++ b/Projects/LRF_Server/LRF_Server.vpj @@ -5,7 +5,8 @@ TemplateName="GNU C/C++" WorkingDir="." BuildSystem="automakefile" - BuildMakeFile="makefile"> + BuildMakeFile="makefile" + VCSProject="Git:"> + OtherOptions="-std=gnu++11 -I../../lib/include"/> - @@ -128,7 +128,7 @@ RunFromDir="%rw"> + OtherOptions="-std=gnu++11 -I../../lib/include"/> - diff --git a/Projects/LRF_Server/makefile b/Projects/LRF_Server/makefile index 508583d5..4500c6d9 100644 --- a/Projects/LRF_Server/makefile +++ b/Projects/LRF_Server/makefile @@ -20,7 +20,7 @@ endif ifeq "$(CFG)" "Debug" OUTDIR=Debug OUTFILE=$(OUTDIR)/LRF_Server -CFG_INC=-I../../lib/include +CFG_INC= CFG_LIB= CFG_OBJ= COMMON_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ @@ -73,7 +73,7 @@ ALL_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ $(OUTDIR)/transportSerial.o $(OUTDIR)/transportSocket.o \ $(OUTDIR)/xmlParser.o -COMPILE=g++ -c -x c++ "-D_THREAD_SAFE" "-D_BSD_SOURCE" "-D_REENTRANT" "-DDEBUG" -O0 -g3 -ggdb -w -Wpointer-arith -std=gnu++11 -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $< +COMPILE=g++ -c -x c++ "-D_THREAD_SAFE" "-D_BSD_SOURCE" "-D_REENTRANT" "-DDEBUG" -O0 -g3 -ggdb -w -Wpointer-arith -std=gnu++11 -I../../lib/include -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $< LINK=g++ -O0 -g3 -ggdb -w -lconfig -lpthread -lelf -lcurses -lcdk -lcurl -o "$(OUTFILE)" $(ALL_OBJ) # Pattern rules @@ -188,7 +188,7 @@ endif ifeq "$(CFG)" "Release" OUTDIR=Release OUTFILE=$(OUTDIR)/LRF_Server -CFG_INC=-I/home/samba/shared/working_dir/source/lib/include +CFG_INC= CFG_LIB= CFG_OBJ= COMMON_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ @@ -241,7 +241,7 @@ ALL_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ $(OUTDIR)/transportSerial.o $(OUTDIR)/transportSocket.o \ $(OUTDIR)/xmlParser.o -COMPILE=g++ -c -x c++ "-D_THREAD_SAFE" "-D_BSD_SOURCE" "-D_REENTRANT" -O3 -w -Wpointer-arith -std=gnu++11 -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $< +COMPILE=g++ -c -x c++ "-D_THREAD_SAFE" "-D_BSD_SOURCE" "-D_REENTRANT" -O3 -w -Wpointer-arith -std=gnu++11 -I../../lib/include -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $< LINK=g++ -O3 -w -lconfig -lpthread -lelf -lcurses -lcdk -lcurl -s -o "$(OUTFILE)" $(ALL_OBJ) # Pattern rules diff --git a/lib/components/base/basicTransport.cpp b/lib/components/base/basicTransport.cpp index c277ddeb..834b00dd 100644 --- a/lib/components/base/basicTransport.cpp +++ b/lib/components/base/basicTransport.cpp @@ -19,7 +19,7 @@ bool basicTransport::addRecipient( protocolParser *ProtoParser ){ return true; }; -void basicTransport::setConnectionStatus(E_CONNECTION_STATUS CS){ +void basicTransport::setConnectionStatus( CONNECTION_STATUS CS){ m_mQueueProtectorMutex.lock(); m_eConnectionStatus = CS; for (parseQueue::iterator index = m_vParsers.begin(); index != m_vParsers.end(); index++){ @@ -28,7 +28,7 @@ void basicTransport::setConnectionStatus(E_CONNECTION_STATUS CS){ m_mQueueProtectorMutex.unlock(); }; -E_CONNECTION_STATUS basicTransport::getConnectionStatus(void){ +CONNECTION_STATUS basicTransport::getConnectionStatus(void){ return m_eConnectionStatus; }; diff --git a/lib/components/base/basicTransport.h b/lib/components/base/basicTransport.h index e047d104..713595dd 100644 --- a/lib/components/base/basicTransport.h +++ b/lib/components/base/basicTransport.h @@ -25,8 +25,8 @@ class basicTransport{ virtual bool sendData(unsigned char *Data, int DataSize){ return true; }; bool getStatus( void ){ return m_eConnectionStatus == CS_CONNECTED; }; virtual bool reconnect( void ){ return false; }; - virtual void setConnectionStatus(E_CONNECTION_STATUS ES); - virtual E_CONNECTION_STATUS getConnectionStatus(void); + void setConnectionStatus( CONNECTION_STATUS ES); + CONNECTION_STATUS getConnectionStatus( void ); }; #endif diff --git a/lib/data/net/clientPort.cpp b/lib/data/net/clientPort.cpp index 36f32294..fd31a298 100644 --- a/lib/data/net/clientPort.cpp +++ b/lib/data/net/clientPort.cpp @@ -128,13 +128,13 @@ bool clientPort::_connect(void){ return false; }; #endif - setConnectionStatus(CS_CONNECTED); + //setConnectionStatus(CS_CONNECTED); return true; }; bool clientPort::connectTo(CSTR Host, int Port){ if( m_eConnectionStatus == CS_CONNECTED ){ - setConnectionStatus(CS_DISCONNECTED); + //setConnectionStatus(CS_DISCONNECTED); #ifdef __linux__ shutdown( m_nSocketFD, SHUT_RDWR ); close( m_nSocketFD ); @@ -174,7 +174,7 @@ int clientPort::sendBlock(unsigned char *Data, int DataSize){ shutdown( m_nSocketFD, 2 ); close( m_nSocketFD ); m_nSocketFD = -1; - setConnectionStatus(CS_DISCONNECTED); + //setConnectionStatus(CS_DISCONNECTED); return -1; }; if( RetVal < 0 ) RetVal = 0; @@ -183,7 +183,7 @@ int clientPort::sendBlock(unsigned char *Data, int DataSize){ } else { //LOG_ERROR("Not Connected!"); //m_bStatus = 0; - setConnectionStatus(CS_DISCONNECTED); + //setConnectionStatus(CS_DISCONNECTED); return -1; }; #else @@ -230,7 +230,7 @@ int clientPort::recptBlock(unsigned char *Buffer, int *BufferLength){ close( m_nSocketFD ); *BufferLength = 0; m_nSocketFD = -1; - setConnectionStatus(CS_DISCONNECTED); + //setConnectionStatus(CS_DISCONNECTED); return -1; } }; @@ -238,12 +238,12 @@ int clientPort::recptBlock(unsigned char *Buffer, int *BufferLength){ shutdown( m_nSocketFD, SHUT_RDWR ); //SD_RECEIVE close( m_nSocketFD ); m_nSocketFD = -1; - setConnectionStatus(CS_DISCONNECTED); + //setConnectionStatus(CS_DISCONNECTED); }; } else { LOG_ERROR("Not Connected!"); *BufferLength = 0; - setConnectionStatus(CS_DISCONNECTED); + //setConnectionStatus(CS_DISCONNECTED); return -1; }; #else @@ -307,13 +307,12 @@ bool clientPort::disconnect(void){ WSACleanup(); m_nSocketFD = INVALID_SOCKET; #endif - setConnectionStatus(CS_DISCONNECTED); + //setConnectionStatus(CS_DISCONNECTED); }; return true; }; - #undef LOG #undef LOG_ERROR diff --git a/lib/data/net/transportSocket.cpp b/lib/data/net/transportSocket.cpp index f6d4e8d0..b26c194a 100644 --- a/lib/data/net/transportSocket.cpp +++ b/lib/data/net/transportSocket.cpp @@ -114,14 +114,6 @@ void transportSocket::m_fThreadBProc(void){ }; }; -void transportSocket::setConnectionStatus( CONNECTION_STATUS CS ){ - m_mQueueProtectorMutex.lock(); - for (parseQueue::iterator index = m_vParsers.begin(); index != m_vParsers.end(); index++){ - (*index)->setConnectionStatus( CS ); - }; - m_mQueueProtectorMutex.unlock(); -} - bool transportSocket::sendData(unsigned char *Data, int DataSize){ if( m_bThreadAStatus != TH_WORKING ) { diff --git a/lib/data/net/transportSocket.h b/lib/data/net/transportSocket.h index 73170568..0aaeaa74 100644 --- a/lib/data/net/transportSocket.h +++ b/lib/data/net/transportSocket.h @@ -26,7 +26,6 @@ protected: virtual void m_fThreadBProc(void); virtual int sendBlock(unsigned char *Data, int DataSize){ return 0; }; virtual int recptBlock(unsigned char *Buffer, int *BufferLength){ return 0; }; - void setConnectionStatus( CONNECTION_STATUS CS ); public: // Constructor transportSocket(); @@ -41,7 +40,7 @@ public: // Assignment operator // TODO: Uncomment the assignment operator when you need it. //transportSocket& operator=(const transportSocket& src); - bool sendData(unsigned char *Data, int DataSize); + bool sendData(unsigned char *Data, int DataSize); }; // TODO: Uncomment the copy constructor when you need it. diff --git a/lib/data/protocol/protocolRGoose.cpp b/lib/data/protocol/protocolRGoose.cpp index b63730f7..4f824433 100644 --- a/lib/data/protocol/protocolRGoose.cpp +++ b/lib/data/protocol/protocolRGoose.cpp @@ -5,26 +5,26 @@ #define LOGS( X ) basicLogCollection::getInstance()->Log( "RGoose", NULL, X ) #define LOG_ERROR( X ) m_pLog->Log( "RGoose", this, _LOG_ERROR, X ) -CSTR defenderStatusMode[] = { +CSTR RGooseStatusMode[] = { "Operational", "Degraded" }; -CSTR defenderFaultCode[] = { +CSTR RGooseFaultCode[] = { "Critical", "Warning", "Info" }; -CSTR defenderCategories[] = { +CSTR RGooseCategories[] = { "STATUS", "ALARM", "ERROR" }; -CSTR defenderTypeDescription[] = { +CSTR RGooseTypeDescription[] = { "Status Message", "Target Detection Event", "Fault Event" }; -CSTR defenderTypeSeverity[] = { +CSTR RGooseTypeSeverity[] = { "very-low", "low", "medium", @@ -43,7 +43,7 @@ static int g_iTimeDiff = 0; #define UNIX_TimeStamp_2_WINDOWS_FileTime_SHIFT 116444736000000000 #ifdef __linux__ -unsigned long long getSHDTimeValue( void ){ +unsigned long long getRSHDTimeValue( void ){ unsigned long long tMilliseconds; struct timeval tData; struct timezone tTZ; @@ -63,7 +63,7 @@ void TimetToFileTime( time_t t, LPFILETIME pft ){ pft->dwLowDateTime = (DWORD) ll; pft->dwHighDateTime = ll >>32; }*/ -unsigned __int64 getSHDTimeValue( void ){ +unsigned __int64 getRSHDTimeValue( void ){ unsigned __int64 tMilliseconds; SYSTEMTIME Ztime; GetSystemTime(&Ztime); @@ -75,7 +75,7 @@ unsigned __int64 getSHDTimeValue( void ){ return tMilliseconds; }; -CSTR getSHDTimeStamp( void ){ +CSTR getRSHDTimeStamp( void ){ CSTR RetVal = NULL; time_t rawtime; uint32_t msec; @@ -102,7 +102,7 @@ CSTR getSHDTimeStamp( void ){ return RetVal; }; -bool correctSHDTime( int diff ){ +bool correctRSHDTime( int diff ){ #ifdef __linux__ struct timeval tData; struct timezone tTZ; @@ -142,7 +142,7 @@ CSTR protocolRGoose::buildURL( CSTR templ, int dim, CSTR devID ){ CSTR protocolRGoose::buildUniqID( void ){ CSTR RetVal; RetVal = (CSTR) malloc(64); - sprintf( RetVal, "%s", MD5String( getSHDTimeStamp() ) ); + sprintf( RetVal, "%s", MD5String( getRSHDTimeStamp() ) ); return RetVal; }; @@ -251,7 +251,7 @@ CSTR protocolRGoose::assembleStatusData( bool StatusOK ){ CSTR tID; RetVal = (CSTR) malloc(CLOG); if ( RetVal != NULL ) { - tBuf = getSHDTimeStamp(); + tBuf = getRSHDTimeStamp(); if( tBuf != NULL ) { tTARGET = (CSTR) malloc(128); if( tTARGET!= NULL) { @@ -261,10 +261,10 @@ CSTR protocolRGoose::assembleStatusData( bool StatusOK ){ if( tID != NULL ) { sprintf( tID, "%s", MD5String( tBuf ) ); sprintf( tSRC, DFSL_SensorSourceDto, DFSL_HARDWARE_TYPE, DFSL_SOURCE_NAME, m_pScannerName ); - sprintf( tTARGET, "{ \"status\": \"%s\" }", defenderStatusMode[((StatusOK)?1:0)] ); + sprintf( tTARGET, "{ \"status\": \"%s\" }", RGooseStatusMode[((StatusOK)?1:0)] ); sprintf( RetVal, PACKAGE_SE_DATA_STATUS_ELEMENT, - defenderTypeDescription[DC_STATUS], + RGooseTypeDescription[DC_STATUS], tBuf, tSRC, "DFSL_STATUS_DATA", @@ -306,7 +306,7 @@ CSTR protocolRGoose::assembleFaultData( uint8_t Code, CSTR Desc ){ CSTR tID; RetVal = (CSTR) malloc(CLOG); if ( RetVal != NULL ) { - tBuf = getSHDTimeStamp(); + tBuf = getRSHDTimeStamp(); if( tBuf != NULL ) { tTARGET = (CSTR) malloc(128); if( tTARGET!= NULL) { @@ -319,7 +319,7 @@ CSTR protocolRGoose::assembleFaultData( uint8_t Code, CSTR Desc ){ sprintf( tTARGET, "{ \"code\": %d, \"description\": \"%s\" }", Code, Desc ); sprintf( RetVal, PACKAGE_SE_DATA_STATUS_ELEMENT, - defenderTypeDescription[DC_ERROR], + RGooseTypeDescription[DC_ERROR], tBuf, tSRC, "DFSL_FAULT_DATA", @@ -361,7 +361,7 @@ CSTR protocolRGoose::assembleTargetData( int targetID, int Range, int Width, int CSTR tID; RetVal = (CSTR) malloc(CLOG); if ( RetVal != NULL ) { - tBuf = getSHDTimeStamp(); + tBuf = getRSHDTimeStamp(); if( tBuf != NULL ) { tTARGET = (CSTR) malloc(128); if( tTARGET!= NULL) { @@ -374,7 +374,7 @@ CSTR protocolRGoose::assembleTargetData( int targetID, int Range, int Width, int sprintf( tTARGET, DFSL_LidarTargetDto, targetID, Azimuth, Elevation, Range, Width ); sprintf( RetVal, PACKAGE_SE_DATA_ELEMENT, - defenderTypeDescription[DC_ALARM], + RGooseTypeDescription[DC_ALARM], tBuf, tSRC, "DFSL_TARGET_DATA", @@ -414,7 +414,7 @@ size_t protocolRGoose::assembleDefenderJSON( CSTR Buffer, defenderCategoryTypes size_t RetVal; CSTR tBuf; RetVal = 0; - tBuf = getSHDTimeStamp(); + tBuf = getRSHDTimeStamp(); DEFENDER_MESSAGE_ID++; //memset( tBuffer, 0, CLOG ); if( tBuf != NULL ){ @@ -436,8 +436,8 @@ size_t protocolRGoose::assembleDefenderJSON( CSTR Buffer, defenderCategoryTypes sprintf( tBuffer, DFSL_SE_ENVELOPE, DEFENDER_MESSAGE_ID, - defenderCategories[Type], - defenderTypeSeverity[Severity], + RGooseCategories[Type], + RGooseTypeSeverity[Severity], tBuf, tBuf, tBuf, tBuf, Location, Data diff --git a/put_to_git b/put_to_git index 5876d7ec..41e97af9 100755 --- a/put_to_git +++ b/put_to_git @@ -1,4 +1,4 @@ #!/bin/bash #git commit -a -m '$1' -git commit -a -m 'Small Changes in POnvif Lib (added ptz_Status) And JSON fix in 3DServer' \ No newline at end of file +git commit -a -m 'Fixed Some issues with BasicTransport object in 3DServer'