#include "rgooseKafkaModule.h" #include "../hardware/soc/general/3DLRF.h" #define LOG( X ) argusKernelModule::m_pLog->Log( "KM", this, X ) #ifdef DEBUG #define LOG_ERROR( X ) {\ char _tBfrErrMSG2w34[256];\ sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ argusKernelModule::m_pLog->Log( "KM", this, _LOG_ERROR, _tBfrErrMSG2w34 );\ } #else #define LOG_ERROR( X ) argusKernelModule::m_pLog->Log( "KM", this, _LOG_ERROR, X ); #endif argusKafkaModule::argusKafkaModule( uint32_t ModuleID ): argusKernelModule( ModuleID, ARGUS_MODULE_KAFKA ){ m_pProtocol = NULL; /* if( DBC != NULL ) { m_pProtocol = new protocolInfoStress(); if( m_pProtocol != NULL ) { if( !basicThread::init() ){ LOG_ERROR("Error Create Thread!"); } else { if( !m_pProtocol->init() ) { LOG_ERROR("Error INIT KAFKA!"); }; }; }; }; */ }; argusKafkaModule::~argusKafkaModule(){ if( m_pProtocol!= NULL ) { delete( m_pProtocol ); }; }; /* Periodical Job Handler */ void argusKafkaModule::m_fThreadProc( void ){ m_bThreadStatus = TH_WORKING; while( m_bThreadStatus < TH_ENDED ) { m_llTicks ++;//= getMilliseconds(); if( m_llTicks % 20 == 0 ) { // each 2 seconds m_pProtocol->StatusUpdate(); //m_lCycleCounter == 0; }; /* No need for time Sync if( m_llTicks % 350 == 0 ) { // each 35 seconds StartTimeSynch(); //m_lCycleCounter == 0; }; */ SLEEP(100); }; }; bool argusKafkaModule::startService(){ if( reloadSettings() ) { if( m_pSettings!= NULL ){ m_pProtocol = new protocolKAFKA( m_pSettings ); if( m_pProtocol->init() ){ return true; }; }; }; return false; }; bool argusKafkaModule::stopService(){ return true; }; bool argusKafkaModule::reloadSettings(){ if( m_pDBC==NULL ) return false; m_pSettings = m_pDBC->getSettingsKAFKA( m_nDBID ); if( m_pSettings != NULL ) { return true; }; return false; }; void argusKafkaModule::dispatchEvent( basicEvent *Evt ){ #ifdef DEBUG LOG( "CLIENT's DISPATCHER"); #endif if( Evt == NULL ) { LOG( "Evt NULL"); return; }; if( Evt->m_eClass == EVT_CLASS_SENSOR ) { #ifdef DEBUG char tBuffer[256]; sprintf( tBuffer, "Event Class %d Type %d ", Evt->m_eClass , Evt->m_eType ); LOG( tBuffer ); #endif // Skip Event Handling by flags if( !m_bEvtFlags[ Evt->m_eType ] ) return; // Hadle Event switch( Evt->m_eType ) { case EVT_TARGET_1D: case EVT_TARGET_2D_WHITE: case EVT_TARGET_2D_BLACK: case EVT_TARGET_3D_WHITE: case EVT_TARGET_3D_BLACK:{ CLIENT_EVENT *tCEVT; tCEVT = (CLIENT_EVENT *) Evt->m_pEvtData; if( tCEVT != NULL ){ float Az, El; uint32_t cRange; cRange = (uint32_t)(((float) tCEVT->range ) * 0.0732421875f ) ; // To meters #ifdef PRU_SLAVE make3Ddeg( tCEVT->th_id, Az, El, false ); #else make3Ddeg( tCEVT->th_id, Az, El, true ); #endif m_pProtocol->Alarm3D( (int)Az, (int)El, cRange , tCEVT->k_id ); }; }; break; case EVT_ERROR: m_pProtocol->SetStatus( false ); break; case EVT_SCAN: //StatusUpdate(); //break; case EVT_FLIP: m_pProtocol->SetStatus( true ); //StatusUpdate(); break; case EVT_COMMAND: break; default: LOG_ERROR("Unknown Event!"); }; } else { #ifdef DEBUG LOG( "No SENSOR EVT "); #endif } }; #undef LOG #undef LOG_ERROR