24 changed files with 1190 additions and 124 deletions
-
20Projects/MastBaum/MastBaum.vpj
-
22Projects/MastBaum/makefile
-
11Projects/argus/argus.vpj
-
92Projects/argus/makefile
-
8lib/App/3dSERVER/LRF_ClientHandler.cpp
-
8lib/App/3dSERVER/LRF_DefenderHandler.cpp
-
8lib/App/3dSERVER/LRF_KafkaHandler.cpp
-
8lib/App/3dSERVER/LRF_SafeShoreHandler.cpp
-
16lib/App/3dSERVER/LRF_TargetTracker.cpp
-
16lib/components/base/basicEvent.cpp
-
12lib/components/base/basicEvent.h
-
1lib/components/base/basicThread.h
-
2lib/data/protocol/protocolInternalLRF3D.h
-
753lib/data/protocol/protocolKAFKA.cpp
-
107lib/data/protocol/protocolKAFKA.h
-
142lib/rgoose/rgooseKafkaModule.cpp
-
26lib/rgoose/rgooseKafkaModule.h
-
16lib/rgoose/rgooseModule.cpp
-
15lib/rgoose/rgooseModule.h
-
2lib/rgoose/rgooseNode3D.h
-
6lib/rgoose/rgooseServerModule.cpp
-
10lib/rgoose/rgooseServerModule.h
-
4lib/rgoose/rgooseUSBRelayModule.cpp
-
9lib/rgoose/rgooseUSBRelayModule.h
@ -0,0 +1,753 @@ |
|||
#include "protocolKAFKA.h"
|
|||
#include "../../alg/generic/md5.h"
|
|||
#include "../json/json_tool.h"
|
|||
#include <strings.h>
|
|||
#include <json/value.h>
|
|||
#include <json/writer.h>
|
|||
#include <json/reader.h>
|
|||
//https://il.iherb.com/pr/KAL-Blood-Sugar-Defense-60-Tablets/70138
|
|||
|
|||
#define LOG( X ) m_pLog->Log( "KAFKA", this, X )
|
|||
#define LOGS( X ) basicLogCollection::getInstance()->Log( "KAFKA_S", NULL, X )
|
|||
#define LOG_ERROR( X ) m_pLog->Log( "KAFKA", this, _LOG_ERROR, X )
|
|||
/*
|
|||
CSTR protocolKAFKA::buildURL( CSTR templ, int dim, CSTR devID ){ |
|||
CSTR RetVal; |
|||
RetVal = (CSTR) malloc( 256 ); |
|||
if (RetVal != NULL) { |
|||
if (m_bUseSSL) { |
|||
sprintf(RetVal, "https://%s:%d%s", m_pServerIP, m_nServerPort, m_pAccessURL); |
|||
} else { |
|||
sprintf(RetVal, "http://%s:%d%s", m_pServerIP, m_nServerPort, m_pAccessURL); |
|||
}; |
|||
}; |
|||
return RetVal; |
|||
}; |
|||
*/ |
|||
|
|||
CSTR protocolKAFKA::buildUniqID( void ){ |
|||
CSTR RetVal; |
|||
RetVal = (CSTR) malloc(64); |
|||
if(RetVal) sprintf( RetVal, "%s", MD5String( getSHDTimeStamp() ) ); |
|||
return RetVal; |
|||
}; |
|||
|
|||
/* Default Constructor */ |
|||
protocolKAFKA::protocolKAFKA( config_setting_t *Settings ){ |
|||
|
|||
m_pLog = basicLogCollection::getInstance(); |
|||
m_pSettings = basicSettingsProvider::getInstance()->getSubNode(Settings, "INFOSTRESS_CONNECTION"); |
|||
m_pKafka = NULL; |
|||
m_pKafkaBrokerSTR = (CSTR)malloc(CLOG); |
|||
if( m_pKafkaBrokerSTR == NULL ) return; |
|||
memset( m_pKafkaBrokerSTR, 0 , CLOG); |
|||
m_pKafkaTopicSTR= (CSTR)malloc(CLOG); |
|||
if( m_pKafkaTopicSTR == NULL ) return; |
|||
memset( m_pKafkaTopicSTR, 0 , CLOG); |
|||
m_pKafkaTopic = NULL; |
|||
|
|||
m_pScannerName = (CSTR)malloc(OS_SCANNER_NAME_SIZE); |
|||
if( m_pScannerName == NULL ) return; |
|||
memset( m_pScannerName, 0 , OS_SCANNER_NAME_SIZE); |
|||
m_pServerIP = (CSTR)malloc(OS_CEP_ADDRESS_SIZE); |
|||
if( m_pServerIP == NULL ) return; |
|||
memset( m_pServerIP, 0 , OS_CEP_ADDRESS_SIZE); |
|||
m_pAccessURL = (CSTR)malloc(CTEXT); |
|||
if (m_pAccessURL == NULL) return; |
|||
memset(m_pAccessURL, 0, CTEXT); |
|||
|
|||
m_bCurrentStatus = false; |
|||
m_bMitigationStatus = false; |
|||
m_bEnabled = false; |
|||
m_bEnableStatus = false; |
|||
|
|||
if( m_pSettings != NULL ){ |
|||
int intVar; |
|||
double floatVar; |
|||
config_setting_t *pSetting; |
|||
if (!config_setting_lookup_float(m_pSettings, "LOCATION_LON", &floatVar)) { |
|||
m_fLon = floatVar = 35.0938962; |
|||
pSetting = config_setting_add(m_pSettings, "LOCATION_LON", CONFIG_TYPE_FLOAT); |
|||
config_setting_set_float(pSetting, floatVar); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
} else { |
|||
m_fLon = floatVar; |
|||
}; |
|||
if (!config_setting_lookup_float(m_pSettings, "LOCATION_LAT", &floatVar)) { |
|||
m_fLat = floatVar = 32.904208; |
|||
pSetting = config_setting_add(m_pSettings, "LOCATION_LAT", CONFIG_TYPE_FLOAT); |
|||
config_setting_set_float(pSetting, floatVar); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
} else { |
|||
m_fLat = floatVar; |
|||
}; |
|||
if (!config_setting_lookup_bool(m_pSettings, "USE_SSL", &intVar)) { |
|||
intVar = m_bUseSSL = false; |
|||
LOG("SSL DISABLED[default]"); |
|||
pSetting = config_setting_add(m_pSettings, "USE_SSL", CONFIG_TYPE_BOOL); |
|||
config_setting_set_bool(pSetting, intVar); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
} else { |
|||
m_bUseSSL = (bool)intVar; |
|||
}; |
|||
if (!config_setting_lookup_bool(m_pSettings, "ENABLE_STATUS_REPORT", &intVar)) { |
|||
intVar = m_bEnableStatus = false; |
|||
LOG("Status Report DISABLED[default]"); |
|||
pSetting = config_setting_add(m_pSettings, "ENABLE_STATUS_REPORT", CONFIG_TYPE_BOOL); |
|||
config_setting_set_bool(pSetting, intVar); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
} else { |
|||
m_bEnableStatus = (bool)intVar; |
|||
}; |
|||
if (!config_setting_lookup_string(m_pSettings, "SCANNER_NAME", (const char**)&m_pScannerName)) { |
|||
strncpy(m_pScannerName, "LRF_2D_001", 64); |
|||
LOG(m_pScannerName); |
|||
pSetting = config_setting_add(m_pSettings, "SCANNER_NAME", CONFIG_TYPE_STRING); |
|||
config_setting_set_string(pSetting, m_pScannerName); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
}; |
|||
if (!config_setting_lookup_int(m_pSettings, "SCANNER_DIMENTIONS", &m_nScannerDimentions)) { |
|||
m_nScannerDimentions = 2; |
|||
pSetting = config_setting_add(m_pSettings, "SCANNER_DIMENTIONS", CONFIG_TYPE_INT); |
|||
config_setting_set_int(pSetting, m_nScannerDimentions); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
}; |
|||
if (!config_setting_lookup_string(m_pSettings, "KAFKA_BROKER_IP", (const char**)&m_pServerIP)) { |
|||
strncpy(m_pServerIP, "192.168.200.204", 16); |
|||
LOG(m_pServerIP); |
|||
pSetting = config_setting_add(m_pSettings, "KAFKA_BROKER_IP", CONFIG_TYPE_STRING); |
|||
config_setting_set_string(pSetting, m_pServerIP); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
}; |
|||
LOG(m_pServerIP); |
|||
if (!config_setting_lookup_int(m_pSettings, "KAFKA_BROKER_PORT", &m_nServerPort)) { |
|||
m_nServerPort = 80; |
|||
pSetting = config_setting_add(m_pSettings, "KAFKA_BROKER_PORT", CONFIG_TYPE_INT); |
|||
config_setting_set_int(pSetting, m_nServerPort); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
}; |
|||
sprintf( m_pKafkaBrokerSTR, "%s:%d", m_pServerIP, m_nServerPort ); |
|||
LOG( m_pKafkaBrokerSTR ); |
|||
if (!config_setting_lookup_string(m_pSettings, "KAFKA_TOPIC", (const char**)&m_pKafkaTopicSTR)) { |
|||
strncpy( m_pKafkaTopicSTR, DFSL_INFOSTRESS_DEFAULT_KAFKA_TOPIC, CTEXT ); |
|||
pSetting = config_setting_add(m_pSettings, "KAFKA_TOPIC", CONFIG_TYPE_STRING); |
|||
config_setting_set_string(pSetting, m_pKafkaTopicSTR); |
|||
basicSettingsProvider::getInstance()->compromise(); |
|||
}; |
|||
LOG( m_pKafkaTopicSTR ); |
|||
basicSettingsProvider::getInstance()->validate(); |
|||
|
|||
}; |
|||
}; |
|||
|
|||
/**
|
|||
* @brief Message delivery report callback. |
|||
* |
|||
* This callback is called exactly once per message, indicating if |
|||
* the message was succesfully delivered |
|||
* (rkmessage->err == RD_KAFKA_RESP_ERR_NO_ERROR) or permanently |
|||
* failed delivery (rkmessage->err != RD_KAFKA_RESP_ERR_NO_ERROR). |
|||
* |
|||
* The callback is triggered from rd_kafka_poll() and executes on |
|||
* the application's thread. |
|||
*/ |
|||
/*
|
|||
static void dr_msg_cb( rd_kafka_t *rk, const rd_kafka_message_t *rkmessage, void *opaque ){ |
|||
if (rkmessage->err) |
|||
fprintf(stderr, "%% Message delivery failed: %s\n", |
|||
rd_kafka_err2str(rkmessage->err)); |
|||
else |
|||
fprintf(stderr, |
|||
"%% Message delivered (%zd bytes, " |
|||
"partition %"PRId32")\n", |
|||
rkmessage->len, rkmessage->partition); |
|||
|
|||
// The rkmessage is destroyed automatically by librdkafka
|
|||
}; |
|||
*/ |
|||
|
|||
protocolKAFKA::~protocolKAFKA(){ |
|||
m_bEnabled = false; |
|||
if( m_pKafka != NULL ){ |
|||
/* Wait for final messages to be delivered or fail.
|
|||
* rd_kafka_flush() is an abstraction over rd_kafka_poll() which |
|||
* waits for all messages to be delivered. */ |
|||
LOG("Flushing final messages.."); |
|||
m_pKafka->flush( 3000 /* wait for max 3 seconds */); |
|||
/* If the output queue is still not empty there is an issue
|
|||
* with producing messages to the clusters. */ |
|||
if (m_pKafka->outq_len() > 0) LOG_ERROR("Some messages are not delivered!"); |
|||
delete m_pKafka; |
|||
}; |
|||
if( m_pScannerName != NULL ) free(m_pScannerName); |
|||
if( m_pServerIP != NULL ) free(m_pServerIP); |
|||
if( m_pAccessURL != NULL ) free(m_pAccessURL); |
|||
}; |
|||
//https://github.com/edenhill/librdkafka/blob/master/examples/producer.c
|
|||
//https://github.com/edenhill/librdkafka/blob/master/examples/producer.cpp
|
|||
|
|||
void protocolKAFKA::dr_cb( RdKafka::Message &message ){ |
|||
/* If message.err() is non-zero the message delivery failed permanently
|
|||
* for the message. */ |
|||
char tBuffer[1024]; |
|||
if( message.err() ){ |
|||
sprintf(tBuffer,"Message delivery failed: %s", message.errstr().c_str() ); |
|||
LOG_ERROR( tBuffer ); |
|||
} |
|||
#ifdef DEBUG
|
|||
else { |
|||
sprintf(tBuffer,"Message delivered to topic: %s [%d] at offset %d", message.topic_name().c_str(), message.partition(), message.offset() ); |
|||
LOG( tBuffer ); |
|||
} |
|||
#endif
|
|||
; |
|||
}; |
|||
|
|||
bool protocolKAFKA::init(){ |
|||
RdKafka::Conf * tProducerConf; |
|||
RdKafka::Conf * tTopicConf; |
|||
|
|||
std::string tBuffer; |
|||
std::string brokers = m_pKafkaBrokerSTR; |
|||
std::string topic = m_pKafkaTopicSTR; |
|||
|
|||
LOG("Begin Init"); |
|||
if( strlen( m_pKafkaBrokerSTR ) == 0 ) { |
|||
LOG_ERROR("No Kafka Brokers are defined!"); |
|||
return false; |
|||
}; |
|||
tProducerConf = RdKafka::Conf::create( RdKafka::Conf::CONF_GLOBAL ); |
|||
if( tProducerConf == NULL ) { |
|||
LOG_ERROR("Eror Creating Producer Conf!"); |
|||
return false; |
|||
}; |
|||
LOG("RdKafka::Conf::CONF_GLOBAL Created"); |
|||
tTopicConf = RdKafka::Conf::create(RdKafka::Conf::CONF_TOPIC); |
|||
if( tTopicConf==NULL ){ |
|||
LOG_ERROR("Eror Creating Topic Conf!"); |
|||
delete( tProducerConf ); |
|||
tProducerConf = NULL; |
|||
return false; |
|||
}; |
|||
LOG("RdKafka::Conf::CONF_TOPIC Created"); |
|||
|
|||
if( tProducerConf->set("bootstrap.servers", brokers, tBuffer ) != RdKafka::Conf::CONF_OK ){ |
|||
LOG_ERROR( tBuffer.c_str() ); |
|||
delete( tProducerConf ); |
|||
delete( tTopicConf ); |
|||
tProducerConf = NULL; |
|||
tTopicConf = NULL; |
|||
return false; |
|||
}; |
|||
LOG("bootstrap.servers is SET"); |
|||
|
|||
if( tProducerConf->set("metadata.broker.list", brokers, tBuffer ) != RdKafka::Conf::CONF_OK ){ |
|||
LOG_ERROR( tBuffer.c_str() ); |
|||
delete( tProducerConf ); |
|||
delete( tTopicConf ); |
|||
tProducerConf = NULL; |
|||
tTopicConf = NULL; |
|||
return false; |
|||
}; |
|||
LOG("metadata.broker.list is SET"); |
|||
/* Set the delivery report callback.
|
|||
* This callback will be called once per message to inform |
|||
* the application if delivery succeeded or failed. |
|||
* See dr_msg_cb() above. |
|||
* The callback is only triggered from rd_kafka_poll() and |
|||
* rd_kafka_flush(). */ |
|||
//tProducerConf->set("queue.buffering.max.ms", "100", tBuffer );
|
|||
//tProducerConf->set("socket.blocking.max.ms", "100", tBuffer );
|
|||
if( tProducerConf->set( "dr_cb", this, tBuffer ) != RdKafka::Conf::CONF_OK ){ |
|||
LOG_ERROR( tBuffer.c_str() ); |
|||
delete( tProducerConf ); |
|||
delete( tTopicConf ); |
|||
tProducerConf = NULL; |
|||
tTopicConf = NULL; |
|||
return false; |
|||
}; |
|||
LOG("dr_cb is SET"); |
|||
if( tProducerConf->set("default_topic_conf", tTopicConf, tBuffer ) != RdKafka::Conf::CONF_OK ){ |
|||
LOG_ERROR( tBuffer.c_str() ); |
|||
delete( tProducerConf ); |
|||
delete( tTopicConf ); |
|||
tProducerConf = NULL; |
|||
tTopicConf = NULL; |
|||
return false; |
|||
}; |
|||
LOG("default_topic_conf is SET"); |
|||
/*
|
|||
* Create producer instance. |
|||
* |
|||
* NOTE: rd_kafka_new() takes ownership of the conf object |
|||
* and the application must not reference it again after |
|||
* this call. |
|||
*/ |
|||
m_pKafka = RdKafka::Producer::create( tProducerConf, tBuffer ); |
|||
if( m_pKafka == NULL ){ |
|||
LOG_ERROR( tBuffer.c_str() ); |
|||
delete( tProducerConf ); |
|||
delete( tTopicConf ); |
|||
tProducerConf = NULL; |
|||
tTopicConf = NULL; |
|||
return false; |
|||
}; |
|||
LOG("RdKafka::Producer Created"); |
|||
m_pKafkaTopic = RdKafka::Topic::create( m_pKafka, topic, tTopicConf, tBuffer ); |
|||
if( m_pKafkaTopic == NULL ) { |
|||
LOG_ERROR( tBuffer.c_str() ); |
|||
delete( tProducerConf ); |
|||
delete( tTopicConf ); |
|||
tProducerConf = NULL; |
|||
tTopicConf = NULL; |
|||
return false; |
|||
}; |
|||
LOG("RdKafka::Topic Created"); |
|||
delete( tProducerConf ); |
|||
delete( tTopicConf ); |
|||
tProducerConf = NULL; |
|||
tTopicConf = NULL; |
|||
LOG("INIT Complete"); |
|||
m_bEnabled = true; |
|||
return true; |
|||
}; |
|||
|
|||
bool protocolKAFKA::issuePost( CSTR Buffer, int BufferSize ){ |
|||
if( m_pKafka == NULL) return false; |
|||
RdKafka::ErrorCode err; |
|||
retry: |
|||
err = m_pKafka->produce( |
|||
m_pKafkaTopic, |
|||
RdKafka::Topic::PARTITION_UA, |
|||
RdKafka::Producer::RK_MSG_COPY, |
|||
(void *)Buffer, |
|||
BufferSize, |
|||
NULL, |
|||
NULL |
|||
); |
|||
if( err != RdKafka::ERR_NO_ERROR ) { |
|||
///std::cerr << "% Failed to produce to topic " << topic << ": " << RdKafka::err2str(err) << std::endl;
|
|||
LOG_ERROR("Failed to produce to topic"); |
|||
if( err == RdKafka::ERR__QUEUE_FULL ){ |
|||
LOG("Internal queue is full!"); |
|||
/* If the internal queue is full, wait for
|
|||
* messages to be delivered and then retry. |
|||
* The internal queue represents both |
|||
* messages to be sent and messages that have |
|||
* been sent or failed, awaiting their |
|||
* delivery report callback to be called. |
|||
* |
|||
* The internal queue is limited by the |
|||
* configuration property |
|||
* queue.buffering.max.messages */ |
|||
m_pKafka->poll(1000/*block for max 1000ms*/); |
|||
goto retry; |
|||
}; |
|||
} |
|||
#ifdef DEBUG
|
|||
else { |
|||
LOG("MSG Queued OK"); |
|||
//std::cerr << "% Enqueued message (" << line.size() << " bytes) " << "for topic " << topic << std::endl;
|
|||
} |
|||
#endif
|
|||
; |
|||
|
|||
/* A producer application should continually serve
|
|||
* the delivery report queue by calling poll() |
|||
* at frequent intervals. |
|||
* Either put the poll call in your main loop, or in a |
|||
* dedicated thread, or call it after every produce() call. |
|||
* Just make sure that poll() is still called |
|||
* during periods where you are not producing any messages |
|||
* to make sure previously produced messages have their |
|||
* delivery report callback served (and any other callbacks |
|||
* you register). */ |
|||
m_pKafka->poll(100); |
|||
//uint8_t cnt = 100;
|
|||
//while ( cnt && m_pKafka->outq_len() > 0) {
|
|||
// LOG("Wait ...");
|
|||
// cnt--;
|
|||
// m_pKafka->poll(100);
|
|||
//};
|
|||
return true; |
|||
}; |
|||
|
|||
void protocolKAFKA::setScannerName( CSTR Name ){ |
|||
sprintf( m_pScannerName, "%s", Name ); |
|||
}; |
|||
void protocolKAFKA::setProtocolType( bool DeviceIs3D ){ |
|||
if( DeviceIs3D ) { |
|||
m_nScannerDimentions = 3; |
|||
} else { |
|||
m_nScannerDimentions = 2; |
|||
}; |
|||
}; |
|||
CSTR protocolKAFKA::assembleStatusData( bool StatusOK ){ |
|||
CSTR RetVal = NULL; |
|||
CSTR TIME_STAMP; |
|||
CSTR tSRC; |
|||
CSTR tTARGET; |
|||
CSTR tID; |
|||
RetVal = (CSTR) malloc(CLOG); |
|||
if ( RetVal != NULL ) { |
|||
TIME_STAMP = getSHDTimeStamp(); |
|||
if( TIME_STAMP != NULL ) { |
|||
tTARGET = (CSTR) malloc(128); |
|||
if( tTARGET!= NULL) { |
|||
tSRC = (CSTR) malloc(128); |
|||
if( tSRC ) { |
|||
tID = (CSTR) malloc(64); |
|||
if( tID != NULL ) { |
|||
sprintf( tID, "%s", MD5String( TIME_STAMP ) ); |
|||
sprintf( tSRC, DFSL_SENSOR_SOURCE_DTO, DFSL_HARDWARE_TYPE, DFRL_PROVIDER_ID, m_pScannerName ); |
|||
sprintf( tTARGET, DFSL_STATUS_DTO, TIME_STAMP , defenderStatusMode[((StatusOK)?1:0)] ); |
|||
sprintf( RetVal, |
|||
PACKAGE_SE_STATUS_DATA_ELEMENT, |
|||
defenderTypeDescription[DC_STATUS], |
|||
TIME_STAMP, |
|||
tSRC, |
|||
"DFSL_LIDAR_SENSOR_STATUS", |
|||
DFSL_DATA_TYPE_STATUS, |
|||
tID, |
|||
tTARGET |
|||
); |
|||
free( tID ); |
|||
free( tSRC ); |
|||
free( tTARGET ); |
|||
free( TIME_STAMP ); |
|||
} else { |
|||
free( tSRC ); |
|||
free( tTARGET ); |
|||
free( TIME_STAMP ); |
|||
free( RetVal ); |
|||
} |
|||
} else { |
|||
free( tTARGET ); |
|||
free( TIME_STAMP ); |
|||
free( RetVal ); |
|||
}; |
|||
} else { |
|||
free( TIME_STAMP ); |
|||
free( RetVal ); |
|||
}; |
|||
} else { |
|||
free( RetVal ); |
|||
RetVal = NULL; |
|||
}; |
|||
}; |
|||
return RetVal; |
|||
}; |
|||
CSTR protocolKAFKA::assembleFaultData( uint8_t Code, CSTR Desc ){ |
|||
CSTR RetVal; |
|||
CSTR TIME_STAMP; |
|||
CSTR tSRC; |
|||
CSTR tTARGET; |
|||
CSTR tID; |
|||
RetVal = (CSTR) malloc(CLOG); |
|||
if ( RetVal != NULL ) { |
|||
TIME_STAMP = getSHDTimeStamp(); |
|||
if( TIME_STAMP != NULL ) { |
|||
tTARGET = (CSTR) malloc(128); |
|||
if( tTARGET!= NULL) { |
|||
tSRC = (CSTR) malloc(128); |
|||
if( tSRC ) { |
|||
tID = (CSTR) malloc(64); |
|||
if( tID != NULL ) { |
|||
sprintf( tID, "%s", MD5String( TIME_STAMP ) ); |
|||
sprintf( tSRC, DFSL_SENSOR_SOURCE_DTO, DFSL_HARDWARE_TYPE, DFRL_PROVIDER_ID, m_pScannerName ); |
|||
sprintf( tTARGET, DFSL_ERROR_DTO, TIME_STAMP, Code, Desc ); |
|||
sprintf( RetVal, |
|||
PACKAGE_SE_STATUS_DATA_ELEMENT, |
|||
Desc, |
|||
TIME_STAMP, |
|||
tSRC, |
|||
"DFSL_LIDARE_SENSOR_FAULT_DATA", |
|||
DFSL_DATA_TYPE_ERROR, |
|||
tID, |
|||
tTARGET |
|||
); |
|||
free( tID ); |
|||
free( tSRC ); |
|||
free( tTARGET ); |
|||
free( TIME_STAMP ); |
|||
} else { |
|||
free( tSRC ); |
|||
free( tTARGET ); |
|||
free( TIME_STAMP ); |
|||
free( RetVal ); |
|||
} |
|||
} else { |
|||
free( tTARGET ); |
|||
free( TIME_STAMP ); |
|||
free( RetVal ); |
|||
}; |
|||
} else { |
|||
free( TIME_STAMP ); |
|||
free( RetVal ); |
|||
}; |
|||
} else { |
|||
free( RetVal ); |
|||
RetVal = NULL; |
|||
}; |
|||
}; |
|||
return RetVal; |
|||
}; |
|||
CSTR protocolKAFKA::assembleTargetData( bool is3D, int targetID, int Range, int Width, int Azimuth, int Elevation ){ |
|||
CSTR RetVal = NULL; |
|||
RetVal = (CSTR) malloc(CLOG); |
|||
if ( RetVal != NULL ) { |
|||
CSTR TIME_STAMP = NULL; |
|||
TIME_STAMP = getTStr(); |
|||
if( TIME_STAMP!= NULL ) { |
|||
char tID[64]; |
|||
float Az; |
|||
float Ra; |
|||
sprintf( tID, "%s", MD5String( TIME_STAMP ) ); |
|||
free( TIME_STAMP ); |
|||
Ra = Range; |
|||
Az = Azimuth; |
|||
if( is3D ) { |
|||
float El; |
|||
El = Elevation; |
|||
sprintf( RetVal, PACKAGE_INFOSTRESS_DATA_3D, tID, m_pScannerName, Az, El, Ra ); |
|||
} else { |
|||
sprintf( RetVal, PACKAGE_INFOSTRESS_DATA_2D, tID, m_pScannerName, Az, Ra, Width ); |
|||
}; |
|||
} else { |
|||
free( RetVal ); |
|||
RetVal = NULL; |
|||
}; |
|||
}; |
|||
return RetVal; |
|||
}; |
|||
|
|||
static uint32_t INFOSTRESS_MESSAGE_ID = 0; |
|||
size_t protocolKAFKA::assembleDefenderJSON( CSTR Buffer, defenderCategoryTypes Type, uint8_t Severity, CSTR Location, CSTR Data ){ |
|||
char tBuffer[CLOG]; |
|||
size_t RetVal; |
|||
CSTR tBuf; |
|||
RetVal = 0; |
|||
tBuf = getSHDTimeStamp(); |
|||
INFOSTRESS_MESSAGE_ID++; |
|||
//memset( tBuffer, 0, CLOG );
|
|||
if( tBuf != NULL ){ |
|||
//char ID[64];
|
|||
switch ( Type ) { |
|||
case DC_STATUS: |
|||
Severity = 0; |
|||
break; |
|||
case DC_ERROR: |
|||
Severity = 2; |
|||
break; |
|||
case DC_ALARM: |
|||
Severity = 4; |
|||
break; |
|||
default: |
|||
Severity = 2; |
|||
}; |
|||
//sprintf( ID, "%s", MD5String( tBuf ) );
|
|||
if( (m_nScannerDimentions > 2) && ( Type == DC_ALARM ) ) Type = DC_ALARM_3D; |
|||
sprintf( tBuffer, |
|||
DFSL_SE_ENVELOPE, |
|||
//DEFENDER_MESSAGE_ID,
|
|||
defenderCategories[Type], |
|||
defenderTypeSeverity[Severity], |
|||
tBuf, tBuf, |
|||
Location, |
|||
Data |
|||
); |
|||
RetVal = strlen(tBuffer); |
|||
memcpy( Buffer, tBuffer, RetVal ); |
|||
Buffer[RetVal] = (char) 0; |
|||
free( tBuf ); |
|||
}; |
|||
return RetVal; |
|||
}; |
|||
|
|||
bool protocolKAFKA::buildStatusPackage( unsigned char *Buffer, int &BufferSize, bool Status ){ |
|||
if( Buffer!= NULL ){ |
|||
CSTR tBuf; |
|||
tBuf = assembleStatusData( Status ); |
|||
#ifdef DEBUG
|
|||
//LOG(tBuf);
|
|||
#endif
|
|||
if( tBuf != NULL ) { |
|||
char DFSL_LOCATION[256]; |
|||
sprintf(DFSL_LOCATION, DFSL_LOCATION_DTO, m_fLon, m_fLat ); |
|||
BufferSize = assembleDefenderJSON( (CSTR)Buffer, DC_STATUS, ((Status)?0:2), DFSL_LOCATION, tBuf ); |
|||
#ifdef DEBUG
|
|||
LOG((CSTR)Buffer); |
|||
#endif
|
|||
free( tBuf ); |
|||
return true; |
|||
} |
|||
}; |
|||
return false; |
|||
}; |
|||
|
|||
|
|||
bool protocolKAFKA::buildFaultPackage( unsigned char *Buffer, int &BufferSize, unsigned char Type, CSTR Description ){ |
|||
if( Buffer!= NULL ){ |
|||
CSTR tBuf; |
|||
tBuf = assembleFaultData( Type, Description ); |
|||
if( tBuf != NULL ){ |
|||
char DFSL_LOCATION[256]; |
|||
sprintf(DFSL_LOCATION, DFSL_LOCATION_DTO, m_fLon, m_fLat ); |
|||
BufferSize = assembleDefenderJSON( (CSTR)Buffer, DC_ERROR, 3, DFSL_LOCATION, tBuf ); |
|||
free( tBuf ); |
|||
return true; |
|||
}; |
|||
}; |
|||
return false; |
|||
}; |
|||
|
|||
bool protocolKAFKA::buildEvent2DPackage( unsigned char *Buffer, int &BufferSize, CSTR msgUID, int targetID, float Angle, float Range, float Width){ |
|||
if( Buffer!= NULL ){ |
|||
CSTR tBuf; |
|||
tBuf = assembleTargetData( false, targetID, Range, Width, Angle, 0 ); |
|||
if( tBuf != NULL ){ |
|||
BufferSize = strlen( tBuf ); |
|||
strncpy( (char *)Buffer, tBuf, BufferSize ); |
|||
Buffer[BufferSize] = (char) 0; |
|||
#ifdef DEBUG
|
|||
LOG((CSTR)Buffer); |
|||
#endif
|
|||
free( tBuf ); |
|||
return true; |
|||
}; |
|||
}; |
|||
return false; |
|||
}; |
|||
|
|||
bool protocolKAFKA::buildEvent3DPackage( unsigned char *Buffer, int &BufferSize, CSTR msgUID, int targetID, float Angle1, float Angle2, float Range ){ |
|||
if( Buffer!= NULL ){ |
|||
CSTR tBuf; |
|||
tBuf = assembleTargetData( true, targetID, Range, 0, Angle1, Angle2 ); |
|||
if( tBuf != NULL ){ |
|||
BufferSize = strlen( tBuf ); |
|||
strncpy( (char *)Buffer, tBuf, BufferSize ); |
|||
Buffer[BufferSize] = (char) 0; |
|||
#ifdef DEBUG
|
|||
LOG((CSTR)Buffer); |
|||
#endif
|
|||
free( tBuf ); |
|||
return true; |
|||
}; |
|||
}; |
|||
return false; |
|||
}; |
|||
|
|||
bool protocolKAFKA::buildClockSyncPackage( unsigned char *Buffer, int &BufferSize ){ |
|||
/*if( Buffer!= NULL ){
|
|||
CSTR tBuf; |
|||
tBuf = getSHTimeStamp(); |
|||
if( tBuf != NULL ){ |
|||
sprintf( |
|||
((char *)(Buffer+BufferSize)), |
|||
PACKAGE_ENVELOPE_TEMPLATE_CLOCKSYNC, |
|||
tBuf |
|||
); |
|||
BufferSize = strlen( (char *)Buffer ); |
|||
free( tBuf ); |
|||
return true; |
|||
}; |
|||
};*/ |
|||
return false; |
|||
}; |
|||
|
|||
bool protocolKAFKA::buildCallBackPackage( unsigned char *Buffer, int &BufferSize, CSTR CallBackPath ){ |
|||
/*if( Buffer!= NULL ){
|
|||
sprintf( |
|||
((char *)(Buffer+BufferSize)), |
|||
PACKAGE_ENVELOPE_TEMPLATE_REG_CALL, |
|||
CallBackPath |
|||
); |
|||
BufferSize = strlen( (char *)Buffer ); |
|||
return true; |
|||
};*/ |
|||
return false; |
|||
}; |
|||
|
|||
|
|||
bool protocolKAFKA::Alarm2D( float Angle, float Range, float Width, int ID ){ |
|||
bool RetVal= false; |
|||
char Buffer[1024]; |
|||
int BufferSize = 0; |
|||
CSTR UID; |
|||
if(!m_bEnabled) return false; |
|||
UID = buildUniqID(); |
|||
if( UID!= NULL ){ |
|||
RetVal = buildEvent2DPackage( ( unsigned char *) Buffer, BufferSize, UID, ID, Angle, Range, Width ); |
|||
RetVal = issuePost( Buffer, BufferSize ); |
|||
free( UID ); |
|||
}; |
|||
return RetVal; |
|||
}; |
|||
|
|||
bool protocolKAFKA::Alarm3D( float Angle1, float Angle2, float Range, int ID ){ |
|||
bool RetVal= false; |
|||
char Buffer[1024]; |
|||
int BufferSize = 0; |
|||
CSTR UID; |
|||
if(!m_bEnabled) return false; |
|||
UID = buildUniqID(); |
|||
if( UID!= NULL ){ |
|||
RetVal = buildEvent3DPackage( ( unsigned char *) Buffer, BufferSize, UID, ID, Angle1, Angle2, Range ); |
|||
RetVal = issuePost( Buffer, BufferSize ); |
|||
free( UID ); |
|||
}; |
|||
return RetVal; |
|||
}; |
|||
|
|||
bool protocolKAFKA::VisibilityChanged( bool Worsened ){ |
|||
if( !m_bEnableStatus ) return true; |
|||
bool RetVal= false; |
|||
char Buffer[1024]; |
|||
int BufferSize = 0; |
|||
if(!m_bEnabled) return false; |
|||
RetVal = buildStatusPackage( ( unsigned char *) Buffer, BufferSize, !Worsened ); |
|||
RetVal = issuePost( Buffer, BufferSize ); |
|||
return RetVal; |
|||
}; |
|||
|
|||
bool protocolKAFKA::StatusUpdate( void ){ |
|||
if( !m_bEnableStatus ) return true; |
|||
bool RetVal= false; |
|||
char Buffer[1024]; |
|||
int BufferSize = 0; |
|||
if(!m_bEnabled) return false; |
|||
RetVal = buildStatusPackage( ( unsigned char *) Buffer, BufferSize, m_bCurrentStatus ); |
|||
RetVal = issuePost( Buffer, BufferSize ); |
|||
return RetVal; |
|||
}; |
|||
|
|||
bool protocolKAFKA::ErrorReporting( int lvl, CSTR Descr ){ |
|||
if( !m_bEnableStatus ) return true; |
|||
bool RetVal= false; |
|||
char Buffer[1024]; |
|||
int BufferSize = 0; |
|||
if(!m_bEnabled) return false; |
|||
RetVal = buildFaultPackage( ( unsigned char *) Buffer, BufferSize, lvl, Descr ); |
|||
RetVal = issuePost( Buffer, BufferSize ); |
|||
return RetVal; |
|||
}; |
|||
|
|||
bool protocolKAFKA::StartTimeSynch( void ){ |
|||
if( !m_bEnableStatus ) return true; |
|||
bool RetVal= false; |
|||
//LOG("TimeSYnc");
|
|||
/*char Buffer[1024];
|
|||
int BufferSize = 0; |
|||
CSTR URL = NULL; |
|||
URL = buildURL( SERVICE_URL_TEMPLATE_CLOCKSYNC, m_nScannerDimentions, m_pScannerName ); |
|||
RetVal = buildClockSyncPackage(( unsigned char *) Buffer, BufferSize ); |
|||
if( URL != NULL ){ |
|||
RetVal = issuePost( URL, Buffer, BufferSize ); |
|||
free( URL ); |
|||
};*/ |
|||
return RetVal; |
|||
}; |
|||
|
|||
|
|||
#undef LOG
|
|||
#undef LOG_ERROR
|
|||
@ -0,0 +1,107 @@ |
|||
#ifndef __PROTOCOL_KAFKA_HEADER__ |
|||
#define __PROTOCOL_KAFKA_HEADER__ |
|||
|
|||
#ifdef __linux__ |
|||
#include <features.h> |
|||
#endif |
|||
|
|||
#include <time.h> |
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
#include <sys/types.h> |
|||
#include <sys/timeb.h> |
|||
#include <string> |
|||
//#include <librdkafka/rdkafka.h> |
|||
#include <librdkafka/rdkafkacpp.h> |
|||
|
|||
#include "protocolEuropeanGeneral.h" |
|||
#include "../../components/base/basicLogCollection.h" |
|||
#include "../../components/base/basicSettingsProvider.h" |
|||
|
|||
typedef struct S_KAFKA_SETTINGS{ |
|||
char brocker_addr[128]; |
|||
uint16_t brocker_port; |
|||
}KAFKA_SETTINGS; |
|||
|
|||
/** |
|||
* TODO: Add class description |
|||
* |
|||
* @author gagua |
|||
*/ |
|||
class protocolKAFKA:public RdKafka::DeliveryReportCb { |
|||
private: |
|||
basicLogCollection * m_pLog; |
|||
config_setting_t * m_pSettings; |
|||
//rd_kafka_t * m_pKafka; /* Producer instance handle */ |
|||
RdKafka::Producer * m_pKafka; /* Producer instance handle */ |
|||
//rd_kafka_conf_t * m_pKafkaConf; /* Temporary configuration object */ |
|||
//RdKafka::Conf * m_pKafkaConf; /* Temporary configuration object */ |
|||
CSTR m_pKafkaBrokerSTR; |
|||
CSTR m_pKafkaTopicSTR; |
|||
RdKafka::Topic * m_pKafkaTopic; |
|||
bool m_bUseCompression; |
|||
bool m_bEnableStatus; |
|||
//uint8_t m_bKafkaBrokersCount; |
|||
|
|||
int m_nScannerDimentions; |
|||
CSTR m_pScannerName; |
|||
CSTR m_pServerIP; |
|||
CSTR m_pAccessURL; |
|||
bool m_bEnabled; |
|||
bool m_bUseSSL; |
|||
bool m_bMitigationStatus; |
|||
float m_fLon; |
|||
float m_fLat; |
|||
int m_nServerPort; |
|||
bool m_bCurrentStatus; |
|||
//CSTR buildURL( CSTR templ, int dim, CSTR devID ); |
|||
CSTR buildUniqID( void ); |
|||
bool buildClockSyncPackage( unsigned char *Buffer, int &BufferSize ); |
|||
bool buildCallBackPackage( unsigned char *Buffer, int &BufferSize, CSTR CallBackPath ); |
|||
bool buildStatusPackage( unsigned char *Buffer, int &BufferSize, bool Status ); |
|||
bool buildFaultPackage( unsigned char *Buffer, int &BufferSize, unsigned char Type, CSTR Description ); |
|||
bool buildEvent2DPackage( unsigned char *Buffer, int &BufferSize, CSTR msgUID, int targetID, float Angle, float Range, float Width ); |
|||
bool buildEvent3DPackage( unsigned char *Buffer, int &BufferSize, CSTR msgUID, int targetID, float Angle1, float Angle2, float Range ); |
|||
|
|||
CSTR assembleStatusData( bool StatusOK ); |
|||
CSTR assembleFaultData( uint8_t Code, CSTR Desc ); |
|||
CSTR assembleTargetData( bool is3D, int targetID, int Range, int Width, int Azimuth, int Elevation = 0 ); |
|||
size_t assembleDefenderJSON( CSTR Buffer, defenderCategoryTypes Type, uint8_t Severity, CSTR Location, CSTR Data ); |
|||
bool issuePost( CSTR Buffer, int BufferSize ); |
|||
public: |
|||
// Constructor |
|||
explicit protocolKAFKA( config_setting_t *Settings ); |
|||
explicit protocolKAFKA( KAFKA_SETTINGS *Settings ); |
|||
//ToDo: change Serial to BaseClass of some kind of socket |
|||
//protocolSafeShore( clientPort *SocketTransport, config_setting_t *Settings = NULL ); |
|||
// Destructor |
|||
virtual ~protocolKAFKA(); |
|||
bool init(); |
|||
bool Alarm2D( float Angle, float Range, float Width, int ID=0 ); |
|||
bool Alarm3D( float Angle1, float Angle2, float Range, int ID=0 ); |
|||
bool VisibilityChanged( bool Worsened ); |
|||
bool StatusUpdate( void ); |
|||
void SetStatus( bool A ){ m_bCurrentStatus = A; }; |
|||
bool ErrorReporting( int lvl, CSTR Descr ); |
|||
bool StartTimeSynch( void ); |
|||
/* Implementation of RdKafka::DeliveryReportCb */ |
|||
virtual void dr_cb( RdKafka::Message &message ); |
|||
#ifdef __linux__ |
|||
//bool FinishTimeSynch( unsigned long long *tVals ); |
|||
#else |
|||
//bool FinishTimeSynch( unsigned __int64 *tVals ); |
|||
#endif |
|||
bool SetupCallBack( CSTR CallBackPath ); |
|||
void setProtocolType( bool DeviceIs3D ); |
|||
void setScannerName( CSTR Name ); |
|||
void setScannerPosition( float Lat, float Lon ){ m_fLon = Lon; m_fLat = Lat; }; |
|||
bool getMitigationStatus(void) { return m_bMitigationStatus; }; |
|||
}; |
|||
|
|||
#ifdef __linux__ |
|||
unsigned long long getSHTimeValue( void ); |
|||
#else |
|||
unsigned __int64 getSHTimeValue( void ); |
|||
#endif |
|||
|
|||
#endif |
|||
@ -0,0 +1,142 @@ |
|||
#include "rgooseKafkaModule.h"
|
|||
|
|||
#define LOG( X ) argusKernelModule::m_pLog->Log( "AKM", 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( "AKM", this, _LOG_ERROR, _tBfrErrMSG2w34 );\ |
|||
} |
|||
#else
|
|||
#define LOG_ERROR( X ) argusKernelModule::m_pLog->Log( "AKM", this, _LOG_ERROR, X );
|
|||
#endif
|
|||
|
|||
argusKafkaModule::argusKafkaModule( uint32_t ModuleID, ARGUS_DBC *DBC ): argusKernelModule( ModuleID, ARGUS_MODULE_KAFKA, DBC ){ |
|||
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
|
|||
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(){ |
|||
}; |
|||
|
|||
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_WHITE: |
|||
case EVT_TARGET_BLACK: |
|||
case EVT_TARGET: |
|||
case EVT_ALARM:{ |
|||
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
|
|||
Alarm3D( (int)Az, (int)El, cRange , tCEVT->k_id ); |
|||
}; |
|||
}; |
|||
break; |
|||
case EVT_ERROR: |
|||
SetStatus( false ); |
|||
break; |
|||
case EVT_SCAN: |
|||
//StatusUpdate();
|
|||
//break;
|
|||
case EVT_FLIP: |
|||
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
|
|||
|
|||
@ -0,0 +1,26 @@ |
|||
#ifndef __RGOOSE_KAFKA_MODULE_HEADERS__ |
|||
#define __RGOOSE_KAFKA_MODULE_HEADERS__ |
|||
|
|||
|
|||
#include "rgooseModule.h" |
|||
#include "../components/base/basicThread.h" |
|||
#include "../data/protocol/protocolKAFKA.h" |
|||
|
|||
class argusKafkaModule: public basicThread, argusKernelModule { |
|||
private: |
|||
KAFKA_SETTINGS *m_pSettings; |
|||
protocolKAFKA *m_pProtocol; |
|||
protected: |
|||
virtual void m_fThreadProc( void ); |
|||
public: |
|||
explicit argusKafkaModule( uint32_t ModuleID, ARGUS_DBC *DBC ); |
|||
virtual ~argusKafkaModule(); |
|||
|
|||
virtual bool reloadSettings(); |
|||
virtual bool startService(); |
|||
virtual bool stopService(); |
|||
virtual void dispatchEvent(basicEvent *Evt); |
|||
}; |
|||
|
|||
|
|||
#endif |
|||
@ -0,0 +1,16 @@ |
|||
#include "rgooseModule.h"
|
|||
|
|||
argusKernelModule( int id, ARGUS_MODULE_TYPE param, ARGUS_DBC *DBC):basicObject(){ |
|||
m_pLog = basicLogCollection::getInstance(); |
|||
m_pDBC = DBC; |
|||
m_eType = param; |
|||
m_nDBID = id; |
|||
m_bDetached = false; |
|||
// Clear Events flags
|
|||
for( int i = 0; i < MAX_EVENT_ID; i++ ) m_bEvtFlags[i] = false; |
|||
}; |
|||
|
|||
~argusKernelModule(){ |
|||
|
|||
}; |
|||
|
|||
@ -1,6 +1,8 @@ |
|||
#include "rgooseServerModule.h"
|
|||
argusServerModule::argusServerModule(ARGUS_DBC * DBC):basicEventHandler(){ |
|||
m_pDBC = DBC; |
|||
|
|||
argusServerModule::argusServerModule( uint32_t ModuleID, ARGUS_DBC * DBC ):argusKernelModule( ModuleID, ARGUS_MODULE_NETWORK, DBC){ |
|||
}; |
|||
|
|||
argusServerModule::~argusServerModule(){}; |
|||
|
|||
void dispatchEvent( basicEvent *Evt ){}; |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue