diff --git a/.gitignore b/.gitignore index a89d8166..22b76dcc 100644 --- a/.gitignore +++ b/.gitignore @@ -85,8 +85,8 @@ /Projects/argus/Debug/* /.vs /Projects/QT-Gui-App/Win32-QT-gui-application_2019.exe -/Release -/Debug +/Release/* +/Debug/* /Linux_Workspace.vpwhistu /x64 /Projects/Cortex_test/x64/Debug @@ -98,3 +98,4 @@ /Projects/MEKOROT/.vs/* /Projects/MEKOROT/x64/* /Projects/MEKOROT/storage/* +Projects/img_mill/Debug/* \ No newline at end of file diff --git a/Projects/LRF_Server/LRF_Server.vpj b/Projects/LRF_Server/LRF_Server.vpj index c60968f9..679446d0 100644 --- a/Projects/LRF_Server/LRF_Server.vpj +++ b/Projects/LRF_Server/LRF_Server.vpj @@ -26,7 +26,7 @@ SaveOption="SaveCurrent" RunFromDir="%rw"> + diff --git a/Projects/img_mill/img_mill.vpj b/Projects/img_mill/img_mill.vpj index 4515f908..f1e2300f 100644 --- a/Projects/img_mill/img_mill.vpj +++ b/Projects/img_mill/img_mill.vpj @@ -12,7 +12,8 @@ DebugCallbackName="gdb" Version="1" OutputFile="%bdimg_mill" - CompilerConfigName="Latest Version"> + CompilerConfigName="Latest Version" + Defines='"/D_OPENCV_" "/DDEBUG"'> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CompilerConfigName="Latest Version" + Defines='"/D_OPENCV_" "/DDEBUG"'> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Filters="*.c;*.C;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.prg;*.pas;*.dpr;*.asm;*.s;*.bas;*.java;*.cs;*.sc;*.e;*.cob;*.html;*.rc;*.tcl;*.py;*.pl;*.d"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Filters="*.h;*.H;*.hh;*.hpp;*.hxx;*.inc;*.sh;*.cpy;*.if"> + + + + + + + + + + diff --git a/Projects/img_mill/makefile b/Projects/img_mill/makefile index b4b50e9a..40ea2429 100644 --- a/Projects/img_mill/makefile +++ b/Projects/img_mill/makefile @@ -20,15 +20,76 @@ endif ifeq "$(CFG)" "Debug" OUTDIR=Debug OUTFILE=$(OUTDIR)/img_mill -CFG_INC= -CFG_LIB= +CFG_INC=-I/usr/local/include/opencv4 -I../../lib/include +CFG_LIB=-lmysqlclient -lssl -lcrypto -lpthread `pkg-config --libs \ + libavcodec libavdevice libavfilter libavformat libavresample \ + libavutil libswresample libswscale libconfig++ libcurl opencv4` -lGL \ + -lGLU -lc -lm -lz CFG_OBJ= -COMMON_OBJ= +COMMON_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ + $(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \ + $(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \ + $(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \ + $(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \ + $(OUTDIR)/basicMediaViewer.o $(OUTDIR)/basicMutex.o \ + $(OUTDIR)/basicRing.o $(OUTDIR)/basicSettings.o \ + $(OUTDIR)/basicSettingsProvider.o $(OUTDIR)/basicThread.o \ + $(OUTDIR)/basicTransport.o $(OUTDIR)/basicVideoAnalyzer.o \ + $(OUTDIR)/database_class.o $(OUTDIR)/IM_Backend.o \ + $(OUTDIR)/IM_ClientHandler.o $(OUTDIR)/IM_ClientProtocol.o \ + $(OUTDIR)/IM_DataBaseAdapter.o $(OUTDIR)/IM_DnnWorker.o \ + $(OUTDIR)/IM_Kernel.o $(OUTDIR)/md5.o $(OUTDIR)/netClientHandler.o \ + $(OUTDIR)/netServer.o $(OUTDIR)/objectConsoleLoggingService.o \ + $(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o OBJ=$(COMMON_OBJ) $(CFG_OBJ) -ALL_OBJ= - -COMPILE=g++ -c -g -o "$(OUTDIR)/$(*F).o" $(CFG_INC) "$<" -LINK=g++ -g -o "$(OUTFILE)" $(OBJ) $(CFG_LIB) +ALL_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ + $(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \ + $(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \ + $(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \ + $(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \ + $(OUTDIR)/basicMediaViewer.o $(OUTDIR)/basicMutex.o \ + $(OUTDIR)/basicRing.o $(OUTDIR)/basicSettings.o \ + $(OUTDIR)/basicSettingsProvider.o $(OUTDIR)/basicThread.o \ + $(OUTDIR)/basicTransport.o $(OUTDIR)/basicVideoAnalyzer.o \ + $(OUTDIR)/database_class.o $(OUTDIR)/IM_Backend.o \ + $(OUTDIR)/IM_ClientHandler.o $(OUTDIR)/IM_ClientProtocol.o \ + $(OUTDIR)/IM_DataBaseAdapter.o $(OUTDIR)/IM_DnnWorker.o \ + $(OUTDIR)/IM_Kernel.o $(OUTDIR)/md5.o $(OUTDIR)/netClientHandler.o \ + $(OUTDIR)/netServer.o $(OUTDIR)/objectConsoleLoggingService.o \ + $(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o -lmysqlclient \ + -lssl -lcrypto -lpthread `pkg-config --libs libavcodec libavdevice \ + libavfilter libavformat libavresample libavutil libswresample \ + libswscale libconfig++ libcurl opencv4` -lGL -lGLU -lc -lm -lz + +COMPILE=g++ -c -x c++ "-D_OPENCV_" "-DDEBUG" -g -ggdb `pkg-config --cflags opencv4` -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $< +LINK=g++ -g -ggdb -o "$(OUTFILE)" $(ALL_OBJ) + +# Pattern rules +$(OUTDIR)/%.o : ../../lib/alg/generic/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : %.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/components/base/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/transport/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/protocol/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/net/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/mysql/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/components/object/%.cpp + $(COMPILE) # Build rules all: $(OUTFILE) @@ -57,15 +118,76 @@ endif ifeq "$(CFG)" "Release" OUTDIR=Release OUTFILE=$(OUTDIR)/img_mill -CFG_INC= -CFG_LIB= +CFG_INC=-I/usr/local/include/opencv4 -I/dr_frucht/lib/include +CFG_LIB=-lmysqlclient -lssl -lcrypto -lpthread `pkg-config --libs \ + libavcodec libavdevice libavfilter libavformat libavresample \ + libavutil libswresample libswscale libconfig++ libcurl opencv4` -lGL \ + -lGLU -lc -lm -lz CFG_OBJ= -COMMON_OBJ= +COMMON_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ + $(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \ + $(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \ + $(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \ + $(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \ + $(OUTDIR)/basicMediaViewer.o $(OUTDIR)/basicMutex.o \ + $(OUTDIR)/basicRing.o $(OUTDIR)/basicSettings.o \ + $(OUTDIR)/basicSettingsProvider.o $(OUTDIR)/basicThread.o \ + $(OUTDIR)/basicTransport.o $(OUTDIR)/basicVideoAnalyzer.o \ + $(OUTDIR)/database_class.o $(OUTDIR)/IM_Backend.o \ + $(OUTDIR)/IM_ClientHandler.o $(OUTDIR)/IM_ClientProtocol.o \ + $(OUTDIR)/IM_DataBaseAdapter.o $(OUTDIR)/IM_DnnWorker.o \ + $(OUTDIR)/IM_Kernel.o $(OUTDIR)/md5.o $(OUTDIR)/netClientHandler.o \ + $(OUTDIR)/netServer.o $(OUTDIR)/objectConsoleLoggingService.o \ + $(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o OBJ=$(COMMON_OBJ) $(CFG_OBJ) -ALL_OBJ= - -COMPILE=g++ -c -o "$(OUTDIR)/$(*F).o" $(CFG_INC) "$<" -LINK=g++ -o "$(OUTFILE)" $(OBJ) $(CFG_LIB) +ALL_OBJ=$(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ + $(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \ + $(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \ + $(OUTDIR)/basicLogCollection.o $(OUTDIR)/basicLoggingService.o \ + $(OUTDIR)/basicMediaDestination.o $(OUTDIR)/basicMediaSource.o \ + $(OUTDIR)/basicMediaViewer.o $(OUTDIR)/basicMutex.o \ + $(OUTDIR)/basicRing.o $(OUTDIR)/basicSettings.o \ + $(OUTDIR)/basicSettingsProvider.o $(OUTDIR)/basicThread.o \ + $(OUTDIR)/basicTransport.o $(OUTDIR)/basicVideoAnalyzer.o \ + $(OUTDIR)/database_class.o $(OUTDIR)/IM_Backend.o \ + $(OUTDIR)/IM_ClientHandler.o $(OUTDIR)/IM_ClientProtocol.o \ + $(OUTDIR)/IM_DataBaseAdapter.o $(OUTDIR)/IM_DnnWorker.o \ + $(OUTDIR)/IM_Kernel.o $(OUTDIR)/md5.o $(OUTDIR)/netClientHandler.o \ + $(OUTDIR)/netServer.o $(OUTDIR)/objectConsoleLoggingService.o \ + $(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o -lmysqlclient \ + -lssl -lcrypto -lpthread `pkg-config --libs libavcodec libavdevice \ + libavfilter libavformat libavresample libavutil libswresample \ + libswscale libconfig++ libcurl opencv4` -lGL -lGLU -lc -lm -lz + +COMPILE=g++ -c -x c++ "-D_OPENCV_" "-DDEBUG" -ggdb `pkg-config --cflags opencv4` -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $< +LINK=g++ -ggdb -o "$(OUTFILE)" $(ALL_OBJ) + +# Pattern rules +$(OUTDIR)/%.o : ../../lib/alg/generic/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : %.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/components/base/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/transport/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/protocol/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/net/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/mysql/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/components/object/%.cpp + $(COMPILE) # Build rules all: $(OUTFILE) diff --git a/lib/components/base/basicEngine.h b/lib/components/base/basicEngine.h index 51284c16..80bcc10a 100644 --- a/lib/components/base/basicEngine.h +++ b/lib/components/base/basicEngine.h @@ -1,6 +1,8 @@ #ifndef __BASICENGINE_H_INCL__ #define __BASICENGINE_H_INCL__ + +class networkClientHandler; /** * TODO: Add class description * @@ -21,9 +23,10 @@ public: // Assignment operator // TODO: Uncomment the assignment operator when you need it. //basicEngine& operator=(const basicEngine& src); - - virtual void start(){}; - virtual void stop(){}; + virtual networkClientHandler * attachNewClient( int SocketID ){ return 0; }; + virtual bool detachClient( networkClientHandler *ptr ){ return false; }; + virtual bool start(){ return false; }; + virtual bool stop( bool force = true ){ return false; }; }; diff --git a/lib/components/base/basicFunctionality.cpp b/lib/components/base/basicFunctionality.cpp index f610523c..986a313e 100644 --- a/lib/components/base/basicFunctionality.cpp +++ b/lib/components/base/basicFunctionality.cpp @@ -3,7 +3,7 @@ #ifdef DEBUG #include "basicLogCollection.h" - #define URGANT_LOG(X) basicLogCollection::getInstance()->Log("basic Functionality", NULL, X ) + #define URGENT_LOG(X) basicLogCollection::getInstance()->Log("basic Functionality", NULL, X ) #endif bool fileExist(const char *strFilename) { @@ -336,12 +336,12 @@ long long getMilliseconds( void ){ tTZ.tz_dsttime = 0; if( gettimeofday( &tData, &tTZ ) == -1 ){ tMilliseconds = (long long) 0; - URGANT_LOG( "EbioMat!"); + URGENT_LOG( "EbioMat'!"); } else { tMilliseconds = (long long) tData.tv_sec; tMilliseconds = ( tMilliseconds * 1000 ); tMilliseconds += (long long)( tData.tv_usec / 1000 ); - //URGANT_LOG("MilSecCollected!"); + //URGENT_LOG("MilSecCollected!"); }; #else #include @@ -648,6 +648,6 @@ localIpAddresses* getLocalIP() { #endif #ifdef DEBUG - #undef URGANT_LOG + #undef URGENT_LOG #endif diff --git a/lib/components/base/basicVideoAnalyzer.h b/lib/components/base/basicVideoAnalyzer.h index 74261cfa..037f9fd5 100644 --- a/lib/components/base/basicVideoAnalyzer.h +++ b/lib/components/base/basicVideoAnalyzer.h @@ -55,7 +55,8 @@ typedef enum E_VIDEO_ANALYZER_TYPE{ VA_OPTIC_FLOW = 3, VA_SURF_DETECT = 4, VA_FEAT_DETECT = 5, - VA_HAAR_DETECT = 6 + VA_HAAR_DETECT = 6, + VA_DNN_ANAL = 7 }VIDEO_ANALYZER_TYPE; class basicVideoAnalyzer : public basicThread, public basicMediaDestination, public basicMediaSource { @@ -63,7 +64,7 @@ class basicVideoAnalyzer : public basicThread, public basicMediaDestination, pub basicLogCollection *m_pLog; basicEventHeap *m_pEventHeap; protected: - void m_fThreadProc( void ); + virtual void m_fThreadProc( void ); protected: VIDEO_ANALYZER_TYPE type; basicMutex m_mBufferProtectorMutex; diff --git a/lib/data/net/clientPort.cpp b/lib/data/net/clientPort.cpp index 26e36fc4..3e7deaee 100644 --- a/lib/data/net/clientPort.cpp +++ b/lib/data/net/clientPort.cpp @@ -28,22 +28,27 @@ clientPort::clientPort(CSTR URI):transportSocket(){ //strncpy(m_sHostName, ptSt, tSize); //m_sHostName[tSize] = (char)0; ptSt[tSize] = (char)0; - if( connectTo(ptSt, m_nPort) ){ - char MsgBuffer[CLOG]; - sprintf(MsgBuffer, "Connect %s [%d] OK", m_sHostName, m_nPort); - LOG(MsgBuffer); - }; + if( connectTo(ptSt, m_nPort) ){ + char MsgBuffer[64]; + sprintf(MsgBuffer, "Connect %s [%d] OK", m_sHostName, m_nPort); + LOG(MsgBuffer); + } else { + LOG_ERROR("Cannot Connect!"); + }; }; }; clientPort::clientPort(CSTR Host, int Port, bool KeepALive ) :transportSocket(){ m_pLog = basicLogCollection::getInstance(); m_bKeepAlive = KeepALive; m_sHostName = NULL; - if( connectTo( Host, Port ) ) { - char MsgBuffer[CLOG]; - sprintf(MsgBuffer, "Connect %s [%d] OK", m_sHostName, m_nPort ); - LOG(MsgBuffer); - }; + if( connectTo( Host, Port ) ) { + char MsgBuffer[64]; + sprintf(MsgBuffer, "Connect %s [%d] OK", m_sHostName, m_nPort ); + init(); + LOG(MsgBuffer); + } else { + LOG_ERROR("Cannot Connect!"); + }; }; clientPort::~clientPort(){ @@ -132,8 +137,9 @@ bool clientPort::_connect(void){ return false; }; #endif - setConnectionStatus(CS_CONNECTED); - return true; + + setConnectionStatus(CS_CONNECTED); + return true; }; bool clientPort::connectTo(CSTR Host, int Port){ diff --git a/lib/data/net/netClientHandler.cpp b/lib/data/net/netClientHandler.cpp index 144b3777..82f0dff6 100644 --- a/lib/data/net/netClientHandler.cpp +++ b/lib/data/net/netClientHandler.cpp @@ -11,12 +11,15 @@ #define LOG_ERROR( X ) m_pLog->Log( "networkClientHandler", this, _LOG_ERROR, X ); #endif -networkClientHandler::networkClientHandler( int SocketFD ): basicEventHandler(){ - m_pPort = NULL; - m_pEngine = NULL; +networkClientHandler::networkClientHandler( int SocketFD, basicEngine *ptr ): basicEventHandler(){ + m_pEngine = ptr; m_pLog = basicLogCollection::getInstance(); m_pPort = new serverPort( SocketFD ); - LOG("Port Created OK!"); +#ifdef DEBUG + if( m_pPort ) { + LOG("Client Port Created OK!"); + }; +#endif }; networkClientHandler::~networkClientHandler(){ diff --git a/lib/data/net/netClientHandler.h b/lib/data/net/netClientHandler.h index 22681354..29027950 100644 --- a/lib/data/net/netClientHandler.h +++ b/lib/data/net/netClientHandler.h @@ -13,7 +13,7 @@ class networkClientHandler: public basicEventHandler{ basicEngine * m_pEngine; serverPort * m_pPort; public: - explicit networkClientHandler( int SocketFD ); + explicit networkClientHandler( int SocketFD, basicEngine *ptr = NULL ); virtual ~networkClientHandler(); bool attachEngine( basicEngine *ptr ); virtual void dispatchEvent( basicEvent *Evt ){}; diff --git a/lib/data/net/netServer.cpp b/lib/data/net/netServer.cpp index 1e0afa10..fc5e8a05 100644 --- a/lib/data/net/netServer.cpp +++ b/lib/data/net/netServer.cpp @@ -1,12 +1,22 @@ #include "netServer.h" -#include "../../App/3dSERVER/LRF_ClientHandler.h" -#define LOG( X ) m_pLog->Log( "networkServer", this, X ) -#define LOG_ERROR( X ) m_pLog->Log( "networkServer", this, _LOG_ERROR, X ) +//#include "../../App/3dSERVER/LRF_ClientHandler.h" +#include "netClientHandler.h" + +#define LOG( X ) m_pLog->Log( "NS", this, X ) +#ifdef DEBUG + #define LOG_ERROR( X ) {\ + char _tBfrErrMSG234[256];\ + sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ + m_pLog->Log( "NS", this, _LOG_ERROR, _tBfrErrMSG234 );\ + } +#else + #define LOG_ERROR( X ) m_pLog->Log( "NS", this, _LOG_ERROR, X ); +#endif void signal_void_handler( int SIG ){ }; -networkServer::networkServer( config_setting_t *Settings ) : basicThread(){ +networkServer::networkServer( config_setting_t *Settings, basicEngine *ptr ) : basicThread(){ m_pLog = basicLogCollection::getInstance(); m_bConnectionType = 0; m_vHandlersPool.clear(); @@ -16,6 +26,7 @@ networkServer::networkServer( config_setting_t *Settings ) : basicThread(){ } else { m_pSettings = basicSettingsProvider::getInstance()->getSubNode( NULL, "NETWORK_SERVER" ); }; + m_pKernelEngine = ptr; }; networkServer::~networkServer(){ @@ -126,8 +137,10 @@ bool networkServer::BootUp( CSTR HOST_NAME, U16 PORT ){ int RetCode; #ifdef __linux__ struct hostent *h_info; - - LOG( "Core BootUp" ); + +#ifdef DEBUG + LOG( "BootUp" ); +#endif MainSocket = socket( AF_INET, SOCK_STREAM, 0 ); if( MainSocket == -1){ @@ -264,11 +277,12 @@ bool networkServer::BootUp( U16 Port ){ }; bool networkServer::attachEngine( basicEngine *ptr ){ - m_pDetectorKernel = ptr; + m_pKernelEngine = ptr; if( m_vHandlersPool.size()) { // Pass Kernel to all already connected nodes for( vectorNetHandlers::iterator index = m_vHandlersPool.begin(); index < m_vHandlersPool.end(); index++ ) { - ((LRF_ClientHandler *)(*index))->attachEngine(m_pDetectorKernel); + //((LRF_ClientHandler *)(*index))->attachEngine(m_pDetectorKernel); + (*index)->attachEngine( m_pKernelEngine ); }; }; return true; @@ -358,14 +372,21 @@ void networkServer::m_fThreadProc( void ){ // Checkup client disconnection if( m_vHandlersPool.size()) { for( vectorNetHandlers::iterator index = m_vHandlersPool.begin(); index < m_vHandlersPool.end(); index++ ) { - LRF_ClientHandler *tClient = (LRF_ClientHandler *)(*index); - if( tClient->getConnectionStatus() == CS_DISCONNECTED ){ + //LRF_ClientHandler *tClient = (LRF_ClientHandler *)(*index); + if( (*index)->getStatus() == false ){ // Remove Client Handler LOG("Remove Client"); - delete( tClient ); - m_vHandlersPool.erase( index ); - LOG("Client Stoped"); - LOG("Remove Client Done"); + if( m_pKernelEngine ){ + if ( m_pKernelEngine->detachClient( (*index) ) ){ +#ifdef DEBUG + LOG("Client Stoped"); +#endif + m_vHandlersPool.erase( index ); +#ifdef DEBUG + LOG("Remove Client Done"); +#endif + } else LOG_ERROR("Client detach from Kernel Failure!"); + } else LOG_ERROR("No Kernel Attached!"); }; }; }; @@ -407,11 +428,12 @@ void networkServer::m_fThreadProc( void ){ #endif }; LOG( "Client Connection Accepted" ); - LRF_ClientHandler *tHandle; - tHandle = new LRF_ClientHandler( ClientSocket ); - if( tHandle != NULL ) { - tHandle->attachEngine( m_pDetectorKernel ); - m_vHandlersPool.push_back( (networkClientHandler *) tHandle ); + if( m_pKernelEngine ) { + networkClientHandler *tHandle; + tHandle = m_pKernelEngine->attachNewClient( ClientSocket ); + if( tHandle ) { + m_vHandlersPool.push_back( tHandle ); + }; }; }; }; diff --git a/lib/data/net/netServer.h b/lib/data/net/netServer.h index ff4f1390..679ac3de 100644 --- a/lib/data/net/netServer.h +++ b/lib/data/net/netServer.h @@ -65,7 +65,7 @@ class networkServer: public basicThread, public basicEventHandler{ private: basicLogCollection * m_pLog; vectorNetHandlers m_vHandlersPool; - basicEngine * m_pDetectorKernel; + basicEngine * m_pKernelEngine; config_setting_t * m_pSettings; struct sockaddr * MainSocketAddress; CSTR m_pHostName; @@ -79,7 +79,7 @@ class networkServer: public basicThread, public basicEventHandler{ protected: void m_fThreadProc( void ); public: - explicit networkServer( config_setting_t *Settings = NULL ); + explicit networkServer( config_setting_t *Settings = NULL, basicEngine *ptr=NULL ); virtual ~networkServer(); bool BootUp( void ); // Config By Settings provided in constructor, on fail uses next BootUp bool BootUp( U16 Port ); // Uses Default Hostname and Port as parameter, on fail (getlocalhost) uses next Bootup diff --git a/lib/rgoose/rgooseKafkaModule.cpp b/lib/rgoose/rgooseKafkaModule.cpp index 01ee7da5..dfd06448 100644 --- a/lib/rgoose/rgooseKafkaModule.cpp +++ b/lib/rgoose/rgooseKafkaModule.cpp @@ -46,6 +46,7 @@ argusKafkaModule::~argusKafkaModule(){ /* Periodical Job Handler */ void argusKafkaModule::m_fThreadProc( void ){ m_bThreadStatus = TH_WORKING; + if( !m_bEnabled ) m_bThreadStatus = TH_ENDED; while( m_bThreadStatus < TH_ENDED ) { m_llTicks ++;//= getMilliseconds(); if( m_llTicks % 20 == 0 ) { // each 2 seconds @@ -67,6 +68,7 @@ void argusKafkaModule::m_fThreadProc( void ){ }; bool argusKafkaModule::startService(){ + if(! m_bEnabled) return false; if( reloadSettings() ) { if( m_pSettings!= NULL ){ m_pProtocol = new protocolKAFKA( m_pSettings ); @@ -87,6 +89,7 @@ bool argusKafkaModule::stopService(){ bool argusKafkaModule::reloadSettings(){ if( m_pDBC==NULL ) return false; + if(! m_bEnabled) return false; m_pSettings = m_pDBC->getSettingsKAFKA( m_nDBAUXID ); if( m_pSettings != NULL ) { if( m_pEvtTemplates != NULL ) { @@ -183,6 +186,7 @@ void argusKafkaModule::dispatchEvent( basicEvent *Evt ){ LOG( "Evt NULL"); return; }; + if( !m_bEnabled )return; if( m_pEvtTemplates[ Evt->m_eClass ]!= NULL ) { // We have defined Channel for that class Events #ifdef DEBUG diff --git a/lib/rgoose/rgooseModule.cpp b/lib/rgoose/rgooseModule.cpp index f61c17a6..0a0feb52 100644 --- a/lib/rgoose/rgooseModule.cpp +++ b/lib/rgoose/rgooseModule.cpp @@ -8,6 +8,7 @@ argusKernelModule::argusKernelModule( uint32_t id, ARGUS_MODULE_TYPE param ):bas m_eType = param; m_nDBID = id; m_bDetached = false; + m_bEnabled = false; m_nDBAUXID = 0; // Clear Events flags if( m_pDBC ) { @@ -15,6 +16,7 @@ argusKernelModule::argusKernelModule( uint32_t id, ARGUS_MODULE_TYPE param ):bas tData = m_pDBC->getModuleData( m_nDBID ); if( tData ) { m_nDBAUXID = tData->aux_id; + m_bEnabled = tData->enabled; free( tData ); }; }; diff --git a/lib/rgoose/rgooseModule.h b/lib/rgoose/rgooseModule.h index 78c1f902..4efd528e 100644 --- a/lib/rgoose/rgooseModule.h +++ b/lib/rgoose/rgooseModule.h @@ -25,6 +25,7 @@ class argusKernelModule: public basicEventHandler, basicObject{ uint32_t m_nDBID; uint32_t m_nDBAUXID; argusKernel * m_pKernel; + bool m_bEnabled; bool m_bDetached; bool m_bEvtFlags[MAX_EVENT_ID]; public: @@ -36,6 +37,7 @@ class argusKernelModule: public basicEventHandler, basicObject{ ARGUS_MODULE_TYPE getType() const { return m_eType; }; bool isDetached() const { return m_bDetached; }; bool isAttached() const { return !m_bDetached; }; + bool isEnabled() const { return m_bEnabled;}; virtual bool reloadSettings(){ return false; }; void setAttached( bool b=true ){ m_bDetached = !b; }; void setDetached( bool b=true ){ m_bDetached = b; }; diff --git a/lib/rgoose/rgooseModuleFactory.cpp b/lib/rgoose/rgooseModuleFactory.cpp index 938c6f9f..008b55f1 100644 --- a/lib/rgoose/rgooseModuleFactory.cpp +++ b/lib/rgoose/rgooseModuleFactory.cpp @@ -72,28 +72,26 @@ argusKernelModule *argusModuleFactory::createModule( int id ){ DBC_MODULE_DATA *tData = NULL; tData = m_pDBC->getModuleData( id ); - if( tData!= NULL ) { - if( tData->enabled ) { - switch( tData->type ) { - case ARGUS_MODULE_ZLMEDIA: - #ifdef DEBUG - LOG("Creating ZLMedia Connector Module"); - #endif - tVal = new ARGUS_ZLMedia( tData->module_id ); - break; - case ARGUS_MODULE_DCBUSB: - #ifdef DEBUG - LOG("Creating Dry Contact USB Module"); - #endif - - break; - case ARGUS_MODULE_KAFKA: - #ifdef DEBUG - LOG("Creating KAFKA Module"); - #endif - tVal = new argusKafkaModule( tData->module_id ); - break; - }; + if( tData!= NULL ) { + switch( tData->type ) { + case ARGUS_MODULE_ZLMEDIA: +#ifdef DEBUG + LOG("Creating ZLMedia Connector Module"); +#endif + tVal = new ARGUS_ZLMedia( tData->module_id ); + break; + case ARGUS_MODULE_DCBUSB: +#ifdef DEBUG + LOG("Creating Dry Contact USB Module"); +#endif + + break; + case ARGUS_MODULE_KAFKA: +#ifdef DEBUG + LOG("Creating KAFKA Module"); +#endif + tVal = new argusKafkaModule( tData->module_id ); + break; }; free(tData); }; diff --git a/lib/rgoose/rgooseNode3D.cpp b/lib/rgoose/rgooseNode3D.cpp index 0d3fe509..d0f4370c 100644 --- a/lib/rgoose/rgooseNode3D.cpp +++ b/lib/rgoose/rgooseNode3D.cpp @@ -1,26 +1,57 @@ #include "rgooseNode3D.h" -#define LOG( X ) m_pLog->Log( (m_bIsMaster?"objectLGS[M]":"objectLGS[S]"), this, X ) -#define LOG_ERROR( X ) m_pLog->Log( (m_bIsMaster?"objectLGS[M]":"objectLGS[S]"), this, _LOG_ERROR, X ) +#define LOG( X ) m_pLog->Log( "NODE3D", this, X ) +#define LOG_ERROR( X ) m_pLog->Log( "NODE3D", this, _LOG_ERROR, X ) argus3DLIDAR::argus3DLIDAR( uint32_t ID ): argusNetNode( ID ){ - + m_pLog = basicLogCollection::getInstance(); + m_pMasterNode = NULL; + m_pSlaveNode = NULL; + m_pEventHeap = NULL; }; argus3DLIDAR::~argus3DLIDAR(){ - + stopService(); }; bool argus3DLIDAR::startService(){ - return false; + LOG("START"); + m_pMasterNode = new objectLGS( NULL, true ); + if( m_pMasterNode != NULL ) { + if(!m_pMasterNode->create() ){ + LOG_ERROR("CANNOT CREATE MASTER DEVICE!"); + delete( m_pMasterNode ); + m_pMasterNode = NULL; + }; + }; + /* + m_pSlaveNode = new objectLGS( NULL, false ); + if( m_pSlaveNode != NULL ) { + if(!m_pSlaveNode->create() ){ + LOG_ERROR("CANNOT CREATE SLAVE DEVICE!"); + delete( m_pSlaveNode ); + m_pSlaveNode = NULL; + }; + }; + */ + return (m_pMasterNode != NULL);// && (m_pSlaveNode != NULL); }; bool argus3DLIDAR::stopService(){ + LOG("STOP"); + if( m_pMasterNode != NULL ) { + delete( m_pMasterNode ); + m_pMasterNode = NULL; + }; + if( m_pSlaveNode != NULL ) { + delete( m_pSlaveNode ); + m_pSlaveNode = NULL; + }; return true; }; bool argus3DLIDAR::validate(){ - return false; + return true; }; @@ -38,6 +69,13 @@ inline void make3D( uint32_t sid, float &az, float &el, bool master = true ){ az = ( sid % TH_LINE_NODES ) * 360.f / TH_LINE_NODES; }; +#undef LOG +#undef LOG_ERROR + +#define LOG( X ) m_pLog->Log( (m_bIsMaster?"objectLGS[M]":"objectLGS[S]"), this, X ) +#define LOG_ERROR( X ) m_pLog->Log( (m_bIsMaster?"objectLGS[M]":"objectLGS[S]"), this, _LOG_ERROR, X ) + + objectLGS::objectLGS(config_setting_t *Settings, bool Master) : basicObject(), basicDualThread(), protocolLGS_CLIENT(), m_mStatusMutex(), m_mPackageMutex(), @@ -178,7 +216,7 @@ bool objectLGS::create( void ){ //m_oProtocol = new protocolLGS_CLIENT( m_pTransport, 0 ); //if (m_oProtocol != NULL) if( setTransport(m_pTransport)) - if(protocolLGS_CLIENT::create() ) + if( protocolLGS_CLIENT::create() ) return basicDualThread::init(); }; }; diff --git a/lib/rgoose/rgooseNodeFactory.cpp b/lib/rgoose/rgooseNodeFactory.cpp index 56ef09db..cb38442b 100644 --- a/lib/rgoose/rgooseNodeFactory.cpp +++ b/lib/rgoose/rgooseNodeFactory.cpp @@ -1,5 +1,6 @@ #include "rgooseNodeFactory.h" #include "rgooseIPCamera.h" +#include "rgooseNode3D.h" #ifdef MEM_DEBUG #include "../alg/generic/heapDebug.h" @@ -105,11 +106,12 @@ argusNetNode *argusNodeFactory::createNode( uint32_t id ){ LOG("Creating LFS Sensor"); #endif break; - case ARGUS_ALS_SENSOR: + case ARGUS_ALS_SENSOR:{ #ifdef DEBUG LOG("Creating ALS Sensor"); #endif - break; + break; + }; case ARGUS_PLS_200_SENSOR: #ifdef DEBUG LOG("Creating PLS200 Sensor"); @@ -120,11 +122,19 @@ argusNetNode *argusNodeFactory::createNode( uint32_t id ){ LOG("Creating PLS360 Sensor"); #endif break; - case ARGUS_3D_SENSOR: + case ARGUS_3D_SENSOR:{ #ifdef DEBUG LOG("Creating 3D Sensor"); #endif - break; + argus3DLIDAR *t3DRadar; + t3DRadar = new argus3DLIDAR( id ); + if( t3DRadar ) { + LOG("Success"); + t3DRadar->startService(); + tVal = ( argusNetNode *) t3DRadar; + }; + break; + }; case ARGUS_JAMER: #ifdef DEBUG LOG("Creating RF Jamer");