67 changed files with 2997 additions and 542 deletions
-
2.gitignore
-
7Projects/la_mojo/build
-
247Projects/la_mojo/la_mojo.vpj
-
392Projects/la_mojo/makefile
-
2Projects/la_serva/build
-
6lib/App/common/SQLite_dataBinder.cpp
-
12lib/App/common/dataBinder.h
-
58lib/App/common/deviceNode2D.cpp
-
15lib/App/common/deviceNode2D.h
-
127lib/App/common/deviceNodeCamera.cpp
-
1lib/App/common/deviceNodeFactory.cpp
-
25lib/App/common/deviceNodeSensor.cpp
-
6lib/App/common/deviceNodeSensor.h
-
12lib/App/common/hardwareResourceNetworkProvider.cpp
-
6lib/App/common/hardwareResourceSerialProvider.cpp
-
1lib/App/common/kernelEventFilterAPF.cpp
-
1lib/App/common/kernelEventFilterBubble.cpp
-
1lib/App/common/kernelEventFilterTrain.cpp
-
3lib/App/common/kernelModule.h
-
770lib/App/common/kernelModuleBosch.cpp
-
38lib/App/common/kernelModuleBosch.h
-
52lib/App/common/kernelModuleEmbedVideo.cpp
-
28lib/App/common/kernelModuleEmbedVideo.h
-
15lib/App/common/kernelModuleFactory.cpp
-
1lib/App/common/kernelModuleFlyHunter.cpp
-
1lib/App/common/kernelModuleKafka.cpp
-
23lib/App/common/kernelModuleKafka.h
-
6lib/App/common/kernelModuleModemManager.cpp
-
130lib/App/common/kernelModuleOnvifObserver.cpp
-
8lib/App/common/kernelModuleRemoteServer.h
-
2lib/App/common/kernelPrototype.h
-
31lib/App/common/serverDataBinder.h
-
182lib/App/common/serverMySQL_dataBinder.cpp
-
5lib/App/common/serverMySQL_dataBinder.h
-
1lib/App/common/targetPipeLine.cpp
-
2lib/App/mojo/mojoBackend.cpp
-
89lib/App/mojo/mojoKernel.cpp
-
2lib/App/mojo/mojoKernel.h
-
4lib/App/mojo/mojoRemoteClient.cpp
-
21lib/App/serva/servaKernel.cpp
-
6lib/App/serva/servaMediaEncoder.cpp
-
415lib/App/serva/servaVideoComposer.cpp
-
17lib/App/serva/servaVideoComposer.h
-
20lib/components/base/basicCameraInfo.cpp
-
1lib/components/base/basicCameraInfo.h
-
1lib/components/base/basicEventHeap.cpp
-
4lib/components/base/basicLIBAV.cpp
-
3lib/components/base/basicLIBAV.h
-
1lib/components/base/basicNCursesEngine.cpp
-
36lib/components/base/basicPosition.cpp
-
19lib/components/base/basicPosition.h
-
35lib/components/base/basicTypes.h
-
1lib/components/base/basicVideoAnalyzer.cpp
-
1lib/components/object/objectCameraPTZ.cpp
-
1lib/components/object/objectFlyHunter.cpp
-
68lib/components/object/objectSystemAnchor.cpp
-
5lib/components/object/objectSystemAnchor.h
-
1lib/data/curl/curlRequestsManager.cpp
-
6lib/data/media/video/videoAVLIBSource.cpp
-
4lib/data/media/video/videoAVLIBSource.h
-
4lib/data/media/video/videoLive555AVLibSource.cpp
-
4lib/data/media/video/videoLive555AVLibSource.h
-
1lib/data/media/video/videoV4L2Source.cpp
-
1lib/data/net/netServer.cpp
-
422lib/data/protocol/protocolBVMS.cpp
-
126lib/data/protocol/protocolBVMS.h
-
1lib/data/ssdp/ssdpAnnouncer.cpp
@ -0,0 +1,770 @@ |
|||||
|
#include "kernelModuleBosch.h"
|
||||
|
// #include "mojoKernel.h"
|
||||
|
|
||||
|
#define LOG(X) kernelModule::m_pLog->Log("MOD_BVMS", 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); \ |
||||
|
kernelModule::m_pLog->Log("MOD_BVMS", this, _LOG_ERROR, _tBfrErrMSG2w34); \ |
||||
|
} |
||||
|
#else
|
||||
|
#define LOG_ERROR(X) kernelModule::m_pLog->Log("MOD_BVMS", this, _LOG_ERROR, X);
|
||||
|
#endif
|
||||
|
|
||||
|
kernelModuleBosch::kernelModuleBosch(uint32_t ModuleID) : |
||||
|
kernelModule(ModuleID, KERNEL_MODULE_BOSCH_REST) |
||||
|
{ |
||||
|
m_pProtocol = NULL; |
||||
|
m_bConsumerEnabled = false; |
||||
|
m_pEventHeap = basicEventHeap::getInstance(); |
||||
|
|
||||
|
memset(m_sServerIP, 0, 48); |
||||
|
CSTR TVAL = NULL; // m_pKernel->getServerIp();
|
||||
|
if (TVAL) |
||||
|
{ |
||||
|
strncpy(m_sServerIP, TVAL, 48); |
||||
|
free(TVAL); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
LOG_ERROR("Error Get Argus Server IP!"); |
||||
|
strncpy(m_sServerIP, "192.168.0.127", 48); |
||||
|
}; |
||||
|
memset(m_sServerName, 0, 48); |
||||
|
TVAL = NULL; // m_pKernel->getServerName();
|
||||
|
if (TVAL) |
||||
|
{ |
||||
|
strncpy(m_sServerName, TVAL, 48); |
||||
|
free(TVAL); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
LOG_ERROR("Error Get Argus Server Name!"); |
||||
|
strncpy(m_sServerName, "Argus Server", 48); |
||||
|
}; |
||||
|
|
||||
|
m_pEvtTemplates = (REST_TEMPLATE ***) calloc(EVT_CLASS_COUNT, sizeof(REST_TEMPLATE **)); |
||||
|
if (m_pEvtTemplates != NULL) |
||||
|
{ |
||||
|
memset(m_pEvtTemplates, 0, EVT_CLASS_COUNT * sizeof(REST_TEMPLATE **)); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
LOG_ERROR("EVT Templates Memory Allocation Error!"); |
||||
|
} |
||||
|
/*
|
||||
|
Do it in Kernel!! |
||||
|
if ( m_pKernel!= NULL ) { |
||||
|
argusHardwareManager *tHWM = m_pKernel->getHardwareManager(); |
||||
|
if( tHWM != NULL ) { |
||||
|
DBC_INT_LIST *rIDS = tHWM->requestResourcesByType( ARGUS_HARDWARE_PROVIDER_NETWORK ); |
||||
|
if( rIDS != NULL ) { |
||||
|
for( DBC_INT_LIST::iterator idx = rIDS->begin(); idx < rIDS->end(); idx++ ){ |
||||
|
argusHardwareResourceNetwork *tRES = (argusHardwareResourceNetwork *) tHWM->requestResource( ARGUS_HARDWARE_PROVIDER_NETWORK, *idx ); |
||||
|
if( tRES != NULL ) { |
||||
|
m_pServerIP = tRES->getAddress(); |
||||
|
break; |
||||
|
} else { |
||||
|
LOG_ERROR("Cannot Get Resource!"); |
||||
|
}; |
||||
|
}; |
||||
|
delete( rIDS ); |
||||
|
} else { |
||||
|
LOG("No Networks Detected!"); |
||||
|
m_bEnabled = false; |
||||
|
}; |
||||
|
} else { |
||||
|
LOG_ERROR("No HW Manager"); |
||||
|
}; |
||||
|
} else { |
||||
|
LOG_ERROR("No Kernel"); |
||||
|
}; |
||||
|
*/ |
||||
|
} |
||||
|
|
||||
|
kernelModuleBosch::~kernelModuleBosch() |
||||
|
{ |
||||
|
|
||||
|
m_bEnabled = false; |
||||
|
|
||||
|
waitThreadEnd(true); |
||||
|
|
||||
|
if (m_pProtocol != NULL) |
||||
|
{ |
||||
|
delete(m_pProtocol); |
||||
|
}; |
||||
|
if (m_pEvtTemplates != NULL) |
||||
|
{ |
||||
|
for (int i = 0; i < EVT_CLASS_COUNT; i++) |
||||
|
{ |
||||
|
if (m_pEvtTemplates[i] != NULL) |
||||
|
{ |
||||
|
for (int j = 0; j < EVT_COUNT; j++) |
||||
|
{ |
||||
|
if (m_pEvtTemplates[i][j] != NULL) |
||||
|
{ |
||||
|
if (m_pEvtTemplates[i][j]->tpl) |
||||
|
{ |
||||
|
free(m_pEvtTemplates[i][j]->tpl); |
||||
|
} |
||||
|
free(m_pEvtTemplates[i][j]); |
||||
|
}; |
||||
|
}; |
||||
|
free(m_pEvtTemplates[i]); |
||||
|
}; |
||||
|
}; |
||||
|
free(m_pEvtTemplates); |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
/* Periodical Job Handler */ |
||||
|
void kernelModuleBosch::m_fThreadProc(void) |
||||
|
{ |
||||
|
#ifdef DEBUG
|
||||
|
LOG("Pereodical Jobs Started"); |
||||
|
#endif
|
||||
|
m_bThreadStatus = TH_WORKING; |
||||
|
pthread_setname_np(pthread_self(), "moduleBVMS"); |
||||
|
if (! m_bEnabled) |
||||
|
{ |
||||
|
m_bThreadStatus = TH_ENDED; |
||||
|
#ifdef DEBUG
|
||||
|
LOG("Module is Disabled!"); |
||||
|
#endif
|
||||
|
}; |
||||
|
while (m_bThreadStatus < TH_ENDED) |
||||
|
{ |
||||
|
m_llTicks++; //= getMilliseconds();
|
||||
|
if (m_llTicks % 20 == 0) |
||||
|
{ // each 2 seconds
|
||||
|
|
||||
|
}; |
||||
|
if (m_bConsumerEnabled) |
||||
|
{ |
||||
|
for (uint8_t idx = 0; idx < EVT_COUNT; idx++) |
||||
|
{ |
||||
|
if (m_pEvtTemplates[EVT_CLASS_EXTERNAL_CMD][idx] != NULL) |
||||
|
{ |
||||
|
/*
|
||||
|
char BUF[1024]; |
||||
|
int len; |
||||
|
if (m_pProtocol->receivePost(m_pEvtTemplates[EVT_CLASS_EXTERNAL_CMD][idx]->topic, partition, start_offset, BUF, len)) |
||||
|
{ |
||||
|
if (len > 0) |
||||
|
{ |
||||
|
start_offset++; |
||||
|
#ifdef DEBUG
|
||||
|
char ttt[64]; |
||||
|
LOG(" HAVE MESSAGE "); |
||||
|
sprintf(ttt, " MSG Len: %d", len); |
||||
|
LOG(ttt); |
||||
|
#endif
|
||||
|
if (len > 0) |
||||
|
{ |
||||
|
LOG(BUF); |
||||
|
try |
||||
|
{ |
||||
|
Json::Value root; |
||||
|
#ifdef OLD_WAY_JSON
|
||||
|
Json::Reader reader; |
||||
|
if (! reader.parse(BUF, root)) |
||||
|
{ |
||||
|
LOG_ERROR("Error parsing the string"); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
#else
|
||||
|
JSONCPP_STRING err; |
||||
|
Json::CharReaderBuilder builder; |
||||
|
const std::unique_ptr<Json::CharReader> reader(builder.newCharReader()); |
||||
|
if (! reader->parse(BUF, BUF + len, &root, &err)) |
||||
|
{ |
||||
|
LOG_ERROR("Error parsing the string"); |
||||
|
LOG_ERROR(err.c_str()); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
#endif
|
||||
|
|
||||
|
if (root.size()) |
||||
|
{ |
||||
|
FH_CTRL_DATA * tData; |
||||
|
basicEventTypeID evtID = EVT_NOINIT; |
||||
|
Json::Value tVal; |
||||
|
tData = (FH_CTRL_DATA *) malloc(sizeof(FH_CTRL_DATA)); |
||||
|
if (tData) |
||||
|
{ |
||||
|
memset(tData, 0, sizeof(FH_CTRL_DATA)); |
||||
|
tVal = root["id"]; |
||||
|
|
||||
|
if (! tVal.isNull()) |
||||
|
{ |
||||
|
#ifdef DEBUG
|
||||
|
LOG(tVal.asString().c_str()); |
||||
|
#endif
|
||||
|
sprintf(tData->cmdUUID, "%s", tVal.asString().c_str()); |
||||
|
}; |
||||
|
tVal = root["action"]; |
||||
|
if (! tVal.isNull()) |
||||
|
{ |
||||
|
#ifdef DEBUG
|
||||
|
LOG(tVal.asString().c_str()); |
||||
|
#endif
|
||||
|
if (strcasecmp(tVal.asString().c_str(), "intercept_target") == 0) |
||||
|
{ |
||||
|
evtID = EVT_FH_MISSION_BEGIN; |
||||
|
}; |
||||
|
if (strcasecmp(tVal.asString().c_str(), "jam_target") == 0) |
||||
|
{ |
||||
|
tData->param = atoi(tVal.asString().c_str() + 10); |
||||
|
if (tData->param == 0) |
||||
|
{ |
||||
|
tData->param = FH_DEFAULT_JAMING_TIME; |
||||
|
}; |
||||
|
evtID = EVT_FH_JAMING_BEGIN; |
||||
|
}; |
||||
|
if (strcasecmp(tVal.asString().c_str(), "cancel") == 0) |
||||
|
{ |
||||
|
evtID = EVT_FH_CANCEL_ACTION; |
||||
|
}; |
||||
|
}; |
||||
|
tVal = root["event_id"]; |
||||
|
if (! tVal.isNull()) |
||||
|
{ |
||||
|
#ifdef DEBUG
|
||||
|
LOG(tVal.asString().c_str()); |
||||
|
#endif
|
||||
|
sprintf(tData->evtUUID, "%s", tVal.asString().c_str()); |
||||
|
}; |
||||
|
tVal = root["target_id"]; |
||||
|
if (! tVal.isNull()) |
||||
|
{ |
||||
|
#ifdef DEBUG
|
||||
|
LOG(tVal.asString().c_str()); |
||||
|
#endif
|
||||
|
sprintf(tData->targetUUID, "%s", tVal.asString().c_str()); |
||||
|
}; |
||||
|
if (evtID) |
||||
|
{ |
||||
|
EVENT_CONTAINER * tEVT; |
||||
|
tEVT = createBasicEvent(0, EVT_CLASS_EXTERNAL_CMD, evtID, NULL, NULL, tData); |
||||
|
if (tEVT) |
||||
|
{ |
||||
|
m_pEventHeap->broadcast(tEVT); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
free(tData); |
||||
|
}; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
free(tData); |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
} |
||||
|
catch (const std::exception & e ) |
||||
|
{ |
||||
|
LOG_ERROR("EXCEPTION"); |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
*/ |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
SLEEP(100); |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
bool kernelModuleBosch::startService(){ |
||||
|
if (! m_bEnabled ) return false; |
||||
|
if( reloadSettings() ){ |
||||
|
m_pProtocol = new protocolBVMS( m_sRestSettings.server_ip, m_sRestSettings.port ); |
||||
|
if (m_pProtocol->init()){ |
||||
|
return init(); |
||||
|
}; |
||||
|
}; |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
bool kernelModuleBosch::stopService(bool force) |
||||
|
{ |
||||
|
if ( force ) { |
||||
|
m_bEnabled = false; |
||||
|
waitThreadEnd( force ); |
||||
|
} else { |
||||
|
m_bEnabled = !uninit(); |
||||
|
}; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
bool kernelModuleBosch::reloadSettings() |
||||
|
{ |
||||
|
if (m_pDBC == NULL) return false; |
||||
|
if (! m_bEnabled) return false; |
||||
|
REST_SETTINGS * tData = m_pDBC->getBoschData( m_nDBAUXID ); |
||||
|
if ( tData != NULL ){ |
||||
|
|
||||
|
free( tData ); |
||||
|
|
||||
|
if (m_pEvtTemplates != NULL) |
||||
|
{ |
||||
|
// Clear Templates
|
||||
|
for (int i = 0; i < EVT_CLASS_COUNT; i++) |
||||
|
{ |
||||
|
for (int j = 0; j < EVT_COUNT; j++) |
||||
|
{ |
||||
|
if (m_pEvtTemplates[i] != NULL) |
||||
|
{ |
||||
|
if (m_pEvtTemplates[i][j] != NULL) |
||||
|
{ |
||||
|
if (m_pEvtTemplates[i][j]->tpl) |
||||
|
{ |
||||
|
free(m_pEvtTemplates[i][j]->tpl); |
||||
|
} |
||||
|
free(m_pEvtTemplates[i][j]); |
||||
|
m_pEvtTemplates[i][j] = NULL; |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
free(m_pEvtTemplates[i]); |
||||
|
m_pEvtTemplates[i] = NULL; |
||||
|
}; |
||||
|
for (int i = 0; i < EVT_CLASS_COUNT; i++) |
||||
|
{ |
||||
|
for (int j = 0; j < EVT_COUNT; j++) |
||||
|
{ |
||||
|
REST_TEMPLATE * tT; |
||||
|
tT = m_pDBC->getRESTTemplateForEvent(m_nDBAUXID, i, j); |
||||
|
if (tT != NULL) |
||||
|
{ |
||||
|
if (m_pEvtTemplates[i] == NULL) |
||||
|
{ |
||||
|
m_pEvtTemplates[i] = (REST_TEMPLATE **) calloc(EVT_COUNT, sizeof(REST_TEMPLATE *)); |
||||
|
memset(m_pEvtTemplates[i], 0, EVT_COUNT * sizeof(REST_TEMPLATE *)); |
||||
|
if (i == EVT_CLASS_EXTERNAL_CMD) |
||||
|
{ |
||||
|
m_bConsumerEnabled = true; |
||||
|
}; |
||||
|
}; |
||||
|
m_pEvtTemplates[i][j] = tT; |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
return true; |
||||
|
}; |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
CSTR kernelModuleBosch::buildTemplate(CSTR tpl, uint32_t source_id, CSTR ts, CSTR uuid, CSTR az, CSTR range, CSTR width, CSTR el, CSTR lat, CSTR lon, CSTR alt, CSTR extID, CSTR src_Name, CSTR src_IP, CSTR src_lat, CSTR src_lon, CSTR src_alt, |
||||
|
CSTR src_rot_x, CSTR src_rot_y, CSTR src_rot_z) |
||||
|
{ |
||||
|
CSTR ct1, ct2; |
||||
|
char sid[64]; |
||||
|
if (tpl) |
||||
|
{ |
||||
|
sprintf(sid, "%d", source_id); |
||||
|
ct1 = strReplace(tpl, KAFKA_TPL_SUBST_ID, sid); |
||||
|
if (ct1) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_TS, ts); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
if (uuid) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_UUID, uuid); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (az) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_AZ, az); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (range) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_RANGE, range); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (width) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_WIDTH, width); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (el) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_EL, el); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (lat) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_LAT, lat); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (lon) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_LON, lon); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (alt) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_ALT, alt); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (extID) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_EXEVTD, extID); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (src_Name) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_NAME, src_Name); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (src_IP) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_IP, src_IP); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (src_lat) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_LAT, src_lat); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (src_lon) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_LON, src_lon); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (src_alt) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_ALT, src_alt); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (src_rot_x) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_ROT_X, src_rot_x); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (src_rot_y) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_ROT_Y, src_rot_y); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
if (src_rot_z) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRC_ROT_Z, src_rot_z); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
}; |
||||
|
// Finalaze Message by System Wide Data
|
||||
|
// UUID
|
||||
|
CSTR TVAL = getUniqID_UUID(); |
||||
|
if (TVAL != NULL) |
||||
|
{ |
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_MSG_UUID, TVAL); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
free(TVAL); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
LOG_ERROR("Error Generate Message UUID!"); |
||||
|
}; |
||||
|
// Server IP
|
||||
|
|
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRV_IP, m_sServerIP); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
// Server Name
|
||||
|
ct2 = strReplace(ct1, KAFKA_TPL_SUBST_SRV_NAME, m_sServerName); |
||||
|
if (ct2) |
||||
|
{ |
||||
|
free(ct1); |
||||
|
ct1 = ct2; |
||||
|
}; |
||||
|
return ct1; |
||||
|
}; |
||||
|
} |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
bool kernelModuleBosch::dispatchEvent(EVENT_CONTAINER * Evt) |
||||
|
{ |
||||
|
if (Evt == NULL) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
if (! m_bEnabled) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
#ifdef DEBUG
|
||||
|
char tBuffer[256]; |
||||
|
sprintf(tBuffer, "Event Class %d Type %d ", Evt->m_eClass, Evt->m_eType); |
||||
|
LOG(tBuffer); |
||||
|
#endif
|
||||
|
if (m_pEvtTemplates[Evt->m_eClass] != NULL) |
||||
|
{ |
||||
|
// We have defined Channel for that class Events
|
||||
|
// Skip Event Handling by flags
|
||||
|
if (! m_bEvtFlags[Evt->m_eType]) |
||||
|
{ |
||||
|
#ifdef DEBUG
|
||||
|
// LOG("Disabled By FLAG!");
|
||||
|
#endif
|
||||
|
// return;
|
||||
|
} |
||||
|
// Hadle Event
|
||||
|
CSTR tDATA = NULL; |
||||
|
if (m_pEvtTemplates[Evt->m_eClass][Evt->m_eType] != NULL) |
||||
|
{ |
||||
|
switch (Evt->m_eType) |
||||
|
{ |
||||
|
case EVT_TARGET_2D_BLACK: |
||||
|
case EVT_TARGET_2D_WHITE: |
||||
|
{ |
||||
|
TARGET_DATA * tTARGET = (TARGET_DATA *) Evt->m_pEvtData; |
||||
|
if (tTARGET != NULL) |
||||
|
{ |
||||
|
char AZ[10]; |
||||
|
char RA[10]; |
||||
|
char WID[10]; |
||||
|
|
||||
|
char LAT[10]; |
||||
|
char LON[10]; |
||||
|
char ALT[10]; |
||||
|
|
||||
|
char SLAT[10]; |
||||
|
char SLON[10]; |
||||
|
char SALT[10]; |
||||
|
char SROT_X[10]; |
||||
|
char SROT_Y[10]; |
||||
|
char SROT_Z[10]; |
||||
|
char SNAME[64]; |
||||
|
char TS[64]; |
||||
|
|
||||
|
sprintf(AZ, "%0.3f", tTARGET->local_target.fi); |
||||
|
sprintf(RA, "%0.3f", tTARGET->local_target.r); |
||||
|
sprintf(WID, "%0.3f", tTARGET->area); |
||||
|
sprintf(LAT, "%0.6f", tTARGET->global_target.lat); |
||||
|
sprintf(LON, "%0.6f", tTARGET->global_target.lon); |
||||
|
sprintf(ALT, "%0.6f", tTARGET->global_target.alt); |
||||
|
sprintf(TS, "%04d-%02d-%02dT%02d:%02d:%02d.%03lldZ", Evt->sTS.tm_year + 1900, Evt->sTS.tm_mon + 1, Evt->sTS.tm_mday, Evt->sTS.tm_hour, Evt->sTS.tm_min, Evt->sTS.tm_sec, Evt->m_UMSTS % 1000); |
||||
|
sprintf(SLAT, "%0.6f", tTARGET->source_position.lat); |
||||
|
sprintf(SLON, "%0.6f", tTARGET->source_position.lon); |
||||
|
sprintf(SALT, "%0.6f", tTARGET->source_position.alt); |
||||
|
|
||||
|
sprintf(SROT_X, "%0.6f", tTARGET->source_orient.rot_x); |
||||
|
sprintf(SROT_Y, "%0.6f", tTARGET->source_orient.rot_y); |
||||
|
sprintf(SROT_Z, "%0.6f", tTARGET->source_orient.rot_z); |
||||
|
CSTR tN = m_pDBC->getNodeName(Evt->m_nSourceNodeID); |
||||
|
if (tN) |
||||
|
{ |
||||
|
strncpy(SNAME, tN, 64); |
||||
|
free(tN); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
strncpy(SNAME, "Noname-Laser-Detector", 64); |
||||
|
}; |
||||
|
tDATA = buildTemplate(m_pEvtTemplates[Evt->m_eClass][Evt->m_eType]->tpl, Evt->m_nSourceNodeID, TS, Evt->m_UUID, AZ, RA, WID, NULL, LAT, LON, ALT, NULL, SNAME, m_sServerIP, SLAT, SLON, SALT, SROT_X, SROT_Y, SROT_Z); |
||||
|
}; |
||||
|
break; |
||||
|
}; |
||||
|
case EVT_TARGET_3D_BLACK: |
||||
|
case EVT_TARGET_3D_WHITE: |
||||
|
{ |
||||
|
TARGET_DATA * tTARGET = (TARGET_DATA *) Evt->m_pEvtData; |
||||
|
if (tTARGET != NULL) |
||||
|
{ |
||||
|
char AZ[10]; |
||||
|
char EL[10]; |
||||
|
char RA[10]; |
||||
|
char WID[10]; |
||||
|
char LAT[10]; |
||||
|
char LON[10]; |
||||
|
char ALT[10]; |
||||
|
|
||||
|
char SLAT[10]; |
||||
|
char SLON[10]; |
||||
|
char SALT[10]; |
||||
|
char SROT_X[10]; |
||||
|
char SROT_Y[10]; |
||||
|
char SROT_Z[10]; |
||||
|
|
||||
|
char SIP[16]; |
||||
|
char SNAME[64]; |
||||
|
|
||||
|
char TS[64]; |
||||
|
sprintf(AZ, "%0.3f", tTARGET->local_target.fi); |
||||
|
sprintf(EL, "%0.3f", tTARGET->local_target.tetta); |
||||
|
sprintf(RA, "%0.3f", tTARGET->local_target.r); |
||||
|
sprintf(WID, "%0.3f", tTARGET->area); |
||||
|
sprintf(LAT, "%0.6f", tTARGET->global_target.lat); |
||||
|
sprintf(LON, "%0.6f", tTARGET->global_target.lon); |
||||
|
sprintf(ALT, "%0.6f", tTARGET->global_target.alt); |
||||
|
sprintf(TS, "%04d-%02d-%02dT%02d:%02d:%02d.%03lldZ", Evt->sTS.tm_year + 1900, Evt->sTS.tm_mon + 1, Evt->sTS.tm_mday, Evt->sTS.tm_hour, Evt->sTS.tm_min, Evt->sTS.tm_sec, Evt->m_UMSTS % 1000); |
||||
|
sprintf(SLAT, "%0.6f", tTARGET->source_position.lat); |
||||
|
sprintf(SLON, "%0.6f", tTARGET->source_position.lon); |
||||
|
sprintf(SALT, "%0.6f", tTARGET->source_position.alt); |
||||
|
|
||||
|
sprintf(SROT_X, "%0.6f", tTARGET->source_orient.rot_x); |
||||
|
sprintf(SROT_Y, "%0.6f", tTARGET->source_orient.rot_y); |
||||
|
sprintf(SROT_Z, "%0.6f", tTARGET->source_orient.rot_z); |
||||
|
CSTR tN = m_pDBC->getNodeName(Evt->m_nSourceNodeID); |
||||
|
if (tN) |
||||
|
{ |
||||
|
strncpy(SNAME, tN, 64); |
||||
|
free(tN); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
strncpy(SNAME, "Noname-Laser-Detector", 64); |
||||
|
}; |
||||
|
|
||||
|
if (0) |
||||
|
{ |
||||
|
strncpy(SIP, tN, 16); |
||||
|
free(tN); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
strncpy(SIP, "192.168.1.24", 16); |
||||
|
}; |
||||
|
|
||||
|
tDATA = buildTemplate(m_pEvtTemplates[Evt->m_eClass][Evt->m_eType]->tpl, Evt->m_nSourceNodeID, TS, Evt->m_UUID, AZ, RA, WID, EL, LAT, LON, ALT, NULL, SNAME, SIP, SLAT, SLON, SALT, SROT_X, SROT_Y, SROT_Z); |
||||
|
}; |
||||
|
break; |
||||
|
}; |
||||
|
case EVT_FH_JAMER_ON: |
||||
|
case EVT_FH_JAMER_OFF: |
||||
|
case EVT_FH_FLY_TO: |
||||
|
case EVT_FH_WAYPOINT: |
||||
|
case EVT_FH_INTERCEPT_OK: |
||||
|
case EVT_FH_INTERCEPT_NOK: |
||||
|
case EVT_FH_BUSY: |
||||
|
case EVT_FH_LANDED: |
||||
|
{ |
||||
|
FH_MISSION_DATA * tPOINT = (FH_MISSION_DATA *) Evt->m_pEvtData; |
||||
|
if (tPOINT) |
||||
|
{ |
||||
|
char TS[64]; |
||||
|
char LAT[10]; |
||||
|
char LON[10]; |
||||
|
char ALT[10]; |
||||
|
sprintf(LAT, "%0.6f", tPOINT->location.lat); |
||||
|
sprintf(LON, "%0.6f", tPOINT->location.lon); |
||||
|
sprintf(ALT, "%0.6f", tPOINT->location.alt); |
||||
|
sprintf(TS, "%04d-%02d-%02dT%02d:%02d:%02d.%03lldZ", Evt->sTS.tm_year + 1900, Evt->sTS.tm_mon + 1, Evt->sTS.tm_mday, Evt->sTS.tm_hour, Evt->sTS.tm_min, Evt->sTS.tm_sec, Evt->m_UMSTS % 1000); |
||||
|
tDATA = buildTemplate(m_pEvtTemplates[Evt->m_eClass][Evt->m_eType]->tpl, Evt->m_nSourceNodeID, TS, Evt->m_UUID, NULL, NULL, NULL, NULL, LAT, LON, ALT, tPOINT->missionID); |
||||
|
}; |
||||
|
break; |
||||
|
}; |
||||
|
default: |
||||
|
{ |
||||
|
break; |
||||
|
}; |
||||
|
}; |
||||
|
if (tDATA != NULL) |
||||
|
{ |
||||
|
#ifdef REST_DUMMY_SEND
|
||||
|
LOG(tDATA); |
||||
|
#else
|
||||
|
int tLen = strlen(tDATA); |
||||
|
m_pProtocol->issuePost(m_pEvtTemplates[Evt->m_eClass][Evt->m_eType]->endpoint, tDATA, tLen ); |
||||
|
#endif
|
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
LOG_ERROR("Cant Build Template!"); |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
#undef LOG
|
||||
|
#undef LOG_ERROR
|
||||
@ -0,0 +1,38 @@ |
|||||
|
#ifndef __KERNEL_BOSCH_MODULE_HEADERS__ |
||||
|
#define __KERNEL_BOSCH_MODULE_HEADERS__ |
||||
|
|
||||
|
#include "../components/base/basicEventHeap.h" |
||||
|
#include "../components/base/basicThread.h" |
||||
|
#include "../data/protocol/protocolBVMS.h" |
||||
|
#include "kernelModule.h" |
||||
|
|
||||
|
class kernelModuleBosch : public kernelModule, public basicThread |
||||
|
{ |
||||
|
private: |
||||
|
protocolBVMS * m_pProtocol; |
||||
|
bool m_bConsumerEnabled; |
||||
|
basicEventHeap * m_pEventHeap; |
||||
|
REST_TEMPLATE ***m_pEvtTemplates; |
||||
|
REST_SETTINGS m_sRestSettings; |
||||
|
char m_sServerIP[48]; |
||||
|
char m_sServerName[48]; |
||||
|
unsigned long long m_llTicks; |
||||
|
CSTR buildTemplate(CSTR tpl, uint32_t source_id, CSTR ts, CSTR uuid = NULL, CSTR az = NULL, CSTR range = NULL, CSTR width = NULL, CSTR el = NULL, CSTR lat = NULL, CSTR lon = NULL, CSTR alt = NULL, CSTR extID = NULL, CSTR src_Name = NULL, |
||||
|
CSTR src_IP = NULL, CSTR src_lat = NULL, CSTR src_lon = NULL, CSTR src_alt = NULL, CSTR src_rot_x = NULL, CSTR src_rot_y = NULL, CSTR src_rot_z = NULL); |
||||
|
|
||||
|
protected: |
||||
|
|
||||
|
virtual void m_fThreadProc(void); |
||||
|
|
||||
|
public: |
||||
|
|
||||
|
explicit kernelModuleBosch(uint32_t ModuleID); |
||||
|
virtual ~kernelModuleBosch(); |
||||
|
|
||||
|
virtual bool reloadSettings(); |
||||
|
virtual bool startService(); |
||||
|
virtual bool stopService(bool force = false); |
||||
|
virtual bool dispatchEvent(EVENT_CONTAINER * Evt); |
||||
|
}; |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,422 @@ |
|||||
|
#include "protocolBVMS.h"
|
||||
|
|
||||
|
#include "../../alg/generic/md5.h"
|
||||
|
|
||||
|
#define LOG(X) m_pLog->Log("PBVMS", this, X)
|
||||
|
#define LOG_ERROR(X) m_pLog->Log("PBVMS", this, _LOG_ERROR, X)
|
||||
|
|
||||
|
CSTR systemStatusMode[] = {"Operational", "Degraded"}; |
||||
|
CSTR systemFaultCode[] = {"Critical", "Warning", "Info"}; |
||||
|
|
||||
|
CSTR getSHTimeStamp(void) |
||||
|
{ |
||||
|
CSTR RetVal; |
||||
|
#ifdef __linux__
|
||||
|
RetVal = (CSTR) malloc(64); |
||||
|
if (RetVal != NULL) |
||||
|
{ |
||||
|
sprintf(RetVal, "%llu", getTimeValue()); |
||||
|
}; |
||||
|
#else
|
||||
|
RetVal = (CSTR) malloc(64); |
||||
|
if (RetVal != NULL) |
||||
|
{ |
||||
|
sprintf(RetVal, "%I64d", getTimeValue()); |
||||
|
}; |
||||
|
#endif
|
||||
|
return RetVal; |
||||
|
} |
||||
|
|
||||
|
CSTR protocolBVMS::buildURL(CSTR templ, int dim, CSTR devID) |
||||
|
{ |
||||
|
CSTR RetVal; |
||||
|
char tpl[256]; |
||||
|
RetVal = (CSTR) malloc(256); |
||||
|
sprintf(tpl, "http://%s:%d%s", m_pServerIP, m_nServerPort, templ); |
||||
|
sprintf(RetVal, tpl, dim, devID); |
||||
|
return RetVal; |
||||
|
} |
||||
|
|
||||
|
CSTR protocolBVMS::buildUniqID(void) |
||||
|
{ |
||||
|
CSTR RetVal; |
||||
|
RetVal = (CSTR) malloc(64); |
||||
|
sprintf(RetVal, "%s", MD5String(getSHTimeStamp())); |
||||
|
return RetVal; |
||||
|
} |
||||
|
|
||||
|
protocolBVMS::protocolBVMS( CSTR server, uint16_t port ){ |
||||
|
m_pServerIP = strdup( server ); |
||||
|
m_nServerPort = port; |
||||
|
} |
||||
|
|
||||
|
/*
|
||||
|
|
||||
|
|
||||
|
1.2 GHz |
||||
|
Number of Cores |
||||
|
Quad-Core |
||||
|
Type |
||||
|
Tegra 3 |
||||
|
Processor Number |
||||
|
T30SL |
||||
|
Manufacturer |
||||
|
NVIDIA |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
Verify that you have the following installed on your system |
||||
|
Ubuntu 16.04 LTS (with GCC 5.4) |
||||
|
NVIDIA Display Driver ver. 375 |
||||
|
NVIDIA VideoSDK 7.1 |
||||
|
cuDNN 6 & TensorRT 2.1 |
||||
|
NVIDIA CUDA 8.0 |
||||
|
Download the DeepStream 1.0 tar file (below) |
||||
|
Extract the package at the location of your choice |
||||
|
Follow the usage instructions from the Deepstream_User_guide.pdf in the downloaded package. |
||||
|
|
||||
|
|
||||
|
*/ |
||||
|
|
||||
|
protocolBVMS::~protocolBVMS() |
||||
|
{ |
||||
|
//if (m_pScannerName != NULL)
|
||||
|
//{
|
||||
|
// free(m_pScannerName);
|
||||
|
//}
|
||||
|
//if (m_pServerIP != NULL)
|
||||
|
//{
|
||||
|
// free(m_pServerIP);
|
||||
|
//}
|
||||
|
} |
||||
|
|
||||
|
void protocolBVMS::setScannerName(CSTR Name) |
||||
|
{ |
||||
|
//sprintf(m_pScannerName, "%s", Name);
|
||||
|
} |
||||
|
|
||||
|
void protocolBVMS::setProtocolType(bool DeviceIs3D) |
||||
|
{ |
||||
|
// if (DeviceIs3D)
|
||||
|
// {
|
||||
|
// m_nScannerDimentions = 3;
|
||||
|
// }
|
||||
|
// else
|
||||
|
// {
|
||||
|
// m_nScannerDimentions = 2;
|
||||
|
// };
|
||||
|
} |
||||
|
|
||||
|
bool protocolBVMS::buildStatusPackage(unsigned char * Buffer, int & BufferSize, bool Status) |
||||
|
{ |
||||
|
if (Buffer != NULL) |
||||
|
{ |
||||
|
CSTR tBuf; |
||||
|
tBuf = getSHTimeStamp(); |
||||
|
if (tBuf != NULL) |
||||
|
{ |
||||
|
if (Status) |
||||
|
{ |
||||
|
// sprintf((char *) (Buffer + BufferSize), PACKAGE_ENVELOPE_TEMPLATE_STATUS, systemStatusMode[0], tBuf);
|
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
// sprintf((char *) (Buffer + BufferSize), PACKAGE_ENVELOPE_TEMPLATE_STATUS, systemStatusMode[1], tBuf);
|
||||
|
}; |
||||
|
BufferSize = strlen((char *) Buffer); |
||||
|
free(tBuf); |
||||
|
return true; |
||||
|
}; |
||||
|
}; |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
bool protocolBVMS::buildFaultPackage(unsigned char * Buffer, int & BufferSize, unsigned char Type, CSTR Description) |
||||
|
{ |
||||
|
if (Buffer != NULL) |
||||
|
{ |
||||
|
CSTR tBuf; |
||||
|
tBuf = getSHTimeStamp(); |
||||
|
if (tBuf != NULL) |
||||
|
{ |
||||
|
// sprintf((char *) (Buffer + BufferSize), PACKAGE_ENVELOPE_TEMPLATE_FAULT, systemFaultCode[Type], tBuf, Description);
|
||||
|
BufferSize = strlen((char *) Buffer); |
||||
|
free(tBuf); |
||||
|
return true; |
||||
|
}; |
||||
|
}; |
||||
|
return false; |
||||
|
} |
||||
|
/*
|
||||
|
bool protocolBVMS::buildEvent2DPackage(unsigned char * Buffer, int & BufferSize, CSTR msgUID, int targetID, int Angle, int Range, int Width) |
||||
|
{ |
||||
|
if (Buffer != NULL) |
||||
|
{ |
||||
|
CSTR tBuf; |
||||
|
tBuf = getSHTimeStamp(); |
||||
|
if (tBuf != NULL) |
||||
|
{ |
||||
|
// sprintf((char *) (Buffer + BufferSize), PACKAGE_ENVELOPE_TEMPLATE_EVT2D, msgUID, tBuf, targetID, Angle, Range, Width);
|
||||
|
BufferSize = strlen((char *) Buffer); |
||||
|
free(tBuf); |
||||
|
return true; |
||||
|
}; |
||||
|
}; |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
bool protocolBVMS::buildEvent3DPackage(unsigned char * Buffer, int & BufferSize, CSTR msgUID, int targetID, int Angle1, int Angle2, int Range) |
||||
|
{ |
||||
|
if (Buffer != NULL) |
||||
|
{ |
||||
|
CSTR tBuf; |
||||
|
tBuf = getSHTimeStamp(); |
||||
|
if (tBuf != NULL) |
||||
|
{ |
||||
|
//sprintf((char *) (Buffer + BufferSize), PACKAGE_ENVELOPE_TEMPLATE_EVT3D, msgUID, tBuf, targetID, Angle1, Angle2, Range);
|
||||
|
BufferSize = strlen((char *) Buffer); |
||||
|
free(tBuf); |
||||
|
return true; |
||||
|
}; |
||||
|
}; |
||||
|
return false; |
||||
|
} |
||||
|
*/ |
||||
|
|
||||
|
bool protocolBVMS::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 protocolBVMS::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 protocolBVMS::Alarm2D(int Angle, int Range, int Width, int ID) |
||||
|
{ |
||||
|
bool RetVal = false; |
||||
|
char Buffer[1024]; |
||||
|
int BufferSize = 0; |
||||
|
CSTR URL; |
||||
|
CSTR UID; |
||||
|
if (! m_bEnabled) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
UID = buildUniqID(); |
||||
|
if (UID != NULL) |
||||
|
{ |
||||
|
//URL = buildURL(SERVICE_URL_TEMPLATE_EVENT, m_nScannerDimentions, m_pScannerName);
|
||||
|
RetVal = buildEvent2DPackage((unsigned char *) Buffer, BufferSize, UID, ID, Angle, Range, Width); |
||||
|
if (URL != NULL) |
||||
|
{ |
||||
|
RetVal = issuePost(URL, Buffer, BufferSize); |
||||
|
free(URL); |
||||
|
}; |
||||
|
free(UID); |
||||
|
}; |
||||
|
return RetVal; |
||||
|
} |
||||
|
|
||||
|
bool protocolBVMS::Alarm3D(int Angle1, int Angle2, int Range, int ID) |
||||
|
{ |
||||
|
bool RetVal = false; |
||||
|
char Buffer[1024]; |
||||
|
int BufferSize = 0; |
||||
|
CSTR URL; |
||||
|
CSTR UID; |
||||
|
if (! m_bEnabled) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
UID = buildUniqID(); |
||||
|
if (UID != NULL) |
||||
|
{ |
||||
|
//URL = buildURL(SERVICE_URL_TEMPLATE_EVENT, m_nScannerDimentions, m_pScannerName);
|
||||
|
LOG(URL); |
||||
|
RetVal = buildEvent3DPackage((unsigned char *) Buffer, BufferSize, UID, ID, Angle1, Angle2, Range); |
||||
|
if (URL != NULL) |
||||
|
{ |
||||
|
RetVal = issuePost(URL, Buffer, BufferSize); |
||||
|
free(URL); |
||||
|
}; |
||||
|
free(UID); |
||||
|
}; |
||||
|
return RetVal; |
||||
|
} |
||||
|
*/ |
||||
|
bool protocolBVMS::VisibilityChanged(bool Worsened) |
||||
|
{ |
||||
|
bool RetVal = false; |
||||
|
char Buffer[1024]; |
||||
|
int BufferSize = 0; |
||||
|
CSTR URL; |
||||
|
//URL = buildURL(SERVICE_URL_TEMPLATE_STATUS, m_nScannerDimentions, m_pScannerName);
|
||||
|
RetVal = buildStatusPackage((unsigned char *) Buffer, BufferSize, ! Worsened); |
||||
|
if (URL != NULL) |
||||
|
{ |
||||
|
RetVal = issuePost(URL, Buffer, BufferSize); |
||||
|
free(URL); |
||||
|
}; |
||||
|
return RetVal; |
||||
|
} |
||||
|
|
||||
|
bool protocolBVMS::StatusUpdate(void) |
||||
|
{ |
||||
|
bool RetVal = false; |
||||
|
char Buffer[1024]; |
||||
|
int BufferSize = 0; |
||||
|
CSTR URL; |
||||
|
//if (! m_bEnabled)
|
||||
|
//{
|
||||
|
// return false;
|
||||
|
//}
|
||||
|
//URL = buildURL(SERVICE_URL_TEMPLATE_STATUS, m_nScannerDimentions, m_pScannerName);
|
||||
|
RetVal = buildStatusPackage((unsigned char *) Buffer, BufferSize, m_bCurrentStatus); |
||||
|
if (URL != NULL) |
||||
|
{ |
||||
|
RetVal = issuePost(URL, Buffer, BufferSize); |
||||
|
free(URL); |
||||
|
}; |
||||
|
return RetVal; |
||||
|
} |
||||
|
|
||||
|
bool protocolBVMS::ErrorReporting(int lvl, CSTR Descr) |
||||
|
{ |
||||
|
bool RetVal = false; |
||||
|
char Buffer[1024]; |
||||
|
int BufferSize = 0; |
||||
|
CSTR URL; |
||||
|
//if (! m_bEnabled)
|
||||
|
//{
|
||||
|
// return false;
|
||||
|
//}
|
||||
|
//URL = buildURL(SERVICE_URL_TEMPLATE_FAULT, m_nScannerDimentions, m_pScannerName);
|
||||
|
RetVal = buildFaultPackage((unsigned char *) Buffer, BufferSize, lvl, Descr); |
||||
|
if (URL != NULL) |
||||
|
{ |
||||
|
RetVal = issuePost(URL, Buffer, BufferSize); |
||||
|
free(URL); |
||||
|
}; |
||||
|
return RetVal; |
||||
|
} |
||||
|
|
||||
|
bool protocolBVMS::StartTimeSynch(void) |
||||
|
{ |
||||
|
bool RetVal = false; |
||||
|
char Buffer[1024]; |
||||
|
int BufferSize = 0; |
||||
|
CSTR URL = NULL; |
||||
|
//if (! m_bEnabled)
|
||||
|
//{
|
||||
|
// return false;
|
||||
|
//}
|
||||
|
//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; |
||||
|
} |
||||
|
|
||||
|
bool protocolBVMS::packetHandler(protocolPackage * Package) |
||||
|
{ |
||||
|
// LOG("PACKET HANDLER");
|
||||
|
//if (! m_bEnabled)
|
||||
|
//{
|
||||
|
// return false;
|
||||
|
//}
|
||||
|
if (Package == NULL) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
if (Package->m_nSize == 0) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
if (Package->m_pData == NULL) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
if (Package->m_nCode != 200) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
/*
|
||||
|
try |
||||
|
{ |
||||
|
XMLNode node1 = XMLNode::parseString((const char *) Package->m_pData, "root"); |
||||
|
if (node1.isEmpty()) |
||||
|
{ |
||||
|
// char BUBU[128];
|
||||
|
// sprintf( BUBU, "The package[%d:%d] XML data is not a valid XML data. Cann't find root element.", strlen(pPackage), Package->m_nSize );
|
||||
|
// LOG_ERROR(BUBU);
|
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
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 = getTimeValue(); |
||||
|
#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!");
|
||||
|
correctSoftTime(jagajaga); |
||||
|
//};
|
||||
|
}; |
||||
|
}; |
||||
|
} |
||||
|
catch (exception e) |
||||
|
{ |
||||
|
}; |
||||
|
*/ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
#undef LOG
|
||||
|
#undef LOG_ERROR
|
||||
@ -0,0 +1,126 @@ |
|||||
|
#ifndef __PROTOCOL_BSCH_VMS_HEADER__ |
||||
|
#define __PROTOCOL_BSCH_VMS_HEADER__ |
||||
|
|
||||
|
#ifdef __linux__ |
||||
|
#include <features.h> |
||||
|
#endif |
||||
|
|
||||
|
#include "../../components/base/basicFunctionality.h" |
||||
|
#include "../../components/base/basicLogCollection.h" |
||||
|
#include "../../components/base/basicSettingsProvider.h" |
||||
|
#include "../../components/base/basicPosition.h" |
||||
|
#include "protocolHTTP.h" |
||||
|
#include "../data/json/json_tool.h" |
||||
|
#include <json/reader.h> |
||||
|
#include <json/value.h> |
||||
|
#include <json/writer.h> |
||||
|
#include <strings.h> |
||||
|
|
||||
|
//#include "xmlParser.h" |
||||
|
|
||||
|
#include <stdio.h> |
||||
|
#include <stdlib.h> |
||||
|
#include <string> |
||||
|
#include <sys/timeb.h> |
||||
|
#include <sys/types.h> |
||||
|
#include <time.h> |
||||
|
|
||||
|
#define SERVICE_URL_TEMPLATE_STATUS "/sensors/lidar%dd/%s/status" |
||||
|
#define SERVICE_URL_TEMPLATE_FAULT "/sensors/lidar%dd/%s/fault" |
||||
|
#define SERVICE_URL_TEMPLATE_EVENT "/sensors/lidar%dd/%s/event" |
||||
|
#define SERVICE_URL_TEMPLATE_CALLBACK "/sensors/lidar%dd/%s/httpcallback" |
||||
|
#define SERVICE_URL_TEMPLATE_CLOCKSYNC "/sensors/lidar%dd/%s/clocksync" |
||||
|
/* |
||||
|
|
||||
|
{ |
||||
|
"EventID": "evt-7734-abc-123", |
||||
|
"EventTime": "2026-04-19T10:00:01Z", |
||||
|
"EventType": "IVA:ObjectInField", |
||||
|
"DeviceID": "CAM-001", |
||||
|
"DeviceName": "Perimeter_North", |
||||
|
"EventState": "Active", |
||||
|
"Priority": "High", |
||||
|
"Description": "Person detected in restricted zone", |
||||
|
"Metadata": { |
||||
|
"IVAPro": { |
||||
|
"ObjectType": "Person", |
||||
|
"Confidence": 95, |
||||
|
"Location": { |
||||
|
"Latitude": 32.0853, |
||||
|
"Longitude": 34.7818, |
||||
|
"Altitude": 0 |
||||
|
}, |
||||
|
"BoundingBox": [100, 200, 300, 400] |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
*/ |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* TODO: Add class description |
||||
|
* |
||||
|
* @author gagua |
||||
|
*/ |
||||
|
class protocolBVMS : public protocolHTTP |
||||
|
{ |
||||
|
private: |
||||
|
|
||||
|
basicLogCollection * m_pLog; |
||||
|
CSTR m_pServerIP; |
||||
|
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 buildEventPackage(unsigned char * Buffer, int & BufferSize, CSTR msgUID, int targetID, int Angle, int Range, int Width); |
||||
|
|
||||
|
protected: |
||||
|
|
||||
|
virtual bool packetHandler(protocolPackage * Package); |
||||
|
|
||||
|
public: |
||||
|
|
||||
|
// Constructor |
||||
|
explicit protocolBVMS( CSTR server, uint16_t port ); |
||||
|
virtual ~protocolBVMS(); |
||||
|
|
||||
|
virtual bool init() |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
bool Alarm( C3D_WGS84_LOC target_location ); // GeoLocation |
||||
|
bool Alarm( C3D_DECART target_location ); // UTM |
||||
|
bool VisibilityChanged(bool Worsened); |
||||
|
bool StatusUpdate(void); |
||||
|
|
||||
|
void SetStatus(bool A) |
||||
|
{ |
||||
|
m_bCurrentStatus = A; |
||||
|
} |
||||
|
|
||||
|
bool ErrorReporting(int lvl, CSTR Descr); |
||||
|
bool StartTimeSynch(void); |
||||
|
#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); |
||||
|
}; |
||||
|
|
||||
|
#ifdef __linux__ |
||||
|
unsigned long long getSHTimeValue(void); |
||||
|
#else |
||||
|
unsigned __int64 getSHTimeValue(void); |
||||
|
#endif |
||||
|
|
||||
|
#endif |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue