diff --git a/Projects/LRF_Server/LRF_Server.vpj b/Projects/LRF_Server/LRF_Server.vpj
index 541cb5a1..0a179a99 100644
--- a/Projects/LRF_Server/LRF_Server.vpj
+++ b/Projects/LRF_Server/LRF_Server.vpj
@@ -26,7 +26,7 @@
SaveOption="SaveCurrent"
RunFromDir="%rw">
addRecipient(( protocolParser *)this );
+ if( m_pKernelEngine!= NULL ) {
+ m_bKernelWorkingMode = m_pKernelEngine->getMode();
+ } else {
+ m_bKernelWorkingMode = WM_NONE;
+ };
+ sendState( m_bKernelWorkingMode );
} else {
LOG_ERROR( "Protocol Parser Creation Failed!");
};
@@ -58,6 +66,11 @@ bool LRF_ClientHandler::attachEngine( basicEngine *ptr ){
return true;
};
+bool LRF_ClientHandler::getStatus( void ){
+ if( m_pPort == NULL ) return false;
+ return m_pPort->getStatus();
+};
+
bool LRF_ClientHandler::packetHandler( protocolPackage *Package ){
if( Package != NULL ) {
#ifdef DUBUG_COMMUNICATION
diff --git a/lib/App/3dSERVER/LRF_ClientHandler.h b/lib/App/3dSERVER/LRF_ClientHandler.h
index 5c607a97..87e0d366 100644
--- a/lib/App/3dSERVER/LRF_ClientHandler.h
+++ b/lib/App/3dSERVER/LRF_ClientHandler.h
@@ -25,13 +25,14 @@ class LRF_ClientHandler : public networkClientHandler, public protocolLGS3D_Serv
bool packetHandler( protocolPackage *Package );
public:
// Constructor
- explicit LRF_ClientHandler( int SockFD );
+ explicit LRF_ClientHandler( int SockFD, basicEngine *ptr = NULL );
// Destructor
- virtual ~LRF_ClientHandler();
+ virtual ~LRF_ClientHandler();
- bool attachEngine( basicEngine *ptr );
- void dispatchEvent( basicEvent *Evt );
+ virtual bool attachEngine( basicEngine *ptr );
+ virtual bool getStatus( void );
+ void dispatchEvent( basicEvent *Evt );
};
#endif // __LRF_CLIENTHANDLER_H_INCL__
diff --git a/lib/App/3dSERVER/LRF_Kernel.cpp b/lib/App/3dSERVER/LRF_Kernel.cpp
index 5c389f14..53d6f28f 100644
--- a/lib/App/3dSERVER/LRF_Kernel.cpp
+++ b/lib/App/3dSERVER/LRF_Kernel.cpp
@@ -15,12 +15,21 @@
#include "LRF_Kernel.h"
#include "LRF_Detector.h"
+#include "LRF_ClientHandler.h"
#define LOG( X ) m_pLog->Log( "Kernel", this, X )
-#define LOG_ERROR( X ) m_pLog->Log( "Kernel", this, _LOG_ERROR, 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( "Kernel", this, _LOG_ERROR, _tBfrErrMSG234 );\
+ }
+#else
+ #define LOG_ERROR( X ) m_pLog->Log( "Kernel", this, _LOG_ERROR, X );
+#endif
// Constructor implementation
-LRF_Kernel::LRF_Kernel( LRF_HardwareManager *HM ): basicThread(){
+LRF_Kernel::LRF_Kernel( LRF_HardwareManager *HM ): basicThread(), basicEngine(){
m_bExitCause = 0;
m_pLog = basicLogCollection::getInstance();
m_pEventHeap = basicEventHeap::getInstance();
@@ -323,7 +332,11 @@ void LRF_Kernel::WaitFinish( bool Force ){
};
waitThreadEnd( Force );
#ifdef DEBUG
- LOG( "Thread is Detached" );
+ if( Force ) {
+ LOG( "Thread forced to be Detached" );
+ } else {
+ LOG( "Thread is Detached by itself" );
+ };
#endif
};
@@ -858,7 +871,25 @@ bool LRF_Kernel::shutdown( bool Restart ){
return true;
};
+networkClientHandler *LRF_Kernel::attachNewClient( int SocketID ){
+ LOG("Creating Client Handler!");
+ LRF_ClientHandler *tal;
+ tal = new LRF_ClientHandler( SocketID, this );
+ if( tal!= NULL ) {
+ LOG("Client Handler Created!");
+ };
+ return (networkClientHandler *) tal;
+};
+
+bool LRF_Kernel::detachClient( networkClientHandler *ptr ){
+ LOG("Delete Client Handler!");
+ if( ptr == NULL ) return false;
+ delete( (LRF_ClientHandler *) ptr );
+ return true;
+};
+
#ifndef PRU_SLAVE //Just Master Stuff
+
bool LRF_Kernel::stopMotors( void ){
#ifndef ONPC_TOTTAL_SIMULATOR
if( m_pHardwareManager!= NULL ) {
@@ -882,5 +913,7 @@ bool LRF_Kernel::shutdown( bool Restart ){
};
#endif
+
+
#undef LOG
#undef LOG_ERROR
diff --git a/lib/App/3dSERVER/LRF_Kernel.h b/lib/App/3dSERVER/LRF_Kernel.h
index 4c742553..4c260814 100644
--- a/lib/App/3dSERVER/LRF_Kernel.h
+++ b/lib/App/3dSERVER/LRF_Kernel.h
@@ -61,7 +61,7 @@
* @author gagua
*/
-class LRF_Kernel: public basicThread {
+class LRF_Kernel: public basicThread, public basicEngine{
private:
basicLogCollection * m_pLog;
LRF_HardwareManager * m_pHardwareManager;
@@ -106,10 +106,12 @@ class LRF_Kernel: public basicThread {
// Destructor
virtual ~LRF_Kernel();
-
+ bool attachNetServer( networkServer *srvPort );
+ virtual networkClientHandler * attachNewClient( int SocketID );
+ virtual bool detachClient( networkClientHandler *ptr );
#ifndef PRU_SLAVE //Just Master Stuff
bool create( LRF_HardwareManager *ptr = NULL, networkServer *srvPort = NULL );
- bool attachNetServer( networkServer *srvPort );
+
bool stopMotors( void );
bool startMotors( void );
#endif
diff --git a/lib/components/base/basicEvent.h b/lib/components/base/basicEvent.h
index d810d480..8e49c836 100644
--- a/lib/components/base/basicEvent.h
+++ b/lib/components/base/basicEvent.h
@@ -41,7 +41,14 @@ typedef enum E_basicEventTypeID {
EVT_CAPTURE_END = 14,
EVT_CAPTURE_DONE = 15,
EVT_ERROR = 16,
- EVT_COUNT = 17
+ EVT_FH_TAKE_OFF = 17,
+ EVT_FH_DEST_REACHED = 18,
+ EVT_FH_TARGET_LOCKED= 19,
+ EVT_FH_INTERCEPT_OK = 20,
+ EVT_FH_INTERCEPT_NOK= 21,
+ EVT_FH_MISSION_END = 22,
+ EVT_FH_LANDED = 23,
+ EVT_COUNT = 24
} basicEventTypeID;
#define MAX_EVENT_ID 17
@@ -59,7 +66,8 @@ typedef enum E_basicEventClassID{
EVT_CLASS_SENSOR_ALS = 10,
EVT_CLASS_SENSOR_3D = 11,
EVT_CLASS_SENSOR_ACC = 12,
- EVT_CLASS_COUNT = 13
+ EVT_CLASS_FLY_HUNTER = 13,
+ EVT_CLASS_COUNT = 14
} basicEventClassID;
typedef struct S_basicEvent{
diff --git a/lib/data/net/netClientHandler.cpp b/lib/data/net/netClientHandler.cpp
index 7a2106cc..43fd9f89 100644
--- a/lib/data/net/netClientHandler.cpp
+++ b/lib/data/net/netClientHandler.cpp
@@ -12,9 +12,10 @@
#endif
networkClientHandler::networkClientHandler( int SocketFD, basicEngine *ptr ): basicEventHandler(){
+ m_pLog = basicLogCollection::getInstance();
+ LOG("CHPOK");
m_pEngine = ptr;
- m_pLog = basicLogCollection::getInstance();
- m_pPort = NULL;//new serverPort( SocketFD );
+ m_pPort = new serverPort( SocketFD );
#ifdef DEBUG
if( m_pPort ) {
LOG("Client Port Created OK!");
diff --git a/lib/data/net/netClientHandler.h b/lib/data/net/netClientHandler.h
index 29027950..f2a2720d 100644
--- a/lib/data/net/netClientHandler.h
+++ b/lib/data/net/netClientHandler.h
@@ -15,7 +15,7 @@ class networkClientHandler: public basicEventHandler{
public:
explicit networkClientHandler( int SocketFD, basicEngine *ptr = NULL );
virtual ~networkClientHandler();
- bool attachEngine( basicEngine *ptr );
+ virtual bool attachEngine( basicEngine *ptr );
virtual void dispatchEvent( basicEvent *Evt ){};
virtual bool getStatus( void ){ return false; };
};
diff --git a/lib/data/net/netServer.cpp b/lib/data/net/netServer.cpp
index fc5e8a05..6d498ea5 100644
--- a/lib/data/net/netServer.cpp
+++ b/lib/data/net/netServer.cpp
@@ -430,10 +430,22 @@ void networkServer::m_fThreadProc( void ){
LOG( "Client Connection Accepted" );
if( m_pKernelEngine ) {
networkClientHandler *tHandle;
+ LOG("Before New Handler");
tHandle = m_pKernelEngine->attachNewClient( ClientSocket );
- if( tHandle ) {
+ LOG("After New Handler");
+ if( tHandle != NULL ) {
+ LOG("Handle Not NULL");
+ //tHandle->attachEngine( m_pKernelEngine );
m_vHandlersPool.push_back( tHandle );
+ } else {
+ LOG_ERROR("No Client Handler Created!");
+ shutdown( ClientSocket, 2 );
+ close( ClientSocket );
};
+ } else {
+ LOG_ERROR("No Kernel Attached!");
+ shutdown( ClientSocket, 2 );
+ close( ClientSocket );
};
};
};
diff --git a/lib/data/net/serverPort.cpp b/lib/data/net/serverPort.cpp
index 7d6c7388..39759776 100644
--- a/lib/data/net/serverPort.cpp
+++ b/lib/data/net/serverPort.cpp
@@ -11,8 +11,10 @@ serverPort::serverPort( SOCKET AcceptedSocket ):transportSocket(){
m_pLog = basicLogCollection::getInstance();
m_bConnected = true;
m_nSocketFD = AcceptedSocket;
- m_bInitComplete = true;
- m_bKeepAlive = true;
+ m_bKeepAlive = true;
+ if( m_bInitComplete = init() ) {
+ setConnectionStatus( CS_CONNECTED );
+ };
};
diff --git a/lib/data/protocol/protocolLGS3D.h b/lib/data/protocol/protocolLGS3D.h
index 288f1000..eefa73ab 100644
--- a/lib/data/protocol/protocolLGS3D.h
+++ b/lib/data/protocol/protocolLGS3D.h
@@ -1,5 +1,5 @@
-#ifndef __PROTOCOL_LGS_3D_HEADERS__
-#define __PROTOCOL_LGS_3D_HEADERS__
+#ifndef __PROTOCOL_LGS_3D_99sd8_HEADERS__
+#define __PROTOCOL_LGS_3D_99sd8_HEADERS__
#include "protocol.h"
#include "protocolLGS_data.h"
diff --git a/lib/data/protocol/protocolLGS3D_server.h b/lib/data/protocol/protocolLGS3D_server.h
index 7baca30f..e5e04b5d 100644
--- a/lib/data/protocol/protocolLGS3D_server.h
+++ b/lib/data/protocol/protocolLGS3D_server.h
@@ -1,9 +1,9 @@
-#ifndef __LGS_3D_SERVER_PROTOCOL_HEADER__
-#define __LGS_3D_SERVER_PROTOCOL_HEADER__
+#ifndef __LGS_3D_SERVER_PROTOCOL_32334_HEADER__
+#define __LGS_3D_SERVER_PROTOCOL_32334_HEADER__
-#include "protocolLGS3D.h"
#include "../../components/base/basicEvent.h"
#include "../../alg/lgs/mask.h"
+#include "protocolLGS3D.h"
class protocolLGS3D_Server: public protocolLGS_3D{
private: