Browse Source

Fixed Some issues with BasicTransport object in 3DServer

Gagua on MyIR master 7 years ago
parent
commit
c011591c70
  1. 9
      Projects/LRF_Server/LRF_Server.vpj
  2. 8
      Projects/LRF_Server/makefile
  3. 4
      lib/components/base/basicTransport.cpp
  4. 4
      lib/components/base/basicTransport.h
  5. 17
      lib/data/net/clientPort.cpp
  6. 8
      lib/data/net/transportSocket.cpp
  7. 3
      lib/data/net/transportSocket.h
  8. 40
      lib/data/protocol/protocolRGoose.cpp
  9. 2
      put_to_git

9
Projects/LRF_Server/LRF_Server.vpj

@ -5,7 +5,8 @@
TemplateName="GNU C/C++"
WorkingDir="."
BuildSystem="automakefile"
BuildMakeFile="makefile">
BuildMakeFile="makefile"
VCSProject="Git:">
<Config
Name="Debug"
Type="gnuc"
@ -26,7 +27,7 @@
RunFromDir="%rw">
<Exec
CmdLine='g++ -c %xup -x c++ %defd -O0 -g3 -ggdb -w -Wpointer-arith %~other -o "%bd%n%oe" %i %f'
OtherOptions="-std=gnu++11"/>
OtherOptions="-std=gnu++11 -I../../lib/include"/>
</Target>
<Target
Name="Link"
@ -104,7 +105,6 @@
Value="Executable"/>
</List>
<Includes>
<Include Dir="../../lib/include"/>
</Includes>
<Libs PreObjects="0"/>
</Config>
@ -128,7 +128,7 @@
RunFromDir="%rw">
<Exec
CmdLine='g++ -c %xup -x c++ %defd -O3 -w -Wpointer-arith %~other -o "%bd%n%oe" %i %f'
OtherOptions="-std=gnu++11"/>
OtherOptions="-std=gnu++11 -I../../lib/include"/>
</Target>
<Target
Name="Link"
@ -206,7 +206,6 @@
Value="Executable"/>
</List>
<Includes>
<Include Dir="../../lib/include"/>
</Includes>
<Libs PreObjects="0"/>
</Config>

8
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

4
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;
};

4
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

17
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

8
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 ) {

3
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.

40
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

2
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'
git commit -a -m 'Fixed Some issues with BasicTransport object in 3DServer'
Loading…
Cancel
Save