diff --git a/Linux_Workspace.vpw b/Linux_Workspace.vpw
index 110127c0..1614899f 100644
--- a/Linux_Workspace.vpw
+++ b/Linux_Workspace.vpw
@@ -8,6 +8,7 @@
+
diff --git a/Projects/img_mill/side/workingConfig.tar.bz2 b/Projects/img_mill/side/workingConfig.tar.bz2
new file mode 100644
index 00000000..213765da
Binary files /dev/null and b/Projects/img_mill/side/workingConfig.tar.bz2 differ
diff --git a/Projects/img_slim/Debug/default.conf b/Projects/img_slim/Debug/default.conf
new file mode 100644
index 00000000..f5ac34f3
--- /dev/null
+++ b/Projects/img_slim/Debug/default.conf
@@ -0,0 +1,25 @@
+NETWORK_SERVER :
+{
+ NW_LISTEN_PORT = 2222;
+};
+KERNEL :
+{
+ DBC :
+ {
+ DATABASE_HOST = "localhost";
+ DATABASE_NAME = "dfsl_gunter";
+ DATABASE_USER = "dbroot";
+ DATABASE_PASSWORD = "123567";
+ DATABASE_PORT = 3306;
+ };
+ DNN :
+ {
+ PICTURES_BASE = "/srv/vault";
+ NET_CONFIG_FILE = "conf/yolo9000.cfg";
+ NET_WEIGHTS_FILE = "data/yolo9000.weights";
+ DETECTION_PROBABILITY = 0.5;
+ USE_CLASS_MAP = false;
+ NET_TARGET_DEVICE = "CPU";
+ NET_BACKEND_ENGINE = "DEFAULT";
+ };
+};
diff --git a/Projects/img_slim/IM_Backend.cpp b/Projects/img_slim/IM_Backend.cpp
new file mode 100644
index 00000000..6c8ffd9c
--- /dev/null
+++ b/Projects/img_slim/IM_Backend.cpp
@@ -0,0 +1,258 @@
+#include "IM_Backend.h"
+
+// Global Variables
+
+CSTR gsCFG_ADDRESS;
+uint16_t guCFG_PORT = DEFAULT_SERVER_PORT;
+CSTR gsCFG_LICENSE;
+CSTR gsCFG_DB_SERVER;
+CSTR gsCFG_DB_NAME;
+CSTR gsCFG_DB_USER;
+CSTR gsCFG_DB_PASSWORD;
+CSTR gsCFG_PID_FILE = (CSTR) DEFAULT_SERVER_PID_FILE;
+SOFTWARE_INFO gsSOFT_INFO;
+bool gbCFG_MASTER_ROLE = true;
+
+bool gModule_GeoFence_Enabled = true;
+bool gModule_SMS_Enabled = false;
+bool gModule_Email_Enabled = false;
+bool gSignal_Handler_Enabled = true;
+
+#define LOG( X ) m_pLog->Log( "main", 0, X )
+#define LOG_ERROR( X ) m_pLog->Log( "main", 0, _LOG_ERROR, X )
+
+IM_Kernel * Kernel = NULL;
+basicLogCollection * m_pLog = NULL;
+networkServer * NetworkManager = NULL;
+
+void (*old_update_handler_2)(int); //SIGINT
+void (*old_kill_handler_3)(int); //SIGQUIT
+void (*old_kill_handler_9)(int); //SIGKILL
+void (*old_alarm_handler_14)(int); //SIGALRM
+void (*old_kill_handler_15)(int); //SIGTERM
+
+
+
+
+void signal_SIGKILL_handler( int SIG ){
+ if( Kernel!= NULL ){
+ if( gSignal_Handler_Enabled ){
+ m_pLog->Log("SIG", 0, _LOG_DEBUG, "Shutdown Service by Signal" );
+ Kernel->setStatus( TH_ENDED ); // Closing all Connections;
+ } else {
+ m_pLog->Log("SIG", 0, _LOG_DEBUG, "Shutdown Signal Handler Disabled" );
+ };
+ };
+};
+
+//#include
+
+int main (int argc, char *argv[]){
+ basicSettingsProvider * SETTINGS = NULL;
+ bool WBG; // Working Background
+ bool SSE; // Server Statistics Engine
+ bool NDC; // No Default Configuration
+ CSTR FLE_NAME;
+ CSTR DCF_NAME;
+ CSTR SSP_NAME;
+ objectFileLoggingService * FLE = NULL;
+ objectConsoleLoggingService * CLE = NULL;
+ // default init
+ WBG = true;
+ FLE_NAME = (CSTR) DEFAULT_SERVER_LOG_FILE;
+ SSE = true;
+ NDC = true;
+ DCF_NAME = (CSTR) DEFAULT_SERVER_CONFIG_PATH;
+ SSP_NAME = (CSTR) DEFAULT_SERVER_SOCKET_PATH;
+ gsSOFT_INFO.SW_BUILD_DATE = UNIX_TIMESTAMP;
+ gsSOFT_INFO.DATA_VALID = false;
+ m_pLog = basicLogCollection::getInstance( _LOG_TIME );
+ gsSOFT_INFO.SW_MODE_FLAGS = 0
+#ifdef SKIP_TARGET_LOG
+ | SW_INFO_NO_TARGET_LOG
+#endif
+#ifdef HIBERNATE_ENABLE
+ | SW_INFO_HIBERNATE_ENA
+#endif
+#ifdef TGD
+ | SW_INFO_TGD_MOTORS
+ #ifdef TGD_VERSION_2
+ | SW_INFO_TGD_VER_2
+ #endif
+#endif
+#ifdef ENCODER_8192
+ | SW_INFO_EU_PROJECT
+#endif
+#ifdef NO_BLACK_TARGETS
+ | SW_INFO_NO_BLACK_TARGETS
+#endif
+#ifndef NO_MOTORS
+ | SW_INFO_MOTOR_CTRL_ENA
+#endif
+#ifdef THREADED_FLIP
+ | SW_INFO_THREAD_FLIP
+#endif
+#ifndef PRU_SLAVE
+ | SW_INFO_FLAG_MASTER
+#endif
+#ifdef DEBUG
+ | SW_INFO_DEBUG_MODE
+#endif
+ ;
+
+
+ // Reading Config
+ if( argc > 1 ){
+ for( int i = 0; i < argc; i++ ){
+ switch( argv[i][0] ){
+ case '-':
+ case '\\':
+ case '/':{
+ switch( argv[i][1] ){
+ case 'h': case 'H': case 'v': case 'V': case '?':{
+ printf( "Image Mill Neural Network Server\n");
+ printf( "Software version <%s>\n", VERSION_NUMBER );
+ printf( " -h -H This Message\n" );
+ printf( " -i -I Interactive Mode\n" );
+ return 0;
+ break;
+ };
+ case 'i': case 'I':{
+ WBG = false;
+ CLE = new objectConsoleLoggingService();
+ if( CLE != NULL ) {
+ m_pLog->addHandler( CLE );
+ };
+ break;
+ };
+ case 'c': case 'C':{
+ DCF_NAME = (CSTR) malloc( MAX_PATH_LEN );
+ if( DCF_NAME != NULL ) {
+ sprintf( DCF_NAME, "%s", argv[i+1] );
+ } else {
+ printf("ERROR!\n\n");
+ return -1;
+ };
+ break;
+ };
+ };
+ break;
+ };
+ };
+ };
+ };
+
+ FLE = new objectFileLoggingService( FLE_NAME );
+ if( FLE != NULL ) {
+ m_pLog->addHandler( FLE );
+ };
+ LOG("Starting Log Engine!");
+ if ( fileExist( DCF_NAME ) ){
+ SETTINGS = basicSettingsProvider::getInstance(DCF_NAME);
+ } else {
+ SETTINGS = basicSettingsProvider::getInstance();
+ };
+
+ // Demonizing or not
+ if( WBG ){
+ printf( "Image Mill Neural Network Server ver. %s\n", VERSION_NUMBER );
+ printf( "Configuration Applied:\n");
+ printf( " Service Established %s at %d\n", gsCFG_ADDRESS, guCFG_PORT );
+ printf( " PID File: %s\n", gsCFG_PID_FILE );
+ printf( " Log File: %s\n", FLE_NAME );
+ printf( " License: %s\n", gsCFG_LICENSE );
+ printf( " Database Server: %s Database: %s\n", gsCFG_DB_SERVER, gsCFG_DB_NAME );
+ if( NDC ){
+ printf( " No configuration file (%s) supplied.\n", DCF_NAME);
+ } else {
+ printf( " Configuration read from: %s\n", DCF_NAME );
+ };
+
+ //Demonizing
+ pid_t pid, sid;
+ sync();
+ close( STDIN_FILENO );
+ close( STDOUT_FILENO );
+ close( STDERR_FILENO );
+
+ pid = fork();
+ if( pid < 0 ){
+ return pid;
+ };
+ if( pid > 0 ){
+ return 0;
+ };
+ //umask(0);
+ sid = setsid();
+ if (sid < 0) {
+ return sid;
+ };
+
+ pid = fork();
+ if( pid < 0 ){
+ return pid;
+ };
+ if( pid > 0 ){
+ FILE *pPIDF = fopen( gsCFG_PID_FILE, "w+" );
+ if( pPIDF ){
+ fprintf( pPIDF, "%d\n", pid );
+ fclose( pPIDF );
+ }
+ return 0;
+ };
+ };
+
+ uint8_t m_bKernelExitCode = 0;
+
+ NetworkManager = new networkServer();
+ if( NetworkManager != NULL ) {
+ if( NetworkManager->BootUp() ){
+ LOG("Net Service is UP");
+ } else {
+ delete(NetworkManager);
+ NetworkManager = NULL;
+ };
+ };
+ do{
+ //Loop till some Restart action
+ Kernel = IM_Kernel::getInstance();
+ if( Kernel == NULL ) {
+ // Aborting Work
+ LOG_ERROR( "++++ Kernel failed to born ++++" );
+ unlink( gsCFG_PID_FILE );
+ LOG( "PID File Deleted" );
+ delete( m_pLog );
+ return -1;
+ } else {
+ if ( Kernel->start() == false ){
+ LOG_ERROR("Kernel create failure!");
+ } else {
+ LOG( "++++ Server Started ++++" );
+ if( NetworkManager!= NULL ) {
+ NetworkManager->attachEngine( Kernel );
+ };
+ //Install Signal Listeners
+ old_kill_handler_15 = signal( 15, signal_SIGKILL_handler );
+ old_kill_handler_9 = signal( 9, signal_SIGKILL_handler );
+ // Waiting for Worker to Shut Down
+ Kernel->stop( false );
+ m_bKernelExitCode = Kernel->getExitCause();
+ signal( 9, old_kill_handler_9 );
+ signal( 15, old_kill_handler_15 );
+ };
+ //Since Kernel is Singletone Object no need to delete
+ delete( Kernel );
+ LOG( "++++ Server Ended ++++" );
+ };
+ } while( m_bKernelExitCode > 0 );
+
+ if( NetworkManager ) delete( NetworkManager );
+ //LOG( "++++ CDC DEL ++++" );
+ unlink( gsCFG_PID_FILE );
+ LOG( "PID File Deleted" );
+ if( FLE!= NULL ) delete( FLE );
+ if( CLE!= NULL ) delete( CLE );
+ delete( m_pLog );
+ return(0);
+}
+
diff --git a/Projects/img_slim/IM_Backend.h b/Projects/img_slim/IM_Backend.h
new file mode 100644
index 00000000..4db45f83
--- /dev/null
+++ b/Projects/img_slim/IM_Backend.h
@@ -0,0 +1,48 @@
+/*******************************************************************
+*
+* DESCRIPTION: Iage Mill project main header file
+*
+* AUTHOR: Gagua
+*
+* HISTORY:
+*
+* DATE:5/29/2019
+*
+*******************************************************************/
+#ifndef __IMG_MILL_BACKEND_MAIN_HEADER__
+#define __IMG_MILL_BACKEND_MAIN_HEADER__
+
+/** include files **/
+
+#include
+#include
+#include
+
+#include "../../lib/components/base/basicSettings.h"
+#include "../../lib/components/base/basicLogCollection.h"
+#include "../../lib/components/base/basicMemoryOperation.h"
+#include "../../lib/components/object/objectFileLoggingService.h"
+#include "../../lib/components/object/objectConsoleLoggingService.h"
+#include "../../lib/data/net/netServer.h"
+//#include "../../lib/data/mysql/database_class.h"
+#include "IM_Kernel.h"
+
+/** local definitions **/
+//http://xmsecu.com:8080/ocx/NewActive.exe
+/* default settings */
+
+/** external functions **/
+
+/** external data **/
+
+/** internal functions **/
+
+/** public data **/
+
+/** private data **/
+
+/** public functions **/
+
+/** private functions **/
+
+#endif
diff --git a/Projects/img_slim/IM_ClientHandler.cpp b/Projects/img_slim/IM_ClientHandler.cpp
new file mode 100644
index 00000000..69629f90
--- /dev/null
+++ b/Projects/img_slim/IM_ClientHandler.cpp
@@ -0,0 +1,230 @@
+#include "IM_ClientHandler.h"
+#include "IM_Kernel.h"
+
+#include "../../lib/components/base/basicFunctionality.h"
+#include "../../lib/data/json/json_tool.h"
+#include "../../lib/data/protocol/xmlParser.h"
+
+#include
+#include
+#include
+#include
+
+
+
+#define LOG( X ) m_pLog->Log( "NCH", 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( "NCH", this, _LOG_ERROR, _tBfrErrMSG234 );\
+ }
+#else
+ #define LOG_ERROR( X ) m_pLog->Log( "NCH", this, _LOG_ERROR, X );
+#endif
+
+// Constructor implementation
+IM_ClientHandler::IM_ClientHandler( int SOCKET, networkServiceEngine *ptr ) : networkClientHandler( SOCKET, ptr ), IM_ClientProtocol(){
+ m_pLog = basicLogCollection::getInstance();
+ m_pDBA = IM_DataBaseAdapter::getInstance();
+ m_pMyCurrentJob = NULL;
+ if( create() ){
+ m_pPort = new serverPort( SOCKET );
+ if( m_pPort != NULL ){
+ setTransport( m_pPort );
+#ifdef DEBUG
+ LOG("Port Created OK!");
+#endif
+ if( m_pPort->create() ){
+ LOG("Port Init OK!");
+ } else LOG_ERROR("Not Connected!");
+ } else LOG_ERROR("Port Not Created!");
+ } else LOG_ERROR( "Protocol Parser Creation Failed!");
+};
+
+// Destructor implementation
+IM_ClientHandler::~IM_ClientHandler(){
+ if( m_pPort != NULL ) delete( m_pPort );
+ if( m_pMyCurrentJob ) free( (IM_JOB *)m_pMyCurrentJob );
+};
+
+bool IM_ClientHandler::getStatus( void ){
+ if( m_pPort!= NULL ) {
+ return m_pPort->getStatus();
+ };
+ return false;
+};
+
+bool IM_ClientHandler::handleItem( IM_ITEM_DATA *ptr ){
+ if( ptr ) {
+ if( m_pEngine != NULL ) {
+ IM_Kernel *tKernel = (IM_Kernel *)m_pEngine;
+ IM_JOB *tJOB;
+ tJOB = (IM_JOB*)malloc(sizeof(IM_JOB));
+ if( tJOB ) {
+ if( m_pMyCurrentJob ) {
+ LOG("CLEANNING UNCLEAN JOB!");
+ //AnyWay Clean Memory that was Used!
+ free((IM_JOB *)m_pMyCurrentJob);
+ };
+ m_pMyCurrentJob = (void*) tJOB;
+ memset( tJOB, 0 , sizeof(IM_JOB));
+ tJOB->dbID = ptr->item_id;
+ tJOB->image_type = ptr->type;
+ tJOB->job_type = ptr->process_type;
+ tJOB->width = ptr->width;
+ tJOB->height = ptr->height;
+ memcpy( tJOB->md5, ptr->md5, 32 );
+ tKernel->enqueueJob( tJOB );
+ };
+ };
+ free( ptr );
+ };
+ return true;
+};
+
+bool IM_ClientHandler::packetHandler( protocolPackage *Package ){
+ if( Package ) {
+ if( Package->m_pData ) {
+ if (Package->m_nSize > 3 ) {
+ if( Package->m_pData[Package->m_nSize-4] == 13 ) Package->m_pData[Package->m_nSize-4] = 0;
+ if( Package->m_pData[Package->m_nSize-3] == 10 ) Package->m_pData[Package->m_nSize-3] = 0;
+ }
+ Package->m_pData[Package->m_nSize-2] = 0;
+ Package->m_pData[Package->m_nSize-1] = 0;
+ LOG( (CSTR) Package->m_pData );
+ try{
+ XMLNode node1 = XMLNode::parseString( (const char *)Package->m_pData, "root");
+ if( !node1.isEmpty() ){
+ LOG( node1.getName() );
+ if( strstr(node1.getName(),"ClockSync")!=NULL ){
+#ifdef __linux__
+ unsigned long long t0, t1, t2, t3;
+#else
+ unsigned __int64 t0, t1, t2, t3;
+#endif
+ XMLNode node3 = node1.getChildNode("t0", 0);
+ XMLNode node4 = node1.getChildNode("t1", 0);
+ XMLNode node5 = node1.getChildNode("t2", 0);
+/*
+ t3 = getSHDTimeValue();
+#ifdef __linux__
+ t0 = atoll(node3.getText(0));
+ t1 = atoll(node4.getText(0));
+ t2 = atoll(node5.getText(0));
+#else
+ t0 = _atoi64(node3.getText(0));
+ t1 = _atoi64(node4.getText(0));
+ t2 = _atoi64(node5.getText(0));
+#endif
+ int offset = ((t1-t0)+(t2-t3))/2;
+ int latency = (t3-t0)-(t2-t1);
+ int jagajaga = offset+latency;
+ //if( 0 & correctSHTime( jagajaga ) ){
+ // LOG("Time is Synced");
+ // g_iTimeDiff = 0;
+ //} else {
+ // LOG_ERROR("Time Sync Unucessfull - Will use DIFF!");
+ g_iTimeDiff = jagajaga;
+ //};
+*/
+ };
+ };
+ } catch( exception e ){
+ LOG_ERROR("Some Error in XML Parser!");
+ };
+ // JSON Parsing
+ try{
+ Json::Value root;
+ Json::Reader reader;
+ if( !reader.parse( (char *)Package->m_pData, root ) ){
+ LOG_ERROR( "The package data is nor a valid JSON data nor valid XML data" );
+ return true;
+ };
+ if( root.size() ){
+ IM_ITEM_DATA * tData = NULL;
+ Json::Value tVal;
+
+ tVal = root["item_id"];
+
+ if( tVal != NULL ){
+ int itemID = atoi( tVal.asString().c_str() ) ;
+ if( itemID > 0 ) {
+ tData = m_pDBA->getItemDataById( itemID );
+ if( tData!= NULL ) tData->process_type = IM_PROC_TYPE_DNN;
+ };
+ };
+
+ tVal = root["item_md5"];
+ if( tVal != NULL ){
+ if( strlen( tVal.asString().c_str())== 32 ){
+ tData = m_pDBA->getItemDataByMd5( (CSTR) tVal.asString().c_str() );
+ if( tData!= NULL ) tData->process_type = IM_PROC_TYPE_DNN;
+ };
+ };
+
+ tVal = root["process_type"];
+ if( tVal != NULL ){
+ if( tData!= NULL ) tData->process_type = atoi( tVal.asString().c_str());
+ };
+
+ if( tData!= NULL ){
+ return handleItem( tData );
+ } else {
+ m_pPort->sendData( (uint8_t *) "{\"STATUS\":\"ERROR\"}\n", 19 );
+ }
+ };
+ } catch ( exception e ){
+ LOG_ERROR("Some Error in JSON Parser!");
+ m_pPort->sendData( (uint8_t *) "{\"STATUS\":\"ERROR\"}\n", 19 );
+ };
+ };
+ };
+ return true;
+};
+
+bool IM_ClientHandler::dispatchEvent( EVENT_CONTAINER *Evt ){
+ if( Evt!= NULL ) {
+ if( Evt->m_eClass == EVT_CLASS_IMAGE ){
+ if( Evt->m_eType == EVT_READY ){
+ IM_RESULT *tData = (IM_RESULT*) Evt->m_pEvtData;
+ if( tData!= NULL ) {
+ if( tData->pJOB == m_pMyCurrentJob ) {
+ LOG("JOB Finished Sucessfully!");
+ for( int i=0; i < tData->nBoxCount; i++ ){
+ m_pDBA->insertItemROI(
+ tData->pJOB->dbID,
+ tData->boxes[i].classID,
+ tData->boxes[i].weight,
+ tData->boxes[i].x,
+ tData->boxes[i].y,
+ tData->boxes[i].width,
+ tData->boxes[i].height
+ );
+ };
+ //handle finished Job
+ free( (IM_JOB *)m_pMyCurrentJob );
+ m_pMyCurrentJob = NULL;
+ free( (IM_CLASS_BOUNDARY_BOX *)tData->boxes );
+ free( (IM_RESULT *)Evt->m_pEvtData );
+ Evt->m_pEvtData = NULL;
+ m_pPort->sendData( (uint8_t *) "{\"STATUS\":\"OK\"}\n", 16 );
+ };
+ } else {
+ LOG("JOB Finished Without Detection!");
+ free( (IM_JOB *)m_pMyCurrentJob );
+ m_pMyCurrentJob = NULL;
+ m_pPort->sendData( (uint8_t *) "{\"STATUS\":\"ERROR\"}\n", 19 );
+ };
+ };
+ };
+ return true;
+ };
+ return false;
+};
+
+
+#undef LOG
+#undef LOG_ERROR
+
+
diff --git a/Projects/img_slim/IM_ClientHandler.h b/Projects/img_slim/IM_ClientHandler.h
new file mode 100644
index 00000000..15771f4b
--- /dev/null
+++ b/Projects/img_slim/IM_ClientHandler.h
@@ -0,0 +1,34 @@
+#ifndef __IM_CLIENTHANDLER_H_INCL__
+#define __IM_CLIENTHANDLER_H_INCL__
+
+#include "../../lib/data/net/netClientHandler.h"
+#include "IM_ClientProtocol.h"
+#include "IM_DataBaseAdapter.h"
+
+
+/**
+ * TODO: Add class description
+ *
+ * @author Gagua
+ */
+class IM_ClientHandler : public networkClientHandler, public IM_ClientProtocol{
+ private:
+ basicLogCollection * m_pLog;
+ void * m_pMyCurrentJob;
+ IM_DataBaseAdapter * m_pDBA;
+ protected:
+ virtual bool packetHandler( protocolPackage *Package );
+ public:
+ // Constructor
+ explicit IM_ClientHandler( int SOCKET, networkServiceEngine *ptr=NULL );
+
+ // Destructor
+ virtual ~IM_ClientHandler();
+ virtual bool getStatus( void );
+ bool handleItem( IM_ITEM_DATA *ptr );
+ virtual bool dispatchEvent( EVENT_CONTAINER *Evt );
+};
+
+
+
+#endif // __IM_CLIENTHANDLER_H_INCL__
diff --git a/Projects/img_slim/IM_ClientProtocol.cpp b/Projects/img_slim/IM_ClientProtocol.cpp
new file mode 100644
index 00000000..48a1e802
--- /dev/null
+++ b/Projects/img_slim/IM_ClientProtocol.cpp
@@ -0,0 +1,57 @@
+#include "IM_ClientProtocol.h"
+
+#define LOG( X ) m_pLog->Log( "NCP", 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( "NCP", this, _LOG_ERROR, _tBfrErrMSG234 );\
+ }
+#else
+ #define LOG_ERROR( X ) m_pLog->Log( "NCP", this, _LOG_ERROR, X );
+#endif
+
+// Constructor implementation
+IM_ClientProtocol::IM_ClientProtocol() : protocolParser(){
+
+};
+
+// Destructor implementation
+IM_ClientProtocol::~IM_ClientProtocol(){
+
+};
+
+int IM_ClientProtocol::packetChecker(U8 *Buffer, size_t BufferSize){
+ // double enter -> finish package
+ if( BufferSize > 2 ){
+ if( ( Buffer[BufferSize-2] == 13 ) && ( Buffer[BufferSize-1] == 13 ) ) return 0;
+ };
+ if( BufferSize > 3 ){
+ if( ( Buffer[BufferSize-4] == 13 ) && ( Buffer[BufferSize-3] == 10 ) && ( Buffer[BufferSize-2] == 13 ) && ( Buffer[BufferSize-1] == 10 ) ) return 0;
+ };
+ return 1;
+};
+
+protocolPackage *IM_ClientProtocol::packetExtractor(U8 *Buffer, size_t BufferSize){
+ protocolPackage *tVal = NULL;
+ tVal = (protocolPackage *) malloc( sizeof(protocolPackage));
+ if(tVal) {
+ tVal->m_pData = (U8*)malloc( BufferSize+1 );
+ if( tVal->m_pData ) {
+ tVal->m_nCode = 200;
+ tVal->m_nSize = BufferSize;
+ memcpy( tVal->m_pData, Buffer, BufferSize );
+ tVal->m_pData[BufferSize]=0;
+ } else {
+ free( tVal );
+ tVal = NULL;
+ };
+ };
+ return tVal;
+};
+
+
+
+#undef LOG
+#undef LOG_ERROR
+
diff --git a/Projects/img_slim/IM_ClientProtocol.h b/Projects/img_slim/IM_ClientProtocol.h
new file mode 100644
index 00000000..41a88538
--- /dev/null
+++ b/Projects/img_slim/IM_ClientProtocol.h
@@ -0,0 +1,24 @@
+#ifndef __IM_CLIENTPROTOCOL_H_INCL__
+#define __IM_CLIENTPROTOCOL_H_INCL__
+
+#include "../../lib/data/protocol/protocol.h"
+
+/**
+ * TODO: Add class description
+ *
+ * @author Gagua
+ */
+class IM_ClientProtocol : public protocolParser {
+ protected:
+ virtual int packetChecker(U8 *Buffer, size_t BufferSize);
+ virtual protocolPackage *packetExtractor(U8 *Buffer, size_t BufferSize);
+ virtual bool packetHandler( protocolPackage *Package ){ return false; };
+ public:
+ // Constructor
+ IM_ClientProtocol();
+
+ // Destructor
+ virtual ~IM_ClientProtocol();
+};
+
+#endif // __IM_CLIENTPROTOCOL_H_INCL__
diff --git a/Projects/img_slim/IM_DLibWorker.cpp b/Projects/img_slim/IM_DLibWorker.cpp
new file mode 100644
index 00000000..b45eac56
--- /dev/null
+++ b/Projects/img_slim/IM_DLibWorker.cpp
@@ -0,0 +1,476 @@
+#include "IM_DLibWorker.h"
+#include
+#include "../../lib/alg/generic/md5.h"
+#include "../../lib/components/base/basicFunctionality.h"
+
+#define LOG( X ) m_pLog->Log( "WDLIB", 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( "WDLIB", this, _LOG_ERROR, _tBfrErrMSG234 );\
+ }
+#else
+ #define LOG_ERROR( X ) m_pLog->Log( "WDLIB", this, _LOG_ERROR, X );
+#endif
+
+
+
+// Constructor implementation
+IM_DlibWorker::IM_DlibWorker( config_setting_t * Settings ) : basicThread(), m_mBufferProtectorMutex(){
+ m_pLog = basicLogCollection::getInstance();
+ m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "DLIB" );
+ m_pEvtHeap = basicEventHeap::getInstance();
+ m_pDBA = IM_DataBaseAdapter::getInstance();
+
+// m_eBackendEngine = cv::dnn::DNN_BACKEND_DEFAULT;
+// m_eTargetDevice = cv::dnn::DNN_TARGET_CPU;
+ m_pActiveJob = NULL;
+
+#ifdef DARKNET
+ m_pDarknetDetector = NULL;
+#endif
+ m_fDetectionProbability = .7f;
+ m_bUseShapePredictor = false;
+ m_bUseFaceRecognition = false;
+ m_bDataIsActive = false;
+};
+
+// Destructor implementation
+IM_DlibWorker::~IM_DlibWorker(){
+#ifdef DARKNET
+ if( m_pDarknetDetector ) delete( m_pDarknetDetector );
+#endif
+};
+
+bool IM_DlibWorker::create( void ){
+ char tBuff[256];
+ if( m_pSettings == NULL ){
+ return false;
+ } else {
+ config_setting_t * tSetting;
+ tSetting = config_setting_get_member( m_pSettings, "PICTURES_BASE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "PICTURES_BASE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "/srv/vault" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Pictures Base Path! Using default!");
+ };
+ sprintf( m_pPicturesBase, "%s", config_setting_get_string(tSetting));
+ tSetting = config_setting_get_member( m_pSettings, "FACEES_BASE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "FACEES_BASE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "/srv/vault/faces" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Face Pictures Base Path! Using default!");
+ };
+ sprintf( m_pFacesBase, "%s", config_setting_get_string(tSetting));
+ tSetting = config_setting_get_member( m_pSettings, "USE_SHAPE_PREDICTOR" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "USE_SHAPE_PREDICTOR", CONFIG_TYPE_BOOL );
+ config_setting_set_bool( tSetting, 0 );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Class Map Usage Set! Using default!");
+ };
+ m_bUseShapePredictor = (bool) config_setting_get_bool(tSetting);
+ if( m_bUseShapePredictor ) {
+ tSetting = config_setting_get_member( m_pSettings, "USE_FACE_RECOGNITION" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "USE_FACE_RECOGNITION", CONFIG_TYPE_BOOL );
+ config_setting_set_bool( tSetting, 0 );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Class Map Usage Set! Using default!");
+ };
+ m_bUseFaceRecognition = (bool) config_setting_get_bool(tSetting);
+
+ tSetting = config_setting_get_member( m_pSettings, "SHAPE_PREDICTOR_LANDMARKS" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "SHAPE_PREDICTOR_LANDMARKS", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "data/shape_predictor_5_face_landmarks.dat" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Net Config File! Using default!");
+ };
+ sprintf( m_pShapePredictorPath, "%s", config_setting_get_string(tSetting));
+ if( m_bUseFaceRecognition ) {
+ tSetting = config_setting_get_member( m_pSettings, "NET_CONFIG_FILE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "NET_CONFIG_FILE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "data/dlib_face_recognition_resnet_model_v1.dat" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Net Weights File! Using default!");
+ };
+ sprintf( m_pNetModelPath, "%s", config_setting_get_string(tSetting));
+ };
+ } else m_bUseFaceRecognition = false;
+
+ tSetting = config_setting_get_member( m_pSettings, "DETECTION_PROBABILITY" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "DETECTION_PROBABILITY", CONFIG_TYPE_FLOAT );
+ config_setting_set_float( tSetting, 0.5f );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Probability Set! Using default!");
+ };
+ m_fDetectionProbability = config_setting_get_float(tSetting);
+
+ tSetting = config_setting_get_member( m_pSettings, "OUTPUT_CHOWN_USER" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "OUTPUT_CHOWN_USER", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "www-data" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No CHOWN USER! Using default!");
+ };
+ sprintf( m_sChownUser, "%s", config_setting_get_string(tSetting));
+
+ tSetting = config_setting_get_member( m_pSettings, "OUTPUT_CHOWN_GROUP" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "OUTPUT_CHOWN_GROUP", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "www-data" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No CHOWN GROUP! Using default!");
+ };
+ sprintf( m_sChownGroup, "%s", config_setting_get_string(tSetting));
+
+
+ /*
+ tSetting = config_setting_get_member( m_pSettings, "USE_CLASS_MAP" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "USE_CLASS_MAP", CONFIG_TYPE_BOOL );
+ config_setting_set_bool( tSetting, 0 );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Class Map Usage Set! Using default!");
+ };
+ m_bUseClassMapping = (bool) config_setting_get_bool(tSetting);
+ if( m_bUseClassMapping ) {
+ char tMapFileName[1024];
+ FILE *fd;
+ tSetting = config_setting_get_member( m_pSettings, "CLASS_MAP_FILE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "CLASS_MAP_FILE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "data/coco9k.map" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Class Map File Set! Using default!");
+ };
+ sprintf( tMapFileName, "%s", config_setting_get_string(tSetting) );
+ fd = fopen( tMapFileName, "r" );
+ if( fd ) {
+ uint32_t tV;
+ uint32_t idx = 0;
+ char tB[128];
+ while( !feof(fd) ) {
+ if( fgets( tB, 128, fd ) ){
+ tV = atoi( tB )+1;
+ m_vClassesMap.push_back( tV );
+ idx++;
+ };
+ };
+ fclose( fd );
+ sprintf( tB, "Loadded %d classes map", idx );
+ LOG( tB );
+ } else {
+ m_bUseClassMapping = false;
+ };
+ };
+ tSetting = config_setting_get_member( m_pSettings, "NET_TARGET_DEVICE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "NET_TARGET_DEVICE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "CPU" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Net Target Device! Using default!");
+ };
+ if( strstr( config_setting_get_string(tSetting), "CPU" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_CPU;
+ if( strstr( config_setting_get_string(tSetting), "OPENCL_FP16" )!=NULL ){
+ m_eTargetDevice = cv::dnn::DNN_TARGET_OPENCL_FP16;
+ } else {
+ if( strstr( config_setting_get_string(tSetting), "OPENCL" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_OPENCL;
+ };
+ if( strstr( config_setting_get_string(tSetting), "MYRIAD" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_MYRIAD;
+ if( strstr( config_setting_get_string(tSetting), "VULKAN" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_VULKAN;
+ if( strstr( config_setting_get_string(tSetting), "FPGA" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_FPGA;
+ if( strstr( config_setting_get_string(tSetting), "CUDA_FP16" )!=NULL ){
+ m_eTargetDevice = cv::dnn::DNN_TARGET_CUDA_FP16;
+ } else {
+ if( strstr( config_setting_get_string(tSetting), "CUDA" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_CUDA;
+ };
+ if( strstr( config_setting_get_string(tSetting), "HDDL" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_HDDL;
+ sprintf( tBuff, "Device: %s", config_setting_get_string(tSetting) );
+ LOG( tBuff );
+
+ tSetting = config_setting_get_member( m_pSettings, "NET_BACKEND_ENGINE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "NET_BACKEND_ENGINE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "DEFAULT" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Net Backend Engine! Using default!");
+ };
+ if( strstr( config_setting_get_string(tSetting), "DEFAULT" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_DEFAULT;
+ if( strstr( config_setting_get_string(tSetting), "HALIDE" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_HALIDE;
+ if( strstr( config_setting_get_string(tSetting), "INFERENCE" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_INFERENCE_ENGINE;
+ if( strstr( config_setting_get_string(tSetting), "OPENCV" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_OPENCV;
+ if( strstr( config_setting_get_string(tSetting), "VKCOM" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_VKCOM;
+ if( strstr( config_setting_get_string(tSetting), "CUDA" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_CUDA;
+ sprintf( tBuff, "Engine: %s", config_setting_get_string(tSetting) );
+ LOG( tBuff );
+ */
+ basicSettingsProvider::getInstance()->validate();
+ };
+ if( m_bUseShapePredictor ) {
+ if( m_bUseFaceRecognition ) {
+ sprintf( tBuff, "loading Data from disk... Shape: %s Face: %s", m_pShapePredictorPath, m_pNetModelPath );
+ } else {
+ sprintf( tBuff, "loading Data from disk... Shape Predictor: %s ", m_pShapePredictorPath );
+ };
+ LOG( tBuff );
+ if(!fileExist( m_pShapePredictorPath )) {
+ LOG_ERROR("No Shape Predictor file exists!");
+ return false;
+ };
+ if( m_bUseFaceRecognition ) {
+ if(!fileExist( m_pNetModelPath )) {
+ LOG_ERROR("No Net Model file exists!");
+ return false;
+ };
+ }
+ }
+
+ m_oFaceDetector = get_frontal_face_detector();
+
+ if( m_bUseShapePredictor ) {
+
+ deserialize( m_pShapePredictorPath ) >> m_oShapePredictor;
+
+ if( m_bUseFaceRecognition ) {
+
+ deserialize( m_pNetModelPath ) >> m_oNet;
+
+ };
+ };
+
+ return init();
+};
+
+std::vector> jitter_image( const matrix& img ){
+ // All this function does is make 100 copies of img, all slightly jittered by being
+ // zoomed, rotated, and translated a little bit differently. They are also randomly
+ // mirrored left to right.
+ thread_local dlib::rand rnd;
+
+ std::vector> crops;
+ for (int i = 0; i < 100; ++i)
+ crops.push_back(jitter_image(img,rnd));
+
+ return crops;
+};
+
+CSTR IM_DlibWorker::m_fSaveFace( matrix &Picture, CSTR md5, uint32_t index ){
+ char tPathSrc[1024];
+ char tPathDest[1024];
+ CSTR nMd5;
+ CSTR nPath;
+ sprintf( tPathSrc, "%s/%s_%d.jpg", m_pFacesBase, md5, index );
+ LOG("Save Face");
+ LOG( tPathSrc );
+ save_jpeg( Picture, tPathSrc, 75 );
+ nMd5 = MD5File( tPathSrc );
+ nPath = buildMd5Path( m_pFacesBase, nMd5, 0755, m_sChownUser, m_sChownGroup );
+ sprintf( tPathDest, "%s/%s.jpg", nPath, nMd5 );
+ free( nPath );
+ //fileCopy( tPathSrc, tPathDest );
+ //remove( tPathSrc );
+ rename ( tPathSrc, tPathDest );
+ ch_chown( tPathDest, m_sChownUser, m_sChownGroup );
+ return nMd5;
+};
+
+IM_RESULT *IM_DlibWorker::m_fImageAnalyzer( cv::Mat &Pic ){
+ IM_RESULT * retVal = NULL;
+ cv_image Picture(Pic);
+ std::vector> faces;
+ std::vector dbIDs;
+ uint32_t idx = 0;
+ CSTR tVAL = NULL;
+ for( auto face : m_oFaceDetector( Picture ) ){
+ //dlib::rectangle face
+ if( m_bUseShapePredictor ) {
+ auto shape = m_oShapePredictor( Picture, face );
+ matrix face_chip;
+ extract_image_chip( Picture, get_face_chip_details( shape, 150, 0.25 ), face_chip );
+ tVAL = m_fSaveFace( face_chip, m_pActiveJob->md5, idx );
+ faces.push_back( move( face_chip ) );
+ } else {
+ matrix face_chip;
+ extract_image_chip( Picture, face, face_chip );
+ tVAL = m_fSaveFace( face_chip, m_pActiveJob->md5, idx );
+ };
+ if( tVAL!= NULL ) {
+ uint32_t tID;
+ tID = m_pDBA->insertItemFace( m_pActiveJob->dbID, tVAL, face.left(), face.top(), face.width(), face.height() );
+ dbIDs.push_back( tID );
+
+ char tB[64];
+ sprintf(tB,"ID:%d", tID);
+ LOG(tB);
+
+ free( tVAL );
+ tVAL = NULL;
+ };
+ idx++;
+ };
+
+ if( m_bUseShapePredictor ) {
+ //if (faces.size() == 0){
+ // cout << "No faces found in image!" << endl;
+ // return 1;
+ //}
+ if( m_bUseFaceRecognition ) {
+ // This call asks the DNN to convert each face image in faces into a 128D vector.
+ // In this 128D vector space, images from the same person will be close to each other
+ // but vectors from different people will be far apart. So we can use these vectors to
+ // identify if a pair of images are from the same person or from different people.
+ if( faces.size() ) {
+ //LOG("Have Detected Faces!");
+ //std::vector> face_descriptors = m_oNet( faces );
+ try{
+ for( int idx = 0; idx < faces.size(); idx++ ) {
+ matrix face_descriptor = mean( mat( m_oNet( jitter_image( faces[idx] ) ) ) );
+ //matrix face_descriptor = m_oNet( faces[0] );
+ //LOG("Classification Done!");
+ for( int i = 0; i < face_descriptor.size(); i++ ) m_pDBA->updateItemFace( dbIDs[idx], i, face_descriptor( i, 0 ) );
+ };
+ } catch ( std::exception& e ){
+ LOG_ERROR( e.what() );
+ };
+ } else {
+ LOG("No Faces Found!");
+ };
+
+ //std::vector> face_descriptors = m_oNet( faces );
+
+ // In particular, one simple thing we can do is face clustering. This next bit of code
+ // creates a graph of connected faces and then uses the Chinese whispers graph clustering
+ // algorithm to identify how many people there are and which faces belong to whom.
+ /*
+ std::vector edges;
+ for (size_t i = 0; i < face_descriptors.size(); ++i){
+ for (size_t j = i; j < face_descriptors.size(); ++j){
+ // Faces are connected in the graph if they are close enough. Here we check if
+ // the distance between two face descriptors is less than 0.6, which is the
+ // decision threshold the network was trained to use. Although you can
+ // certainly use any other threshold you find useful.
+ if (length(face_descriptors[i]-face_descriptors[j]) < 0.6)
+ edges.push_back(sample_pair(i,j));
+ };
+ };
+ std::vector labels;
+ const auto num_clusters = chinese_whispers(edges, labels);
+ */
+ // This will correctly indicate that there are 4 people in the image.
+ //cout << "number of people found in the image: "<< num_clusters << endl;
+
+
+ // Now let's display the face clustering results on the screen. You will see that it
+ // correctly grouped all the faces.
+ /*
+ std::vector win_clusters(num_clusters);
+ for( size_t cluster_id = 0; cluster_id < num_clusters; ++cluster_id ){
+ std::vector> temp;
+ for( size_t j = 0; j < labels.size(); ++j ){
+ if (cluster_id == labels[j]) temp.push_back(faces[j]);
+ };
+ win_clusters[cluster_id].set_title("face cluster " + cast_to_string(cluster_id));
+ win_clusters[cluster_id].set_image(tile_images(temp));
+ };
+
+ // Finally, let's print one of the face descriptors to the screen.
+ cout << "face descriptor for one face: " << trans(face_descriptors[0]) << endl;
+
+ // It should also be noted that face recognition accuracy can be improved if jittering
+ // is used when creating face descriptors. In particular, to get 99.38% on the LFW
+ // benchmark you need to use the jitter_image() routine to compute the descriptors,
+ // like so:
+ matrix face_descriptor = mean(mat(net(jitter_image(faces[0]))));
+ cout << "jittered face descriptor for one face: " << trans(face_descriptor) << endl;
+ // If you use the model without jittering, as we did when clustering the bald guys, it
+ // gets an accuracy of 99.13% on the LFW benchmark. So jittering makes the whole
+ // procedure a little more accurate but makes face descriptor calculation slower.
+ */
+ };
+ };
+ return retVal;
+};
+
+void IM_DlibWorker::m_fThreadProc( void ){
+ m_bThreadStatus = TH_WORKING;
+ EVENT_CONTAINER *EVT_PTR = NULL;
+ while( m_bThreadStatus < TH_ENDED ) {
+ while (!m_bDataIsActive && m_bThreadStatus < TH_ENDED ) SLEEP( 20 );
+ if( m_mBufferProtectorMutex.try_lock() ){
+ if( m_bDataIsActive ){
+ EVT_PTR =(EVENT_CONTAINER *) malloc(sizeof(EVENT_CONTAINER));
+ if( EVT_PTR ) {
+ memset( EVT_PTR, 0, sizeof(EVENT_CONTAINER));
+ EVT_PTR->m_eClass = EVT_CLASS_IMAGE;
+ EVT_PTR->m_eType = EVT_READY;
+ if( IM_RESULT *tData = m_fImageAnalyzer( m_oWorkingMat ) ){
+ //generate detection event
+ EVT_PTR->m_pEvtData = tData;
+ } else {
+ //generate NOT detection event
+ EVT_PTR->m_pEvtData = NULL;
+ };
+ };
+ m_pActiveJob = NULL;
+ m_bDataIsActive = false;
+ };
+ m_mBufferProtectorMutex.unlock();
+ };
+ if( EVT_PTR != NULL ) {
+ m_pEvtHeap->broadcast( EVT_PTR );
+ EVT_PTR = NULL;
+ };
+ };
+};
+
+bool IM_DlibWorker::enqueueJob( IM_JOB *ptr ){
+ if( ptr ) {
+ char tPath[1024];
+ char p1[3];
+ char p2[3];
+ char p3[3];
+ LOG( ptr->md5 );
+ memcpy( p1, ptr->md5 , 2); p1[2]=(char)0;
+ memcpy( p2, ptr->md5+2, 2); p2[2]=(char)0;
+ memcpy( p3, ptr->md5+4, 2); p3[2]=(char)0;
+ switch( ptr->image_type ) {
+ case IM_ITEM_TYPE_JPEG: sprintf( tPath, "%s/%s/%s/%s/%s.jpg", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ case IM_ITEM_TYPE_PNG: sprintf( tPath, "%s/%s/%s/%s/%s.png", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ case IM_ITEM_TYPE_GIF: sprintf( tPath, "%s/%s/%s/%s/%s.gif", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ case IM_ITEM_TYPE_AGIF: sprintf( tPath, "%s/%s/%s/%s/%s.gif", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ case IM_ITEM_TYPE_TIFF: sprintf( tPath, "%s/%s/%s/%s/%s.tiff", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ };
+#ifdef DEBUG
+ LOG( tPath );
+#endif
+ Mat Frame = cv::imread( tPath, IMREAD_COLOR );
+ try{
+ while( m_bThreadStatus < TH_ENDED ) {
+ if( m_mBufferProtectorMutex.try_lock() ) {
+ Frame.copyTo( m_oWorkingMat );
+#ifdef DEBUG
+ cv::imwrite("cur-test-img.jpg", m_oWorkingMat );
+ //save_jpeg( m_oInputImg, "cur-test-img.jpg", 75 );
+#endif
+ m_bDataIsActive = true;
+ m_pActiveJob = ptr;
+ m_mBufferProtectorMutex.unlock();
+ return true;
+ } else SLEEP(5);
+ };
+ } catch ( exception e ){
+ LOG_ERROR( "Failure during Image Read!" );
+ };
+ };
+ return false;
+};
+
+#undef LOG
+#undef LOG_ERROR
diff --git a/Projects/img_slim/IM_DLibWorker.h b/Projects/img_slim/IM_DLibWorker.h
new file mode 100644
index 00000000..ae0b9992
--- /dev/null
+++ b/Projects/img_slim/IM_DLibWorker.h
@@ -0,0 +1,118 @@
+#ifndef __IMAGE_MILL_DLIB_WORKER_HEADER__
+#define __IMAGE_MILL_DLIB_WORKER_HEADER__
+
+#include "../../lib/components/base/basicThread.h"
+#include "../../lib/components/base/basicMutex.h"
+#include "../../lib/components/base/basicSettingsProvider.h"
+#include "../../lib/components/base/basicEventHeap.h"
+
+#include "IM_DataStructs.h"
+#include "IM_DataBaseAdapter.h"
+
+#define DLIB
+
+#ifdef DLIB
+ #define GPU
+ //#include
+ //#include
+ #undef GPU
+#endif
+
+#include
+#include
+#include
+#include
+#include
+
+#include
+//#include
+#include
+#include
+#include
+#include
+#include
+
+
+using namespace cv;
+using namespace dlib;
+using namespace std;
+
+template class,int,typename> class block, int N, templateclass BN, typename SUBNET>
+using residual = add_prev1>>;
+
+template class,int,typename> class block, int N, templateclass BN, typename SUBNET>
+using residual_down = add_prev2>>>>>;
+
+template class BN, int stride, typename SUBNET>
+using block = BN>>>>;
+
+template using ares = relu>;
+template using ares_down = relu>;
+
+template using alevel0 = ares_down<256,SUBNET>;
+template using alevel1 = ares<256,ares<256,ares_down<256,SUBNET>>>;
+template using alevel2 = ares<128,ares<128,ares_down<128,SUBNET>>>;
+template using alevel3 = ares<64,ares<64,ares<64,ares_down<64,SUBNET>>>>;
+template using alevel4 = ares<32,ares<32,ares<32,SUBNET>>>;
+
+using anet_type = loss_metric
+ >>>>>>>>>>>>;
+
+// ----------------------------------------------------------------------------------------
+
+
+std::vector> jitter_image( const matrix& img );
+
+/**
+ * TODO: Add class description
+ *
+ * @author Gagua
+ */
+class IM_DlibWorker : public basicThread{
+ private:
+
+ frontal_face_detector m_oFaceDetector;
+ shape_predictor m_oShapePredictor;
+ anet_type m_oNet;
+ IM_DataBaseAdapter * m_pDBA;
+ //matrix m_oInputImg;
+ //std::vector> m_vFacesImg;
+
+ basicLogCollection * m_pLog;
+ config_setting_t * m_pSettings;
+ basicEventHeap * m_pEvtHeap;
+ cv::Mat m_oWorkingMat;
+ float m_fDetectionProbability;
+ bool m_bUseShapePredictor;
+ bool m_bUseFaceRecognition;
+ char m_pPicturesBase[1024];
+ char m_pFacesBase[1024];
+ char m_pShapePredictorPath[1024];
+ char m_pNetModelPath[1024];
+ char m_sChownUser[64];
+ char m_sChownGroup[64];
+ basicMutex m_mBufferProtectorMutex;
+ IM_JOB * m_pActiveJob;
+ bool m_bDataIsActive;
+ CSTR m_fSaveFace( matrix &Picture, CSTR md5, uint32_t index );
+ IM_RESULT * m_fImageAnalyzer( cv::Mat &Picture );
+ protected:
+ virtual void m_fThreadProc( void );//getLayerNames()
+ public:
+ // Constructor
+ explicit IM_DlibWorker( config_setting_t * Settings = NULL );
+ // Destructor
+ virtual ~IM_DlibWorker();
+ bool create( void );
+ bool enqueueJob( IM_JOB *ptr );
+};
+
+
+#endif
diff --git a/Projects/img_slim/IM_DataBaseAdapter.cpp b/Projects/img_slim/IM_DataBaseAdapter.cpp
new file mode 100644
index 00000000..1bc3dce1
--- /dev/null
+++ b/Projects/img_slim/IM_DataBaseAdapter.cpp
@@ -0,0 +1,251 @@
+#include "IM_DataBaseAdapter.h"
+#include "../../lib/alg/generic/md5.h"
+
+#define LOG( X ) m_pLog->Log( "IMDBA", 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( "IMDBA", this, _LOG_ERROR, _tBfrErrMSG234 );\
+ }
+#else
+ #define LOG_ERROR( X ) m_pLog->Log( "IMDBA", this, _LOG_ERROR, X );
+#endif
+
+IM_DataBaseAdapter* IM_DataBaseAdapter::_instance = NULL;
+
+/**
+ * Returns the single instance of the object.
+ */
+IM_DataBaseAdapter* IM_DataBaseAdapter::getInstance( config_setting_t * Settings ) {
+ // check if the instance has been created yet
+ if( NULL == _instance ){
+ // if not, then create it
+ _instance = new IM_DataBaseAdapter( Settings );
+ };
+ // return the single instance
+ return _instance;
+};
+
+// Constructor implementation
+inline IM_DataBaseAdapter::IM_DataBaseAdapter( config_setting_t * Settings ){
+ m_pLog = basicLogCollection::getInstance();
+ m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "DBC" );
+ m_bIsConnected = false;
+ if( m_pSettings!= NULL ) {
+ config_setting_t * tSetting;
+ char tDBHost[128];
+ char tDBName[128];
+ char tDBUser[128];
+ char tDBPass[128];
+ uint16_t tDBPort = 3306;
+ tSetting = config_setting_get_member( m_pSettings, "DATABASE_HOST" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "DATABASE_HOST", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "localhost" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No DB Host Setting! Using default!");
+ };
+ sprintf(tDBHost, "%s", config_setting_get_string(tSetting));
+ tSetting = config_setting_get_member( m_pSettings, "DATABASE_NAME" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "DATABASE_NAME", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "dfsl_gunter" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No DB Database Setting! Using default!");
+ };
+ sprintf(tDBName, "%s", config_setting_get_string(tSetting));
+ tSetting = config_setting_get_member( m_pSettings, "DATABASE_USER" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "DATABASE_USER", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "dbroot" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No DB User Setting! Using default!");
+ };
+ sprintf(tDBUser, "%s", config_setting_get_string(tSetting));
+ tSetting = config_setting_get_member( m_pSettings, "DATABASE_PASSWORD" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "DATABASE_PASSWORD", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "123567" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No DB Password Setting! Using default!");
+ };
+ sprintf(tDBPass, "%s", config_setting_get_string(tSetting));
+ tSetting = config_setting_get_member( m_pSettings, "DATABASE_PORT" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "DATABASE_PORT", CONFIG_TYPE_INT );
+ config_setting_set_int( tSetting, 3306 );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No DB Port Setting! Using default!");
+ };
+ tDBPort = config_setting_get_int( tSetting );
+ basicSettingsProvider::getInstance()->validate();
+ m_pConnectorClass = new MySQL_Connector( tDBName, tDBHost, tDBUser, tDBPass, tDBPort );
+ m_bIsConnected = ( m_pConnectorClass != NULL );
+ } else {
+ LOG_ERROR("No Settings Provided!");
+ };
+};
+
+// Destructor implementation
+inline IM_DataBaseAdapter::~IM_DataBaseAdapter(){
+ if( m_pConnectorClass ) delete( m_pConnectorClass );
+};
+
+IM_ITEM_DATA *IM_DataBaseAdapter::getItemDataById( uint32_t itemID ){
+ IM_ITEM_DATA *tVal = NULL;
+ if( m_pConnectorClass ) {
+ char tQBuf[CTEXT];
+ AAssoc *result;
+ sprintf(tQBuf, "SELECT `id`, `md5`, `width`, `height`, `4cc` FROM `items` WHERE `type`=2 AND `id`=%d", itemID );
+#ifdef DEBUG
+ LOG(tQBuf);
+#endif
+ result = m_pConnectorClass->Query( tQBuf );
+ if( result!= NULL ) {
+ if( result->size() > 0 ) {
+ Assoc *cArr;
+ tVal = (IM_ITEM_DATA*) malloc(sizeof(IM_ITEM_DATA));
+ if( tVal != NULL ) {
+ Assoc::iterator it;
+
+ memset( tVal, 0, sizeof(IM_ITEM_DATA) );
+ cArr = result->at(0);
+ it = cArr->find("id");
+ if( it != cArr->end() ){
+ tVal->item_id = atoi( it->second.c_str() );
+ };
+ it = cArr->find("md5");
+ if( it != cArr->end() ){
+ strncpy( tVal->md5, it->second.c_str(), 32 );
+ };
+ it = cArr->find("width");
+ if( it != cArr->end() ){
+ tVal->width = atoi( it->second.c_str() );
+ };
+ it = cArr->find("height");
+ if( it != cArr->end() ){
+ tVal->height = atoi( it->second.c_str() );
+ };
+ it = cArr->find("4cc");
+ if( it != cArr->end() ){
+ if( strstr( it->second.c_str(),"JPEG" ) ) tVal->type = IM_ITEM_TYPE_JPEG;
+ if( strstr( it->second.c_str(),"PNG" ) ) tVal->type = IM_ITEM_TYPE_PNG;
+ if( strstr( it->second.c_str(),"GIF" ) ) tVal->type = IM_ITEM_TYPE_GIF;
+ if( strstr( it->second.c_str(),"TIFF" ) ) tVal->type = IM_ITEM_TYPE_TIFF;
+ if( strstr( it->second.c_str(),"AGIF" ) ) tVal->type = IM_ITEM_TYPE_AGIF;
+ };
+ };
+ };
+ };
+ deleteResult( result );
+ };
+ return tVal;
+};
+
+IM_ITEM_DATA *IM_DataBaseAdapter::getItemDataByMd5( CSTR md5 ){
+ IM_ITEM_DATA *tVal = NULL;
+ if( m_pConnectorClass ) {
+ char tQBuf[CTEXT];
+ AAssoc *result;
+ sprintf(tQBuf, "SELECT `id`, `md5`, `width`, `height`, `4cc` FROM `items` WHERE `type`=2 AND `md5`='%s'", md5 );
+#ifdef DEBUG
+ LOG(tQBuf);
+#endif
+ result = m_pConnectorClass->Query( tQBuf );
+ if( result!= NULL ) {
+ if( result->size() > 0 ) {
+ Assoc *cArr;
+ tVal = (IM_ITEM_DATA*) malloc(sizeof(IM_ITEM_DATA));
+ if( tVal != NULL ) {
+ Assoc::iterator it;
+
+ memset( tVal, 0, sizeof(IM_ITEM_DATA) );
+ cArr = result->at(0);
+ it = cArr->find("id");
+ if( it != cArr->end() ){
+ tVal->item_id = atoi( it->second.c_str() );
+ };
+ it = cArr->find("md5");
+ if( it != cArr->end() ){
+ strncpy( tVal->md5, it->second.c_str(), 32 );
+ };
+ it = cArr->find("width");
+ if( it != cArr->end() ){
+ tVal->width = atoi( it->second.c_str() );
+ };
+ it = cArr->find("height");
+ if( it != cArr->end() ){
+ tVal->height = atoi( it->second.c_str() );
+ };
+ it = cArr->find("4cc");
+ if( it != cArr->end() ){
+ if( strstr( it->second.c_str(),"JPEG" ) ) tVal->type = IM_ITEM_TYPE_JPEG;
+ if( strstr( it->second.c_str(),"PNG" ) ) tVal->type = IM_ITEM_TYPE_PNG;
+ if( strstr( it->second.c_str(),"GIF" ) ) tVal->type = IM_ITEM_TYPE_GIF;
+ if( strstr( it->second.c_str(),"TIFF" ) ) tVal->type = IM_ITEM_TYPE_TIFF;
+ if( strstr( it->second.c_str(),"AGIF" ) ) tVal->type = IM_ITEM_TYPE_AGIF;
+ };
+ };
+ };
+ };
+ deleteResult( result );
+ };
+ return tVal;
+};
+
+void IM_DataBaseAdapter::insertItemROI( uint32_t itemID, uint32_t classID, float weight, uint32_t x, uint32_t y, uint32_t w, uint32_t h ){
+ if( m_pConnectorClass ) {
+ char tQBuf[CTEXT];
+ sprintf(tQBuf, "INSERT INTO `item_rois` SET `item_id`=%d, `class_id`=%d, `probability`=%.5f, `x`=%d, `y`=%d, `width`=%d, `height`=%d", itemID, classID, weight, x, y, w, h );
+#ifdef DEBUG
+ LOG(tQBuf);
+#endif
+ m_pConnectorClass->SilentQuery( tQBuf );
+ };
+};
+
+uint32_t IM_DataBaseAdapter::insertItemFace( uint32_t itemID, CSTR md5, uint32_t x, uint32_t y, uint32_t w, uint32_t h ){
+ uint32_t RetVal = 0;
+ if( m_pConnectorClass ) {
+ char tQBuf[CTEXT];
+ sprintf(tQBuf, "INSERT INTO `faces_chips` SET `item_id`=%d, `md5`='%s', `x`=%d, `y`=%d, `w`=%d, `h`=%d ON DUPLICATE KEY UPDATE `item_id`=%d, `x`=%d, `y`=%d, `w`=%d", itemID, md5, x, y, w, h, itemID, x, y, w, h );
+#ifdef DEBUG
+ LOG(tQBuf);
+#endif
+ RetVal = m_pConnectorClass->QueryID( tQBuf );
+ if( RetVal == 0 ) {
+ AAssoc *result;
+ sprintf(tQBuf, "SELECT `id` FROM `faces_chips` WHERE `md5`='%s' ", md5 );
+ result = m_pConnectorClass->Query( tQBuf );
+ if( result!= NULL ) {
+ if( result->size() > 0 ) {
+ Assoc *cArr;
+ Assoc::iterator it;
+ cArr = result->at(0);
+ it = cArr->find("id");
+ if( it != cArr->end() ){
+ RetVal = atoi( it->second.c_str() );
+ };
+ };
+ };
+ deleteResult( result );
+ };
+ };
+ return RetVal;
+};
+
+void IM_DataBaseAdapter::updateItemFace( uint32_t itemID, uint8_t dID, float P ){
+ if( m_pConnectorClass ) {
+ char tQBuf[CTEXT];
+ sprintf(tQBuf, "UPDATE `faces_chips` SET `a_%d`=%.5f WHERE `id`=%d", dID, P, itemID );
+#ifdef DEBUG
+ LOG(tQBuf);
+#endif
+ m_pConnectorClass->SilentQuery( tQBuf );
+ };
+};
+
+#undef LOG
+#undef LOG_ERROR
+
diff --git a/Projects/img_slim/IM_DataBaseAdapter.h b/Projects/img_slim/IM_DataBaseAdapter.h
new file mode 100644
index 00000000..1c2480bc
--- /dev/null
+++ b/Projects/img_slim/IM_DataBaseAdapter.h
@@ -0,0 +1,53 @@
+#ifndef __IM_DATABASEADAPTER_H_INCL__
+#define __IM_DATABASEADAPTER_H_INCL__
+
+#include "../../lib/data/mysql/mysql_class.h"
+#include "../../lib/components/base/basicSettingsProvider.h"
+#include "IM_DataStructs.h"
+
+/**
+ * TODO: Add class description
+ *
+ * @author Gagua
+ */
+class IM_DataBaseAdapter {
+ private:
+ basicLogCollection * m_pLog;
+ config_setting_t * m_pSettings;
+ bool m_bIsConnected;
+ MySQL_Connector * m_pConnectorClass;
+ public:
+ // Method to fetch singleton instance.
+ static IM_DataBaseAdapter* getInstance( config_setting_t * Settings = NULL );
+
+ // Destructor
+ virtual ~IM_DataBaseAdapter();
+
+ IM_ITEM_DATA * getItemDataById( uint32_t itemID );
+ IM_ITEM_DATA * getItemDataByMd5( CSTR md5 );
+ void insertItemROI( uint32_t itemID, uint32_t classID, float weight, uint32_t x, uint32_t y, uint32_t w, uint32_t h );
+ uint32_t insertItemFace( uint32_t itemID, CSTR md5, uint32_t x, uint32_t y, uint32_t w, uint32_t h );
+ void updateItemFace( uint32_t itemID, uint8_t dID, float P );
+ protected:
+ // Constructor - protected so users cannot call it.
+ explicit IM_DataBaseAdapter( config_setting_t * Settings );
+
+ private:
+ // private static member referencing the single instance of the object
+ // TODO: Replace IM_DataBaseAdapter with the type of object you want to
+ // return the single instance of
+ static IM_DataBaseAdapter* _instance;
+
+ // Copy constructor
+ // Declared but not defined to prevent auto-generated
+ // copy constructor. Refer to "Effective C++" by Meyers
+ IM_DataBaseAdapter(const IM_DataBaseAdapter& src);
+
+ // Assignment operator
+ // Declared but not defined to prevent auto-generated
+ // assignment operator. Refer to "Effective C++" by Meyers
+ IM_DataBaseAdapter& operator=(const IM_DataBaseAdapter& src);
+
+};
+
+#endif // __IM_DATABASEADAPTER_H_INCL__
diff --git a/Projects/img_slim/IM_DataStructs.cpp b/Projects/img_slim/IM_DataStructs.cpp
new file mode 100644
index 00000000..2cd4eb8c
--- /dev/null
+++ b/Projects/img_slim/IM_DataStructs.cpp
@@ -0,0 +1,30 @@
+#include "IM_DataStructs.h"
+
+CSTR buildMd5Path( CSTR base, CSTR md5, mode_t mode, CSTR user, CSTR group ){
+ char tPath[1024];
+ char p1[3];
+ char p2[3];
+ char p3[3];
+ if(!fileExist( base )) return NULL;
+ memcpy( p1, md5 , 2); p1[2]=(char)0;
+ sprintf( tPath, "%s/%s", base, p1 );
+ if(!fileExist( tPath )) {
+ if( mkdir( tPath, mode )==-1) return NULL;
+ if( user!= NULL && group!= NULL ) ch_chown( tPath, user, group );
+ };
+ memcpy( p2, md5+2, 2); p2[2]=(char)0;
+ sprintf( tPath, "%s/%s/%s", base, p1, p2 );
+ if(!fileExist( tPath )){
+ if( mkdir( tPath, mode )==-1) return NULL;
+ if( user!= NULL && group!= NULL ) ch_chown( tPath, user, group );
+ };
+ memcpy( p3, md5+4, 2); p3[2]=(char)0;
+ sprintf( tPath, "%s/%s/%s/%s", base, p1, p2, p3 );
+ if(!fileExist( tPath )) {
+ if( mkdir( tPath, mode )==-1) return NULL;
+ if( user!= NULL && group!= NULL ) ch_chown( tPath, user, group );
+ };
+ return strdup( tPath );
+};
+
+
diff --git a/Projects/img_slim/IM_DataStructs.h b/Projects/img_slim/IM_DataStructs.h
new file mode 100644
index 00000000..654e64e4
--- /dev/null
+++ b/Projects/img_slim/IM_DataStructs.h
@@ -0,0 +1,60 @@
+#ifndef __IMAGE_MILL_DATA_STRUCTURES_HEADER__
+#define __IMAGE_MILL_DATA_STRUCTURES_HEADER__
+
+#include "../../lib/components/base/basicFunctionality.h"
+#include
+
+typedef struct S_IM_ITEM_DATA{
+ uint32_t item_id;
+ char md5[33];
+ uint8_t process_type;
+ uint32_t width;
+ uint32_t height;
+ uint8_t type;
+}IM_ITEM_DATA;
+
+typedef enum E_IM_ITEM_TYPES{
+ IM_ITEM_TYPE_JPEG = 0,
+ IM_ITEM_TYPE_PNG = 1,
+ IM_ITEM_TYPE_GIF = 2,
+ IM_ITEM_TYPE_AGIF = 3,
+ IM_ITEM_TYPE_TIFF = 4
+}IM_ITEM_TYPES;
+
+typedef enum E_IM_PROCESS_TYPES{
+ IM_PROC_TYPE_DNN = 0,
+ IM_PROC_TYPE_FACE = 1
+}IM_PROCESS_TYPES;
+
+typedef struct S_IM_JOB{
+ uint32_t dbID;
+ uint8_t job_type;
+ uint8_t image_type;
+ uint32_t width;
+ uint32_t height;
+ uint32_t depth;
+ char md5[33];
+}IM_JOB;
+
+typedef struct S_IM_CLASS_BOUNDARY_BOX{
+ uint32_t classID;
+ float weight;
+ uint32_t x;
+ uint32_t y;
+ uint32_t width;
+ uint32_t height;
+ uint32_t depth;
+}IM_CLASS_BOUNDARY_BOX;
+
+typedef struct S_IM_RESULT{
+ IM_JOB * pJOB;
+ uint32_t nBoxCount;
+ IM_CLASS_BOUNDARY_BOX * boxes;
+}IM_RESULT;
+
+typedef std::queue IM_JOB_QUEUE;
+
+CSTR buildMd5Path( CSTR base, CSTR md5, mode_t mode = 0755, CSTR user=NULL, CSTR group=NULL );
+
+
+#endif
diff --git a/Projects/img_slim/IM_DnnWorker.cpp b/Projects/img_slim/IM_DnnWorker.cpp
new file mode 100644
index 00000000..148d9913
--- /dev/null
+++ b/Projects/img_slim/IM_DnnWorker.cpp
@@ -0,0 +1,349 @@
+#include "IM_DnnWorker.h"
+#include "../../lib/components/base/basicFunctionality.h"
+
+#define LOG( X ) m_pLog->Log( "WDNN", 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( "WDNN", this, _LOG_ERROR, _tBfrErrMSG234 );\
+ }
+#else
+ #define LOG_ERROR( X ) m_pLog->Log( "WDNN", this, _LOG_ERROR, X );
+#endif
+
+// Constructor implementation
+IM_DnnWorker::IM_DnnWorker( config_setting_t * Settings ) : basicThread(), m_mBufferProtectorMutex(){
+ m_pLog = basicLogCollection::getInstance();
+ m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "DNN" );
+ m_pEvtHeap = basicEventHeap::getInstance();
+ m_eBackendEngine = cv::dnn::DNN_BACKEND_DEFAULT;
+ m_eTargetDevice = cv::dnn::DNN_TARGET_CPU;
+ m_pActiveJob = NULL;
+
+#ifdef DARKNET
+ m_pDarknetDetector = NULL;
+#endif
+
+ m_bDataIsActive = false;
+};
+
+// Destructor implementation
+IM_DnnWorker::~IM_DnnWorker(){
+#ifdef DARKNET
+ if( m_pDarknetDetector ) delete( m_pDarknetDetector );
+#endif
+};
+
+bool IM_DnnWorker::create( void ){
+ char tBuff[256];
+ if( m_pSettings == NULL ){
+ return false;
+ } else {
+ config_setting_t * tSetting;
+ tSetting = config_setting_get_member( m_pSettings, "PICTURES_BASE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "PICTURES_BASE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "/srv/vault" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Pictures Base Path! Using default!");
+ };
+ sprintf( m_pPicturesBase, "%s", config_setting_get_string(tSetting));
+ tSetting = config_setting_get_member( m_pSettings, "NET_CONFIG_FILE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "NET_CONFIG_FILE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "conf/yolo9000.cfg" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Net Config File! Using default!");
+ };
+ sprintf( m_pConfigPath, "%s", config_setting_get_string(tSetting));
+ tSetting = config_setting_get_member( m_pSettings, "NET_WEIGHTS_FILE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "NET_WEIGHTS_FILE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "data/yolo9000.weights" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Net Weights File! Using default!");
+ };
+ sprintf( m_pWeightsPath, "%s", config_setting_get_string(tSetting));
+ tSetting = config_setting_get_member( m_pSettings, "DETECTION_PROBABILITY" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "DETECTION_PROBABILITY", CONFIG_TYPE_FLOAT );
+ config_setting_set_float( tSetting, 0.5f );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Probability Set! Using default!");
+ };
+ m_fDetectionProbability = config_setting_get_float(tSetting);
+ tSetting = config_setting_get_member( m_pSettings, "USE_CLASS_MAP" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "USE_CLASS_MAP", CONFIG_TYPE_BOOL );
+ config_setting_set_bool( tSetting, 0 );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Class Map Usage Set! Using default!");
+ };
+ m_bUseClassMapping = (bool) config_setting_get_bool(tSetting);
+ if( m_bUseClassMapping ) {
+ char tMapFileName[1024];
+ FILE *fd;
+ tSetting = config_setting_get_member( m_pSettings, "CLASS_MAP_FILE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "CLASS_MAP_FILE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "data/coco9k.map" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Class Map File Set! Using default!");
+ };
+ sprintf( tMapFileName, "%s", config_setting_get_string(tSetting) );
+ fd = fopen( tMapFileName, "r" );
+ if( fd ) {
+ uint32_t tV;
+ uint32_t idx = 0;
+ char tB[128];
+ while( !feof(fd) ) {
+ if( fgets( tB, 128, fd ) ){
+ tV = atoi( tB )+1;
+ m_vClassesMap.push_back( tV );
+ idx++;
+ };
+ };
+ fclose( fd );
+ sprintf( tB, "Loadded %d classes map", idx );
+ LOG( tB );
+ } else {
+ m_bUseClassMapping = false;
+ };
+ };
+ tSetting = config_setting_get_member( m_pSettings, "NET_TARGET_DEVICE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "NET_TARGET_DEVICE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "CPU" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Net Target Device! Using default!");
+ };
+ if( strstr( config_setting_get_string(tSetting), "CPU" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_CPU;
+ if( strstr( config_setting_get_string(tSetting), "OPENCL_FP16" )!=NULL ){
+ m_eTargetDevice = cv::dnn::DNN_TARGET_OPENCL_FP16;
+ } else {
+ if( strstr( config_setting_get_string(tSetting), "OPENCL" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_OPENCL;
+ };
+ if( strstr( config_setting_get_string(tSetting), "MYRIAD" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_MYRIAD;
+ if( strstr( config_setting_get_string(tSetting), "VULKAN" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_VULKAN;
+ if( strstr( config_setting_get_string(tSetting), "FPGA" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_FPGA;
+ if( strstr( config_setting_get_string(tSetting), "CUDA_FP16" )!=NULL ){
+ m_eTargetDevice = cv::dnn::DNN_TARGET_CUDA_FP16;
+ } else {
+ if( strstr( config_setting_get_string(tSetting), "CUDA" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_CUDA;
+ };
+ if( strstr( config_setting_get_string(tSetting), "HDDL" )!=NULL ) m_eTargetDevice = cv::dnn::DNN_TARGET_HDDL;
+ sprintf( tBuff, "Device: %s", config_setting_get_string(tSetting) );
+ LOG( tBuff );
+
+ tSetting = config_setting_get_member( m_pSettings, "NET_BACKEND_ENGINE" );
+ if( tSetting == NULL ){
+ tSetting = config_setting_add(m_pSettings, "NET_BACKEND_ENGINE", CONFIG_TYPE_STRING );
+ config_setting_set_string( tSetting, "DEFAULT" );
+ basicSettingsProvider::getInstance()->compromise();
+ LOG("No Net Backend Engine! Using default!");
+ };
+ if( strstr( config_setting_get_string(tSetting), "DEFAULT" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_DEFAULT;
+ if( strstr( config_setting_get_string(tSetting), "HALIDE" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_HALIDE;
+ if( strstr( config_setting_get_string(tSetting), "INFERENCE" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_INFERENCE_ENGINE;
+ if( strstr( config_setting_get_string(tSetting), "OPENCV" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_OPENCV;
+ if( strstr( config_setting_get_string(tSetting), "VKCOM" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_VKCOM;
+ if( strstr( config_setting_get_string(tSetting), "CUDA" )!=NULL ) m_eBackendEngine = cv::dnn::DNN_BACKEND_CUDA;
+ sprintf( tBuff, "Engine: %s", config_setting_get_string(tSetting) );
+ LOG( tBuff );
+ basicSettingsProvider::getInstance()->validate();
+ };
+ sprintf( tBuff, "loading DNN from disk... CONF: %s WEIGHT: %s", m_pConfigPath, m_pWeightsPath );
+ LOG( tBuff );
+ if(!fileExist( m_pConfigPath )) {
+ LOG_ERROR("No Config file exists!");
+ return false;
+ };
+ if(!fileExist( m_pWeightsPath )) {
+ LOG_ERROR("No Weight file exists!");
+ return false;
+ };
+#ifdef DARKNET
+ try {
+ m_pDarknetDetector = new Detector( m_pConfigPath, m_pWeightsPath );
+ if( m_pDarknetDetector ) {
+ LOG("DarkNet Detector Created");
+ } else {
+ LOG_ERROR("Failure during DarkNet Detector Creation!");
+ };
+ } catch ( exception e ) {
+ LOG_ERROR( e.what() );
+ };
+#else
+ m_net = cv::dnn::readNetFromDarknet( m_pConfigPath, m_pWeightsPath );
+ m_net.setPreferableBackend( m_eBackendEngine );
+ m_net.setPreferableTarget( m_eTargetDevice );
+ std::vector outNames = m_net.getUnconnectedOutLayersNames();
+ LOG("OutNames");
+ for( std::vector::iterator idx = outNames.begin(); idx < outNames.end(); idx++ ) {
+ LOG( (*idx).c_str() );
+ };
+#endif
+ return init();
+};
+
+IM_RESULT *IM_DnnWorker::m_fImageAnalyzer( Mat &Picture ){
+ Size inpSize;
+ bool swapRB = true; //BGR->RGB
+ double scale = 1.0;///255.0;
+ Scalar mean;
+ IM_RESULT * retVal = NULL;
+ inpSize.width = Picture.cols;
+ inpSize.height = Picture.rows;
+#ifndef DARKNET
+ try {
+ LOG("Create a 4D blob from a frame");
+ //cv::resize( m_oWorkingMat, m_oWorkingMat, cv::Size(416, 416));
+ Mat blob = cv::dnn::blobFromImage( Picture, scale, Size(416, 416), mean, swapRB, false, CV_8U );
+
+ if( blob.empty() ) {
+ LOG_ERROR("Failure Creating Blob!");
+ return retVal;
+ };
+ // construct a blob from the input frame and then perform a forward
+ // pass of the YOLO object detector, giving us our bounding boxes
+ // and associated probabilities
+ //blob = cv2.dnn.blobFromImage(frame, 1 / 255.0, (416, 416), swapRB=True, crop=False )
+ //net.setInput(blob)
+ //layerOutputs = net.forward(ln)
+ // Run a model.
+ LOG("Set BLOB to NET");
+ m_net.setInput( blob );
+ //std::vector outs;
+ //std::vector outNames = m_net.getUnconnectedOutLayersNames();
+ Mat outMat = m_net.forward( String( "detection_out" ));
+ LOG("DONE!");
+ /*
+ if( m_net.getLayer(0)->outputNameToIndex("im_info") != -1 ){
+ // Faster-RCNN or R-FCN
+ //resize( Picture, Picture, inpSize );
+ cv::resize( Picture, Picture, cv::Size(416, 416));
+ Mat imInfo = ( Mat_(1, 3) << inpSize.height, inpSize.width, 1.6f);
+ m_net.setInput( imInfo, "im_info" );
+ };
+ */
+ } catch ( cv::Exception& e ) {
+ LOG_ERROR("Catched Exception");
+ LOG_ERROR( e.what() );
+ };
+#else
+ std::shared_ptr img = m_pDarknetDetector->mat_to_image_resize( Picture );
+ std::vector result_vec;
+ //result_vec = detector.detect_resized( * img, inpSize.width, inpSize.height, thresh, true);
+ result_vec = m_pDarknetDetector->detect_resized( *img, inpSize.width, inpSize.height, m_fDetectionProbability, true);
+ if( result_vec.size() ) {
+ retVal = (IM_RESULT *)malloc(sizeof(IM_RESULT));
+ if( retVal ) {
+ retVal->pJOB = m_pActiveJob;
+ retVal->nBoxCount = result_vec.size();
+ retVal->boxes = (IM_CLASS_BOUNDARY_BOX *) calloc( retVal->nBoxCount,sizeof(IM_CLASS_BOUNDARY_BOX));
+ if( retVal->boxes ) {
+ for( int i=0; i< result_vec.size(); i++ ) {
+ bbox_t * b = &(result_vec.at(i));
+ retVal->boxes[i].weight = b->prob;
+ retVal->boxes[i].x = b->x;
+ retVal->boxes[i].y = b->y;
+ retVal->boxes[i].width = b->w;
+ retVal->boxes[i].height = b->h;
+ if( m_bUseClassMapping ){
+ retVal->boxes[i].classID = m_vClassesMap[b->obj_id];
+ } else {
+ retVal->boxes[i].classID = b->obj_id;
+ };
+#ifdef DEBUG
+ char msg[256];
+ sprintf( msg, "[%d] Class: %d Prob: %.2f X:%d Y:%d W:%d H:%d", i, retVal->boxes[i].classID, retVal->boxes[i].weight, b->x, b->y, b->w, b->h );
+ LOG( msg );
+#endif
+ };
+ } else {
+ free(retVal);
+ retVal = NULL;
+ };
+ };
+ };
+#endif
+ return retVal;
+};
+
+void IM_DnnWorker::m_fThreadProc( void ){
+ m_bThreadStatus = TH_WORKING;
+ EVENT_CONTAINER *EVT_PTR = NULL;
+ while( m_bThreadStatus < TH_ENDED ) {
+ while (!m_bDataIsActive && m_bThreadStatus < TH_ENDED ) SLEEP( 20 );
+ if( m_mBufferProtectorMutex.try_lock() ){
+ if( m_bDataIsActive ){
+ EVT_PTR =(EVENT_CONTAINER *) malloc(sizeof(EVENT_CONTAINER));
+ if( EVT_PTR ) {
+ memset( EVT_PTR, 0, sizeof(EVENT_CONTAINER));
+ EVT_PTR->m_eClass = EVT_CLASS_IMAGE;
+ EVT_PTR->m_eType = EVT_READY;
+ if( IM_RESULT *tData = m_fImageAnalyzer( m_oWorkingMat ) ){
+ //generate detection event
+ EVT_PTR->m_pEvtData = tData;
+ } else {
+ //generate NOT detection event
+ EVT_PTR->m_pEvtData = NULL;
+ };
+ };
+ m_pActiveJob = NULL;
+ m_bDataIsActive = false;
+ };
+ m_mBufferProtectorMutex.unlock();
+ };
+ if( EVT_PTR != NULL ) {
+ m_pEvtHeap->broadcast( EVT_PTR );
+ EVT_PTR = NULL;
+ };
+ };
+};
+
+bool IM_DnnWorker::enqueueJob( IM_JOB *ptr ){
+ if( ptr ) {
+ char tPath[1024];
+ char p1[3];
+ char p2[3];
+ char p3[3];
+ LOG( ptr->md5 );
+ memcpy( p1, ptr->md5 , 2); p1[2]=(char)0;
+ memcpy( p2, ptr->md5+2, 2); p2[2]=(char)0;
+ memcpy( p3, ptr->md5+4, 2); p3[2]=(char)0;
+ switch( ptr->image_type ) {
+ case IM_ITEM_TYPE_JPEG: sprintf( tPath, "%s/%s/%s/%s/%s.jpg", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ case IM_ITEM_TYPE_PNG: sprintf( tPath, "%s/%s/%s/%s/%s.png", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ case IM_ITEM_TYPE_GIF: sprintf( tPath, "%s/%s/%s/%s/%s.gif", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ case IM_ITEM_TYPE_AGIF: sprintf( tPath, "%s/%s/%s/%s/%s.gif", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ case IM_ITEM_TYPE_TIFF: sprintf( tPath, "%s/%s/%s/%s/%s.tiff", m_pPicturesBase, p1, p2, p3, ptr->md5 ); break;
+ };
+#ifdef DEBUG
+ LOG( tPath );
+#endif
+ Mat Frame = cv::imread( tPath, IMREAD_COLOR );
+ if( !Frame.empty() ){
+ while( m_bThreadStatus < TH_ENDED ) {
+ if( m_mBufferProtectorMutex.try_lock() ) {
+ Frame.copyTo( m_oWorkingMat );
+#ifdef DEBUG
+ cv::imwrite("cur-test-img.jpg", m_oWorkingMat );
+#endif
+ m_bDataIsActive = true;
+ m_pActiveJob = ptr;
+ m_mBufferProtectorMutex.unlock();
+ return true;
+ } else SLEEP(5);
+ };
+ } else {
+ LOG_ERROR( "Failure during Image Read!" );
+ };
+ };
+ return false;
+};
+
+#undef LOG
+#undef LOG_ERROR
+
diff --git a/Projects/img_slim/IM_DnnWorker.h b/Projects/img_slim/IM_DnnWorker.h
new file mode 100644
index 00000000..41fc07f4
--- /dev/null
+++ b/Projects/img_slim/IM_DnnWorker.h
@@ -0,0 +1,66 @@
+#ifndef __IM_DNNWORKER_H_INCL__
+#define __IM_DNNWORKER_H_INCL__
+
+#include "../../lib/components/base/basicThread.h"
+#include "../../lib/components/base/basicMutex.h"
+#include "../../lib/components/base/basicSettingsProvider.h"
+#include "../../lib/components/base/basicEventHeap.h"
+#include "IM_DataStructs.h"
+
+#define DARKNET
+
+#ifdef DARKNET
+ #define GPU
+ //#include
+ #include
+ #undef GPU
+#endif
+
+#include
+#include
+#include
+#include
+#include
+
+using namespace cv;
+/**
+ * TODO: Add class description
+ *
+ * @author Gagua
+ */
+class IM_DnnWorker : public basicThread {
+ private:
+#ifdef DARKNET
+ Detector * m_pDarknetDetector;
+#else
+#endif
+ basicLogCollection * m_pLog;
+ config_setting_t * m_pSettings;
+ cv::dnn::Backend m_eBackendEngine;
+ cv::dnn::Target m_eTargetDevice;
+ cv::dnn::Net m_net;
+ cv::Mat m_oWorkingMat;
+ float m_fDetectionProbability;
+ bool m_bUseClassMapping;
+ std::vector m_vClassesMap;
+ basicEventHeap * m_pEvtHeap;
+ char m_pPicturesBase[1024];
+ char m_pConfigPath[1024];
+ char m_pWeightsPath[1024];
+ basicMutex m_mBufferProtectorMutex;
+ IM_JOB * m_pActiveJob;
+ bool m_bDataIsActive;
+ IM_RESULT * m_fImageAnalyzer( Mat &Picture );
+ protected:
+ virtual void m_fThreadProc( void );//getLayerNames()
+ public:
+ // Constructor
+ explicit IM_DnnWorker( config_setting_t * Settings = NULL );
+ // Destructor
+ virtual ~IM_DnnWorker();
+ bool create( void );
+ bool enqueueJob( IM_JOB *ptr );
+};
+
+
+#endif // __IM_DNNWORKER_H_INCL__
diff --git a/Projects/img_slim/IM_Kernel.cpp b/Projects/img_slim/IM_Kernel.cpp
new file mode 100644
index 00000000..c523dbc5
--- /dev/null
+++ b/Projects/img_slim/IM_Kernel.cpp
@@ -0,0 +1,148 @@
+#include "IM_Kernel.h"
+#include "IM_ClientHandler.h"
+
+#define LOG( X ) m_pLog->Log( "KRNL", 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( "KRNL", this, _LOG_ERROR, _tBfrErrMSG234 );\
+ }
+#else
+ #define LOG_ERROR( X ) m_pLog->Log( "KRNL", this, _LOG_ERROR, X );
+#endif
+
+IM_Kernel *IM_Kernel::_instance = NULL;
+
+IM_Kernel *IM_Kernel::getInstance(){
+ if( _instance == NULL ) {
+ _instance = new IM_Kernel;
+ };
+ return _instance;
+};
+
+// Constructor implementation
+inline IM_Kernel::IM_Kernel( config_setting_t *Settings ) : networkServiceEngine(), basicThread(){
+ m_pLog = basicLogCollection::getInstance();
+ m_pSettings = basicSettingsProvider::getInstance()->getSubNode( Settings, "KERNEL" );
+ m_pEvtHeap = basicEventHeap::getInstance();
+ m_bExitCause = 0;
+ m_pWorker = NULL;
+ m_pRecognizer = NULL;
+ m_pDBA = NULL;
+ m_pActiveJob = NULL;
+};
+
+// Destructor implementation
+inline IM_Kernel::~IM_Kernel(){
+ waitThreadEnd( true );
+ if( m_pWorker ) delete( m_pWorker );
+ if( m_pRecognizer ) delete( m_pRecognizer );
+ if( m_pDBA ) delete( m_pDBA );
+ _instance = NULL;
+};
+
+bool IM_Kernel::start(){
+ m_pDBA = IM_DataBaseAdapter::getInstance( m_pSettings );
+ if( m_pDBA ==NULL ) {
+ LOG_ERROR("Error Creating DataBase Adapter!");
+ return false;
+ };
+ m_pWorker = new IM_DnnWorker( m_pSettings );
+ if( m_pWorker ) {
+ if( !m_pWorker->create() ){
+ LOG_ERROR( "DNN Worker INIT Failure!" );
+ return false;
+ };
+ } else LOG_ERROR( "DNN Worker Create Failure!" );
+
+ m_pRecognizer = new IM_DlibWorker( m_pSettings );
+ if( m_pRecognizer ) {
+ if( !m_pRecognizer->create() ){
+ LOG_ERROR( "DLib Worker INIT Failure!" );
+ return false;
+ };
+ } else LOG_ERROR( "DLib Worker Create Failure!" );
+ return init();
+};
+
+bool IM_Kernel::stop( bool Force ){
+ waitThreadEnd( Force );
+ return true;
+};
+
+networkClientHandler *IM_Kernel::attachNewClient( int SocketID ){
+ IM_ClientHandler *tVal;
+ tVal = new IM_ClientHandler( SocketID, this );
+ return (networkClientHandler *) tVal;
+};
+
+bool IM_Kernel::detachClient( networkClientHandler *ptr ){
+ delete( (IM_ClientHandler *) ptr );
+ return true;
+};
+
+
+void IM_Kernel::m_fThreadProc( void ){
+ m_bThreadStatus = TH_WORKING;
+ while( m_bThreadStatus < TH_ENDED ) {
+ if( m_qJOBS.size() ) {
+ if( m_pWorker ){
+ m_pActiveJob = m_qJOBS.front();
+ m_qJOBS.pop();
+ switch( m_pActiveJob->job_type ) {
+ case IM_PROC_TYPE_FACE:
+ if( !m_pRecognizer->enqueueJob( m_pActiveJob ) ) {
+#ifdef DEBUG
+ LOG("Not Inserted Job Must generate EVT");
+#endif
+ EVENT_CONTAINER *tEVT;
+ tEVT = (EVENT_CONTAINER *)malloc(sizeof(EVENT_CONTAINER));
+ if( tEVT ) {
+ memset(tEVT,0,sizeof(EVENT_CONTAINER));
+ tEVT->m_eClass = EVT_CLASS_IMAGE;
+ tEVT->m_eType = EVT_READY;
+ m_pEvtHeap->broadcast( tEVT );
+ } else {
+ LOG_ERROR( "Failure to Emmit EVENT!");
+ };
+ };
+ break;
+ default:
+ if( !m_pWorker->enqueueJob( m_pActiveJob ) ) {
+#ifdef DEBUG
+ LOG("Not Inserted Job Must generate EVT");
+#endif
+ EVENT_CONTAINER *tEVT;
+ tEVT = (EVENT_CONTAINER *)malloc(sizeof(EVENT_CONTAINER));
+ if( tEVT ) {
+ memset(tEVT,0,sizeof(EVENT_CONTAINER));
+ tEVT->m_eClass = EVT_CLASS_IMAGE;
+ tEVT->m_eType = EVT_READY;
+ m_pEvtHeap->broadcast( tEVT );
+ } else {
+ LOG_ERROR( "Failure to Emmit EVENT!");
+ };
+ };
+ };
+ } else LOG_ERROR( "DNN Worker Not Created!" );
+ };
+ SLEEP( DEFAULT_THREAD_SLEEP_TIME );
+ };
+};
+
+bool IM_Kernel::enqueueJob( IM_JOB *ptr ){
+ if( m_pWorker ) {
+ if( ptr!= NULL ) {
+#ifdef DEBUG
+ LOG( "New Job Enqueued" );
+#endif
+ m_qJOBS.push( ptr );
+ };
+ } else LOG_ERROR( "DNN Worker Not Created!" );
+ return false;
+};
+
+#undef LOG
+#undef LOG_ERROR
+
diff --git a/Projects/img_slim/IM_Kernel.h b/Projects/img_slim/IM_Kernel.h
new file mode 100644
index 00000000..a6ca5dbb
--- /dev/null
+++ b/Projects/img_slim/IM_Kernel.h
@@ -0,0 +1,52 @@
+#ifndef __IM_KERNEL_H_INCL__
+#define __IM_KERNEL_H_INCL__
+
+#include "../../lib/data/net/netServiceEngine.h"
+#include "../../lib/components/base/basicThread.h"
+#include "../../lib/components/base/basicSettingsProvider.h"
+#include "IM_DataStructs.h"
+#include "IM_DnnWorker.h"
+#include "IM_DLibWorker.h"
+#include "IM_DataBaseAdapter.h"
+
+class networkClientHandler;
+
+/**
+ * TODO: Add class description
+ *
+ * @author Gagua
+ */
+class IM_Kernel : public networkServiceEngine, public basicThread {
+ private:
+ basicLogCollection * m_pLog;
+ config_setting_t * m_pSettings;
+ basicEventHeap * m_pEvtHeap;
+ IM_DataBaseAdapter * m_pDBA;
+ uint8_t m_bExitCause;
+ IM_DnnWorker * m_pWorker;
+ IM_DlibWorker * m_pRecognizer;
+ IM_JOB_QUEUE m_qJOBS;
+ IM_JOB * m_pActiveJob;
+ protected:
+ virtual void m_fThreadProc( void );
+ public:
+
+ static IM_Kernel * getInstance();
+ // Destructor
+ virtual ~IM_Kernel();
+ bool signalEvent( void );
+ virtual bool start();
+ virtual bool stop( bool Force = false );
+ uint8_t getExitCause( void ){ return m_bExitCause;};
+ virtual networkClientHandler * attachNewClient( int SocketID );
+ virtual bool detachClient( networkClientHandler *ptr );
+ bool enqueueJob( IM_JOB *ptr );
+ //IM_RESULT * getResult( IM_JOB *ptr );
+ private:
+ static IM_Kernel * _instance;
+ // Constructor
+ explicit IM_Kernel( config_setting_t * Settings = NULL );
+};
+
+
+#endif // __IM_KERNEL_H_INCL__
diff --git a/Projects/img_slim/build b/Projects/img_slim/build
new file mode 100755
index 00000000..30213720
--- /dev/null
+++ b/Projects/img_slim/build
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+
+#make clean -e "CFG=Debug"
+make -j$(nproc) -e "CFG=Debug"
+
+
+#make clean -e "CFG=Release"
+#make -j$(nproc) -e "CFG=Release"
diff --git a/Projects/img_slim/img_slim.vpj b/Projects/img_slim/img_slim.vpj
new file mode 100644
index 00000000..06ec27e5
--- /dev/null
+++ b/Projects/img_slim/img_slim.vpj
@@ -0,0 +1,332 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Projects/img_slim/makefile b/Projects/img_slim/makefile
new file mode 100644
index 00000000..4a65ed54
--- /dev/null
+++ b/Projects/img_slim/makefile
@@ -0,0 +1,275 @@
+# SlickEdit generated file. Do not edit this file except in designated areas.
+
+# Make command to use for dependencies
+MAKE=make
+RM=rm
+MKDIR=mkdir
+
+# -----Begin user-editable area-----
+
+# -----End user-editable area-----
+
+# If no configuration is specified, "Debug" will be used
+ifndef CFG
+CFG=Debug
+endif
+
+#
+# Configuration: Debug
+#
+ifeq "$(CFG)" "Debug"
+OUTDIR=Debug
+OUTFILE=$(OUTDIR)/img_mill
+CFG_INC=-I/usr/local/include/opencv4 -I../../lib/include
+CFG_LIB=-lmysqlclient -lssl -lcrypto -lpthread `pkg-config --libs \
+ libcurl opencv4 dlib-1` -lconfig -ljpeg -lc -lm -lz -ldarknet
+CFG_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)/basicObject.o $(OUTDIR)/basicRing.o \
+ $(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
+ $(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \
+ $(OUTDIR)/IM_Backend.o $(OUTDIR)/IM_ClientHandler.o \
+ $(OUTDIR)/IM_ClientProtocol.o $(OUTDIR)/IM_DataBaseAdapter.o \
+ $(OUTDIR)/IM_DataStructs.o $(OUTDIR)/IM_DLibWorker.o \
+ $(OUTDIR)/IM_DnnWorker.o $(OUTDIR)/IM_Kernel.o \
+ $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
+ $(OUTDIR)/json_writer.o $(OUTDIR)/md5.o $(OUTDIR)/mysql_class.o \
+ $(OUTDIR)/netClientHandler.o $(OUTDIR)/netServer.o \
+ $(OUTDIR)/objectConsoleLoggingService.o \
+ $(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \
+ $(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o \
+ $(OUTDIR)/xmlParser.o
+OBJ=$(COMMON_OBJ) $(CFG_OBJ)
+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)/basicObject.o $(OUTDIR)/basicRing.o \
+ $(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
+ $(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \
+ $(OUTDIR)/IM_Backend.o $(OUTDIR)/IM_ClientHandler.o \
+ $(OUTDIR)/IM_ClientProtocol.o $(OUTDIR)/IM_DataBaseAdapter.o \
+ $(OUTDIR)/IM_DataStructs.o $(OUTDIR)/IM_DLibWorker.o \
+ $(OUTDIR)/IM_DnnWorker.o $(OUTDIR)/IM_Kernel.o \
+ $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
+ $(OUTDIR)/json_writer.o $(OUTDIR)/md5.o $(OUTDIR)/mysql_class.o \
+ $(OUTDIR)/netClientHandler.o $(OUTDIR)/netServer.o \
+ $(OUTDIR)/objectConsoleLoggingService.o \
+ $(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \
+ $(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o \
+ $(OUTDIR)/xmlParser.o -lmysqlclient -lssl -lcrypto -lpthread \
+ `pkg-config --libs libcurl opencv4 dlib-1` -lconfig -ljpeg -lc -lm \
+ -lz -ldarknet
+
+COMPILE=g++ -c -x c++ "-D_OPENCV_" "-DDEBUG" "-DOPENCV" -g -ggdb -Wno-write-strings -I../../lib/include `pkg-config opencv4 libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale live555 --cflags` -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
+LINK=g++ -g -ggdb -o "$(OUTFILE)" $(ALL_OBJ)
+
+# Pattern rules
+$(OUTDIR)/%.o : ../../lib/components/object/%.cpp
+ $(COMPILE)
+
+$(OUTDIR)/%.o : ../../lib/data/json/%.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/base/%.cpp
+ $(COMPILE)
+
+$(OUTDIR)/%.o : ../../lib/alg/generic/%.cpp
+ $(COMPILE)
+
+$(OUTDIR)/%.o : %.cpp
+ $(COMPILE)
+
+# Build rules
+all: $(OUTFILE)
+
+$(OUTFILE): $(OUTDIR) $(OBJ)
+ $(LINK)
+
+$(OUTDIR):
+ $(MKDIR) -p "$(OUTDIR)"
+
+# Rebuild this project
+rebuild: cleanall
+ @$(MAKE) -f "$(strip $(MAKEFILE_LIST))" $(MAKEFLAGS) all
+
+# Clean this project
+clean:
+ $(RM) -f $(OUTFILE)
+ $(RM) -f $(OBJ)
+
+# Clean this project and all dependencies
+cleanall: clean
+endif
+
+#
+# Configuration: Release
+#
+ifeq "$(CFG)" "Release"
+OUTDIR=Release
+OUTFILE=$(OUTDIR)/img_mill
+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=$(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)/basicObject.o $(OUTDIR)/basicRing.o \
+ $(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
+ $(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \
+ $(OUTDIR)/IM_Backend.o $(OUTDIR)/IM_ClientHandler.o \
+ $(OUTDIR)/IM_ClientProtocol.o $(OUTDIR)/IM_DataBaseAdapter.o \
+ $(OUTDIR)/IM_DataStructs.o $(OUTDIR)/IM_DLibWorker.o \
+ $(OUTDIR)/IM_DnnWorker.o $(OUTDIR)/IM_Kernel.o \
+ $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
+ $(OUTDIR)/json_writer.o $(OUTDIR)/md5.o $(OUTDIR)/mysql_class.o \
+ $(OUTDIR)/netClientHandler.o $(OUTDIR)/netServer.o \
+ $(OUTDIR)/objectConsoleLoggingService.o \
+ $(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \
+ $(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o \
+ $(OUTDIR)/xmlParser.o
+OBJ=$(COMMON_OBJ) $(CFG_OBJ)
+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)/basicObject.o $(OUTDIR)/basicRing.o \
+ $(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \
+ $(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \
+ $(OUTDIR)/IM_Backend.o $(OUTDIR)/IM_ClientHandler.o \
+ $(OUTDIR)/IM_ClientProtocol.o $(OUTDIR)/IM_DataBaseAdapter.o \
+ $(OUTDIR)/IM_DataStructs.o $(OUTDIR)/IM_DLibWorker.o \
+ $(OUTDIR)/IM_DnnWorker.o $(OUTDIR)/IM_Kernel.o \
+ $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \
+ $(OUTDIR)/json_writer.o $(OUTDIR)/md5.o $(OUTDIR)/mysql_class.o \
+ $(OUTDIR)/netClientHandler.o $(OUTDIR)/netServer.o \
+ $(OUTDIR)/objectConsoleLoggingService.o \
+ $(OUTDIR)/objectFileLoggingService.o $(OUTDIR)/protocol.o \
+ $(OUTDIR)/serverPort.o $(OUTDIR)/transportSocket.o \
+ $(OUTDIR)/xmlParser.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_" -O3 `pkg-config --cflags opencv4` -s -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
+LINK=g++ -O3 -s -o "$(OUTFILE)" $(ALL_OBJ)
+
+# Pattern rules
+$(OUTDIR)/%.o : ../../lib/components/object/%.cpp
+ $(COMPILE)
+
+$(OUTDIR)/%.o : ../../lib/data/json/%.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/base/%.cpp
+ $(COMPILE)
+
+$(OUTDIR)/%.o : ../../lib/alg/generic/%.cpp
+ $(COMPILE)
+
+$(OUTDIR)/%.o : %.cpp
+ $(COMPILE)
+
+# Build rules
+all: $(OUTFILE)
+
+$(OUTFILE): $(OUTDIR) $(OBJ)
+ $(LINK)
+
+$(OUTDIR):
+ $(MKDIR) -p "$(OUTDIR)"
+
+# Rebuild this project
+rebuild: cleanall
+ @$(MAKE) -f "$(strip $(MAKEFILE_LIST))" $(MAKEFLAGS) all
+
+# Clean this project
+clean:
+ $(RM) -f $(OUTFILE)
+ $(RM) -f $(OBJ)
+
+# Clean this project and all dependencies
+cleanall: clean
+endif
+
+#
+# include dependencies:
+#
+$(OUTDIR)/basicDualThread.o: ../../lib/components/base/basicDualThread.cpp ../../lib/components/base/basicDualThread.h
+$(OUTDIR)/basicEngine.o: ../../lib/components/base/basicEngine.cpp ../../lib/components/base/basicEngine.h
+$(OUTDIR)/basicEvent.o: ../../lib/components/base/basicEvent.cpp ../../lib/components/base/basicEvent.h ../../lib/components/base/basicFunctionality.h
+$(OUTDIR)/basicEventHandler.o: ../../lib/components/base/basicEventHandler.cpp ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicEventHeap.h
+$(OUTDIR)/basicEventHeap.o: ../../lib/components/base/basicEventHeap.cpp ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicEventHandler.h
+$(OUTDIR)/basicFunctionality.o: ../../lib/components/base/basicFunctionality.cpp ../../lib/components/base/basicFunctionality.h ../../lib/alg/generic/md5.h ../../lib/components/base/basicLogCollection.h
+$(OUTDIR)/basicLogCollection.o: ../../lib/components/base/basicLogCollection.cpp ../../lib/components/base/basicLogCollection.h ../../lib/alg/generic/heapDebug.h
+$(OUTDIR)/basicLoggingService.o: ../../lib/components/base/basicLoggingService.cpp ../../lib/components/base/basicLoggingService.h
+$(OUTDIR)/basicMediaDestination.o: ../../lib/components/base/basicMediaDestination.cpp ../../lib/components/base/basicMediaDestination.h
+$(OUTDIR)/basicMediaSource.o: ../../lib/components/base/basicMediaSource.cpp ../../lib/components/base/basicMediaSource.h
+$(OUTDIR)/basicMediaViewer.o: ../../lib/components/base/basicMediaViewer.cpp ../../lib/components/base/basicMediaViewer.h
+$(OUTDIR)/basicMutex.o: ../../lib/components/base/basicMutex.cpp ../../lib/components/base/basicMutex.h
+$(OUTDIR)/basicObject.o: ../../lib/components/base/basicObject.cpp ../../lib/components/base/basicObject.h ../../lib/alg/generic/md5.h
+$(OUTDIR)/basicRing.o: ../../lib/components/base/basicRing.cpp ../../lib/components/base/basicRing.h
+$(OUTDIR)/basicSettings.o: ../../lib/components/base/basicSettings.cpp ../../lib/components/base/basicSettings.h
+$(OUTDIR)/basicSettingsProvider.o: ../../lib/components/base/basicSettingsProvider.cpp ../../lib/components/base/basicSettingsProvider.h
+$(OUTDIR)/basicThread.o: ../../lib/components/base/basicThread.cpp ../../lib/components/base/basicThread.h
+$(OUTDIR)/basicTransport.o: ../../lib/components/base/basicTransport.cpp ../../lib/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h
+$(OUTDIR)/IM_Backend.o: IM_Backend.cpp IM_Backend.h ../../lib/components/base/basicSettings.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicMemoryOperation.h ../../lib/components/object/objectFileLoggingService.h ../../lib/components/object/objectConsoleLoggingService.h ../../lib/data/net/netServer.h IM_Kernel.h ../../lib/data/net/netServiceEngine.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicSettingsProvider.h IM_DataStructs.h ../../lib/components/base/basicFunctionality.h IM_DnnWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DLibWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h
+$(OUTDIR)/IM_ClientHandler.o: IM_ClientHandler.cpp IM_ClientHandler.h ../../lib/data/net/netClientHandler.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicLogCollection.h ../../lib/data/net/serverPort.h ../../lib/data/net/netServiceEngine.h IM_ClientProtocol.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_Kernel.h ../../lib/data/net/netServiceEngine.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicSettingsProvider.h IM_DataStructs.h ../../lib/components/base/basicFunctionality.h IM_DnnWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DLibWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h ../../lib/components/base/basicFunctionality.h ../../lib/data/json/json_tool.h ../../lib/data/protocol/xmlParser.h ../../lib/include/json/value.h ../../lib/include/json/writer.h ../../lib/include/json/reader.h
+$(OUTDIR)/IM_ClientProtocol.o: IM_ClientProtocol.cpp IM_ClientProtocol.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h
+$(OUTDIR)/IM_DataBaseAdapter.o: IM_DataBaseAdapter.cpp IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h ../../lib/alg/generic/md5.h
+$(OUTDIR)/IM_DataStructs.o: IM_DataStructs.cpp IM_DataStructs.h ../../lib/components/base/basicFunctionality.h
+$(OUTDIR)/IM_DLibWorker.o: IM_DLibWorker.cpp IM_DLibWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h ../../lib/alg/generic/md5.h ../../lib/components/base/basicFunctionality.h
+$(OUTDIR)/IM_DnnWorker.o: IM_DnnWorker.cpp IM_DnnWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicFunctionality.h
+$(OUTDIR)/IM_Kernel.o: IM_Kernel.cpp IM_Kernel.h ../../lib/data/net/netServiceEngine.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicSettingsProvider.h IM_DataStructs.h ../../lib/components/base/basicFunctionality.h IM_DnnWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DLibWorker.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicEventHeap.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h IM_ClientHandler.h ../../lib/data/net/netClientHandler.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicLogCollection.h ../../lib/data/net/serverPort.h ../../lib/data/net/netServiceEngine.h IM_ClientProtocol.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h IM_DataBaseAdapter.h ../../lib/data/mysql/mysql_class.h
+$(OUTDIR)/json_reader.o: ../../lib/data/json/json_reader.cpp ../../lib/data/json/json_tool.h ../../lib/include/json/assertions.h ../../lib/include/json/reader.h ../../lib/include/json/value.h
+$(OUTDIR)/json_value.o: ../../lib/data/json/json_value.cpp ../../lib/include/json/assertions.h ../../lib/include/json/value.h ../../lib/include/json/writer.h ../../lib/data/json/json_valueiterator.inl
+$(OUTDIR)/json_writer.o: ../../lib/data/json/json_writer.cpp ../../lib/data/json/json_tool.h ../../lib/include/json/writer.h
+$(OUTDIR)/md5.o: ../../lib/alg/generic/md5.cpp ../../lib/alg/generic/md5.h
+$(OUTDIR)/mysql_class.o: ../../lib/data/mysql/mysql_class.cpp ../../lib/data/mysql/mysql_class.h
+$(OUTDIR)/netClientHandler.o: ../../lib/data/net/netClientHandler.cpp ../../lib/data/net/netClientHandler.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicLogCollection.h ../../lib/data/net/serverPort.h ../../lib/data/net/netServiceEngine.h
+$(OUTDIR)/netServer.o: ../../lib/data/net/netServer.cpp ../../lib/data/net/netServer.h ../../lib/data/net/netClientHandler.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicLogCollection.h ../../lib/data/net/serverPort.h ../../lib/data/net/netServiceEngine.h
+$(OUTDIR)/objectConsoleLoggingService.o: ../../lib/components/object/objectConsoleLoggingService.cpp ../../lib/components/object/objectConsoleLoggingService.h
+$(OUTDIR)/objectFileLoggingService.o: ../../lib/components/object/objectFileLoggingService.cpp ../../lib/components/object/objectFileLoggingService.h
+$(OUTDIR)/protocol.o: ../../lib/data/protocol/protocol.cpp ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h
+$(OUTDIR)/serverPort.o: ../../lib/data/net/serverPort.cpp ../../lib/data/net/serverPort.h
+$(OUTDIR)/transportSocket.o: ../../lib/data/transport/transportSocket.cpp ../../lib/data/transport/transportSocket.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicSettingsProvider.h ../../lib/components/base/basicThread.h
+$(OUTDIR)/xmlParser.o: ../../lib/data/protocol/xmlParser.cpp ../../lib/data/protocol/xmlParser.h
diff --git a/lib/App/common/SQLite_dataBinder.cpp b/lib/App/common/SQLite_dataBinder.cpp
index 05a6cb01..d1965b80 100644
--- a/lib/App/common/SQLite_dataBinder.cpp
+++ b/lib/App/common/SQLite_dataBinder.cpp
@@ -760,10 +760,62 @@ void sqliteDBC::updateStats( bool evt, bool video, uint8_t ses_status ){
m_pDataStatistics->SilentQuery( tQBuf );
break;
};
+ case SESSION_DROP:{
+ //sprintf( tQBuf, "UPDATE `days` SET `session_count`=`session_count`-1, `session_closed`=1 WHERE `year`='%s' AND `month`='%s' AND `day`='%s'",
+ sprintf( tQBuf, "UPDATE `days` SET `session_closed`=1 WHERE `year`='%s' AND `month`='%s' AND `day`='%s'",
+ m_sCRepInfo.YEAR, m_sCRepInfo.MONTH, m_sCRepInfo.DAY );
+#ifdef DEBUG_ALL
+ LOG( tQBuf );
+#endif
+ m_pDataStatistics->SilentQuery( tQBuf );
+ break;
+ };
};
};
};
+bool sqliteDBC::dropSession(){
+ if ( m_bRepIsConnected ) {
+ char tQBuf[1024];
+ AAssoc *result;
+ sprintf( tQBuf, "SELECT `ts`, `ts_ms` FROM `events` WHERE `evt_type`=%d ORDER BY `ts` DESC,`ts_ms` DESC LIMIT 1", EVT_LRF_START_SESSION );
+ m_pDataReports->Query(tQBuf);
+#ifdef DEBUG_ALL
+ LOG(tQBuf);
+#endif
+ result = m_pDataReports->Query( tQBuf );
+ if( result!= NULL ) {
+ uint32_t ts = 0;
+ uint32_t ms = 0;
+ uint64_t r = 0;
+ if( result->size() > 0 ) {
+ Assoc *cArr;
+ Assoc::iterator it;
+ cArr = result->at(0);
+ it = cArr->find("ts");
+ if( it != cArr->end() ){
+ ts = atoi( it->second.c_str() );
+ };
+ it = cArr->find("ts_ms");
+ if( it != cArr->end() ){
+ ms = atoi( it->second.c_str() );
+ };
+ r = ts;
+ r = ( r * 1000 ) + ms;
+ };
+ deleteResult( result );
+ if ( r ) {
+ sprintf(tQBuf, "DELETE FROM `events` WHERE (`ts`*1000+`ts_ms`) >= %" PRIu64, r );
+#ifdef DEBUG_ALL
+ LOG(tQBuf);
+#endif
+ m_pDataReports->SilentQuery( tQBuf );
+ };
+ };
+ };
+ updateStats( false, false, SESSION_DROP );
+ return true;
+}
uint32_t sqliteDBC::addEvent( DBC_EVT_RECORD *ptr ){
if ( ptr == NULL ) return 0;
if ( m_bRepIsConnected ) {
@@ -796,15 +848,46 @@ uint32_t sqliteDBC::addEvent( DBC_EVT_RECORD *ptr ){
case EVT_FLT_LATF_TRP_DET:
case EVT_FLT_LATF_TRP_UPDT:
case EVT_FLT_LATF_SUSP_START:
- case EVT_FLT_LATF_SUSP_NAK:
case EVT_FLT_LATF_REGULAR:
case EVT_FLT_LATF_DISABLED:
case EVT_FLT_LATF_SUSP_DET:
- case EVT_FLT_LATF_DIFF_DET:
+ case EVT_FLT_LATF_DIFF_DET:{
+ updateStats();
+ sprintf( tQBuf, "INSERT INTO `events`(`node_id`,`uuid`,`ts`,`ts_ms`,`evt_type`,`lrf_id`,`range_digital`,`azimuth`,`range`,`area`,`lat`,`lon`,`alt`)" \
+ " VALUES(%d,'%s',%d,%d,%d,%d,%d,%0.2f,%0.2f,%0.2f,%0.7f,%0.7f,%0.2f)",
+ ptr->node_id,
+ ptr->uuid,
+ ptr->ts_s,
+ ptr->ts_ms,
+ ptr->type,
+ ptr->lrf_id,
+ ptr->range_digital,
+ ptr->az,
+ ptr->ra,
+ ptr->area,
+ ptr->lat,
+ ptr->lon,
+ ptr->alt
+ );
+ break;
+ };
case EVT_FLT_LATF_OP_DISABLED:
case EVT_FLT_LATF_OP_TD:
case EVT_FLT_LATF_OP_TG:
case EVT_FLT_LATF_OP_EXP:
+ case EVT_FLT_LATF_TRP_EXP:
+ case EVT_FLT_LATF_SUSP_NAK:
+ case EVT_FLT_LATF_SUSP_EXP:{
+ updateStats();
+ sprintf( tQBuf, "INSERT INTO `events`(`node_id`,`uuid`,`ts`,`ts_ms`,`evt_type`) VALUES(%d,'%s',%d,%d,%d)",
+ ptr->node_id,
+ ptr->uuid,
+ ptr->ts_s,
+ ptr->ts_ms,
+ ptr->type
+ );
+ break;
+ };
case EVT_OP_ACK_MASK:
case EVT_OP_NACK_MASK:
case EVT_OP_ON_MASK:
@@ -2880,6 +2963,14 @@ DBC_SITE_DATA *sqliteDBC::getSiteData( uint32_t ID ){
if( it != cArr->end() ){
tVal->remote_port = atoi(it->second.c_str());
};
+ it = cArr->find("remote_backup_ip");
+ if( it != cArr->end() ){
+ sprintf( tVal->remote_ip, it->second.c_str() );
+ };
+ it = cArr->find("remote_backup_port");
+ if( it != cArr->end() ){
+ tVal->remote_port = atoi(it->second.c_str());
+ };
it = cArr->find("use_remote_server");
if( it != cArr->end() ){
tVal->use_remote_server = atoi(it->second.c_str());
@@ -3036,10 +3127,26 @@ TRAIN_FILTER_DATA *sqliteDBC::getTrainFilterData( uint32_t ID ){
if( it != cArr->end() ){
strncpy( tVal->aux_ip, it->second.c_str(), 15 );
};
- //it = cArr->find("AUX_PORT");
- //if( it != cArr->end() ){
- // tVal->aux_port = atoi( it->second.c_str() );
- //};
+ it = cArr->find("AUX_PORT");
+ if( it != cArr->end() ){
+ tVal->aux_port = atoi( it->second.c_str() );
+ };
+#ifdef EFT_AUTO_RESET_UPPER_SENSOR
+ it = cArr->find("UPPER_RESTART");
+ if( it != cArr->end() ){
+ tVal->nUpperSensorRestartTO = atoi( it->second.c_str() ) * 3600; // Hours -> Seconds
+ } else {
+ tVal->nUpperSensorRestartTO = 24 * 3600;
+ };
+#endif
+#ifdef EFT_MINIMAL_RANGE_SUSPICIOUS
+ it = cArr->find("MINIMAL_RANGE");
+ if( it != cArr->end() ){
+ tVal->fMinimalRange = atof( it->second.c_str() );
+ } else {
+ tVal->fMinimalRange = 0.0;
+ };
+#endif
it = cArr->find("DEBUG");
if( it != cArr->end() ){
tVal->bDebugMode = (bool)atoi( it->second.c_str() );
@@ -4102,10 +4209,10 @@ DBC_CAM_DATA *sqliteDBC::getCamData( uint32_t ID ){
if( it != cArr->end() ){
tVal->homing_to = atoi( it->second.c_str() );
};
- //it = cArr->find("home_token");
- //if( it != cArr->end() ){
- // strncpy( tVal->home_token, it->second.c_str(), 32 );
- //};
+ it = cArr->find("home_token");
+ if( it != cArr->end() ){
+ strncpy( tVal->home_token, it->second.c_str(), 32 );
+ };
it = cArr->find("eco_ir");
if( it != cArr->end() ){
tVal->eco_ir = (bool) atoi( it->second.c_str() );
diff --git a/lib/App/common/SQLite_dataBinder.h b/lib/App/common/SQLite_dataBinder.h
index 5da8c82f..aa10c466 100644
--- a/lib/App/common/SQLite_dataBinder.h
+++ b/lib/App/common/SQLite_dataBinder.h
@@ -12,6 +12,8 @@
#define SESSION_CONTINUE 0x00
#define SESSION_START 0x01
#define SESSION_END 0x02
+#define SESSION_DROP 0x03
+
class sqliteDBC: public dataBinder {
private:
basicLogCollection * m_pLog;
@@ -67,6 +69,7 @@ class sqliteDBC: public dataBinder {
virtual bool isLocal( void ) const { return true; };
virtual bool addDeviceDraw( uint32_t DBID, uint8_t type, uint8_t lrf, void *th_data, uint32_t th_size );
virtual uint32_t addEvent( DBC_EVT_RECORD *ptr );
+ virtual bool dropSession();
virtual bool addIPCam( OBSERVER_RESULT *tPtr );
virtual uint32_t addLocalCam( CSTR name, CSTR hardware, CSTR path, uint32_t width, uint32_t height, uint16_t fps, uint16_t den = 1 );
virtual uint32_t addLocalNetwork( uint32_t NIF_ID, NETWORK_TYPE net_type, CSTR address, CSTR mask, CSTR gateway, CSTR broadcast );
diff --git a/lib/App/common/dataBinder.h b/lib/App/common/dataBinder.h
index 417f2e86..afd01088 100644
--- a/lib/App/common/dataBinder.h
+++ b/lib/App/common/dataBinder.h
@@ -12,6 +12,7 @@ class dataBinder{
virtual bool isLocal(){ return true; };
//virtual uint32_t addEvent( uint32_t SRC, CSTR UUID, uint32_t tss, uint32_t tsms, uint8_t evt_type, uint8_t k_id=0, uint16_t dig_r=0, float EL=.0f, float AZ=.0f, float RANGE=.0f, float AREA=.0f, float lat=.0f, float lon=.0f, float alt=.0f, uint32_t RefID=0, CSTR RefUUID=NULL );
virtual uint32_t addEvent( DBC_EVT_RECORD *ptr ){ return 0;};
+ virtual bool dropSession(){ return false; };
virtual bool addDeviceDraw( uint32_t DBID, uint8_t type, uint8_t lrf, void *th_data, uint32_t th_size ){ return false;};
//virtual bool addLRFDraw( uint32_t DBID, uint32_t SIZE, CSTR ID, uint8_t kID =0, uint8_t type = 0, bool rendered = false ){ return false;};
diff --git a/lib/App/common/dataBinder_structures.h b/lib/App/common/dataBinder_structures.h
index d1b088a6..375afb22 100644
--- a/lib/App/common/dataBinder_structures.h
+++ b/lib/App/common/dataBinder_structures.h
@@ -235,7 +235,7 @@ typedef struct S_DBC_CAM_DATA{
bool manual;
bool homing_enable;
uint32_t homing_to;
- //char home_token[33];
+ char home_token[33];
bool eco_ir;
bool prefered_events_only;
}DBC_CAM_DATA;
@@ -562,6 +562,8 @@ typedef struct S_DBC_SITE_DATA{
uint32_t preserve_empty;
char remote_ip[16];
uint16_t remote_port;
+ char remote_backup_ip[16];
+ uint16_t remote_backup_port;
bool use_remote_server;
bool skip_local_report;
}DBC_SITE_DATA;
@@ -726,6 +728,9 @@ typedef struct S_DBC_SSDP_SETTINGS{
}DBC_SSDP_SETTINGS;
+#define EFT_AUTO_RESET_UPPER_SENSOR
+#define EFT_MINIMAL_RANGE_SUSPICIOUS
+
typedef struct S_TRAIN_FILTER_DATA{
uint8_t bZoneCount;
uint32_t nUpperSensorID;
@@ -738,6 +743,12 @@ typedef struct S_TRAIN_FILTER_DATA{
uint32_t nSuspectTime;
char aux_ip[16];
uint16_t aux_port;
+#ifdef EFT_AUTO_RESET_UPPER_SENSOR
+ uint32_t nUpperSensorRestartTO;
+#endif
+#ifdef EFT_MINIMAL_RANGE_SUSPICIOUS
+ float fMinimalRange;
+#endif
}TRAIN_FILTER_DATA;
typedef struct S_VIDEO_SEGMENT_INFO{
diff --git a/lib/App/common/deviceNode.h b/lib/App/common/deviceNode.h
index 8af2f7c2..e972f5be 100644
--- a/lib/App/common/deviceNode.h
+++ b/lib/App/common/deviceNode.h
@@ -21,6 +21,7 @@ class deviceNode: public cmdNodeConveyor, public basicEngine{
uint32_t getDeviceParam() const { return m_sNodeData.aux_parameter; };
ARGUS_NODE_TYPE getNodeType() const { return (ARGUS_NODE_TYPE) m_sNodeData.type; };
bool isNodeOnline( void ) const { return m_sNodeData.online; };
+ virtual bool reset(){ return false; };
virtual bool validate();
};
diff --git a/lib/App/common/deviceNode2D.cpp b/lib/App/common/deviceNode2D.cpp
index 017495b8..78237192 100644
--- a/lib/App/common/deviceNode2D.cpp
+++ b/lib/App/common/deviceNode2D.cpp
@@ -58,6 +58,7 @@ void device2DSensor::cleanupDeviceStructures( void ){
m_bRequestedDeviceWM = MODE_NONE;
//m_bSupportedFS = false;
m_bDeviceIsSynced = false;
+ m_bTargetArived = false;
m_nSleepTime = LGS_DEFAULT_SLEEP_TIME;
#ifdef DEBUG_EXTRA
LOG("Clean Basic Structures!");
@@ -171,6 +172,14 @@ bool device2DSensor::stopService() {
bool device2DSensor::validate(){
if( m_pDBC == NULL ) return false;
+ //Validate Alarm mode
+ if( m_bTargetArived == false ){
+ // Clear Alarm Mode to Idle
+ if( LRF_WM_ALARM == getWM() ){
+ if( m_sLRF_DATA.data_status != ARGUS_DS_READY ) updateDataStatus( ARGUS_DS_READY );
+ setWM( LRF_WM_IDLE );
+ };
+ } else m_bTargetArived = false;
// Check Settings
if( !deviceNodeSensor::validate() ) return false;
return true;
@@ -435,6 +444,22 @@ void device2DSensor::readMode(){
case STG_POOL: poolStateFunction(); break;
};
};
+
+bool device2DSensor::reset(){
+ DELAY_10MS(10); // 100 ms
+ if( !doFullReset()) {
+ LOG_ERROR("Fall Back to Disconnected!");
+ setWM( LRF_WM_CONNECTION );
+ return false;
+ } else {
+ m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
+ updateDataStatus( ARGUS_DS_BUSY );
+ DELAY_10MS(10); // 100 ms
+ };
+ setWM( LRF_WM_CONNECTION );
+ return true;
+};
+
/*
NOTE: The Detection parameters must be sent by last transaction
*/
@@ -2813,7 +2838,6 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){
#endif
m_bDeviceIsSynced = true; // At this point all data structs must be synced?!
//setStage( LRF_WS_STAGE_2 );
-
while( Package->m_nSize > ( cIDX + 2 ) ) {
m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER;
switch( Package->m_pData[cIDX+1] ) {
@@ -2834,6 +2858,8 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){
//Triggering Session in Kernel
kernelPrototype *AK = kernelPrototype::getInstance();
if ( AK ) AK->startSession();
+ if( m_sLRF_DATA.data_status != ARGUS_DS_ALARMED ) updateDataStatus( ARGUS_DS_ALARMED );
+ m_bTargetArived = true;
#ifdef DEBUG_EXTRA
sprintf( tBuff, "AZ: %d RANGE: %d WIDTH: %d", AZ, RANGE, WIDTH );
@@ -2844,10 +2870,7 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){
if( m_pTargetFilter != NULL ) {
if( m_pTargetFilter->validateTarget( m_sNodeData.node_id, tData ) ){
free( tData );
- //Proceed Statuss of target
- if ( LRF_WM_ALARM != getWM()) {
- setWM(LRF_WM_ALARM);
- };
+ if ( LRF_WM_ALARM != getWM()) setWM(LRF_WM_ALARM);
cIDX += 6;
break;
};
@@ -2865,9 +2888,7 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){
#else
free( tData );
#endif
- if ( LRF_WM_ALARM != getWM()) {
- setWM(LRF_WM_ALARM);
- };
+ if ( LRF_WM_ALARM != getWM()) setWM(LRF_WM_ALARM);
cIDX += 6;
break;
};
@@ -3004,6 +3025,8 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){
//Triggering Session in Kernel
kernelPrototype *AK = kernelPrototype::getInstance();
if ( AK ) AK->startSession();
+ if( m_sLRF_DATA.data_status != ARGUS_DS_ALARMED ) updateDataStatus( ARGUS_DS_ALARMED );
+ m_bTargetArived = true;
#ifdef DEBUG_EXTRA
sprintf( tBuff, "AZ: %d RANGE: %d WIDTH: %d", AZ, RANGE, WIDTH );
@@ -3014,14 +3037,7 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){
if( m_pTargetFilter != NULL ) {
if( m_pTargetFilter->validateTarget( m_sNodeData.node_id, tData ) ){
free( tData );
- if( m_sLRF_DATA.data_status!= ARGUS_DS_ALARMED ) updateDataStatus( ARGUS_DS_ALARMED );
- //Proceed Statuses Of Target
- //if ( !m_bSessionStarted ) startSession();
- //m_nSleepTime = LGS_ALERT_SLEEP_TIME;
- if ( LRF_WM_ALARM != getWM()) {
- setWM(LRF_WM_ALARM);
- };
-
+ if ( LRF_WM_ALARM != getWM()) setWM(LRF_WM_ALARM);
cIDX += 10;
break;
};
@@ -3039,12 +3055,7 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){
#else
free( tData );
#endif
- if( m_sLRF_DATA.data_status!= ARGUS_DS_ALARMED ) updateDataStatus( ARGUS_DS_ALARMED );
- //m_nSleepTime = LGS_ALERT_SLEEP_TIME;
- if ( LRF_WM_ALARM != getWM()) {
- setWM(LRF_WM_ALARM);
- };
-
+ if ( LRF_WM_ALARM != getWM()) setWM(LRF_WM_ALARM);
cIDX += 10;
break;
};
diff --git a/lib/App/common/deviceNode2D.h b/lib/App/common/deviceNode2D.h
index 2f7a00ef..060029bd 100644
--- a/lib/App/common/deviceNode2D.h
+++ b/lib/App/common/deviceNode2D.h
@@ -17,6 +17,8 @@
#define SEND_MASKS_VIA_FILE
+//#define SIMULATE_2D_TARGETS
+
//To Save rasterized masks
#ifdef DEBUG
#include
@@ -132,6 +134,7 @@ class device2DSensor: public deviceNodeSensor, public protocolLGS_2D{
bool m_bForceSync;
bool m_bSerialStringValid;
bool m_bVersionStringValid;
+ bool m_bTargetArived;
char m_tSN[65];
char m_tSV[129];
@@ -193,6 +196,8 @@ class device2DSensor: public deviceNodeSensor, public protocolLGS_2D{
virtual void proceedDBCommands();
virtual void cleanupDeviceStructures();
+ virtual bool reset();
+
virtual void save_ini();
virtual void save_detection();
virtual void save_masks();
diff --git a/lib/App/common/deviceNodeCamera.cpp b/lib/App/common/deviceNodeCamera.cpp
index f67f695e..9dfdac4e 100644
--- a/lib/App/common/deviceNodeCamera.cpp
+++ b/lib/App/common/deviceNodeCamera.cpp
@@ -1205,9 +1205,10 @@ void deviceNodeCamera::m_fThreadProc( void ){
break;
};
case CAM_WS_GO_HOMING_PRESET:{
- CSTR TK = getPresetToken( ARGUS_PRESET_TYPE_HOME );
- if( TK ) {
- if ( !m_bCameraOnHomePosition ) {
+ if ( !m_bCameraOnHomePosition ) {
+ // For new Camera Presets
+ CSTR TK = getPresetToken( ARGUS_PRESET_TYPE_HOME );
+ if( TK ) {
#ifdef DEBUG_EXTRA
LOG("Go Home!");
LOG( TK );
@@ -1215,10 +1216,21 @@ void deviceNodeCamera::m_fThreadProc( void ){
if( !m_pProtocol->goPreset( TK )){
LOG_ERROR("Cannot Issue goPreset Command!");
};
- m_bCameraOnHomePosition = true;
- m_bCurrentPresetCol = 0;
- m_bCurrentPresetRow = 0;
+ } else {
+ //Old Method
+ if( m_sCamData.home_token[0] != (char)0 ) {
+#ifdef DEBUG_EXTRA
+ LOG("Go Home!");
+ LOG( m_sCamData.home_token );
+#endif
+ if( !m_pProtocol->goPreset( m_sCamData.home_token )){
+ LOG_ERROR("Cannot Issue goPreset Command!");
+ };
+ };
};
+ m_bCameraOnHomePosition = true;
+ m_bCurrentPresetCol = 0;
+ m_bCurrentPresetRow = 0;
};
setWM( CAM_WS_READY );
break;
diff --git a/lib/App/common/deviceNodeSensor.cpp b/lib/App/common/deviceNodeSensor.cpp
index 29437f15..cd8fbf03 100644
--- a/lib/App/common/deviceNodeSensor.cpp
+++ b/lib/App/common/deviceNodeSensor.cpp
@@ -1047,7 +1047,7 @@ void deviceNodeSensor::m_fThreadProc( void ){
setWM( LRF_WM_CONNECTION );
DELAY_10MS( 200 );
};
- };
+ };
switch( getWM() ) {
case LRF_WM_INIT: reloadDeviceNodeFromDB(); setWM( LRF_WM_CONNECTION ); break;
case LRF_WM_CONNECTION: connectMode(); break;
diff --git a/lib/App/common/deviceNodeSensor.h b/lib/App/common/deviceNodeSensor.h
index 0d52369d..85bb349c 100644
--- a/lib/App/common/deviceNodeSensor.h
+++ b/lib/App/common/deviceNodeSensor.h
@@ -243,7 +243,7 @@ class deviceNodeSensor: public deviceNode, public basicThread{
explicit deviceNodeSensor( DBC_NODE_DATA *Data );
virtual ~deviceNodeSensor();
virtual void simulateTarget( void ){};
- bool validate();
+ virtual bool validate();
};
diff --git a/lib/App/common/kernelEventFilter.cpp b/lib/App/common/kernelEventFilter.cpp
index eec4867f..2bbd3570 100644
--- a/lib/App/common/kernelEventFilter.cpp
+++ b/lib/App/common/kernelEventFilter.cpp
@@ -35,17 +35,30 @@ kernelEventFilter::kernelEventFilter( uint32_t id, TARGET_FILTER_TYPE type ){
kernelEventFilter::~kernelEventFilter(){
};
-void kernelEventFilter::createFilterEvent( basicEventTypeID typ, CSTR msg ){
+void kernelEventFilter::createFilterEvent( basicEventTypeID typ, TARGET_DATA *ptr, CSTR msg, uint32_t special ){
if ( m_pEventHeap!= NULL ) {
EVENT_CONTAINER *tEvt = NULL;
- switch ( m_sFilterData.type ) {
+ TARGET_DATA *local_ptr = NULL;
+ if ( ptr ) {
+ local_ptr = ( TARGET_DATA *) malloc( sizeof( TARGET_DATA ));
+ if ( local_ptr ) {
+ memcpy( local_ptr, ptr, sizeof( TARGET_DATA ) );
+ };
+ };
+ switch (m_sFilterData.type) {
case TF_LA_METRO_TRAIN_FILTER:{
- tEvt = createBasicEvent( m_sFilterData.id, EVT_CLASS_KRNL_FILTER_LATF, typ, NULL, msg );
+ if( special ){
+ tEvt = createBasicEvent( special, EVT_CLASS_KRNL_FILTER_LATF, typ, NULL, msg, local_ptr );
+ } else {
+ tEvt = createBasicEvent(m_sFilterData.id, EVT_CLASS_KRNL_FILTER_LATF, typ, NULL, msg, local_ptr );
+ };
break;
};
};
if( tEvt ){
m_pEventHeap->broadcast( tEvt );
+ } else {
+ if ( local_ptr ) free( local_ptr );
};
};
};
diff --git a/lib/App/common/kernelEventFilter.h b/lib/App/common/kernelEventFilter.h
index 840f1f39..499f33d1 100644
--- a/lib/App/common/kernelEventFilter.h
+++ b/lib/App/common/kernelEventFilter.h
@@ -12,7 +12,7 @@ class kernelEventFilter{
dataBinder * m_pDBC;
basicEventHeap * m_pEventHeap;
bool m_bActive;
- void createFilterEvent( basicEventTypeID typ, CSTR msg = NULL );
+ void createFilterEvent( basicEventTypeID typ, TARGET_DATA *ptr = NULL, CSTR msg = NULL, uint32_t special = 0 );
public:
explicit kernelEventFilter( uint32_t id, TARGET_FILTER_TYPE type = TF_UNDEFINED_FILTER );
virtual ~kernelEventFilter();
diff --git a/lib/App/common/kernelEventFilterTrain.cpp b/lib/App/common/kernelEventFilterTrain.cpp
index 9852e304..e4e2450d 100644
--- a/lib/App/common/kernelEventFilterTrain.cpp
+++ b/lib/App/common/kernelEventFilterTrain.cpp
@@ -16,94 +16,110 @@
kernelEventFilterTrain::kernelEventFilterTrain( uint32_t id ): kernelEventFilter( id, TF_LA_METRO_TRAIN_FILTER ){
m_pLog = basicLogCollection::getInstance();
m_oOSP_Helper = NULL;
- memset( &m_sTrainFilterData, 0, sizeof(TRAIN_FILTER_DATA));
+ m_nAutoResetUpperTO = 0;
+ memset( &m_sTrainFilterData, 0, sizeof(TRAIN_FILTER_DATA));
};
kernelEventFilterTrain::~kernelEventFilterTrain(){
if( m_oOSP_Helper ) delete( m_oOSP_Helper );
};
+#ifdef EFT_AUTO_RESET_UPPER_SENSOR
+ #include "deviceNodeFactory.h"
+#endif
+
bool kernelEventFilterTrain::validate(){
if ( m_pDBC == NULL ) return false;
TRAIN_FILTER_DATA *tData = m_pDBC->getTrainFilterData( m_sFilterData.aux_id );
if ( tData ) {
if( memcmp(&m_sTrainFilterData, tData, sizeof(TRAIN_FILTER_DATA) ) != 0 ) {
+ m_mStateProtector.lock();
memcpy(&m_sTrainFilterData, tData, sizeof(TRAIN_FILTER_DATA));
+ m_mStateProtector.unlock();
};
free( tData );
- return true;
- };
- return kernelEventFilter::validate();
-};
-
-void kernelEventFilterTrain::createEvent( uint8_t EVT ){
- if( m_sTrainFilterData.bDebugMode ){
- createFilterEvent( (basicEventTypeID) EVT );
- } else {
- if( m_sTrainFilterData.bDetectTrain ) {
- if( ( (basicEventTypeID) EVT ) == EVT_FLT_LATF_OP_TD ) createFilterEvent( EVT_FLT_LATF_OP_TD );
- };
- };
-};
-
-bool kernelEventFilterTrain::validateTarget( uint32_t DevID, TARGET_DATA *ptr ){
- if( m_bActive && ( ptr != NULL ) ){
-#ifdef DEBUG_EXTRA
- if( m_sTrainFilterData.bDebugMode ){
- createFilterEvent( EVT_FLT_LATF_CHK );
- char tmpC[CTEXT];
- // Mark Event Message
- sprintf( tmpC, "A:%0.3f R:%0.3f W:%d", ptr->local_target.fi, ptr->local_target.r, ptr->area );
- LOG( tmpC );
- };
+ } else return false;
+#ifdef EFT_AUTO_RESET_UPPER_SENSOR
+ if ( m_sTrainFilterData.nUpperSensorRestartTO ) {
+ /// Restart Upper Sensor
+ if ( m_nAutoResetUpperTO > m_sTrainFilterData.nUpperSensorRestartTO ) {
+ LOG("Reseting Upper Sensor [Maintenece]");
+ deviceNodeFactory *tFactory = deviceNodeFactory::getInstance();
+ if ( tFactory ) {
+ deviceNode *tNode = tFactory->getNode( m_sTrainFilterData.nUpperSensorID );
+ if ( tNode ) {
+ if ( tNode->reset() ) {
+ // Block Detections
+ m_sUpperZone.TrainOnTheField = true;
+ m_nAutoResetUpperTO = 0;
+ } else LOG_ERROR("Failure to Reset Upper Sensor!");
+ } else LOG_ERROR("Cannot Get Upper Sensor from Node Factory!");
+ } else LOG_ERROR("Cannot Get Node Factory!");
+ } else m_nAutoResetUpperTO++;
+ } else m_nAutoResetUpperTO = 0;
#endif
- // Validate Zones and statuses (EXP)
+ // Internal values
+ if( m_bActive ){
+
uint64_t cts = getMilliseconds();
+ m_mStateProtector.lock();
+ // Validate Zones and statuses (EXP)
//Upper Sensor Zone
if( m_sUpperZone.TrainOnTheField ){
if( ( cts - m_sUpperZone.ts ) > m_sTrainFilterData.nDecisionTime ){
// Clear Expired Suspicious
- m_sUpperZone.TrainOnTheField = false;
- m_sUpperZone.startAngle = 0;
- m_sUpperZone.endAngle = 0;
+ memset( &m_sUpperZone, 0, sizeof( EFT_UPPER_ZONE ) );
+ createEvent( EVT_FLT_LATF_TRP_EXP );
#ifdef SECOND_PEER_PORT
// Inform Other Peer train is gone
if( m_oOSP_Helper ) m_oOSP_Helper->setLocalStatus( m_sUpperZone.TrainOnTheField );
#endif
- };
- };
- if( m_sUpperZone.SuspiciousUnconfirmed ){
- if( ( cts - m_sUpperZone.ts ) > ( m_sTrainFilterData.nSuspectTime << 1 ) ){
- m_sUpperZone.SuspiciousUnconfirmed = false;
- };
- };
- if( m_sUpperZone.SuspiciousObject ){
- if( ( cts - m_sUpperZone.ts ) > m_sTrainFilterData.nSuspectTime ){
- m_sUpperZone.SuspiciousObject = false;
- if( !m_sUpperZone.TrainOnTheField ) m_sUpperZone.SuspiciousUnconfirmed = true;
+
};
};
//Bottom Sensor Zone
- if( m_sBottomZone.TrainOnTheField ){
- if( ( cts - m_sBottomZone.ts ) > m_sTrainFilterData.nDecisionTime ){
- // Clear Expired Suspicious
- m_sBottomZone.TrainOnTheField = false;
- m_sBottomZone.startAngle = 0;
- m_sBottomZone.endAngle = 0;
- };
- };
if( m_sBottomZone.SuspiciousUnconfirmed ){
if( ( cts - m_sBottomZone.ts ) > ( m_sTrainFilterData.nSuspectTime << 1 ) ){
- m_sBottomZone.SuspiciousUnconfirmed = false;
+ //m_sBottomZone.SuspiciousUnconfirmed = false;
+ // Clear Expired Suspicious
+ memset( &m_sBottomZone, 0, sizeof( EFT_BOTTOM_ZONE ) );
+ createEvent( EVT_FLT_LATF_SUSP_EXP );
};
};
if( m_sBottomZone.SuspiciousObject ){
if( ( cts - m_sBottomZone.ts ) > m_sTrainFilterData.nSuspectTime ){
m_sBottomZone.SuspiciousObject = false;
- if( !m_sBottomZone.TrainOnTheField ) m_sBottomZone.SuspiciousUnconfirmed = true;
+ m_sBottomZone.SuspiciousUnconfirmed = true;
+ createEvent( EVT_FLT_LATF_SUSP_NAK );
};
};
+ m_mStateProtector.unlock();
+ };
+ return kernelEventFilter::validate();
+};
+void kernelEventFilterTrain::createEvent( uint8_t EVT ){
+ if( m_sTrainFilterData.bDebugMode ){
+ createFilterEvent( (basicEventTypeID) EVT );
+ } else {
+ if( m_sTrainFilterData.bDetectTrain ) {
+ //if( ( (basicEventTypeID) EVT ) == EVT_FLT_LATF_TRP_DET ) createFilterEvent( EVT_FLT_LATF_TRP_DET );
+ if( ( (basicEventTypeID) EVT ) == EVT_FLT_LATF_OP_TD ) {
+ //Triggering Session in Kernel
+ kernelPrototype *AK = kernelPrototype::getInstance();
+ if ( AK ) AK->startSession();
+ createFilterEvent( EVT_FLT_LATF_OP_TD );
+ };
+ };
+ };
+};
+
+bool kernelEventFilterTrain::validateTarget( uint32_t DevID, TARGET_DATA *ptr ){
+ if( m_bActive && ( ptr != NULL ) ){
+
+ uint64_t cts = getMilliseconds();
+ // Validate Zones and statuses (EXP) -> Moved to Filter Validation
+ m_mStateProtector.lock();
// Check Current Target
float tAngleWidth;
if( ptr->digital > 0 ) {
@@ -113,109 +129,145 @@ bool kernelEventFilterTrain::validateTarget( uint32_t DevID, TARGET_DATA *ptr ){
};
if( DevID == m_sTrainFilterData.nUpperSensorID ){ //If Upper Sensor
- // Train is detected;
+ // Train is detected
if( m_sUpperZone.TrainOnTheField ){
// Already was Train Detection
m_sUpperZone.ts = cts; // Update TS
if( ( ptr->local_target.fi - tAngleWidth ) < m_sUpperZone.startAngle ) m_sUpperZone.startAngle = ptr->local_target.fi - tAngleWidth;
if( ( ptr->local_target.fi + tAngleWidth ) > m_sUpperZone.endAngle ) m_sUpperZone.endAngle = ptr->local_target.fi + tAngleWidth;
- if( m_sTrainFilterData.bDebugMode ){
+ if( ( m_sTrainFilterData.bDebugMode && ( m_sUpperZone.LastEvtType != EVT_FLT_LATF_TRP_UPDT ) ) || m_sTrainFilterData.bTrackTrain ){
//Train Position Update Event
- createFilterEvent( EVT_FLT_LATF_TRP_UPDT );
+#ifdef DEBUG_EXTRA
+ char tB[128];
+ sprintf(tB, "Train Updated Digi:%d R:%0.3f", ptr->digital, ptr->local_target.r );
+ LOG( tB );
+#endif
+
+ //Triggering Session in Kernel
+ kernelPrototype *AK = kernelPrototype::getInstance();
+ if ( AK ) AK->startSession();
+
+ m_sUpperZone.LastEvtType = EVT_FLT_LATF_TRP_UPDT;
+ createFilterEvent( EVT_FLT_LATF_TRP_UPDT, ptr, NULL, DevID );
// Proceed Event as normal
// return false;
};
} else {
// Newly Detected Train
m_sUpperZone.TrainOnTheField = true;
- // Clear Suspicies - Train Detected!
- m_sUpperZone.SuspiciousObject = false;
- m_sUpperZone.SuspiciousUnconfirmed = false;
m_sUpperZone.ts = cts;
m_sUpperZone.startAngle = ptr->local_target.fi - tAngleWidth;
m_sUpperZone.endAngle = ptr->local_target.fi + tAngleWidth;
- if( m_sTrainFilterData.bDetectTrain || m_sTrainFilterData.bDebugMode ){
+ if( ( m_sTrainFilterData.bDebugMode && ( m_sUpperZone.LastEvtType != EVT_FLT_LATF_TRP_DET ) ) || m_sTrainFilterData.bDetectTrain ){
//Train Detection Event
- createFilterEvent( EVT_FLT_LATF_TRP_DET );
- // Proceed Event as normal
+#ifdef DEBUG_EXTRA
+ char tB[128];
+ sprintf(tB, "Train Detected Digi:%d R:%0.3f", ptr->digital, ptr->local_target.r );
+ LOG( tB );
+#endif
+ //Triggering Session in Kernel
+ kernelPrototype *AK = kernelPrototype::getInstance();
+ if ( AK ) AK->startSession();
+
+ m_sUpperZone.LastEvtType = EVT_FLT_LATF_TRP_DET;
+ createFilterEvent( EVT_FLT_LATF_TRP_DET, ptr, NULL, DevID );
};
};
+
#ifdef SECOND_PEER_PORT
// Inform Other Peer Train status
if( m_oOSP_Helper ) m_oOSP_Helper->setLocalStatus( m_sUpperZone.TrainOnTheField );
#endif
- if ( m_sTrainFilterData.bTrackTrain ) return false;
+ m_mStateProtector.unlock();
// Block Event
return true;
- } else {
+ } else {
+ /*************
+ Bottom Sensor
+ ****************/
+ // Train is detected by Upper Sensor Yet
+ if( m_sUpperZone.TrainOnTheField ){
+ if( m_sTrainFilterData.bDebugMode && m_sBottomZone.LastEvtType != EVT_FLT_LATF_DISABLED ){
+ m_sBottomZone.LastEvtType = EVT_FLT_LATF_DISABLED;
+ createFilterEvent( EVT_FLT_LATF_DISABLED, ptr, NULL, DevID );
+ };
+ memset( &m_sBottomZone, 0, sizeof( EFT_BOTTOM_ZONE ) );
+ m_mStateProtector.unlock();
+ return true;
+ };
+#ifdef SECOND_PEER_PORT
+ // Check Other Peer
+ if( m_oOSP_Helper )
+ if ( m_oOSP_Helper->getRemoteStatus() ){
+ if( m_sTrainFilterData.bDebugMode && ( m_sBottomZone.LastEvtType != EVT_FLT_LATF_OP_DISABLED ) ){
+ m_sBottomZone.LastEvtType = EVT_FLT_LATF_OP_DISABLED;
+ createFilterEvent( EVT_FLT_LATF_OP_DISABLED, ptr, NULL, DevID );
+ };
+ memset( &m_sBottomZone, 0, sizeof( EFT_BOTTOM_ZONE ) );
+ m_mStateProtector.unlock();
+ return true;
+ };
+#endif
// check pedestrians detection as Train
if( m_sBottomZone.SuspiciousObject == false ){
- // No Train is detected by Upper Sensor Yet
- if( m_sUpperZone.TrainOnTheField == false ){
-#ifdef SECOND_PEER_PORT
- // Check Other Peer
- if( m_oOSP_Helper )
- if ( m_oOSP_Helper->getRemoteStatus() ){
- if( m_sTrainFilterData.bDebugMode ){
- createFilterEvent( EVT_FLT_LATF_OP_DISABLED );
- };
- return true;
- };
+ // If the object is suspicious
+ if( m_sBottomZone.SuspiciousUnconfirmed == false ){
+ // Check New Suspicious
+#ifdef EFT_MINIMAL_RANGE_SUSPICIOUS
+ if ( ptr->local_target.r > m_sTrainFilterData.fMinimalRange ) {
#endif
- //if( m_sBottomZone.TrainOnTheField == false ){
- // If the object is suspicious
- if( m_sBottomZone.SuspiciousUnconfirmed == false ){
- // Check New Suspicious
- if( ptr->area > m_sTrainFilterData.nTrainWidth ){
- m_sBottomZone.SuspiciousObject = true;
- m_sBottomZone.ts = cts;
- if( m_sTrainFilterData.bDebugMode ){
+ if ( ptr->area > m_sTrainFilterData.nTrainWidth ) {
+ m_sBottomZone.SuspiciousObject = true;
+ m_sBottomZone.ts = cts;
+ // Always make Suspiciouse Start Event -> Starts the session
+ //if( m_sTrainFilterData.bDebugMode ){
+ if ( m_sBottomZone.LastEvtType != EVT_FLT_LATF_SUSP_START ){
// Suspisious Detection
- createFilterEvent( EVT_FLT_LATF_SUSP_START );
- // Proceed Event as normal
- //return false;
- };
- return true;
- };
- // Regular Target
- if( m_sTrainFilterData.bDebugMode ){
- createFilterEvent( EVT_FLT_LATF_REGULAR );
- };
- } else {
- // Unconfirmed Suspicious
- if( m_sTrainFilterData.bDebugMode ){
- createFilterEvent( EVT_FLT_LATF_SUSP_NAK );
- };
- };
- } else {
- // Disable Targets while Train is present
-
- // Detect Targets from others than train angles
- //if( m_bTrackTrainDetection ){
- // if( ( event.target.dAngle < ( m_sGroupZone[cGID].startAngle - tAngleWidth ) )
- // ||
- // ( event.target.dAngle > ( m_sGroupZone[cGID].endAngle + tAngleWidth ) ) ) {
- // EVT_FLT_LATF_DIFF_DET
- // return false;
- // };
- //};
-
- if( m_sTrainFilterData.bDebugMode ){
- createFilterEvent( EVT_FLT_LATF_DISABLED );
- };
- return true;
- };
+ m_sBottomZone.LastEvtType = EVT_FLT_LATF_SUSP_START;
+
+ //Triggering Session in Kernel
+ kernelPrototype *AK = kernelPrototype::getInstance();
+ if ( AK ) AK->startSession();
+
+ createFilterEvent( EVT_FLT_LATF_SUSP_START, ptr, NULL, DevID );
+ };
+ m_mStateProtector.unlock();
+ return true;
+ };
+#ifdef EFT_MINIMAL_RANGE_SUSPICIOUS
+ };
+#endif
+ // Regular Target
+ if( m_sTrainFilterData.bDebugMode && m_sBottomZone.LastEvtType != EVT_FLT_LATF_REGULAR ){
+ m_sBottomZone.LastEvtType = EVT_FLT_LATF_REGULAR;
+ createFilterEvent( EVT_FLT_LATF_REGULAR, ptr, NULL, DevID );
+ };
+ } else {
+#ifdef EFT_CONTINIOUS_SUSPICIOUS_MODE
+ // Continue this mode only on Wide Targets
+ if( ptr->area > m_sTrainFilterData.nTrainWidth ){
+ m_sBottomZone.ts = cts;
+ };
+#endif
+ // Unconfirmed Suspicious
+ //if( m_sTrainFilterData.bDebugMode && m_bEvtSupressLTF != EVT_FLT_LATF_SUSP_NAK ){
+ // m_bEvtSupressLTF = EVT_FLT_LATF_SUSP_NAK;
+ // createFilterEvent( EVT_FLT_LATF_SUSP_NAK, ptr, NULL, DevID );
+ //};
+ };
} else {
// Suspicious Mode Target
- if( m_sTrainFilterData.bDebugMode ){
- createFilterEvent( EVT_FLT_LATF_SUSP_DET );
- //return false;
+ if( m_sTrainFilterData.bDebugMode && m_sBottomZone.LastEvtType != EVT_FLT_LATF_SUSP_DET ){
+ m_sBottomZone.LastEvtType = EVT_FLT_LATF_SUSP_DET;
+ createFilterEvent( EVT_FLT_LATF_SUSP_DET, ptr, NULL, DevID );
};
+ m_mStateProtector.unlock();
return true;
};
};
+ m_mStateProtector.unlock();
};
- return ( m_sUpperZone.TrainOnTheField || m_sBottomZone.TrainOnTheField ); //false;
+ return false;
};
bool kernelEventFilterTrain::initFilter(){
@@ -252,6 +304,8 @@ bool kernelEventFilterTrain::initFilter(){
};
};
};
+ memset( &m_sUpperZone, 0, sizeof( EFT_UPPER_ZONE ) );
+ memset( &m_sBottomZone, 0, sizeof( EFT_BOTTOM_ZONE ) );
if ( m_bActive ) m_bActive = m_sFilterData.enabled;
return m_bActive;
};
@@ -303,9 +357,7 @@ TrainFilterOSP_Helper::TrainFilterOSP_Helper( CSTR remote_ip ){
};
TrainFilterOSP_Helper::~TrainFilterOSP_Helper(){
- LOG("Destructor");
waitThreadEnd( true );
- LOG("Destructor Finished");
};
//https://www.geeksforgeeks.org/udp-server-client-implementation-c/
@@ -313,6 +365,7 @@ TrainFilterOSP_Helper::~TrainFilterOSP_Helper(){
bool TrainFilterOSP_Helper::create( kernelEventFilterTrain *MF ){
bool rv = false;
m_pMasterFilter = MF;
+ if( m_pMasterFilter == NULL ) return false;
if( ( m_iSocketUDP = socket(AF_INET, SOCK_DGRAM, 0)) < 0 ){
LOG_ERROR("socket creation failed");
} else {
@@ -343,7 +396,7 @@ void TrainFilterOSP_Helper::m_fThreadProc( void ){
n = recvfrom( m_iSocketUDP, buffer, 255, MSG_DONTWAIT/*MSG_WAITALL*/, ( struct sockaddr *) &cliaddr, &len );
if( n >= 0 ){
bool tStatus = (bool) atoi( buffer );
-#ifdef DEBUG_EXTRA
+#ifdef DEBUG
char tB[512];
buffer[n] = (char)0;
sprintf( tB, "From Other Peer: %s", buffer );
@@ -353,14 +406,14 @@ void TrainFilterOSP_Helper::m_fThreadProc( void ){
m_bValid = true;
if( m_pMasterFilter ){
if( tStatus ){
- m_mStatusProtector.lock();
- if ( m_bRemoteStatus ) {
+ if (m_bRemoteStatus) {
// Updated
m_pMasterFilter->createEvent( EVT_FLT_LATF_OP_UP );
} else {
// Detected
m_pMasterFilter->createEvent( EVT_FLT_LATF_OP_TD );
};
+ m_mStatusProtector.lock();
m_bRemoteStatus = tStatus;
m_mStatusProtector.unlock();
} else {
diff --git a/lib/App/common/kernelEventFilterTrain.h b/lib/App/common/kernelEventFilterTrain.h
index 08c17b7d..25da252e 100644
--- a/lib/App/common/kernelEventFilterTrain.h
+++ b/lib/App/common/kernelEventFilterTrain.h
@@ -2,20 +2,40 @@
#define __KERNEL_EVENT_FILTER_TRAIN__
#include "kernelEventFilter.h"
+#include "kernelPrototype.h"
#include "../../components/base/basicThread.h"
#include "../../components/base/basicMutex.h"
#define SECOND_PEER_PORT 2020
+#define EFT_CONTINIOUS_SUSPICIOUS_MODE
+
typedef std::vector groupArray;
-typedef struct S_EFT_ZONE {
+/*typedef struct S_EFT_ZONE {
bool TrainOnTheField;
bool SuspiciousObject;
bool SuspiciousUnconfirmed;
uint64_t ts;
float startAngle;
float endAngle;
+ uint8_t LastEvtType;
} EFT_ZONE;
+*/
+
+typedef struct S_EFT_U_ZONE {
+ bool TrainOnTheField;
+ uint64_t ts;
+ float startAngle;
+ float endAngle;
+ uint8_t LastEvtType;
+} EFT_UPPER_ZONE;
+
+typedef struct S_EFT_B_ZONE {
+ bool SuspiciousObject;
+ bool SuspiciousUnconfirmed;
+ uint64_t ts;
+ uint8_t LastEvtType;
+} EFT_BOTTOM_ZONE;
class kernelEventFilterTrain;
@@ -68,10 +88,17 @@ class kernelEventFilterTrain: public kernelEventFilter{
private:
basicLogCollection * m_pLog;
TRAIN_FILTER_DATA m_sTrainFilterData;
- EFT_ZONE m_sUpperZone;
- EFT_ZONE m_sBottomZone;
+ EFT_UPPER_ZONE m_sUpperZone;
+ EFT_BOTTOM_ZONE m_sBottomZone;
groupArray m_aUpperFIFO;
groupArray m_aBottomFIFO;
+ //uint8_t m_bEvtSupressLTF;
+ //uint8_t m_bEvtSupressUTF;
+ basicMutex m_mStateProtector;
+#ifdef EFT_AUTO_RESET_UPPER_SENSOR
+ uint32_t m_nAutoResetUpperTO;
+#endif
+
#ifdef SECOND_PEER_PORT
TrainFilterOSP_Helper * m_oOSP_Helper;
void createEvent( uint8_t EVT );
diff --git a/lib/App/mojo/mojoKernel.cpp b/lib/App/mojo/mojoKernel.cpp
index 0194dc02..35c9044a 100644
--- a/lib/App/mojo/mojoKernel.cpp
+++ b/lib/App/mojo/mojoKernel.cpp
@@ -59,6 +59,8 @@ mojoKernel::mojoKernel( config_setting_t *ptr ):kernelPrototype( ptr ){
m_pShadow = NULL;
m_pSystemAnchor = NULL;
m_bSessionStarted = false;
+ m_bSessionMustPreserve = false;
+ m_bFirstSession = true;
m_bWorkWithRemoteServer = false;
m_bKeepLocalReport = true;
m_bMediaMode = 0;
@@ -137,6 +139,9 @@ mojoKernel::~mojoKernel(){
};
bool mojoKernel::create(){
+ m_bSessionStarted = false;
+ m_bSessionMustPreserve = false;
+ m_bFirstSession = true;
if( m_pSettings != NULL ) {
config_setting_t * pSetting;
int tVal;
@@ -180,10 +185,9 @@ bool mojoKernel::create(){
basicSettingsProvider::getInstance()->compromise();
LOG("Autoreset not defined - Set Disabled!");
} else {
- m_bEnableAutoReset = true;
m_nAutoResetTime = tVal;
+ m_bEnableAutoReset = ( m_nAutoResetTime > 0 );
sprintf( tBuffer, "App Autoreset Read From Settings: %d", m_nAutoResetTime );
- if ( m_nAutoResetTime == 0 ) m_bEnableAutoReset = false;
LOG(tBuffer);
};
#endif
@@ -301,26 +305,11 @@ void mojoKernel::startSession(){
m_mSessionProtector.lock();
m_nNoAlarmCounter = 0;
if( !m_bSessionStarted ) {
- /*
- if( m_bKeepLocalReport ){
- DBC_EVT_RECORD tRecord;
- memset( &tRecord, 0, sizeof(DBC_EVT_RECORD));
- uint64_t TS_64 = getMilliseconds() - 20; // -20 msec before
- tRecord.ts_s = TS_64/ 1000;
- tRecord.ts_ms = TS_64 % 1000;
- tRecord.node_id = m_nServerNodeID;
- tRecord.type = EVT_LRF_START_SESSION;
- CSTR tUUID = getUniqID_UUID( tRecord.ts_s );
- if( tUUID ) {
- strncpy(tRecord.uuid, tUUID, 64 );
- free( tUUID );
- } else {
- memset( tRecord.uuid, 0, 65 );
- };
- m_pDBC->addEvent( &tRecord );
- };
- */
- //Propogate Event
+ if( !m_bFirstSession ) {
+ if (!m_bSessionMustPreserve) m_pDBC->dropSession();
+ m_bSessionMustPreserve = false;
+ } else m_bFirstSession = false;
+
uint64_t TS_64 = getMilliseconds() - 20; // -20 msec before
uint32_t ts_s = TS_64 / 1000;
uint16_t ts_ms = TS_64 % 1000;
@@ -339,26 +328,6 @@ void mojoKernel::startSession(){
void mojoKernel::stopSession( bool forced ){
m_mSessionProtector.lock();
if( m_bSessionStarted ){
- /*
- if ( m_bKeepLocalReport ) {
- DBC_EVT_RECORD tRecord;
- memset( &tRecord, 0, sizeof(DBC_EVT_RECORD));
- uint64_t TS_64 = getMilliseconds() + 20; // +20 msec before
- tRecord.ts_s = TS_64/ 1000;
- tRecord.ts_ms = TS_64 % 1000;
- tRecord.node_id = m_nServerNodeID;
- tRecord.type = forced ? EVT_LRF_END_SESSION_MA:EVT_LRF_END_SESSION_TO;
- CSTR tUUID = getUniqID_UUID( tRecord.ts_s );
- if( tUUID ) {
- strncpy(tRecord.uuid, tUUID, 64 );
- free( tUUID );
- } else {
- memset( tRecord.uuid, 0, 65 );
- };
- m_pDBC->addEvent( &tRecord );
- };
- */
- //Propogate Event
uint64_t TS_64 = getMilliseconds() + 20; // +20 msec after
uint32_t ts_s = TS_64 / 1000;
uint16_t ts_ms = TS_64 % 1000;
@@ -381,25 +350,9 @@ void mojoKernel::validateSession(){
if( m_nNoAlarmCounter < NOTARGET_SESSION_CLOSE ){
m_nNoAlarmCounter++;
} else {
-#ifdef EMBED_AUTORESET
- m_nSessionCounter = 0;
-#endif
- DBC_EVT_RECORD tRecord;
- memset( &tRecord, 0, sizeof(DBC_EVT_RECORD));
- uint64_t TS_64 = getMilliseconds() + 20;
- tRecord.ts_s = TS_64/ 1000;
- tRecord.ts_ms = TS_64 % 1000;
- tRecord.node_id = m_nServerNodeID;
- tRecord.type = EVT_LRF_END_SESSION_TO;
- CSTR tUUID = getUniqID_UUID( tRecord.ts_s );
- if( tUUID ) {
- strncpy(tRecord.uuid, tUUID, 64 );
- free( tUUID );
- } else {
- memset( tRecord.uuid, 0, 65 );
- };
- m_pDBC->addEvent( &tRecord );
- m_bSessionStarted = false;
+ m_mSessionProtector.unlock();
+ stopSession( false );
+ m_mSessionProtector.lock();
};
#ifdef EMBED_AUTORESET
if ( m_bEnableAutoReset ) {
@@ -415,7 +368,7 @@ void mojoKernel::validateSession(){
};
delete( tL );
};
- m_nNoAlarmCounter = NOTARGET_SESSION_CLOSE;//Session will be closed in 1 second
+ m_nNoAlarmCounter = NOTARGET_SESSION_CLOSE;//Session will be closed on next validation
};
};
#endif
@@ -547,11 +500,8 @@ void mojoKernel::m_fThreadProc( void ){
};
#endif
m_bDebugMode = m_pDBC->getAppDebugMode();
-
validateFilters();
-
validateSession();
-
validateReports();
//??
if( !m_pHardwareManager->validate() ){
@@ -569,7 +519,6 @@ void mojoKernel::m_fThreadProc( void ){
m_bWorkWithRemoteServer = ( m_pRPC->getConnectionStatus() == CS_CONNECTED );
};
};
-
DBC_PUSHED_CMD * tCMD = m_pDBC->getNodePushedCMD( m_nServerNodeID ); //Kernel
if( tCMD != NULL ) {
m_pDBC->updateNodePushedCMD( tCMD->id, DBC_CMD_STARTED );
@@ -1032,6 +981,7 @@ bool mojoKernel::dispatchEvent( EVENT_CONTAINER *Evt ){
case EVT_TARGET_1D:{
//startSession();
+ preserveSession();
TARGET_DATA *tDATA =(TARGET_DATA *) Evt->m_pEvtData;
if( tDATA != NULL ) {
@@ -1065,6 +1015,7 @@ bool mojoKernel::dispatchEvent( EVENT_CONTAINER *Evt ){
case EVT_TARGET_2D_WHITE:{
//startSession();
+ preserveSession();
TARGET_DATA *tDATA = (TARGET_DATA *)Evt->m_pEvtData;
if( tDATA != NULL ) {
@@ -1095,6 +1046,7 @@ bool mojoKernel::dispatchEvent( EVENT_CONTAINER *Evt ){
case EVT_TARGET_3D_WHITE:{
//startSession();
+ preserveSession();
TARGET_DATA *tDATA = (TARGET_DATA *) Evt->m_pEvtData;
if( tDATA != NULL ) {
@@ -1172,33 +1124,57 @@ bool mojoKernel::dispatchEvent( EVENT_CONTAINER *Evt ){
};
break;
case EVT_CLASS_KRNL_FILTER_LATF:{
- /*switch( Evt->m_eType ) {
- case EVT_FLT_LATF_CHK:
- case EVT_FLT_LATF_UP_DETEC:
- case EVT_FLT_LATF_BT_DETEC:
- case EVT_FLT_LATF_TRP_DET:
- case EVT_FLT_LATF_TRP_UPDT:
- case EVT_FLT_LATF_SUSP_START:
- case EVT_FLT_LATF_SUSP_NAK:
- case EVT_FLT_LATF_REGULAR:
- case EVT_FLT_LATF_DISABLED:
- case EVT_FLT_LATF_SUSP_DET:
- case EVT_FLT_LATF_DIFF_DET:
- };*/
- DBC_EVT_RECORD tRecord;
- memset( &tRecord, 0, sizeof(DBC_EVT_RECORD));
- uint32_t TS_A, TS_B;
-
- TS_A = Evt->m_UMSTS / 1000;
- TS_B = Evt->m_UMSTS % 1000;
-
- tRecord.node_id = m_nServerNodeID;
- tRecord.type = Evt->m_eType;
- strncpy( tRecord.uuid, Evt->m_UUID, 64 );
- tRecord.ts_s = TS_A;
- tRecord.ts_ms = TS_B;
-
- Evt->m_db_id = m_pDBC->addEvent( &tRecord );
+ TARGET_DATA *tDATA = (TARGET_DATA *) Evt->m_pEvtData;
+ if ( ( Evt->m_eType > EVT_FLT_LATF_DIFF_DET ) || ( tDATA == NULL ) ) {
+ //AUX messages (no additional target data)
+ DBC_EVT_RECORD tRecord;
+ memset( &tRecord, 0, sizeof(DBC_EVT_RECORD));
+ uint32_t TS_A, TS_B;
+
+ TS_A = Evt->m_UMSTS / 1000;
+ TS_B = Evt->m_UMSTS % 1000;
+
+ tRecord.node_id = m_nServerNodeID;
+ tRecord.type = Evt->m_eType;
+ strncpy( tRecord.uuid, Evt->m_UUID, 64 );
+ tRecord.ts_s = TS_A;
+ tRecord.ts_ms = TS_B;
+
+ Evt->m_db_id = m_pDBC->addEvent( &tRecord );
+ } else {
+ //If First Suspiciouse -> Start session to collect Fliter Messages
+ //if( Evt->m_eType == EVT_FLT_LATF_SUSP_START ) startSession();
+
+ // Regular LATF with target Info
+ DBC_EVT_RECORD tRecord;
+ memset( &tRecord, 0, sizeof(DBC_EVT_RECORD));
+ uint32_t TS_A, TS_B;
+
+ TS_A = Evt->m_UMSTS / 1000;
+ TS_B = Evt->m_UMSTS % 1000;
+
+ tRecord.node_id = Evt->m_nSourceNodeID;// m_nServerNodeID;//??
+ tRecord.type = Evt->m_eType;
+ strncpy( tRecord.uuid, Evt->m_UUID, 64 );
+ tRecord.ts_s = TS_A;
+ tRecord.ts_ms = TS_B;
+
+ tRecord.lrf_id = tDATA->lrf_id;
+ tRecord.range_digital = tDATA->digital;
+ tRecord.az = tDATA->local_target.fi;
+ tRecord.el = tDATA->local_target.tetta;
+ tRecord.ra = tDATA->local_target.r;
+ tRecord.area = tDATA->area;
+ tRecord.lat = 0;
+ tRecord.lon = 0;
+ tRecord.alt = 0;
+#ifdef DEBUG_EXTRA
+ char tB[243];
+ sprintf( tB,"Az: %0.3f El: %0.3f Ra: %0.3f Dig: %d Width: %0.3f", tRecord.az, tRecord.el, tRecord.ra, tRecord.range_digital, tRecord.area );
+ LOG( tB );
+#endif
+ Evt->m_db_id = m_pDBC->addEvent( &tRecord );
+ };
break;
};
};
diff --git a/lib/App/mojo/mojoKernel.h b/lib/App/mojo/mojoKernel.h
index dc579be6..8845ea29 100644
--- a/lib/App/mojo/mojoKernel.h
+++ b/lib/App/mojo/mojoKernel.h
@@ -19,9 +19,9 @@
#define LA_METRO 1
#define MER_INC 2
-#define NOTARGET_SESSION_CLOSE 300 //sec
+#define NOTARGET_SESSION_CLOSE 120 //sec
-#define EMBED_AUTORESET 300 //sec
+//#define EMBED_AUTORESET 300 //sec
#include "../../components/base/basicThread.h"
#include "../../components/base/basicSettingsProvider.h"
@@ -76,6 +76,8 @@ class mojoKernel: public kernelPrototype{
bool m_bKeepLocalReport;
bool m_bWorkWithRemoteServer;
bool m_bSessionStarted;
+ bool m_bSessionMustPreserve;
+ bool m_bFirstSession;
uint8_t m_bMediaMode;
uint32_t m_nNoAlarmCounter;
#ifdef EMBED_AUTORESET
@@ -95,6 +97,7 @@ class mojoKernel: public kernelPrototype{
basicMutex m_mSessionProtector;
void stopSession( bool forced = true );
+ void preserveSession(){ m_bSessionMustPreserve = true; };
static mojoKernel * _instance;
diff --git a/lib/App/mojo/mojoRemoteClient.cpp b/lib/App/mojo/mojoRemoteClient.cpp
index 3f817574..27fb5fd6 100644
--- a/lib/App/mojo/mojoRemoteClient.cpp
+++ b/lib/App/mojo/mojoRemoteClient.cpp
@@ -22,6 +22,8 @@ mojoRemoteClient::mojoRemoteClient( mojoKernel * ptr ):protocolParser(){
m_bShutdownCommunication = true;
m_bCommunicationEstablished = false;
m_bRegisteredWithRemotePeer = false;
+ m_bUseBackupServer = false;
+ m_bActiveServer = 0;
m_pVideoHelper = new mojoVideoTransferHelper( ARGUS_RPC_DEFAULT_MEDIA_CHUNK );
m_qCMD = new RPC_CMD_QUEUE();
};
@@ -50,6 +52,8 @@ bool mojoRemoteClient::create(){
if( m_bCommunicationEstablished && ( m_bThreadStatus == TH_WORKING ) ) return true;
m_bAutomationStage = ARGUS_RPC_STAGE_CONNECT;
m_pCurrentCMD = NULL;
+ m_bActiveServer = 0;
+ m_bUseBackupServer = ( ( m_pMaster->m_sSiteData.remote_backup_port > 0 ) && ( strlen( m_pMaster->m_sSiteData.remote_backup_ip ) > 7 ) );
return init();
};
@@ -395,8 +399,12 @@ void mojoRemoteClient::m_fThreadProc( void ){
sprintf(tB,"Creating Remote connection to [%s:%d]", m_pMaster->m_sSiteData.remote_ip, m_pMaster->m_sSiteData.remote_port );
LOG( tB );
#endif
- if( m_pMaster->m_sSiteData.remote_port ) {
- m_pPort = new clientPort( m_pMaster->m_sSiteData.remote_ip, m_pMaster->m_sSiteData.remote_port );
+ if ( m_bUseBackupServer ) {
+ if ( m_bActiveServer == 0 ) {
+ m_pPort = new clientPort( m_pMaster->m_sSiteData.remote_ip, m_pMaster->m_sSiteData.remote_port );
+ } else {
+ m_pPort = new clientPort( m_pMaster->m_sSiteData.remote_backup_ip, m_pMaster->m_sSiteData.remote_backup_port );
+ }
if( m_pPort ) {
if( m_pPort->create() ) {
#ifdef DEBUG
@@ -415,10 +423,37 @@ void mojoRemoteClient::m_fThreadProc( void ){
m_bShutdownCommunication = true;
m_bCommunicationEstablished = false;
m_bRegisteredWithRemotePeer = false;
+ m_bActiveServer = 1 - m_bActiveServer;
setTO( 30 ); //30 sec to wait
setAutomationStage( ARGUS_RPC_STAGE_WAIT_RECONNECT );
};
};
+ } else {
+ if (m_pMaster->m_sSiteData.remote_port) {
+ m_pPort = new clientPort( m_pMaster->m_sSiteData.remote_ip, m_pMaster->m_sSiteData.remote_port );
+ if( m_pPort ) {
+ if( m_pPort->create() ) {
+ #ifdef DEBUG
+ LOG("Connection Sucessfull");
+ #endif
+ m_bShutdownCommunication = false;
+ m_bCommunicationEstablished = true;
+ m_bRegisteredWithRemotePeer = false;
+ setTransport( m_pPort, false );
+ setAutomationStage( ARGUS_RPC_STAGE_REGISTER );
+ } else {
+ setConnectionStatus( CS_DISCONNECTED );
+ setTransport( NULL, false );
+ delete( m_pPort );
+ m_pPort = NULL;
+ m_bShutdownCommunication = true;
+ m_bCommunicationEstablished = false;
+ m_bRegisteredWithRemotePeer = false;
+ setTO( 30 ); //30 sec to wait
+ setAutomationStage( ARGUS_RPC_STAGE_WAIT_RECONNECT );
+ };
+ };
+ };
};
break;
};
@@ -489,7 +524,7 @@ void mojoRemoteClient::m_fThreadProc( void ){
// bTO_COUNTER = 1;
// setAutomationStage( ARGUS_RPC_STAGE_WAIT_ACK );
//} else setAutomationStage( ARGUS_RPC_STAGE_CLOSE );
- break;
+ //break; ---> Go to reconnect to other server
};
case ARGUS_RPC_STAGE_CLOSE:{
// Just Disconnect
@@ -502,6 +537,7 @@ void mojoRemoteClient::m_fThreadProc( void ){
m_bCommunicationEstablished = false;
m_bRegisteredWithRemotePeer = false;
setTO( 30 ); //30 sec to wait
+ m_bActiveServer = 1 - m_bActiveServer;
setAutomationStage( ARGUS_RPC_STAGE_WAIT_RECONNECT );
break;
};
@@ -562,6 +598,10 @@ bool mojoRemoteClient::validate(){
delete( m_pPort );
};
m_bAutomationStage = ARGUS_RPC_STAGE_CONNECT;
+ // Revalidate Data!!!
+ //m_bActiveServer = 0;
+ //m_bUseBackupServer = ( ( m_pMaster->m_sSiteData.remote_backup_port > 0 ) && strlen( ( m_pMaster->m_sSiteData.remote_backup_ip ) > 7 ) );
+
/*m_pPort = new clientPort( m_pMaster->m_sSiteData.remote_ip, m_pMaster->m_sSiteData.remote_port );
if( m_pPort ) {
if( m_pPort->create() ) {
diff --git a/lib/App/mojo/mojoRemoteClient.h b/lib/App/mojo/mojoRemoteClient.h
index 1b53a1b2..f31b4c6b 100644
--- a/lib/App/mojo/mojoRemoteClient.h
+++ b/lib/App/mojo/mojoRemoteClient.h
@@ -47,6 +47,8 @@ class mojoRemoteClient: public basicThread, public protocolParser{
private:
basicLogCollection * m_pLog;
mojoKernel * m_pMaster;
+ bool m_bUseBackupServer;
+ uint8_t m_bActiveServer;
clientPort * m_pPort;
basicMutex m_mQueryProtector;
basicMutex m_mAutomationStageProtector;
diff --git a/lib/components/base/basicEvent.h b/lib/components/base/basicEvent.h
index 1fa9d27a..2788628e 100644
--- a/lib/components/base/basicEvent.h
+++ b/lib/components/base/basicEvent.h
@@ -74,7 +74,7 @@ typedef enum E_basicEventTypeID {
EVT_FLT_LATF_TRP_DET = 42,
EVT_FLT_LATF_TRP_UPDT = 43,
EVT_FLT_LATF_SUSP_START = 44,
- EVT_FLT_LATF_SUSP_NAK = 45,
+ _EVT_FLT_LATF_SUSP_NAK = 45,
EVT_FLT_LATF_REGULAR = 46,
EVT_FLT_LATF_DISABLED = 47,
EVT_FLT_LATF_SUSP_DET = 48,
@@ -106,7 +106,11 @@ typedef enum E_basicEventTypeID {
EVT_FLT_LATF_OP_UP = 74,
EVT_FLT_LATF_OP_TG = 75,
EVT_FLT_LATF_OP_EXP = 76,
- EVT_COUNT = 77
+ EVT_FLT_LATF_TRP_EXP = 77,
+ EVT_FLT_LATF_SUSP_NAK = 78,
+ EVT_FLT_LATF_SUSP_EXP = 79,
+ EVT_COUNT = 80
+
} basicEventTypeID;