From 0e2003e4bf8ea2978414f1c72286982cbea09c8c Mon Sep 17 00:00:00 2001 From: Evgeny Gagua Date: Mon, 15 Jun 2026 23:35:05 +0300 Subject: [PATCH] VideoComposer_debug2 --- .gitignore | 2 + Projects/la_mojo/build | 7 +- Projects/la_mojo/la_mojo.vpj | 247 ++++-- Projects/la_mojo/makefile | 392 ++++++--- Projects/la_serva/build | 2 +- lib/App/common/SQLite_dataBinder.cpp | 6 +- lib/App/common/dataBinder.h | 12 +- lib/App/common/deviceNode2D.cpp | 58 +- lib/App/common/deviceNode2D.h | 15 +- lib/App/common/deviceNodeCamera.cpp | 127 ++- lib/App/common/deviceNodeFactory.cpp | 1 + lib/App/common/deviceNodeSensor.cpp | 25 +- lib/App/common/deviceNodeSensor.h | 6 +- .../hardwareResourceNetworkProvider.cpp | 12 +- .../common/hardwareResourceSerialProvider.cpp | 6 +- lib/App/common/kernelEventFilterAPF.cpp | 1 + lib/App/common/kernelEventFilterBubble.cpp | 1 + lib/App/common/kernelEventFilterTrain.cpp | 1 + lib/App/common/kernelModule.h | 3 +- lib/App/common/kernelModuleBosch.cpp | 770 ++++++++++++++++++ lib/App/common/kernelModuleBosch.h | 38 + lib/App/common/kernelModuleEmbedVideo.cpp | 52 +- lib/App/common/kernelModuleEmbedVideo.h | 28 +- lib/App/common/kernelModuleFactory.cpp | 15 +- lib/App/common/kernelModuleFlyHunter.cpp | 1 + lib/App/common/kernelModuleKafka.cpp | 1 + lib/App/common/kernelModuleKafka.h | 23 +- lib/App/common/kernelModuleModemManager.cpp | 6 +- lib/App/common/kernelModuleOnvifObserver.cpp | 130 +-- lib/App/common/kernelModuleRemoteServer.h | 8 +- lib/App/common/kernelPrototype.h | 2 + lib/App/common/serverDataBinder.h | 31 +- lib/App/common/serverMySQL_dataBinder.cpp | 182 ++++- lib/App/common/serverMySQL_dataBinder.h | 5 + lib/App/common/targetPipeLine.cpp | 1 + lib/App/mojo/mojoBackend.cpp | 2 +- lib/App/mojo/mojoKernel.cpp | 89 +- lib/App/mojo/mojoKernel.h | 2 + lib/App/mojo/mojoRemoteClient.cpp | 4 +- lib/App/serva/servaKernel.cpp | 21 +- lib/App/serva/servaMediaEncoder.cpp | 6 +- lib/App/serva/servaVideoComposer.cpp | 415 ++++++++-- lib/App/serva/servaVideoComposer.h | 17 +- lib/components/base/basicCameraInfo.cpp | 20 +- lib/components/base/basicCameraInfo.h | 1 + lib/components/base/basicEventHeap.cpp | 1 + lib/components/base/basicLIBAV.cpp | 4 + lib/components/base/basicLIBAV.h | 3 +- lib/components/base/basicNCursesEngine.cpp | 1 + lib/components/base/basicPosition.cpp | 36 +- lib/components/base/basicPosition.h | 19 +- lib/components/base/basicTypes.h | 35 + lib/components/base/basicVideoAnalyzer.cpp | 1 + lib/components/object/objectCameraPTZ.cpp | 1 + lib/components/object/objectFlyHunter.cpp | 1 + lib/components/object/objectSystemAnchor.cpp | 68 +- lib/components/object/objectSystemAnchor.h | 5 +- lib/data/curl/curlRequestsManager.cpp | 1 + lib/data/media/video/videoAVLIBSource.cpp | 6 +- lib/data/media/video/videoAVLIBSource.h | 4 + .../media/video/videoLive555AVLibSource.cpp | 4 + .../media/video/videoLive555AVLibSource.h | 4 + lib/data/media/video/videoV4L2Source.cpp | 1 + lib/data/net/netServer.cpp | 1 + lib/data/protocol/protocolBVMS.cpp | 422 ++++++++++ lib/data/protocol/protocolBVMS.h | 126 +++ lib/data/ssdp/ssdpAnnouncer.cpp | 1 + 67 files changed, 2997 insertions(+), 542 deletions(-) create mode 100644 lib/App/common/kernelModuleBosch.cpp create mode 100644 lib/App/common/kernelModuleBosch.h create mode 100644 lib/data/protocol/protocolBVMS.cpp create mode 100644 lib/data/protocol/protocolBVMS.h diff --git a/.gitignore b/.gitignore index da359efd..1b573622 100644 --- a/.gitignore +++ b/.gitignore @@ -127,3 +127,5 @@ Projects/img_mill/side/DarkHelp Projects/img_mill/side/codeberg_darknet Projects/img_mill/side/DarkHelp/* Projects/img_mill/side/codeberg_darknet/* +Projects/la_mojo/LRF_Proxy_ONLY +Projects/la_mojo/LRF_Proxy_ONLY/* \ No newline at end of file diff --git a/Projects/la_mojo/build b/Projects/la_mojo/build index 7e6d8d1c..2eb8ed96 100755 --- a/Projects/la_mojo/build +++ b/Projects/la_mojo/build @@ -4,8 +4,11 @@ #make clean -e "CFG=Debug" #make -e "CFG=Debug" -j$(nproc) -make clean -e "CFG=Debug86" -make -e "CFG=Debug86" -j$(nproc) +make clean -e "CFG=LRF_Proxy_ONLY" +make -e "CFG=LRF_Proxy_ONLY" -j$(nproc) + +#make clean -e "CFG=Debug86" +#make -e "CFG=Debug86" -j$(nproc) #cd Debug86 #strip ./mojo_d #cd .. diff --git a/Projects/la_mojo/la_mojo.vpj b/Projects/la_mojo/la_mojo.vpj index f8a85a85..d7ce366e 100644 --- a/Projects/la_mojo/la_mojo.vpj +++ b/Projects/la_mojo/la_mojo.vpj @@ -506,7 +506,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -590,6 +771,7 @@ + @@ -611,71 +793,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Projects/la_mojo/makefile b/Projects/la_mojo/makefile index 7950b5bd..94ed2835 100644 --- a/Projects/la_mojo/makefile +++ b/Projects/la_mojo/makefile @@ -56,9 +56,9 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ - $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \ - $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \ - $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ $(OUTDIR)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -69,15 +69,15 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ - $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolHTTP.o \ - $(OUTDIR)/protocolKAFKA.o $(OUTDIR)/protocolLGS2D.o \ - $(OUTDIR)/protocolLGS3D.o $(OUTDIR)/protocolLGS3D_client.o \ - $(OUTDIR)/protocolONVIF.o $(OUTDIR)/protocolPTZ.o \ - $(OUTDIR)/protocolPTZ_ONVIF.o $(OUTDIR)/protocolPTZ_PELCO.o \ - $(OUTDIR)/protocolPTZ_VISCA.o $(OUTDIR)/serverPort.o \ - $(OUTDIR)/sqlite_class.o $(OUTDIR)/SQLite_dataBinder.o \ - $(OUTDIR)/targetPipeLine.o $(OUTDIR)/Transform.o \ - $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ $(OUTDIR)/xmlParser.o OBJ=$(COMMON_OBJ) $(CFG_OBJ) @@ -109,9 +109,9 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ - $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \ - $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \ - $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ $(OUTDIR)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -122,15 +122,15 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ - $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolHTTP.o \ - $(OUTDIR)/protocolKAFKA.o $(OUTDIR)/protocolLGS2D.o \ - $(OUTDIR)/protocolLGS3D.o $(OUTDIR)/protocolLGS3D_client.o \ - $(OUTDIR)/protocolONVIF.o $(OUTDIR)/protocolPTZ.o \ - $(OUTDIR)/protocolPTZ_ONVIF.o $(OUTDIR)/protocolPTZ_PELCO.o \ - $(OUTDIR)/protocolPTZ_VISCA.o $(OUTDIR)/serverPort.o \ - $(OUTDIR)/sqlite_class.o $(OUTDIR)/SQLite_dataBinder.o \ - $(OUTDIR)/targetPipeLine.o $(OUTDIR)/Transform.o \ - $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ $(OUTDIR)/xmlParser.o -lsqlite3 -lpthread -lmysqlclient -lssl -lcurl \ -lm -lcrypto -lconfig -lz -lv4l1 -lv4l2 -lhidapi-libusb `pkg-config \ @@ -253,9 +253,9 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ - $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \ - $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \ - $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ $(OUTDIR)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -266,15 +266,15 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ - $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolHTTP.o \ - $(OUTDIR)/protocolKAFKA.o $(OUTDIR)/protocolLGS2D.o \ - $(OUTDIR)/protocolLGS3D.o $(OUTDIR)/protocolLGS3D_client.o \ - $(OUTDIR)/protocolONVIF.o $(OUTDIR)/protocolPTZ.o \ - $(OUTDIR)/protocolPTZ_ONVIF.o $(OUTDIR)/protocolPTZ_PELCO.o \ - $(OUTDIR)/protocolPTZ_VISCA.o $(OUTDIR)/serverPort.o \ - $(OUTDIR)/sqlite_class.o $(OUTDIR)/SQLite_dataBinder.o \ - $(OUTDIR)/targetPipeLine.o $(OUTDIR)/Transform.o \ - $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ $(OUTDIR)/xmlParser.o OBJ=$(COMMON_OBJ) $(CFG_OBJ) @@ -306,9 +306,9 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ - $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \ - $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \ - $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ $(OUTDIR)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -319,15 +319,15 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ - $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolHTTP.o \ - $(OUTDIR)/protocolKAFKA.o $(OUTDIR)/protocolLGS2D.o \ - $(OUTDIR)/protocolLGS3D.o $(OUTDIR)/protocolLGS3D_client.o \ - $(OUTDIR)/protocolONVIF.o $(OUTDIR)/protocolPTZ.o \ - $(OUTDIR)/protocolPTZ_ONVIF.o $(OUTDIR)/protocolPTZ_PELCO.o \ - $(OUTDIR)/protocolPTZ_VISCA.o $(OUTDIR)/serverPort.o \ - $(OUTDIR)/sqlite_class.o $(OUTDIR)/SQLite_dataBinder.o \ - $(OUTDIR)/targetPipeLine.o $(OUTDIR)/Transform.o \ - $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ $(OUTDIR)/xmlParser.o @@ -450,9 +450,9 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ - $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \ - $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \ - $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ $(OUTDIR)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -463,15 +463,15 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ - $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolHTTP.o \ - $(OUTDIR)/protocolKAFKA.o $(OUTDIR)/protocolLGS2D.o \ - $(OUTDIR)/protocolLGS3D.o $(OUTDIR)/protocolLGS3D_client.o \ - $(OUTDIR)/protocolONVIF.o $(OUTDIR)/protocolPTZ.o \ - $(OUTDIR)/protocolPTZ_ONVIF.o $(OUTDIR)/protocolPTZ_PELCO.o \ - $(OUTDIR)/protocolPTZ_VISCA.o $(OUTDIR)/serverPort.o \ - $(OUTDIR)/sqlite_class.o $(OUTDIR)/SQLite_dataBinder.o \ - $(OUTDIR)/targetPipeLine.o $(OUTDIR)/Transform.o \ - $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ $(OUTDIR)/xmlParser.o OBJ=$(COMMON_OBJ) $(CFG_OBJ) @@ -503,9 +503,9 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ - $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \ - $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \ - $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ $(OUTDIR)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -516,15 +516,15 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ - $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolHTTP.o \ - $(OUTDIR)/protocolKAFKA.o $(OUTDIR)/protocolLGS2D.o \ - $(OUTDIR)/protocolLGS3D.o $(OUTDIR)/protocolLGS3D_client.o \ - $(OUTDIR)/protocolONVIF.o $(OUTDIR)/protocolPTZ.o \ - $(OUTDIR)/protocolPTZ_ONVIF.o $(OUTDIR)/protocolPTZ_PELCO.o \ - $(OUTDIR)/protocolPTZ_VISCA.o $(OUTDIR)/serverPort.o \ - $(OUTDIR)/sqlite_class.o $(OUTDIR)/SQLite_dataBinder.o \ - $(OUTDIR)/targetPipeLine.o $(OUTDIR)/Transform.o \ - $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ $(OUTDIR)/xmlParser.o -lsqlite3 -lpthread -lmysqlclient -lssl -lcurl \ -lm -lcrypto -lconfig -lz -lv4l1 -lv4l2 -lhidapi-libusb `pkg-config \ @@ -652,9 +652,9 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ - $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \ - $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \ - $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ $(OUTDIR)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -665,15 +665,15 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ - $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolHTTP.o \ - $(OUTDIR)/protocolKAFKA.o $(OUTDIR)/protocolLGS2D.o \ - $(OUTDIR)/protocolLGS3D.o $(OUTDIR)/protocolLGS3D_client.o \ - $(OUTDIR)/protocolONVIF.o $(OUTDIR)/protocolPTZ.o \ - $(OUTDIR)/protocolPTZ_ONVIF.o $(OUTDIR)/protocolPTZ_PELCO.o \ - $(OUTDIR)/protocolPTZ_VISCA.o $(OUTDIR)/serverPort.o \ - $(OUTDIR)/sqlite_class.o $(OUTDIR)/SQLite_dataBinder.o \ - $(OUTDIR)/targetPipeLine.o $(OUTDIR)/Transform.o \ - $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ $(OUTDIR)/xmlParser.o OBJ=$(COMMON_OBJ) $(CFG_OBJ) @@ -705,9 +705,9 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ - $(OUTDIR)/kernelModuleEmbedVideo.o $(OUTDIR)/kernelModuleFactory.o \ - $(OUTDIR)/kernelModuleFlyHunter.o $(OUTDIR)/kernelModuleKafka.o \ - $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ $(OUTDIR)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -718,15 +718,15 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ - $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolHTTP.o \ - $(OUTDIR)/protocolKAFKA.o $(OUTDIR)/protocolLGS2D.o \ - $(OUTDIR)/protocolLGS3D.o $(OUTDIR)/protocolLGS3D_client.o \ - $(OUTDIR)/protocolONVIF.o $(OUTDIR)/protocolPTZ.o \ - $(OUTDIR)/protocolPTZ_ONVIF.o $(OUTDIR)/protocolPTZ_PELCO.o \ - $(OUTDIR)/protocolPTZ_VISCA.o $(OUTDIR)/serverPort.o \ - $(OUTDIR)/sqlite_class.o $(OUTDIR)/SQLite_dataBinder.o \ - $(OUTDIR)/targetPipeLine.o $(OUTDIR)/Transform.o \ - $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ $(OUTDIR)/xmlParser.o -lsqlite3 -lpthread -lmysqlclient -lssl -lcurl \ -lm -lcrypto -lconfig -lz -lv4l1 -lv4l2 -lhidapi-libusb `pkg-config \ @@ -812,6 +812,202 @@ clean: cleanall: clean endif +# +# Configuration: LRF_Proxy_ONLY +# +ifeq "$(CFG)" "LRF_Proxy_ONLY" +OUTDIR=LRF_Proxy_ONLY +OUTFILE=$(OUTDIR)/mojo_d +CFG_INC= +CFG_LIB=-lsqlite3 -lpthread -lmysqlclient -lssl -lcurl -lm -lcrypto \ + -lconfig -lz -lhidapi-libusb -latomic `pkg-config --libs openssl \ + rdkafka++` -lgroupsock +CFG_OBJ= +COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ + $(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ + $(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \ + $(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \ + $(OUTDIR)/basicLIBAV.o $(OUTDIR)/basicLogCollection.o \ + $(OUTDIR)/basicLoggingService.o $(OUTDIR)/basicObject.o \ + $(OUTDIR)/basicPosition.o $(OUTDIR)/basicRing.o \ + $(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \ + $(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \ + $(OUTDIR)/clientPort.o $(OUTDIR)/cmdNodeConveyor.o \ + $(OUTDIR)/curlRequest.o $(OUTDIR)/curlRequestsManager.o \ + $(OUTDIR)/dataBinder.o $(OUTDIR)/dataBinder_ReportAux.o \ + $(OUTDIR)/detector.o $(OUTDIR)/deviceNode.o $(OUTDIR)/deviceNode2D.o \ + $(OUTDIR)/deviceNode3D.o $(OUTDIR)/deviceNodeCamera.o \ + $(OUTDIR)/deviceNodeEthernet2Serial.o $(OUTDIR)/deviceNodeFactory.o \ + $(OUTDIR)/deviceNodePresetCamControl.o \ + $(OUTDIR)/deviceNodePTZCamControl.o $(OUTDIR)/deviceNodeSensor.o \ + $(OUTDIR)/deviceNodeStaticCamControl.o $(OUTDIR)/fs_helper.o \ + $(OUTDIR)/FSClient.o $(OUTDIR)/hardwareManager.o \ + $(OUTDIR)/hardwareResource.o \ + $(OUTDIR)/hardwareResourceDryContactProvider.o \ + $(OUTDIR)/hardwareResourceNetworkProvider.o \ + $(OUTDIR)/hardwareResourceSerialProvider.o \ + $(OUTDIR)/hardwareResourceVideoProvider.o $(OUTDIR)/heapDebug.o \ + $(OUTDIR)/hid_dc.o $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \ + $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ + $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ + $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleOnvifObserver.o \ + $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ + $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ + $(OUTDIR)/libzip.o $(OUTDIR)/mask.o $(OUTDIR)/md5.o \ + $(OUTDIR)/mojoBackend.o $(OUTDIR)/mojoKernel.o \ + $(OUTDIR)/mojoRemoteClient.o $(OUTDIR)/mysql_class.o \ + $(OUTDIR)/MySQL_dataBinder.o $(OUTDIR)/netClientHandler.o \ + $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ + $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ + $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ + $(OUTDIR)/xmlParser.o +OBJ=$(COMMON_OBJ) $(CFG_OBJ) +ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.o \ + $(OUTDIR)/basicDualThread.o $(OUTDIR)/basicEngine.o \ + $(OUTDIR)/basicEvent.o $(OUTDIR)/basicEventHandler.o \ + $(OUTDIR)/basicEventHeap.o $(OUTDIR)/basicFunctionality.o \ + $(OUTDIR)/basicLIBAV.o $(OUTDIR)/basicLogCollection.o \ + $(OUTDIR)/basicLoggingService.o $(OUTDIR)/basicObject.o \ + $(OUTDIR)/basicPosition.o $(OUTDIR)/basicRing.o \ + $(OUTDIR)/basicSettings.o $(OUTDIR)/basicSettingsProvider.o \ + $(OUTDIR)/basicThread.o $(OUTDIR)/basicTransport.o \ + $(OUTDIR)/clientPort.o $(OUTDIR)/cmdNodeConveyor.o \ + $(OUTDIR)/curlRequest.o $(OUTDIR)/curlRequestsManager.o \ + $(OUTDIR)/dataBinder.o $(OUTDIR)/dataBinder_ReportAux.o \ + $(OUTDIR)/detector.o $(OUTDIR)/deviceNode.o $(OUTDIR)/deviceNode2D.o \ + $(OUTDIR)/deviceNode3D.o $(OUTDIR)/deviceNodeCamera.o \ + $(OUTDIR)/deviceNodeEthernet2Serial.o $(OUTDIR)/deviceNodeFactory.o \ + $(OUTDIR)/deviceNodePresetCamControl.o \ + $(OUTDIR)/deviceNodePTZCamControl.o $(OUTDIR)/deviceNodeSensor.o \ + $(OUTDIR)/deviceNodeStaticCamControl.o $(OUTDIR)/fs_helper.o \ + $(OUTDIR)/FSClient.o $(OUTDIR)/hardwareManager.o \ + $(OUTDIR)/hardwareResource.o \ + $(OUTDIR)/hardwareResourceDryContactProvider.o \ + $(OUTDIR)/hardwareResourceNetworkProvider.o \ + $(OUTDIR)/hardwareResourceSerialProvider.o \ + $(OUTDIR)/hardwareResourceVideoProvider.o $(OUTDIR)/heapDebug.o \ + $(OUTDIR)/hid_dc.o $(OUTDIR)/json_reader.o $(OUTDIR)/json_value.o \ + $(OUTDIR)/json_writer.o $(OUTDIR)/kernelEventFilter.o \ + $(OUTDIR)/kernelEventFilterAPF.o $(OUTDIR)/kernelEventFilterBubble.o \ + $(OUTDIR)/kernelEventFilterTrain.o $(OUTDIR)/kernelModule.o \ + $(OUTDIR)/kernelModuleBosch.o $(OUTDIR)/kernelModuleEmbedVideo.o \ + $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ + $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.o \ + $(OUTDIR)/kernelModuleOnvifObserver.o \ + $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ + $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ + $(OUTDIR)/libzip.o $(OUTDIR)/mask.o $(OUTDIR)/md5.o \ + $(OUTDIR)/mojoBackend.o $(OUTDIR)/mojoKernel.o \ + $(OUTDIR)/mojoRemoteClient.o $(OUTDIR)/mysql_class.o \ + $(OUTDIR)/MySQL_dataBinder.o $(OUTDIR)/netClientHandler.o \ + $(OUTDIR)/netServer.o $(OUTDIR)/objectFileLoggingService.o \ + $(OUTDIR)/objectSystemAnchor.o $(OUTDIR)/ponvif.o \ + $(OUTDIR)/protocol.o $(OUTDIR)/protocolARGUS.o \ + $(OUTDIR)/protocolARGUS_DATA.o $(OUTDIR)/protocolBVMS.o \ + $(OUTDIR)/protocolHTTP.o $(OUTDIR)/protocolKAFKA.o \ + $(OUTDIR)/protocolLGS2D.o $(OUTDIR)/protocolLGS3D.o \ + $(OUTDIR)/protocolLGS3D_client.o $(OUTDIR)/protocolONVIF.o \ + $(OUTDIR)/protocolPTZ.o $(OUTDIR)/protocolPTZ_ONVIF.o \ + $(OUTDIR)/protocolPTZ_PELCO.o $(OUTDIR)/protocolPTZ_VISCA.o \ + $(OUTDIR)/serverPort.o $(OUTDIR)/sqlite_class.o \ + $(OUTDIR)/SQLite_dataBinder.o $(OUTDIR)/targetPipeLine.o \ + $(OUTDIR)/Transform.o $(OUTDIR)/transportSocket.o $(OUTDIR)/utm.o \ + $(OUTDIR)/videoAVLIBSource.o $(OUTDIR)/videoLive555AVLibSource.o \ + $(OUTDIR)/xmlParser.o -lsqlite3 -lpthread -lmysqlclient -lssl -lcurl \ + -lm -lcrypto -lconfig -lz -lhidapi-libusb -latomic `pkg-config \ + --libs openssl rdkafka++` -lgroupsock + +COMPILE=g++ -c -x c++ "-DDEBUG" "-DLRF_PROXY_ONLY" "-D__STDC_CONSTANT_MACROS" "-D_CLIENT_APPLICATION_" "-D_OPENCV_" -O0 -Wall -pedantic -W -std=c++17 -Wno-write-strings -I../../lib/include -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $< +LINK=g++ -O0 -Wall -pedantic -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/App/mojo/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/rfs/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/App/common/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/net/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/media/video/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/hardware/hid/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/alg/lgs/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/mysql/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/components/base/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/curl/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/alg/generic/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/sqlite/%.cpp + $(COMPILE) + +$(OUTDIR)/%.o : ../../lib/data/ponvif/%.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: # @@ -868,8 +1064,9 @@ $(OUTDIR)/kernelEventFilterAPF.o: ../../lib/App/common/kernelEventFilterAPF.cpp $(OUTDIR)/kernelEventFilterBubble.o: ../../lib/App/common/kernelEventFilterBubble.cpp ../../lib/App/common/kernelEventFilterBubble.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicThread.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/App/common/kernelEventFilter.h ../../lib/App/common/kernelPrototype.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicPosition.h ../../lib/components/base/basicTypes.h ../../lib/alg/generic/Transform.h ../../lib/components/object/objectSystemAnchor.h $(OUTDIR)/kernelEventFilterTrain.o: ../../lib/App/common/kernelEventFilterTrain.cpp ../../lib/App/common/kernelEventFilterTrain.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/App/common/deviceNodeFactory.h $(OUTDIR)/kernelModule.o: ../../lib/App/common/kernelModule.cpp ../../lib/App/common/kernelModule.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h +$(OUTDIR)/kernelModuleBosch.o: ../../lib/App/common/kernelModuleBosch.cpp ../../lib/App/common/kernelModuleBosch.h $(OUTDIR)/kernelModuleEmbedVideo.o: ../../lib/App/common/kernelModuleEmbedVideo.cpp ../../lib/App/common/kernelModuleEmbedVideo.h ../../lib/App/common/deviceNodeCamera.h ../../lib/App/common/deviceNodeFactory.h -$(OUTDIR)/kernelModuleFactory.o: ../../lib/App/common/kernelModuleFactory.cpp ../../lib/App/common/kernelModuleFactory.h ../../lib/App/common/kernelModuleEmbedVideo.h ../../lib/App/common/kernelModuleFlyHunter.h ../../lib/App/common/kernelModuleKafka.h ../../lib/App/common/kernelModuleModemManager.h ../../lib/App/common/kernelModuleOnvifObserver.h ../../lib/App/common/kernelModuleSSDP.h ../../lib/App/common/kernelModuleUSBRelay.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h +$(OUTDIR)/kernelModuleFactory.o: ../../lib/App/common/kernelModuleFactory.cpp ../../lib/App/common/kernelModuleFactory.h ../../lib/App/common/kernelModuleEmbedVideo.h ../../lib/App/common/kernelModuleFlyHunter.h ../../lib/App/common/kernelModuleKafka.h ../../lib/App/common/kernelModuleModemManager.h ../../lib/App/common/kernelModuleOnvifObserver.h ../../lib/App/common/kernelModuleSSDP.h ../../lib/App/common/kernelModuleUSBRelay.h ../../lib/App/common/kernelModuleBosch.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h $(OUTDIR)/kernelModuleFlyHunter.o: ../../lib/App/common/kernelModuleFlyHunter.cpp ../../lib/App/common/kernelModuleFlyHunter.h $(OUTDIR)/kernelModuleKafka.o: ../../lib/App/common/kernelModuleKafka.cpp ../../lib/App/common/kernelModuleKafka.h $(OUTDIR)/kernelModuleModemManager.o: ../../lib/App/common/kernelModuleModemManager.cpp ../../lib/App/common/kernelModuleModemManager.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h @@ -894,6 +1091,7 @@ $(OUTDIR)/ponvif.o: ../../lib/data/ponvif/ponvif.cpp ../../lib/data/ponvif/ponvi $(OUTDIR)/protocol.o: ../../lib/data/protocol/protocol.cpp ../../lib/data/protocol/protocol.h $(OUTDIR)/protocolARGUS.o: ../../lib/data/protocol/protocolARGUS.cpp ../../lib/data/protocol/protocolARGUS.h $(OUTDIR)/protocolARGUS_DATA.o: ../../lib/data/protocol/protocolARGUS_DATA.cpp ../../lib/data/protocol/protocolARGUS_DATA.h +$(OUTDIR)/protocolBVMS.o: ../../lib/data/protocol/protocolBVMS.cpp ../../lib/data/protocol/protocolBVMS.h ../../lib/alg/generic/md5.h $(OUTDIR)/protocolHTTP.o: ../../lib/data/protocol/protocolHTTP.cpp ../../lib/data/protocol/protocolHTTP.h $(OUTDIR)/protocolKAFKA.o: ../../lib/data/protocol/protocolKAFKA.cpp ../../lib/data/protocol/protocolKAFKA.h ../../lib/alg/generic/md5.h ../../lib/data/json/json_tool.h $(OUTDIR)/protocolLGS2D.o: ../../lib/data/protocol/protocolLGS2D.cpp ../../lib/data/protocol/protocolLGS2D.h diff --git a/Projects/la_serva/build b/Projects/la_serva/build index 8d62327c..7efee7e2 100755 --- a/Projects/la_serva/build +++ b/Projects/la_serva/build @@ -4,7 +4,7 @@ #make clean -e "CFG=Debug" #make -e "CFG=Debug" -j$(nproc) -make clean -e "CFG=Debug86" +#make clean -e "CFG=Debug86" make -e "CFG=Debug86" -j$(nproc) #make clean -e "CFG=Release86" diff --git a/lib/App/common/SQLite_dataBinder.cpp b/lib/App/common/SQLite_dataBinder.cpp index 6b1c2a15..99e2fe8f 100644 --- a/lib/App/common/SQLite_dataBinder.cpp +++ b/lib/App/common/SQLite_dataBinder.cpp @@ -5583,7 +5583,7 @@ bool sqliteDBC::updateIPCam(uint32_t CamID, CSTR Addr) tPos2 = strstr(tPos + 2, ":"); if (tPos2 != NULL) { - LOG("IP Port Defined!"); + //LOG("IP Port Defined!"); int len;//, len2, len3; len = tPos2 - tPos - 2; strncpy(tIpBuf, tPos + 2, len); @@ -5605,14 +5605,14 @@ bool sqliteDBC::updateIPCam(uint32_t CamID, CSTR Addr) else { tPos2 = strstr(tPos + 2, "/"); - LOG_ERROR("Pos 2 - err"); + //LOG_ERROR("Pos 2 - err"); tIpBuf[0] = (char) 0; }; }; } else { - LOG_ERROR("Pos 0 - err"); + //LOG_ERROR("Pos 0 - err"); tIpBuf[0] = (char) 0; }; if (tPort) diff --git a/lib/App/common/dataBinder.h b/lib/App/common/dataBinder.h index 23744a13..fee36337 100644 --- a/lib/App/common/dataBinder.h +++ b/lib/App/common/dataBinder.h @@ -397,6 +397,12 @@ class dataBinder return NULL; } + virtual REST_SETTINGS * getBoschData( uint32_t id ) + { + if ( !id ) return NULL; + return NULL; + } + virtual DBC_CAP_DATA * getCamCapPictureData(uint32_t PicID) { if ( !PicID ) return NULL; @@ -726,7 +732,11 @@ class dataBinder if ( NodeID || type || auxID ) return 0; return 0; } - + virtual REST_TEMPLATE * getRESTTemplateForEvent(uint32_t ModuleID, uint32_t ClassID, uint32_t EventID) + { + if ( ModuleID || ClassID || EventID ) return NULL; + return NULL; + } virtual uint32_t getServerID(CSTR identity) { if ( !identity ) return 0; diff --git a/lib/App/common/deviceNode2D.cpp b/lib/App/common/deviceNode2D.cpp index f1d7cde0..61288439 100644 --- a/lib/App/common/deviceNode2D.cpp +++ b/lib/App/common/deviceNode2D.cpp @@ -612,8 +612,10 @@ void device2DSensor::readMode() #ifdef SEND_MASKS_VIA_FILE generateMaskFiles("data/shadow_v.txt", "data/shadow_b.txt"); #endif +#ifndef LRF_PROXY_ONLY #ifdef DEBUG makeShadowPic("data/shadow_device.png"); +#endif #endif saveShadowToDB(); setWM(LRF_WM_IDLE); @@ -1416,6 +1418,8 @@ void device2DSensor::save_ini() { char tName[256]; sprintf(tName, "data/uploads/%s", m_pTGENFILENAMES[idx]); + LOG("Delete File"); + LOG( tName ); unlink(tName); }; }; @@ -1581,6 +1585,13 @@ void device2DSensor::save_detection() }; } +void device2DSensor::wait_channel(){ + if( m_nChannelTO ){ + m_nChannelTO--; + SLEEP(10); + } else setWM( LRF_WM_IDLE ); +} + void device2DSensor::wait_device() { #ifdef DEBUG_EXTRA @@ -1655,9 +1666,11 @@ void device2DSensor::save_masks() { if (rasterizeShadow()) { + #ifndef LRF_PROXY_ONLY #ifdef DEBUG makeShadowPic("data/shadow.png"); #endif + #endif if (generateMaskFiles("data/uploads/shadow_v.txt", "data/uploads/shadow_b.txt")) { if (generateRestartFile(0)) @@ -2234,6 +2247,8 @@ void device2DSensor::fileTransferMode() { char tName[256]; sprintf(tName, "data/uploads/%s", m_sGetFileTransfers.helpers[idx]->sourceName); + LOG("Delete File"); + LOG( tName ); unlink(tName); }; }; @@ -2491,6 +2506,10 @@ void device2DSensor::drawMode() { m_nCurrentAngle = 0; m_bOpRetryCnt = LGS_CMD_RETRY_COUNT << 1; + kernelPrototype * AK = kernelPrototype::getInstance(); + if( AK ){ + AK->requestExplicitChannel( m_sNodeData.node_id, m_sLRF_DATA.uart_id, 240 ); + } }; switch (getPPStatus()) { @@ -2507,6 +2526,10 @@ void device2DSensor::drawMode() m_bRequestedDeviceWM = MODE_BORDER; if (! setMode(MODE_BORDER)) { + kernelPrototype * AK = kernelPrototype::getInstance(); + if( AK ){ + AK->releaseExplicitChannel( m_sNodeData.node_id, m_sLRF_DATA.uart_id ); + } LOG_ERROR("Fall Back to Disconnected!"); setWM(LRF_WM_CONNECTION); } @@ -2534,6 +2557,10 @@ void device2DSensor::drawMode() #endif if (! getFastDraw(m_nCurrentAngle)) { + kernelPrototype * AK = kernelPrototype::getInstance(); + if( AK ){ + AK->releaseExplicitChannel( m_sNodeData.node_id, m_sLRF_DATA.uart_id ); + } LOG_ERROR("Fall Back to Disconnected!"); setWM(LRF_WM_CONNECTION); } @@ -2548,6 +2575,11 @@ void device2DSensor::drawMode() #ifdef DEBUG_EXTRA LOG("DRAW FINISHING"); #endif + kernelPrototype * AK = kernelPrototype::getInstance(); + if( AK ){ + AK->releaseExplicitChannel( m_sNodeData.node_id, m_sLRF_DATA.uart_id ); + } + m_bTimeOutCounter = LGS_DEFAULT_TO_COUNTER; m_bRequestedDeviceWM = MODE_DETECTOR; if (! setMode(MODE_DETECTOR)) @@ -2563,7 +2595,8 @@ void device2DSensor::drawMode() }; case LRF_WS_STAGE_4: { - updateDataStatus(ARGUS_DS_READY); + kernelPrototype * AK = kernelPrototype::getInstance(); + updateDataStatus(ARGUS_DS_READY); setWM(LRF_WM_IDLE); break; }; @@ -4434,8 +4467,8 @@ TARGET_DATA * device2DSensor::prepareTargetData(uint16_t AZ, uint16_t RANGE, uin else { // ToDo: Fix Convert! - tSystem->convertToGlobal(&m_oPosition, tVal->local_target, tVal->global_target); - // tSystem->convertToGlobal( &m_oPosition, tVal->system_target, tVal->global_target ); + //tSystem->convertToGlobal(&m_oPosition, tVal->local_target, tVal->global_target); + tSystem->convertToGlobal( &m_oPosition, tVal->system_target, tVal->global_target ); }; #ifdef DEBUG_EXTRA char tB[128]; @@ -4451,6 +4484,21 @@ TARGET_DATA * device2DSensor::prepareTargetData(uint16_t AZ, uint16_t RANGE, uin return tVal; } + +void device2DSensor::setChannelBusy( uint32_t channelID, uint8_t seconds_TO ){ + if ( m_sLRF_DATA.uart_id == channelID ) { + m_nChannelTO = seconds_TO * 100; + setWM( LRF_WM_WAIT_CHANNEL ); + }; +} + +void device2DSensor::setChannelReady( uint32_t channelID ){ + if ( m_sLRF_DATA.uart_id == channelID && getWM() == LRF_WM_WAIT_CHANNEL ) { + m_nChannelTO = 1; + setWM( LRF_WM_IDLE ); + }; +} + void device2DSensor::simulateTarget(void) { uint16_t AZ, RANGE; @@ -5006,6 +5054,7 @@ bool device2DSensor::saveShadowToDB(void) return true; } +#ifndef LRF_PROXY_ONLY #ifdef DEBUG void device2DSensor::makeShadowPic(CSTR picname) { @@ -5054,7 +5103,8 @@ void device2DSensor::makeShadowPic(CSTR picname) }; buf.clear(); } -#endif +#endif // DEBUG +#endif // !LRF_PROXY_ONLY #ifdef SEND_MASKS_VIA_FILE bool device2DSensor::generateMaskFiles(CSTR vname, CSTR bname) diff --git a/lib/App/common/deviceNode2D.h b/lib/App/common/deviceNode2D.h index 496daa72..7ce4a9a0 100644 --- a/lib/App/common/deviceNode2D.h +++ b/lib/App/common/deviceNode2D.h @@ -23,8 +23,10 @@ #define PERSISTED_TARGET_SIM #endif // To Save rasterized masks -#ifdef DEBUG - #include +#ifndef LRF_PROXY_ONLY + #ifdef DEBUG + #include + #endif #endif typedef enum E_WORKING_STATE_LRF2D @@ -189,9 +191,10 @@ FS_DATA_EX m_sOutFSData; // COMMAND_SEQUENCE_TYPE m_eCurrentSequence; // uint8_t m_bSequenceStep; // bool runSequence( COMMAND_SEQUENCE_TYPE SequenceID ); - -#ifdef DEBUG +#ifndef LRF_PROXY_ONLY + #ifdef DEBUG void makeShadowPic(CSTR picname); + #endif #endif #ifdef SEND_MASKS_VIA_FILE bool generateMaskFiles(CSTR vname, CSTR bname); @@ -219,6 +222,7 @@ FS_DATA_EX m_sOutFSData; virtual void save_masks(); virtual void save_eprom(); virtual void wait_device(); + virtual void wait_channel(); virtual bool validateCommunicationRessource(); virtual bool packetHandler(protocolPackage * Package); @@ -230,6 +234,9 @@ FS_DATA_EX m_sOutFSData; virtual bool stopService(); virtual bool validate(); virtual void simulateTarget(void); + //virtual uint32_t getChannelId( void ); + virtual void setChannelBusy( uint32_t channelID, uint8_t seconds_TO ); + virtual void setChannelReady( uint32_t channelID ); }; #endif diff --git a/lib/App/common/deviceNodeCamera.cpp b/lib/App/common/deviceNodeCamera.cpp index 194402f6..989c9cf5 100644 --- a/lib/App/common/deviceNodeCamera.cpp +++ b/lib/App/common/deviceNodeCamera.cpp @@ -200,7 +200,8 @@ void deviceNodeCamera::updateOpticalParameters(uint16_t frame_width, uint16_t fr #ifdef DEBUG LOG("\tManual Zoom"); #endif - m_fMinRange = 5.0f; // Minimal 5 meters + //The Fixing minimal distance from 5 meters to a 0.5 + m_fMinRange = 0.5f; // Minimal 0.5 meters if (m_sCamData.max_range < m_fMinRange) { m_fMaxRange = m_fMinRange; @@ -731,92 +732,55 @@ bool deviceNodeCamera::fusion_consumeData(uint32_t db_id, C3D_SPH_DEGREES tOR) tTrackRecord->target_direction.tetta = tOR.tetta; tTrackRecord->evt_db_ID = db_id; tTrackRecord->ts_ms = getMilliseconds(); + m_mROIsProtector.lock(); - if (m_vROIS.size()) - { - vCAM_ROIS::iterator idx = m_vROIS.begin(); - for (; idx < m_vROIS.end(); idx++) - { - if (fusion_compare(*idx, tOR)) - { - break; - } - } - if (idx != m_vROIS.end()) - { - // have Match! -#ifdef DEBUG_EXTRA - LOG("ROI MATCHED!"); -#endif - (*idx)->targets.push_back(tTrackRecord); - fusion_validateROI(tTrackRecord->ts_ms, *idx); - } - else - { + + vCAM_ROIS::iterator idx = m_vROIS.begin(); + for (; idx < m_vROIS.end(); idx++) + { + if (fusion_compare(*idx, tOR)) + { + break; + } + } + if (idx != m_vROIS.end()) + { + // have Match! #ifdef DEBUG_EXTRA - LOG("NO MATCH FOUND!"); + LOG("ROI MATCHED!"); #endif - // No mathced ROI -> create new one - //CAM_ROI * tROI = (CAM_ROI *) malloc(sizeof(CAM_ROI)); - CAM_ROI * tROI = new CAM_ROI(); - if (tROI) - { - //memset(tROI, 0, sizeof(CAM_ROI)); - tROI->ts_ms = tTrackRecord->ts_ms; - spherical2onvif(tOR, tROI->cam_orientation, m_fMaxRange, m_sCamData.pan_model, m_sCamData.pan_angles, m_sCamData.tilt_model, m_sCamData.tilt_angles); - - tROI->cam_position.fi = tOR.fi; - tROI->cam_position.tetta = tOR.tetta; - tROI->cam_position.r = tOR.r; - - float cFL = m_fMinFL + m_fR2FL * (tROI->cam_position.r - m_fMinRange); - - tROI->max_range = calcMaxDistance_mm(AC_imager_diag[m_sCamData.imager_type], cFL, m_nRealFrameWidth); - tROI->min_range = calcMinDistance_mm(AC_imager_diag[m_sCamData.imager_type], cFL, m_nRealFrameWidth); - tROI->h_fov = rad2deg(calcFOV_mm(AC_imager_width[m_sCamData.imager_type], cFL)) / 2.0f; // div to no to div in comparation function - tROI->v_fov = rad2deg(calcFOV_mm(AC_imager_height[m_sCamData.imager_type], cFL)) / 2.0f; // that will be called more ofthen - - tROI->targets.push_back(tTrackRecord); - m_vROIS.push_back(tROI); - }; - }; - } - else - { + (*idx)->targets.push_back(tTrackRecord); + fusion_validateROI(tTrackRecord->ts_ms, *idx); + } + else + { #ifdef DEBUG_EXTRA - LOG("Fusion: NO ROI -> CREATE!"); + LOG("NO MATCH FOUND!"); #endif - // - //CAM_ROI * tROI = (CAM_ROI *) malloc(sizeof(CAM_ROI)); + // No mathced ROI -> create new one + //CAM_ROI * tROI = (CAM_ROI *) malloc(sizeof(CAM_ROI)); CAM_ROI * tROI = new CAM_ROI(); - if (tROI) - { - //memset(tROI, 0, sizeof(CAM_ROI)); - tROI->ts_ms = tTrackRecord->ts_ms; - // Set vector Cam Coordinates - tROI->cam_position.fi = tOR.fi; - tROI->cam_position.tetta = tOR.tetta; - tROI->cam_position.r = tOR.r; - // Set vector OnVIF coordinates - spherical2onvif(tOR, tROI->cam_orientation, m_fMaxRange, m_sCamData.pan_model, m_sCamData.pan_angles, m_sCamData.tilt_model, m_sCamData.tilt_angles); - - // make fusion data BOX - float cFL = m_fMinFL + m_fR2FL * (tROI->cam_position.r); // - m_fMinRange ); - - tROI->min_range = calcMinDistance_mm(AC_imager_diag[m_sCamData.imager_type], cFL, m_nRealFrameWidth); - tROI->max_range = calcMaxDistance_mm(AC_imager_diag[m_sCamData.imager_type], cFL, m_nRealFrameWidth); - tROI->h_fov = rad2deg(calcFOV_mm(AC_imager_width[m_sCamData.imager_type], cFL)) / 2.0f; // div to prevent division in comparation - tROI->v_fov = rad2deg(calcFOV_mm(AC_imager_height[m_sCamData.imager_type], cFL)) / 2.0f; // function that will be called more ofthen - - // Add ROI to vector - tROI->targets.push_back(tTrackRecord); - m_vROIS.push_back(tROI); - } - else - { - LOG_ERROR("No MEM4ROI"); - } - }; + if (tROI) + { + tROI->ts_ms = tTrackRecord->ts_ms; + spherical2onvif(tOR, tROI->cam_orientation, m_fMaxRange, m_sCamData.pan_model, m_sCamData.pan_angles, m_sCamData.tilt_model, m_sCamData.tilt_angles); + + tROI->cam_position.fi = tOR.fi; + tROI->cam_position.tetta = tOR.tetta; + tROI->cam_position.r = tOR.r; + + float cFL = m_fMinFL + m_fR2FL * (tROI->cam_position.r - m_fMinRange); + + tROI->max_range = calcMaxDistance_mm(AC_imager_diag[m_sCamData.imager_type], cFL, m_nRealFrameWidth); + tROI->min_range = calcMinDistance_mm(AC_imager_diag[m_sCamData.imager_type], cFL, m_nRealFrameWidth); + tROI->h_fov = rad2deg(calcFOV_mm(AC_imager_width[m_sCamData.imager_type], cFL)) / 2.0f; // div to no to div in comparation function + tROI->v_fov = rad2deg(calcFOV_mm(AC_imager_height[m_sCamData.imager_type], cFL)) / 2.0f; // that will be called more ofthen + + tROI->targets.push_back(tTrackRecord); + m_vROIS.push_back(tROI); + }; + }; + m_mROIsProtector.unlock(); return true; } @@ -1086,6 +1050,7 @@ void deviceNodeCamera::m_fThreadProc(void) bool bNewSecondLoop = false; uint32_t cTimeSeconds = 0; uint32_t oTimeSeconds = 0; + pthread_setname_np( pthread_self(), "NodeCamera" ); while (m_bThreadStatus < TH_ENDED) { diff --git a/lib/App/common/deviceNodeFactory.cpp b/lib/App/common/deviceNodeFactory.cpp index c060c70e..1a8daa58 100644 --- a/lib/App/common/deviceNodeFactory.cpp +++ b/lib/App/common/deviceNodeFactory.cpp @@ -585,6 +585,7 @@ void deviceNodeFactory::m_fThreadProc(void) } else { + pthread_setname_np( pthread_self(), "NodeFactory" ); m_bThreadStatus = TH_WORKING; while (m_bThreadStatus < TH_ENDED) { diff --git a/lib/App/common/deviceNodeSensor.cpp b/lib/App/common/deviceNodeSensor.cpp index 399ba464..9e012bc3 100644 --- a/lib/App/common/deviceNodeSensor.cpp +++ b/lib/App/common/deviceNodeSensor.cpp @@ -3,8 +3,6 @@ #include "../../components/object/objectSystemAnchor.h" #include "kernelPrototype.h" -#include - #define LOG(X) deviceNode::m_pLog->Log("NODSEN", this, X) #define LOG_ERROR(X) deviceNode::m_pLog->Log("NODSEN", this, _LOG_ERROR, X) @@ -213,18 +211,24 @@ deviceNodeSensor::deviceNodeSensor(uint32_t id) : { if (SA->beLocal()) { - m_oPosition.setPositionXYZ(m_sLRF_DATA.x, m_sLRF_DATA.y, m_sLRF_DATA.z, 0); // SA->getUTMZone() ); + LOG_ERROR("Local Coords!"); + m_oPosition.setPositionXYZ(m_sLRF_DATA.x, m_sLRF_DATA.y, m_sLRF_DATA.z); m_oPosition.setOrientationDeg(m_sLRF_DATA.x_rot, m_sLRF_DATA.y_rot, m_sLRF_DATA.z_rot); } else { + LOG_ERROR("WGS Coords!"); C3D_DECART LD = SA->getXYZ(); - m_oPosition.setPositionXYZ(LD.x + m_sLRF_DATA.x, LD.y + m_sLRF_DATA.y, LD.z + m_sLRF_DATA.z, SA->getUTMZone()); + char tZ[256]; + sprintf( tZ, "SX:%f SY:%f SZ:%f LX:%f LY:%f LZ:%f SH:%d Zone:%d", LD.x, LD.y, LD.z, m_sLRF_DATA.x, m_sLRF_DATA.y, m_sLRF_DATA.z, SA->getSH(), SA->getUTMZone() ); + LOG(tZ); + m_oPosition.setPositionXYZ(LD.x + m_sLRF_DATA.x, LD.y + m_sLRF_DATA.y, LD.z + m_sLRF_DATA.z, SA->getSH(), SA->getUTMZone() ); m_oPosition.setOrientationDeg(m_sLRF_DATA.x_rot, m_sLRF_DATA.y_rot, m_sLRF_DATA.z_rot); }; } else { + LOG_ERROR("No System Anchor Object - Using Local Binding!"); m_oPosition.setPositionXYZ(m_sLRF_DATA.x, m_sLRF_DATA.y, m_sLRF_DATA.z); m_oPosition.setOrientationDeg(m_sLRF_DATA.x_rot, m_sLRF_DATA.y_rot, m_sLRF_DATA.z_rot); }; @@ -536,9 +540,13 @@ uint8_t * deviceNodeSensor::create2dDraw(uint32_t * out_size, uint32_t * th_data } #endif // GEN_DRAW_IMAGE +#ifndef LRF_PROXY_ONLY + #include +#endif bool deviceNodeSensor::handleDeviceDraw(uint8_t kID, void * th_data, size_t th_size, bool byMinimum) { - if (th_data == NULL) + if ( byMinimum ) byMinimum = true; + if (th_data == NULL) { return false; } @@ -661,6 +669,7 @@ bool deviceNodeSensor::handleDeviceDraw(uint8_t kID, void * th_data, size_t th_s }; case ARGUS_3D_SENSOR: { +#ifndef LRF_PROXY_ONLY char * emptyBG = "data/assets/images/empty_3d.png"; thresholdNode * ptr = (thresholdNode *) th_data; @@ -892,6 +901,7 @@ bool deviceNodeSensor::handleDeviceDraw(uint8_t kID, void * th_data, size_t th_s free(uid); return false; }; +#endif //!LRF_PROXY_ONLY break; }; default: break; @@ -1247,7 +1257,7 @@ void deviceNodeSensor::m_fThreadProc(void) time_t tTimeT_Old = time(NULL); m_bThreadStatus = TH_WORKING; setWM(LRF_WM_INIT); - LOG("Start Dev Thread"); + pthread_setname_np( pthread_self(), "NodeSensor" ); while (m_bThreadStatus < TH_ENDED) { tTimeT_Current = time(NULL); @@ -1299,7 +1309,8 @@ void deviceNodeSensor::m_fThreadProc(void) case LRF_WM_SAVE_DETECTION : save_detection(); break; case LRF_WM_SAVE_EPROM : save_eprom(); break; case LRF_WM_SAVE_MASKS : save_masks(); break; - case LRF_WM_WAIT_ONLINE_SPECIAL: wait_device(); break; + case LRF_WM_WAIT_ONLINE_SPECIAL: wait_device(); break; + case LRF_WM_WAIT_CHANNEL : wait_channel(); break; default : LOG("WM NOT REG"); setWM(LRF_WM_IDLE); }; }; diff --git a/lib/App/common/deviceNodeSensor.h b/lib/App/common/deviceNodeSensor.h index 0cc316cd..078d3154 100644 --- a/lib/App/common/deviceNodeSensor.h +++ b/lib/App/common/deviceNodeSensor.h @@ -110,6 +110,7 @@ typedef enum E_LRF_WORK_MODE LRF_WM_ALARM, LRF_WM_IDLE, LRF_WM_WAIT_ONLINE_SPECIAL, + LRF_WM_WAIT_CHANNEL, LRF_WM_COUNT } LRF_WORK_MODE; @@ -164,7 +165,6 @@ class deviceNodeSensor : public deviceNode, public basicThread basicMutex m_mPPModeProtector; uint32_t m_nCommErrorsCounter; uint32_t m_nCommErrorsStatTO; - protected: DBC_LRF_DATA m_sLRF_DATA; @@ -178,7 +178,7 @@ class deviceNodeSensor : public deviceNode, public basicThread uint16_t m_bTimeOutCounter; E_MODES m_bActualDeviceWM; E_MODES m_bRequestedDeviceWM; - + uint32_t m_nChannelTO; uint8_t m_bValidationSkipCounter; char m_pTGENFILENAMES[3][33]; @@ -245,6 +245,8 @@ class deviceNodeSensor : public deviceNode, public basicThread virtual void wait_device() {} + virtual void wait_channel() {} + virtual void proceedDBCommands() {} virtual void cleanupDeviceStructures() {} diff --git a/lib/App/common/hardwareResourceNetworkProvider.cpp b/lib/App/common/hardwareResourceNetworkProvider.cpp index c038757b..46f223b2 100644 --- a/lib/App/common/hardwareResourceNetworkProvider.cpp +++ b/lib/App/common/hardwareResourceNetworkProvider.cpp @@ -110,24 +110,20 @@ CSTR hardwareResourceNetwork::getAddress(NETWORK_TYPE nt) CSTR hardwareResourceNetwork::getBroadcast(NETWORK_TYPE nt) { - if (m_sNetworkData.networkCount) + if ( m_sNetworkData.networkCount ) { - LOG("HAHA"); for (int i = 0; i < m_sNetworkData.networkCount; i++) { - LOG("N!"); if (m_sNetworkData.networks[i] != NULL) { - LOG("NN!"); if (m_sNetworkData.networks[i]->type == nt) { - LOG("Matched!"); if (m_sNetworkData.networks[i]->broadcast[0] != (char) 0) { - LOG(m_sNetworkData.networks[i]->broadcast); - return strdup(m_sNetworkData.networks[i]->broadcast); + LOG( m_sNetworkData.networks[i]->broadcast ); + return strdup( m_sNetworkData.networks[i]->broadcast ); }; - break; + //break; //? Why not search till the end of nifs ? }; } }; diff --git a/lib/App/common/hardwareResourceSerialProvider.cpp b/lib/App/common/hardwareResourceSerialProvider.cpp index 238c4a9e..63db4061 100644 --- a/lib/App/common/hardwareResourceSerialProvider.cpp +++ b/lib/App/common/hardwareResourceSerialProvider.cpp @@ -906,7 +906,7 @@ void hardwareResourceSerialProvider::m_fThreadAProc(void) #endif m_bThreadAStatus = TH_WORKING; #ifdef DEBUG - LOG("Sender Thread Started!"); + pthread_setname_np( pthread_self(), "UART Sender" ); #endif while (m_bThreadAStatus < TH_ENDED) { @@ -1008,7 +1008,7 @@ void hardwareResourceSerialProvider::m_fThreadBProc(void) #endif m_bThreadBStatus = TH_WORKING; #ifdef DEBUG - LOG("Recipient Thread Started!"); + pthread_setname_np(pthread_self(), "UART Receiver"); #endif while (m_bThreadBStatus < TH_ENDED) { @@ -1152,7 +1152,7 @@ void hardwareResourceSerialProvider::m_fThreadProc(void) int RetVal; m_bThreadStatus = TH_WORKING; #ifdef DEBUG_EXTRA - LOG("Sender Thread Started!"); + pthread_setname_np(pthread_self(), "UART HalfDuplex"); #endif while (m_bThreadStatus < TH_ENDED) { diff --git a/lib/App/common/kernelEventFilterAPF.cpp b/lib/App/common/kernelEventFilterAPF.cpp index a53393ce..068467aa 100644 --- a/lib/App/common/kernelEventFilterAPF.cpp +++ b/lib/App/common/kernelEventFilterAPF.cpp @@ -177,6 +177,7 @@ void kernelEventFilterAPF::m_fThreadProc(void) memset(&CA, 0, caLen); m_bActive = true; m_bThreadStatus = TH_WORKING; + pthread_setname_np(pthread_self(), "filterAPF"); while (m_bThreadStatus < TH_ENDED) { memset(inBuff, 0, 1024); diff --git a/lib/App/common/kernelEventFilterBubble.cpp b/lib/App/common/kernelEventFilterBubble.cpp index 8d408aa5..2886c35d 100644 --- a/lib/App/common/kernelEventFilterBubble.cpp +++ b/lib/App/common/kernelEventFilterBubble.cpp @@ -199,6 +199,7 @@ bool kernelEventFilterBubble::initFilter() void kernelEventFilterBubble::m_fThreadProc(void) { m_bThreadStatus = TH_WORKING; + pthread_setname_np(pthread_self(), "filterBubble"); while (m_bThreadStatus < TH_ENDED) { m_mDataProtector.lock(); diff --git a/lib/App/common/kernelEventFilterTrain.cpp b/lib/App/common/kernelEventFilterTrain.cpp index 32a7c9be..f46aa1a4 100644 --- a/lib/App/common/kernelEventFilterTrain.cpp +++ b/lib/App/common/kernelEventFilterTrain.cpp @@ -545,6 +545,7 @@ void TrainFilterOSP_Helper::m_fThreadProc(void) char buffer[255]; memset(&cliaddr, 0, sizeof(cliaddr)); m_bThreadStatus = TH_WORKING; + pthread_setname_np(pthread_self(), "filterTrain"); while (m_bThreadStatus < TH_ENDED) { len = sizeof(cliaddr); diff --git a/lib/App/common/kernelModule.h b/lib/App/common/kernelModule.h index 28e21113..2a394c12 100644 --- a/lib/App/common/kernelModule.h +++ b/lib/App/common/kernelModule.h @@ -23,7 +23,8 @@ typedef enum E_KERNEL_MODULE_TYPE KERNEL_MODULE_EMBED_VIDEO = 8, KERNEL_MODULE_MODEM_MANAGER = 9, KERNEL_MODULE_REMOTE_SERVER = 10, - KERNEL_MODULE_REPORT_BACKUPPER = 11 + KERNEL_MODULE_REPORT_BACKUPPER = 11, + KERNEL_MODULE_BOSCH_REST = 12 } KERNEL_MODULE_TYPE; class kernelModule : public basicEventHandler, public basicEngine diff --git a/lib/App/common/kernelModuleBosch.cpp b/lib/App/common/kernelModuleBosch.cpp new file mode 100644 index 00000000..68ea7ab4 --- /dev/null +++ b/lib/App/common/kernelModuleBosch.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 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 diff --git a/lib/App/common/kernelModuleBosch.h b/lib/App/common/kernelModuleBosch.h new file mode 100644 index 00000000..1f21dfa7 --- /dev/null +++ b/lib/App/common/kernelModuleBosch.h @@ -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 diff --git a/lib/App/common/kernelModuleEmbedVideo.cpp b/lib/App/common/kernelModuleEmbedVideo.cpp index b105c337..ba19f10f 100644 --- a/lib/App/common/kernelModuleEmbedVideo.cpp +++ b/lib/App/common/kernelModuleEmbedVideo.cpp @@ -1,4 +1,18 @@ #include "kernelModuleEmbedVideo.h" + +#define LOG(X) kernelModule::m_pLog->Log("MOD_EVIDEO", this, X) +#ifdef DEBUG + #define LOG_ERROR(X) \ + { \ + char _tBfrErrMSG2w34[2048]; \ + sprintf(_tBfrErrMSG2w34, "In file %s[%d] in func:%s %s", __FILE__, __LINE__, __func__, X); \ + kernelModule::m_pLog->Log("MOD_EVIDEO", this, _LOG_ERROR, _tBfrErrMSG2w34); \ + } +#else + #define LOG_ERROR(X) kernelModule::m_pLog->Log("MOD_EVIDEO", this, _LOG_ERROR, X); +#endif + +#ifndef LRF_PROXY_ONLY // #include "rgooseHardwareResourceNetworkProvider.h" // #include "mojoKernel.h" #include "../alg/generic/base64.h" @@ -41,18 +55,6 @@ const char * m_pVideoScratchPath = VIDEO_SCRATCHPAD_PATH; #define STORAGE_FILE_MODE 0x1B6 #endif -#define LOG(X) kernelModule::m_pLog->Log("MOD_EVIDEO", this, X) -#ifdef DEBUG - #define LOG_ERROR(X) \ - { \ - char _tBfrErrMSG2w34[2048]; \ - sprintf(_tBfrErrMSG2w34, "In file %s[%d] in func:%s %s", __FILE__, __LINE__, __func__, X); \ - kernelModule::m_pLog->Log("MOD_EVIDEO", this, _LOG_ERROR, _tBfrErrMSG2w34); \ - } -#else - #define LOG_ERROR(X) kernelModule::m_pLog->Log("MOD_EVIDEO", this, _LOG_ERROR, X); -#endif - #define TLOG(X) basicLogCollection::getInstance()->Log("MOD_EVIDEO_T", CTX, X) #ifdef DEBUG #define TLOG_ERROR(X) \ @@ -324,6 +326,7 @@ void * kernelModuleEmbedVideo::webClientProc(void * ptr) #ifdef DEBUG_EXTRA TLOG("Start WebClient"); #endif + pthread_setname_np(pthread_self(), "LiveVideoCL"); if (CTX) { char mesg[1024]; @@ -677,6 +680,7 @@ void * kernelModuleEmbedVideo::viewClientProc(void * ptr) uint8_t yaba[2] = {0xff, 0xd9}; FILE * tFID = NULL; TLOG("Start ViewClient"); + pthread_setname_np(pthread_self(), "ReportVideoCL"); if (CTX) { char mesg[1024]; @@ -988,6 +992,7 @@ void kernelModuleEmbedVideo::m_fThreadAProc(void) #ifdef DEBUG_EXTRA LOG("[LIVE] Module Started!"); #endif + pthread_setname_np(pthread_self(), "Live Video Stream"); struct pollfd pfd[1]; pfd->fd = m_nSocketDescriptor; pfd->events = POLLIN | POLLHUP; @@ -1140,6 +1145,7 @@ void kernelModuleEmbedVideo::m_fThreadBProc(void) pfd->fd = m_nViewSocketDescriptor; pfd->events = POLLIN | POLLHUP; m_bThreadBStatus = TH_WORKING; + pthread_setname_np(pthread_self(), "Report Video View"); while (m_bThreadBStatus < TH_ENDED) { if (! m_bEnabled) @@ -4455,6 +4461,7 @@ void streamHandler::m_fThreadProc(void) av_init_packet(&mPacket); #endif #endif + pthread_setname_np(pthread_self(), "VideoStream"); while (m_bThreadStatus != TH_ENDED) { // At the begining All streams are closed --> try to Open @@ -5135,7 +5142,24 @@ bool streamHandler::validate(void) // #undef DEBUG_EXTRA // #undef DEBUG -#undef LOG -#undef LOG_ERROR #undef TLOG #undef TLOG_ERROR + +#else //LRF_PROXY_ONLY + +kernelModuleEmbedVideo::kernelModuleEmbedVideo(uint32_t moduleID) : + kernelModule(moduleID, KERNEL_MODULE_EMBED_VIDEO) +{ + +} + +kernelModuleEmbedVideo::~kernelModuleEmbedVideo() +{ + +} + +#endif //LRF_PROXY_ONLY + +#undef LOG +#undef LOG_ERROR + diff --git a/lib/App/common/kernelModuleEmbedVideo.h b/lib/App/common/kernelModuleEmbedVideo.h index fd995f78..7abeff4d 100644 --- a/lib/App/common/kernelModuleEmbedVideo.h +++ b/lib/App/common/kernelModuleEmbedVideo.h @@ -4,9 +4,16 @@ #include "../../components/base/basicEventHeap.h" #include "../../components/base/basicMutex.h" #include "kernelModule.h" -// #include "../../data/media/video/videoAVLIBDestination.h" -#include "../../components/base/basicMediaDestination.h" -#include "../../components/base/basicMediaSource.h" + +#define EVE_OUTPUT_PICTURES 1 +#define EVE_OUTPUT_VIDEO 2 +#define EVE_OUTPUT_PIC_AND_VID 3 + +#ifndef LRF_PROXY_ONLY + // #include "../../data/media/video/videoAVLIBDestination.h" + #include "../../components/base/basicMediaDestination.h" + #include "../../components/base/basicMediaSource.h" + #define HAVE_SMAL_PREVIEW_STREAMS @@ -209,9 +216,7 @@ typedef map mapSTREAMMAPS; #define ENCODING_SEGMENT_LIMIT_MILSECONDS 60000 // 1 minute // #define ENCODING_SEGMENT_LIMIT_MILSECONDS 900000 // 15 minutes -#define EVE_OUTPUT_PICTURES 1 -#define EVE_OUTPUT_VIDEO 2 -#define EVE_OUTPUT_PIC_AND_VID 3 + // #define ENCODER_DISABLED 0 // #define ENCODER_ENABLED 1 @@ -466,7 +471,7 @@ class kernelModuleEmbedVideo : public kernelModule, public basicDualThread public: explicit kernelModuleEmbedVideo(uint32_t moduleID); - ~kernelModuleEmbedVideo(); + virtual ~kernelModuleEmbedVideo(); /* From Kernel Module */ virtual bool reloadSettings(); virtual bool startService(); @@ -487,4 +492,13 @@ class kernelModuleEmbedVideo : public kernelModule, public basicDualThread uint8_t getMediaMode(void); friend class streamHandler; }; +#else //LRF_PROXY_ONLY +class kernelModuleEmbedVideo : public kernelModule{ + public: + explicit kernelModuleEmbedVideo(uint32_t moduleID); + virtual ~kernelModuleEmbedVideo(); +}; +#endif //LRF_PROXY_ONLY + + #endif diff --git a/lib/App/common/kernelModuleFactory.cpp b/lib/App/common/kernelModuleFactory.cpp index 193b0d55..9124d2eb 100644 --- a/lib/App/common/kernelModuleFactory.cpp +++ b/lib/App/common/kernelModuleFactory.cpp @@ -7,6 +7,7 @@ #include "kernelModuleOnvifObserver.h" #include "kernelModuleSSDP.h" #include "kernelModuleUSBRelay.h" +#include "kernelModuleBosch.h" #ifdef MEM_DEBUG #include "../alg/generic/heapDebug.h" @@ -80,7 +81,8 @@ void kernelModuleFactory::shutdownServices(bool force) case KERNEL_MODULE_SSDP_ANONCE : sprintf(tB, "Stop Service of SSDP Module"); break; case KERNEL_MODULE_ONVIF_OBSERVER: sprintf(tB, "Stop Service of OnVif Observer Module"); break; case KERNEL_MODULE_EMBED_VIDEO : sprintf(tB, "Stop Service of EmbedVideo Module"); break; - case KERNEL_MODULE_MODEM_MANAGER : sprintf(tB, "Stop Service of Modem Manager Module"); break; + case KERNEL_MODULE_MODEM_MANAGER : sprintf(tB, "Stop Service of Modem Manager Module"); break; + case KERNEL_MODULE_BOSCH_REST : sprintf(tB, "Stop Service of Bosch REST Module"); break; default : sprintf(tB, "Stop Service of UNKNOWN[%d] Module", (*index)->getType()); break; }; LOG(tB); @@ -219,6 +221,12 @@ kernelModule * kernelModuleFactory::createModule(int id) #endif tVal = new kernelModuleModemManager(tData->module_id); break; + case KERNEL_MODULE_BOSCH_REST: +#ifdef DEBUG + LOG("Creating Bosch REST Module"); +#endif + tVal = new kernelModuleBosch(tData->module_id); + break; }; free(tData); } @@ -259,7 +267,8 @@ kernelModule * kernelModuleFactory::createModule(int id) delete((kernelModuleEmbedVideo *) tVal); }; break; - case KERNEL_MODULE_MODEM_MANAGER: delete((kernelModuleModemManager *) tVal); break; + case KERNEL_MODULE_MODEM_MANAGER: delete((kernelModuleModemManager *) tVal); break; + case KERNEL_MODULE_BOSCH_REST: delete((kernelModuleBosch *) tVal); break; }; delete(tVal); tVal = NULL; @@ -283,6 +292,7 @@ void kernelModuleFactory::deleteModule(kernelModule * M) case KERNEL_MODULE_ONVIF_OBSERVER: delete((kernelModuleOnvifObserver *) M); break; case KERNEL_MODULE_EMBED_VIDEO : delete((kernelModuleEmbedVideo *) M); break; case KERNEL_MODULE_MODEM_MANAGER : delete((kernelModuleModemManager *) M); break; + case KERNEL_MODULE_BOSCH_REST : delete((kernelModuleBosch *) M); break; default: LOG("Can not Delete Unknown Type Module!"); }; }; @@ -415,6 +425,7 @@ void kernelModuleFactory::m_fThreadProc(void) size_t memStart, memEnd, memDiff; char MEM_MSG[256]; #endif + pthread_setname_np( pthread_self(), "ModuleFactory" ); m_bThreadStatus = TH_WORKING; while (m_bThreadStatus < TH_ENDED) { diff --git a/lib/App/common/kernelModuleFlyHunter.cpp b/lib/App/common/kernelModuleFlyHunter.cpp index f565719f..01f63e32 100644 --- a/lib/App/common/kernelModuleFlyHunter.cpp +++ b/lib/App/common/kernelModuleFlyHunter.cpp @@ -97,6 +97,7 @@ void kernelModuleFlyHunter::m_fThreadProc() #ifdef DEBUG LOG("Module Started!"); #endif + pthread_setname_np(pthread_self(), "moduleFlyHunter"); while (m_bThreadStatus < TH_ENDED) { switch (m_bWorkingMode) diff --git a/lib/App/common/kernelModuleKafka.cpp b/lib/App/common/kernelModuleKafka.cpp index fb650138..71993cc0 100644 --- a/lib/App/common/kernelModuleKafka.cpp +++ b/lib/App/common/kernelModuleKafka.cpp @@ -146,6 +146,7 @@ void kernelModuleKafka::m_fThreadProc(void) LOG("Pereodical Jobs Started"); #endif m_bThreadStatus = TH_WORKING; + pthread_setname_np(pthread_self(), "moduleKafka"); if (! m_bEnabled) { m_bThreadStatus = TH_ENDED; diff --git a/lib/App/common/kernelModuleKafka.h b/lib/App/common/kernelModuleKafka.h index 59810d15..af8ffd8f 100644 --- a/lib/App/common/kernelModuleKafka.h +++ b/lib/App/common/kernelModuleKafka.h @@ -9,28 +9,7 @@ // #define SIMULATOR // #define KAFKA_DUMMY_SEND -#define KAFKA_TPL_SUBST_ID "%%ID%%" -#define KAFKA_TPL_SUBST_UUID "%%UUID%%" -#define KAFKA_TPL_SUBST_TS "%%TIMESTAMP%%" -#define KAFKA_TPL_SUBST_AZ "%%AZIMUTH%%" -#define KAFKA_TPL_SUBST_RANGE "%%RANGE%%" -#define KAFKA_TPL_SUBST_EL "%%ELEVATION%%" -#define KAFKA_TPL_SUBST_WIDTH "%%WIDTH%%" -#define KAFKA_TPL_SUBST_LON "%%LON%%" -#define KAFKA_TPL_SUBST_LAT "%%LAT%%" -#define KAFKA_TPL_SUBST_ALT "%%ALT%%" -#define KAFKA_TPL_SUBST_EXEVTD "%%EXEVTID%%" -#define KAFKA_TPL_SUBST_SRC_LON "%%SRC_LON%%" -#define KAFKA_TPL_SUBST_SRC_LAT "%%SRC_LAT%%" -#define KAFKA_TPL_SUBST_SRC_ALT "%%SRC_ALT%%" -#define KAFKA_TPL_SUBST_SRC_ROT_X "%%SRC_ROT_X%%" -#define KAFKA_TPL_SUBST_SRC_ROT_Y "%%SRC_ROT_Y%%" -#define KAFKA_TPL_SUBST_SRC_ROT_Z "%%SRC_ROT_Z%%" -#define KAFKA_TPL_SUBST_SRC_IP "%%SRC_IP%%" -#define KAFKA_TPL_SUBST_SRV_IP "%%SRV_IP%%" -#define KAFKA_TPL_SUBST_SRV_NAME "%%SRV_NAME%%" -#define KAFKA_TPL_SUBST_SRC_NAME "%%SRC_NAME%%" -#define KAFKA_TPL_SUBST_MSG_UUID "%%MUID%%" + #define FH_DEFAULT_JAMING_TIME 10 diff --git a/lib/App/common/kernelModuleModemManager.cpp b/lib/App/common/kernelModuleModemManager.cpp index 402d0703..961091d1 100644 --- a/lib/App/common/kernelModuleModemManager.cpp +++ b/lib/App/common/kernelModuleModemManager.cpp @@ -153,6 +153,7 @@ void kernelModuleModemManager::m_fThreadProc(void) uint32_t nCurrentPhoneBookId = 0; int32_t nCurrentCallId = 0; uint64_t lNextWindowAction = 0; + pthread_setname_np( pthread_self(), "ModemManager" ); m_bThreadStatus = TH_WORKING; while (m_bThreadStatus < TH_ENDED) { @@ -549,8 +550,9 @@ bool kernelModuleModemManager::dispatchEvent(EVENT_CONTAINER * Evt) case EVT_TARGET_2D_WHITE: case EVT_TARGET_2D_BLACK: { - sessionStarted = true; - setWM(MDM_INIT_CALL_WM); + //Only Work On Session Start -> No need to follow each detection + //sessionStarted = true; + //setWM(MDM_INIT_CALL_WM); break; }; case EVT_LRF_END_SESSION_TO: diff --git a/lib/App/common/kernelModuleOnvifObserver.cpp b/lib/App/common/kernelModuleOnvifObserver.cpp index ba7b2d2c..cef2bcf5 100644 --- a/lib/App/common/kernelModuleOnvifObserver.cpp +++ b/lib/App/common/kernelModuleOnvifObserver.cpp @@ -224,10 +224,11 @@ void kernelModuleOnvifObserver::m_fThreadProc() //int iOptLen; uint16_t bCounterTO = 600; // 3 second char rBuffer[MAX_BUFF_SIZE]; -#ifdef DEBUG +#ifdef DEBUG_EXTRA char tB[128]; LOG("Module Started!"); #endif + pthread_setname_np( pthread_self(), "OnvifObserver" ); m_bDetached = false; m_bThreadStatus = TH_WORKING; while (m_bThreadStatus < TH_ENDED) @@ -249,7 +250,7 @@ void kernelModuleOnvifObserver::m_fThreadProc() { sprintf(tB, "(%d){%d}MSG[%d] from %s", bCounterTO, socketFD, RetVal, inet_ntoa(((struct sockaddr_in *) &src_addr)->sin_addr)); LOG(tB); - LOG(rBuffer); + //LOG(rBuffer); }; #else // http://192.168.200.127/axis-cgi/com/ptz.cgi?info=1&camera=1 RetVal = recvfrom(socketFD, rBuffer, MAX_BUFF_SIZE, 0, NULL, NULL); @@ -313,7 +314,7 @@ void kernelModuleOnvifObserver::m_fThreadProc() m_mNIFMUTEX.lock(); if (m_vNIFIPS.size()) { -#ifdef DEBUG +#ifdef DEBUG_EXTRA sprintf(tB, "Starting probe on %s address", m_vNIFIPS.at(m_bCurrentNIF)); LOG(tB); #endif @@ -324,27 +325,18 @@ void kernelModuleOnvifObserver::m_fThreadProc() r_address.sin_family = AF_INET; r_address.sin_port = htons(HTTPMU_HOST_PORT); r_address.sin_addr.s_addr = inet_addr(m_vNIFIPS.at(m_bCurrentNIF)); - bOptVal = true; -#ifdef DEBUG - LOG("Set Broadcast Flag"); -#endif - bOptLen = sizeof(bool); - RetVal = setsockopt(socketFD, SOL_SOCKET, SO_BROADCAST, (char *) &bOptVal, bOptLen); - struct group_req req; - req.gr_interface = 0; - memcpy(&req.gr_group, &r_address, sizeof(r_address)); -#ifdef DEBUG - LOG("Join Broadcast Group"); + + int reuse = 1; +#ifdef DEBUG_EXTRA + LOG("Set Reuse Socket Flag"); #endif - RetVal = setsockopt(socketFD, IPPROTO_IP, MCAST_JOIN_GROUP, (char *) &req, sizeof(req)); - // The broadcast address to be used may be determined by issuing an ioctl() with the SIOCGIFBRDADDR request. - - if (RetVal > -1) + RetVal = setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse)); + if( RetVal < 0 ) { - LOG_ERROR("Setting Socked as Broadcasted Error!"); + LOG_ERROR("Setting Reuse Flag Error!"); }; - // + struct sockaddr_in tServerAddr; memset(&tServerAddr, 0, sizeof(tServerAddr)); tServerAddr.sin_family = AF_INET; // IPv4 @@ -353,43 +345,77 @@ void kernelModuleOnvifObserver::m_fThreadProc() // Bind the socket with the server address RetVal = bind(socketFD, (const struct sockaddr *) &tServerAddr, sizeof(tServerAddr)); - if (RetVal > -1) - { - LOG_ERROR("Bind Socked Error!"); - }; -#ifdef DEBUG - LOG("Sending Probe Request"); -#endif - RetVal = sendto(socketFD, send_buff, strlen(send_buff), 0, (struct sockaddr *) &r_address, sizeof(struct sockaddr_in)); - if (RetVal > -1) - { -#ifdef DEBUG - sprintf(tB, "Sent %d Bytes of %lu", RetVal, strlen(send_buff)); - LOG(tB); -#endif - -#ifdef __linux__ - fcntl(socketFD, F_SETFL, fcntl(socketFD, F_GETFL, 0) | O_NONBLOCK); -#else - u_long val = 1; - ioctlsocket(socketFD, FIONBIO, &val); // none block -#endif - bCounterTO = 600; - m_bProbeIsActive = true; - } - else + if( RetVal < 0 ) { -#ifdef DEBUG_EXTRA - // Failure to send probe package - LOG_ERROR("Error in sending Probe Request"); -#endif + LOG_ERROR("Bind Socket Error!"); #ifdef __linux__ - close(socketFD); + close(socketFD); #else - closesocket(socketFD); + closesocket(socketFD); #endif - }; + } else { + + #ifdef DEBUG_EXTRA + LOG("Set Broadcast Flag"); + #endif + bOptVal = true; + bOptLen = sizeof(bool); + RetVal = setsockopt(socketFD, SOL_SOCKET, SO_BROADCAST, (char *) &bOptVal, bOptLen); + if( RetVal < 0 ) + { + LOG_ERROR("Setting Socket as Broadcasted Error!"); + }; + + #ifdef DEBUG_EXTRA + LOG("Join Boadcast Group"); + #endif + + struct group_req req; + req.gr_interface = 0; + memcpy(&req.gr_group, &r_address, sizeof(r_address)); + RetVal = setsockopt(socketFD, IPPROTO_IP, MCAST_JOIN_GROUP, (char *) &req, sizeof(req)); + // The broadcast address to be used may be determined by issuing an ioctl() with the SIOCGIFBRDADDR request. + + if( RetVal < 0 ) + { + LOG_ERROR("Join Socket to a Broadcast Group Error!"); + }; + + #ifdef DEBUG_EXTRA + LOG("Sending Probe Request"); + #endif + RetVal = sendto(socketFD, send_buff, strlen(send_buff), 0, (struct sockaddr *) &r_address, sizeof(struct sockaddr_in)); + if (RetVal > -1) + { + #ifdef DEBUG_EXTRA + sprintf(tB, "Sent %d Bytes of %lu", RetVal, strlen(send_buff)); + LOG(tB); + #endif + + #ifdef __linux__ + fcntl(socketFD, F_SETFL, fcntl(socketFD, F_GETFL, 0) | O_NONBLOCK); + #else + u_long val = 1; + ioctlsocket(socketFD, FIONBIO, &val); // none block + #endif + bCounterTO = 600; + m_bProbeIsActive = true; + } + else + { + #ifdef DEBUG_EXTRA + // Failure to send probe package + LOG_ERROR("Error in sending Probe Request"); + #endif + #ifdef __linux__ + close(socketFD); + #else + closesocket(socketFD); + #endif + }; + } }; + // Proceed to next NIF m_bCurrentNIF++; if (m_bCurrentNIF == m_vNIFIPS.size()) { diff --git a/lib/App/common/kernelModuleRemoteServer.h b/lib/App/common/kernelModuleRemoteServer.h index 8c87fd08..2b0c72d0 100644 --- a/lib/App/common/kernelModuleRemoteServer.h +++ b/lib/App/common/kernelModuleRemoteServer.h @@ -1,5 +1,5 @@ -#ifndef __KERNEL_KAFKA_MODULE_HEADERS__ -#define __KERNEL_KAFKA_MODULE_HEADERS__ +#ifndef __KERNEL_RSERVER_MODULE_HEADERS__ +#define __KERNEL_RSERVER_MODULE_HEADERS__ #include "../components/base/basicEventHeap.h" #include "../components/base/basicThread.h" @@ -30,8 +30,8 @@ class kernelModuleRemoteServer : public kernelModule, public basicThread public: - explicit kernelModuleKafka(uint32_t ModuleID); - virtual ~kernelModuleKafka(); + explicit kernelModuleRemoteServer(uint32_t ModuleID); + virtual ~kernelModuleRemoteServer(); virtual bool reloadSettings(); virtual bool startService(); diff --git a/lib/App/common/kernelPrototype.h b/lib/App/common/kernelPrototype.h index 094065b7..66c11aed 100644 --- a/lib/App/common/kernelPrototype.h +++ b/lib/App/common/kernelPrototype.h @@ -113,6 +113,8 @@ class kernelPrototype : public basicThread, public basicEventHandler return m_pDBC; } #endif + virtual void requestExplicitChannel( uint32_t node_id, uint32_t channel_id, uint8_t seconds_to ){}; + virtual void releaseExplicitChannel( uint32_t node_id, uint32_t channel_id ){}; }; #endif diff --git a/lib/App/common/serverDataBinder.h b/lib/App/common/serverDataBinder.h index 0ba6b709..53e0fed9 100644 --- a/lib/App/common/serverDataBinder.h +++ b/lib/App/common/serverDataBinder.h @@ -87,6 +87,7 @@ typedef struct S_DBC_SERVA_CONFIG uint8_t historyAutoDeleteLimit; uint8_t historyPreserveFreeSpacePerc; uint32_t historyPreserveFreeSpaceMB; + uint32_t composerProceedDelay; } DBC_SERVA_CONFIG; typedef struct S_MODBUS_RTU_INFO @@ -176,13 +177,15 @@ typedef struct S_DBC_IS_TRACK_DATA uint64_t platform_id; char side; char name[65]; - char short[33]; + char abbr[33]; } DBC_IS_TRACK_DATA; // Infrostructure Track Data typedef struct S_DBC_MEDIA_COMPOSER_DATA{ - uint16_t out_width; - uint16_t out_height; - uint8_t out_fps; + uint16_t out_width; + uint16_t out_height; + uint8_t out_fps; + bool prependEmptyFrames; + bool debugMode; }DBC_MEDIA_COMPOSER_DATA; class serverDataBinder @@ -237,7 +240,10 @@ class serverDataBinder { return false; } - + virtual DBC_SERVA_MEDIA_ENCODER_SETTINGS *getMediaEncoderSettings(void) + { + return NULL; + } virtual CSTR getMediaUUID(uint64_t id) { return NULL; @@ -303,6 +309,12 @@ class serverDataBinder return 0; } + virtual uint64_t getSessionWithUnmergedVideo( uint32_t delay_secs ) + { + if ( delay_secs ) delay_secs++; + return 0; + } + virtual DBC_SERVA_CONFIG * getServaConfig() { return NULL; @@ -328,6 +340,10 @@ class serverDataBinder return NULL; } + virtual DBC_MEDIA_COMPOSER_DATA * getVideoComposerData(){ + return NULL; + } + virtual uint64_t getUpperLRF(uint64_t id) { return 0; @@ -488,6 +504,11 @@ class serverDataBinder return false; } + virtual bool updateSessionFinal( uint64_t id, char BB ) + { + return false; + } + virtual bool updateSessionStatus(uint64_t id, uint8_t status) { return false; diff --git a/lib/App/common/serverMySQL_dataBinder.cpp b/lib/App/common/serverMySQL_dataBinder.cpp index b48be997..5eba09ea 100644 --- a/lib/App/common/serverMySQL_dataBinder.cpp +++ b/lib/App/common/serverMySQL_dataBinder.cpp @@ -165,6 +165,69 @@ bool servaMySQLDBC::deleteSession(uint64_t id) return true; } +DBC_SERVA_MEDIA_ENCODER_SETTINGS * servaMySQLDBC::getMediaEncoderSettings() +{ + DBC_SERVA_MEDIA_ENCODER_SETTINGS * RetVal = NULL; + if (m_bIsConnected) + { + char tQBuf[MAX_PATH_LEN]; + AAssoc * result; + sprintf(tQBuf, "SELECT * FROM `system_props` WHERE `id`=1"); +#ifdef DEBUG_ALL + LOG(tQBuf); +#endif + result = m_pDatabase->Query(tQBuf); + if (result != NULL) + { + if (result->size() > 0) + { + Assoc * cArr; + Assoc::iterator it; + RetVal = (DBC_SERVA_MEDIA_ENCODER_SETTINGS *) malloc(sizeof(DBC_SERVA_MEDIA_ENCODER_SETTINGS)); + if (RetVal) + { + memset(RetVal, 0, sizeof(DBC_SERVA_MEDIA_ENCODER_SETTINGS)); + + RetVal->CRF = 28;//20; + strncpy( RetVal->preset, "slow", 15 ); + strncpy( RetVal->tune, "fastdecode", 15 ); + strncpy( RetVal->profile, "main", 15 ); + //RetVal->TH_MODE = FF_THREAD_FRAME; + RetVal->bitrate = 666; + strncpy( RetVal->CONTAINER, "mp4", 4 ); + strncpy( RetVal->CODEC, "h264", 4 ); + + cArr = result->at(0); + it = cArr->find("media_fmt"); + if (it != cArr->end()) + { + strncpy(RetVal->CODEC, it->second.c_str(), 4); + RetVal->CODEC[4] = (char) 0; + }; + it = cArr->find("media_pck"); + if (it != cArr->end()) + { + strncpy(RetVal->CONTAINER, it->second.c_str(), 4); + RetVal->CONTAINER[4] = (char) 0; + }; + it = cArr->find("media_brate"); + if (it != cArr->end()) + { + RetVal->bitrate = atoi(it->second.c_str()); + }; + //it = cArr->find("media_special"); + //if (it != cArr->end()) + //{ + // RetVal->historyPreserveFreeSpaceMB = atoi(it->second.c_str()); + //}; + }; + }; + }; + deleteResult(result); + }; + return RetVal; +} + CSTR servaMySQLDBC::getMediaUUID(uint64_t id) { CSTR RetVal = NULL; @@ -893,6 +956,11 @@ DBC_SERVA_CONFIG * servaMySQLDBC::getServaConfig() { RetVal->historyAutoDeleteLimit = atoi(it->second.c_str()); }; + it = cArr->find("composer_proceed_delay"); + if (it != cArr->end()) + { + RetVal->composerProceedDelay = atoi(it->second.c_str()); + }; // RetVal->lts = time(NULL); // it = cArr->find("uuid"); // if( it != cArr->end() ){ @@ -977,7 +1045,7 @@ uint64_t servaMySQLDBC::getSessionOlderThan(uint32_t ts, uint8_t min_lvl) { char tQBuf[MAX_PATH_LEN]; AAssoc * result; - sprintf(tQBuf, "SELECT `id` FROM `sessions` WHERE `ts`<=%d AND `status`<=%d AND `final`='Y' LIMIT 1", ts, min_lvl); + sprintf(tQBuf, "SELECT `id` FROM `sessions` WHERE `ts`<=%d AND `status`<=%d AND `final`!='N' LIMIT 1", ts, min_lvl); #ifdef DEBUG_ALL LOG(tQBuf); #endif @@ -1008,7 +1076,7 @@ uint64_t servaMySQLDBC::getSessionOldest(uint8_t min_lvl) { char tQBuf[MAX_PATH_LEN]; AAssoc * result; - sprintf(tQBuf, "SELECT `id` FROM `sessions` WHERE `status`<=%d AND `final`='Y' ORDER BY `ts` LIMIT 1", min_lvl); + sprintf(tQBuf, "SELECT `id` FROM `sessions` WHERE `status`<=%d AND `final`!='N' ORDER BY `ts` LIMIT 1", min_lvl); #ifdef DEBUG_ALL LOG(tQBuf); #endif @@ -1101,6 +1169,41 @@ uint64_t servaMySQLDBC::getSessionTrackId(uint64_t id) }; return RetVal; } +uint64_t servaMySQLDBC::getSessionWithUnmergedVideo( uint32_t delay_secs ){ + uint64_t RetVal = 0; + if (m_bIsConnected) + { + char tQBuf[MAX_PATH_LEN]; + AAssoc * result; + if ( delay_secs ) { + uint32_t stc = (uint32_t) time( NULL ); + sts -= delay_secs-1; + sprintf(tQBuf, "SELECT `id` FROM `sessions` WHERE `final`='Y' AND `ts` < %d ORDER BY `ts` LIMIT 1", sts ); + } else { + sprintf(tQBuf, "SELECT `id` FROM `sessions` WHERE `final`='Y' ORDER BY `ts` LIMIT 1"); + }æ +#ifdef DEBUG_ALL + LOG(tQBuf); +#endif + result = m_pDatabase->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 = atoll(it->second.c_str()); + }; + }; + }; + deleteResult(result); + }; + return RetVal; +} SCADA_TRACK_INFO * servaMySQLDBC::getTrackSCADA(uint64_t id) { @@ -1199,8 +1302,8 @@ DBC_IS_TRACK_DATA * servaMySQLDBC::getTrackData(uint64_t id) it = cArr->find("short"); if (it != cArr->end()) { - strncpy(RetVal->short, it->second.c_str(), 32); - RetVal->short[32] = (char) 0; + strncpy(RetVal->abbr, it->second.c_str(), 32); + RetVal->abbr[32] = (char) 0; }; }; }; @@ -1272,6 +1375,62 @@ uint64_t servaMySQLDBC::getUpperLRF(uint64_t id) return RetVal; } +DBC_MEDIA_COMPOSER_DATA * servaMySQLDBC::getVideoComposerData() +{ + DBC_MEDIA_COMPOSER_DATA * RetVal = NULL; + if (m_bIsConnected) + { + char tQBuf[MAX_PATH_LEN]; + AAssoc * result; + sprintf(tQBuf, "SELECT * FROM `system_props` WHERE `id`=1"); +#ifdef DEBUG_ALL + LOG(tQBuf); +#endif + result = m_pDatabase->Query(tQBuf); + if (result != NULL) + { + if (result->size() > 0) + { + Assoc * cArr; + Assoc::iterator it; + RetVal = (DBC_MEDIA_COMPOSER_DATA *) malloc(sizeof(DBC_MEDIA_COMPOSER_DATA)); + if (RetVal) + { + memset(RetVal, 0, sizeof(DBC_MEDIA_COMPOSER_DATA)); + cArr = result->at(0); + it = cArr->find("composer_out_width"); + if (it != cArr->end()) + { + RetVal->out_width = atoi(it->second.c_str()); + }; + it = cArr->find("composer_out_height"); + if (it != cArr->end()) + { + RetVal->out_height = atoi(it->second.c_str()); + }; + it = cArr->find("composer_out_fps"); + if (it != cArr->end()) + { + RetVal->out_fps = atoi(it->second.c_str()); + }; + it = cArr->find("composer_prepend_ef"); + if (it != cArr->end()) + { + RetVal->prependEmptyFrames = (bool) atoi(it->second.c_str()); + }; + it = cArr->find("composer_debug_mode"); + if (it != cArr->end()) + { + RetVal->debugMode = (bool) atoi(it->second.c_str()); + }; + }; + }; + }; + deleteResult(result); + }; + return RetVal; +} + DBC_UINT64_LIST * servaMySQLDBC::listMediaQueueItems(uint8_t status) { DBC_UINT64_LIST * tVal = NULL; @@ -1998,6 +2157,21 @@ bool servaMySQLDBC::updateServerUtilisation(DBC_SYS_LOAD_INFO * ptr) return rval; } +bool servaMySQLDBC::updateSessionFinal(uint64_t id, char BB ) +{ + if (m_bIsConnected) + { + char tQBuf[MAX_PATH_LEN]; + sprintf(tQBuf, "UPDATE `sessions` SET `final`='%c' WHERE `id`=%" PRIu64, BB, id); +#ifdef DEBUG_ALL + LOG(tQBuf); +#endif + m_pDatabase->SilentQuery(tQBuf); + return true; + }; + return false; +} + bool servaMySQLDBC::updateSessionStatus(uint64_t id, uint8_t status) { if (m_bIsConnected) diff --git a/lib/App/common/serverMySQL_dataBinder.h b/lib/App/common/serverMySQL_dataBinder.h index 7a39a98d..7227b1ee 100644 --- a/lib/App/common/serverMySQL_dataBinder.h +++ b/lib/App/common/serverMySQL_dataBinder.h @@ -38,6 +38,7 @@ class servaMySQLDBC : public serverDataBinder virtual uint32_t getCloudLTS(uint8_t Obj, uint64_t id); virtual uint8_t getCloudStatus(uint8_t Obj, uint64_t id); virtual bool getDBLoggingSettings(void); + virtual DBC_SERVA_MEDIA_ENCODER_SETTINGS *getMediaEncoderSettings(void); virtual CSTR getMediaUUID(uint64_t id); virtual MODBUS_MANAGER_DATA * getModBusManagerData(); virtual MODBUS_RTU_INFO * getModBusRTU(uint64_t id); @@ -53,10 +54,13 @@ class servaMySQLDBC : public serverDataBinder virtual uint64_t getSessionOldest(uint8_t min_lvl = 2); virtual uint16_t getSessionTimeOut(); virtual uint64_t getSessionTrackId(uint64_t id); + virtual uint64_t getSessionWithUnmergedVideo( uint32_t delay_secs ); virtual DBC_IS_TRACK_DATA * getTrackData(uint64_t id); virtual uint64_t getTrackIdByMojo(uint64_t id); virtual SCADA_TRACK_INFO * getTrackSCADA(uint64_t id); virtual uint64_t getUpperLRF(uint64_t id); + virtual DBC_MEDIA_COMPOSER_DATA * getVideoComposerData(); + virtual DBC_UINT64_LIST * listMediaQueueItems(uint8_t status); virtual DBC_UINT64_LIST * listMetroModules(char status); virtual DBC_UINT64_LIST * listModBusRTUs(uint8_t status = 0, char mode = 'E'); @@ -88,6 +92,7 @@ class servaMySQLDBC : public serverDataBinder virtual bool updateModBusRTU(uint64_t dbid, uint8_t status = 0, uint8_t inputs = 0, uint8_t outputs = 0); virtual bool updateModuleData(uint64_t m_dMojoDBID, uint32_t UPPER_ID, uint32_t BOTTOM_ID, uint32_t CAM_ID, uint32_t CAM_STREAM_ID, CSTR vstr, CSTR lstr); virtual bool updateServerUtilisation(DBC_SYS_LOAD_INFO * ptr); + virtual bool updateSessionFinal(uint64_t id, char BB ); virtual bool updateSessionStatus(uint64_t id, uint8_t status); virtual bool updateWebCmdStatus(uint64_t id, uint8_t status); }; diff --git a/lib/App/common/targetPipeLine.cpp b/lib/App/common/targetPipeLine.cpp index a8cff9db..4cc730f9 100644 --- a/lib/App/common/targetPipeLine.cpp +++ b/lib/App/common/targetPipeLine.cpp @@ -54,6 +54,7 @@ targetPipeLine::~targetPipeLine() void targetPipeLine::m_fThreadProc(void) { m_bThreadStatus = TH_WORKING; + pthread_setname_np(pthread_self(), "targetPipeLine"); while (m_bThreadStatus < TH_ENDED) { m_mTargetProtector.lock(); diff --git a/lib/App/mojo/mojoBackend.cpp b/lib/App/mojo/mojoBackend.cpp index 33d8e301..bea0ea0c 100644 --- a/lib/App/mojo/mojoBackend.cpp +++ b/lib/App/mojo/mojoBackend.cpp @@ -448,7 +448,7 @@ int main(int argc, char * argv[]) return 0; }; }; - + pthread_setname_np( pthread_self(), "backend(Main)" ); // Block Some Signals // sigset_t signal_mask; // sigfillset( &signal_mask ); diff --git a/lib/App/mojo/mojoKernel.cpp b/lib/App/mojo/mojoKernel.cpp index 6a38beb2..83f6d852 100644 --- a/lib/App/mojo/mojoKernel.cpp +++ b/lib/App/mojo/mojoKernel.cpp @@ -245,7 +245,7 @@ bool mojoKernel::create() t.lat = tSiteData->lat; t.lon = tSiteData->lon; t.alt = tSiteData->alt; - m_pSystemAnchor = systemAnchor::getInstance(tSiteData->SH, &t, tSiteData->local_binding); + m_pSystemAnchor = systemAnchor::getInstance( &t, tSiteData->local_binding ); memcpy(&m_sSiteData, tSiteData, sizeof(DBC_SITE_DATA)); free(tSiteData); } @@ -257,7 +257,7 @@ bool mojoKernel::create() t.lon = 0; t.alt = 0; memset(&m_sSiteData, 0, sizeof(DBC_SITE_DATA)); - m_pSystemAnchor = systemAnchor::getInstance(false, &t, true); + m_pSystemAnchor = systemAnchor::getInstance( &t, true ); }; m_bKeepLocalReport = ! m_sSiteData.skip_local_report; @@ -323,6 +323,7 @@ bool mojoKernel::create() m_pModuleFactory->loadModules(); // Read Media Mode ( Video/Pictures ) +#ifndef LRF_PROXY_ONLY kernelModuleEmbedVideo * tMO = (kernelModuleEmbedVideo *) m_pModuleFactory->getModule(KERNEL_MODULE_EMBED_VIDEO); if (tMO) { @@ -332,6 +333,10 @@ bool mojoKernel::create() { LOG_ERROR("No Embed Video Processing Module!"); }; +#else + LOG_ERROR("DATA PROXY Processing Module!"); + m_bMediaMode = 0; +#endif; m_pNodeFactory = deviceNodeFactory::getInstance(); if (! m_pNodeFactory) @@ -364,6 +369,84 @@ bool mojoKernel::create() return init(); } +#include "../common/deviceNode2D.h" + +void mojoKernel::releaseExplicitChannel( uint32_t node_id, uint32_t channel_id ){ + if ( m_pNodeFactory ) { + deviceNode ** tA = NULL; + uint32_t tCNT = m_pNodeFactory->fetchNodes(ARGUS_ALS_SENSOR, tA ); + for ( uint32_t i = 0; i < tCNT; i++ ) { + if ( tA[i]->getNodeID() != node_id ) ( (device2DSensor *)tA[i] )->setChannelReady( channel_id ); + }; + if (tCNT){ + free(tA); + tA = NULL; + }; + tCNT = m_pNodeFactory->fetchNodes(ARGUS_LFS_SENSOR, tA ); + for ( uint32_t i = 0; i < tCNT; i++ ) { + if ( tA[i]->getNodeID() != node_id ) ( (device2DSensor *)tA[i] )->setChannelReady( channel_id ); + }; + if (tCNT){ + free(tA); + tA = NULL; + }; + tCNT = m_pNodeFactory->fetchNodes(ARGUS_PLS_200_SENSOR, tA ); + for ( uint32_t i = 0; i < tCNT; i++ ) { + if ( tA[i]->getNodeID() != node_id ) ( (device2DSensor *)tA[i] )->setChannelReady( channel_id ); + }; + if (tCNT){ + free(tA); + tA = NULL; + }; + tCNT = m_pNodeFactory->fetchNodes(ARGUS_PLS_360_SENSOR, tA ); + for ( uint32_t i = 0; i < tCNT; i++ ) { + if ( tA[i]->getNodeID() != node_id ) ( (device2DSensor *)tA[i] )->setChannelReady( channel_id ); + }; + if (tCNT){ + free(tA); + tA = NULL; + }; + }; +} + +void mojoKernel::requestExplicitChannel( uint32_t node_id, uint32_t channel_id, uint8_t seconds_to ){ + if ( m_pNodeFactory ) { + deviceNode ** tA = NULL; + uint32_t tCNT = m_pNodeFactory->fetchNodes(ARGUS_ALS_SENSOR, tA ); + for ( uint32_t i = 0; i < tCNT; i++ ) { + if ( tA[i]->getNodeID() != node_id ) ( (device2DSensor *)tA[i] )->setChannelBusy( channel_id, seconds_to ); + }; + if (tCNT){ + free(tA); + tA = NULL; + }; + tCNT = m_pNodeFactory->fetchNodes(ARGUS_LFS_SENSOR, tA ); + for ( uint32_t i = 0; i < tCNT; i++ ) { + if ( tA[i]->getNodeID() != node_id ) ( (device2DSensor *)tA[i] )->setChannelBusy( channel_id, seconds_to ); + }; + if (tCNT){ + free(tA); + tA = NULL; + }; + tCNT = m_pNodeFactory->fetchNodes(ARGUS_PLS_200_SENSOR, tA ); + for ( uint32_t i = 0; i < tCNT; i++ ) { + if ( tA[i]->getNodeID() != node_id ) ( (device2DSensor *)tA[i] )->setChannelBusy( channel_id, seconds_to ); + }; + if (tCNT){ + free(tA); + tA = NULL; + }; + tCNT = m_pNodeFactory->fetchNodes(ARGUS_PLS_360_SENSOR, tA ); + for ( uint32_t i = 0; i < tCNT; i++ ) { + if ( tA[i]->getNodeID() != node_id ) ( (device2DSensor *)tA[i] )->setChannelBusy( channel_id, seconds_to ); + }; + if (tCNT){ + free(tA); + tA = NULL; + }; + }; +} + void mojoKernel::startSession() { m_mSessionProtector.lock(); @@ -628,7 +711,7 @@ void mojoKernel::m_fThreadProc(void) { time_t tTimeTSeconds = 0; m_bThreadStatus = TH_WORKING; - LOG("Mojo Started!"); + pthread_setname_np( pthread_self(), "Kernel" ); while (m_bThreadStatus < TH_ENDED) { m_tTimeTSeconds = time(NULL); diff --git a/lib/App/mojo/mojoKernel.h b/lib/App/mojo/mojoKernel.h index a1dbf759..70e0e27a 100644 --- a/lib/App/mojo/mojoKernel.h +++ b/lib/App/mojo/mojoKernel.h @@ -143,6 +143,8 @@ class mojoKernel : public kernelPrototype #ifdef __MOJO_REMOTE_CLIENT_HEADER__ bool fillMojoInfo(ARGUS_DATA_MOJO_INFO * ptr); #endif + virtual void requestExplicitChannel( uint32_t node_id, uint32_t channel_id, uint8_t seconds_to ); + virtual void releaseExplicitChannel( uint32_t node_id, uint32_t channel_id ); friend class mojoRemoteClient; }; diff --git a/lib/App/mojo/mojoRemoteClient.cpp b/lib/App/mojo/mojoRemoteClient.cpp index 403fd10b..2b75ead8 100644 --- a/lib/App/mojo/mojoRemoteClient.cpp +++ b/lib/App/mojo/mojoRemoteClient.cpp @@ -710,9 +710,7 @@ void mojoRemoteClient::m_fThreadProc(void) uint32_t tSecondsCounter = 0; m_bThreadStatus = TH_WORKING; -#ifdef DEBUG - LOG("Connector Thread Started"); -#endif + pthread_setname_np( pthread_self(), "remoteClient" ); while (m_bThreadStatus < TH_ENDED) { // seconds Counter (for internal purposes) diff --git a/lib/App/serva/servaKernel.cpp b/lib/App/serva/servaKernel.cpp index 6b02bf89..63ddc504 100644 --- a/lib/App/serva/servaKernel.cpp +++ b/lib/App/serva/servaKernel.cpp @@ -28,6 +28,7 @@ #include "../common/serverMySQL_dataBinder.h" #include "servaModBusManager.h" +#include "servaVideoComposer.h" #define LOG( X ) kernelPrototype::m_pLog->Log( "KRNL", this, X ) #ifdef DEBUG @@ -151,6 +152,13 @@ bool servaKernel::create(){ } else delete( tModBus ); }; + /* Test Composer */ + + //servaVideoComposer *tVC = new servaVideoComposer( 49 ); + //if ( tVC ) { + // tVC->compose(); + //}; + m_pRPC = servaRemoteClient::getInstance(this); if ( m_pRPC ) { if( m_pRPC->start() ) return init(); @@ -367,7 +375,18 @@ void servaKernel::m_fThreadProc( void ){ if ( m_pLifeMonitor ) m_pLifeMonitor->validate(); if ( m_pModBus ) ((servaModBusManager *)m_pModBus)->validate(); //m_pHardwareManager->updateSysInfo( &m_sSysInfo ); - + if ( m_pVideoComposer == NULL ) { + uint64_t tSID = m_pDBC->getSessionWithUnmergedVideo( m_sServaConfig.composerProceedDelay ); + if ( tSID ) { + m_pVideoComposer = new servaVideoComposer( tSID ); + if ( m_pVideoComposer ) { + if( !m_pVideoComposer->compose() ){ + delete( m_pVideoComposer ); + m_pVideoComposer = NULL; + }; + }; + }; + }; }; SLEEP(SLEEP_KERNEL_INTERVAL); }; diff --git a/lib/App/serva/servaMediaEncoder.cpp b/lib/App/serva/servaMediaEncoder.cpp index a83576e1..d8344026 100644 --- a/lib/App/serva/servaMediaEncoder.cpp +++ b/lib/App/serva/servaMediaEncoder.cpp @@ -19,20 +19,22 @@ servaMediaEncoder::servaMediaEncoder( uint64_t Ref ):basicThread(){ m_nInFileSize = 0; m_nOutFileSize = 0; m_bStatus = ENCODER_NONE; - DBC_SERVA_MEDIA_ENCODER_SETTINGS *tData = NULL;//m_pDBC->getMediaEncoderSettings(); + DBC_SERVA_MEDIA_ENCODER_SETTINGS *tData = servaMySQLDBC::getInstance()->getMediaEncoderSettings(); if( tData ){ memcpy( &m_sEncoderSettings, tData, sizeof( DBC_SERVA_MEDIA_ENCODER_SETTINGS ) ); + free( tData ); } else { memset( &m_sEncoderSettings, 0, sizeof( DBC_SERVA_MEDIA_ENCODER_SETTINGS )); m_sEncoderSettings.CRF = 28;//20; strncpy( m_sEncoderSettings.preset, "slow", 15 ); strncpy( m_sEncoderSettings.tune, "fastdecode", 15 ); strncpy( m_sEncoderSettings.profile, "main", 15 ); - m_sEncoderSettings.TH_MODE = FF_THREAD_FRAME; + //m_sEncoderSettings.TH_MODE = FF_THREAD_FRAME; m_sEncoderSettings.bitrate = 666; strncpy( m_sEncoderSettings.CONTAINER, "mp4", 4 ); strncpy( m_sEncoderSettings.CODEC, "h264", 4 ); } + m_sEncoderSettings.TH_MODE = FF_THREAD_FRAME; memset( &m_sDecoderVS, 0, sizeof(LIBAV_VS)); memset( &m_sEncoderVS, 0, sizeof(LIBAV_VS)); }; diff --git a/lib/App/serva/servaVideoComposer.cpp b/lib/App/serva/servaVideoComposer.cpp index 5ef07980..bbfdd339 100644 --- a/lib/App/serva/servaVideoComposer.cpp +++ b/lib/App/serva/servaVideoComposer.cpp @@ -1,6 +1,9 @@ #include "servaVideoComposer.h" -const unsigned char no_frame_png_1600x900[21311] = { +#include "../common/serverMySQL_dataBinder.h" + +#define no_frame_data_size 21311 +const unsigned char no_frame_png_1600x900[no_frame_data_size] = { 0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52, 0x00,0x00,0x06,0x40,0x00,0x00,0x03,0x84,0x08,0x06,0x00,0x00,0x00,0xf9,0x4d,0xfd, 0xa2,0x00,0x00,0x00,0x09,0x70,0x48,0x59,0x73,0x00,0x00,0x0b,0x13,0x00,0x00,0x0b, @@ -1351,27 +1354,45 @@ const unsigned char no_frame_png_1600x900[21311] = { servaVideoComposer::servaVideoComposer( uint64_t session_id ){ m_pLog = basicLogCollection::getInstance(); - m_bStatus = VIDEO_COMPOSER_NA; + m_bComposerStatus = VIDEO_COMPOSER_NA; //Load Module Data m_pDBC = servaMySQLDBC::getInstance(); m_uLModuleID = 0; m_uRModuleID = 0; + m_nSessionID = session_id; if ( m_pDBC ) { DBC_MEDIA_COMPOSER_DATA * tData = m_pDBC->getVideoComposerData(); if (tData) { - memcpy(m_sComposerSettings, tData, sizeof(DBC_MEDIA_COMPOSER_DATA)); + LOG("Settings OK"); + memcpy( &m_sComposerSettings, tData, sizeof(DBC_MEDIA_COMPOSER_DATA)); free( tData ); } else { LOG_ERROR("Settings Load Failure!"); - memset(m_sComposerSettings, 0, sizeof(DBC_MEDIA_COMPOSER_DATA)); - m_bStatus = VIDEO_COMPOSER_ERR; - }; - // If settings are OK + memset(&m_sComposerSettings, 0, sizeof(DBC_MEDIA_COMPOSER_DATA)); + m_bComposerStatus = VIDEO_COMPOSER_ERR; + }; + }; + LOG("Con Done!"); +}; + +servaVideoComposer::~servaVideoComposer(){ + finishupCompose(); +}; + +bool servaVideoComposer::compose(){ + // If settings are OK + LOG("Compose"); + if ( m_bComposerStatus != VIDEO_COMPOSER_ERR ) { if (m_sComposerSettings.out_width && m_sComposerSettings.out_height) { // create supplimentary data - m_oNoVideoMat = cv::imdecode( no_frame_png_1600x900, cv::IMREAD_COLOR ); + LOG("Decode No Frame Image"); + cv::Mat rawBufferMat(1, no_frame_data_size, CV_8UC1, const_cast(no_frame_png_1600x900)); + + //m_oNoVideoMat = cv::imdecode( cv::InputArray( no_frame_png_1600x900 ), cv::IMREAD_COLOR ); + m_oNoVideoMat = cv::imdecode(rawBufferMat, cv::IMREAD_UNCHANGED); //Check if need to resize no pic mat if( ( m_oNoVideoMat.cols != m_sComposerSettings.out_width ) || ( m_oNoVideoMat.rows != m_sComposerSettings.out_height ) ) { + LOG("Resize No Frame Image"); cv::resize( m_oNoVideoMat, m_oNoVideoMat, @@ -1380,15 +1401,18 @@ servaVideoComposer::servaVideoComposer( uint64_t session_id ){ );//cv::INTER_NEAREST cv::INTER_LINEAR cv::INTER_CUBIC cv::INTER_AREA }; //Load Session Data - m_pSessionData = m_pDBC->getSessionData( session_id ); + LOG("Get Session Data"); + m_pSessionData = m_pDBC->getSessionData( m_nSessionID ); if ( m_pSessionData ) { servaSessionManager *tSM = servaSessionManager::getInstance(); - CSTR *tPath = tSM->getReportDir( m_pSessionData->track_id, m_pSessionData->sts ); + CSTR tPath = tSM->getReportDir( m_pSessionData->track_id, m_pSessionData->sts ); if ( tPath ) { + LOG("Have Report Dir"); strncpy( m_pSessionData->reportVaultPath, tPath, MAX_PATH ); free( tPath ); char tName[MAX_PATH]; sprintf( tName, "%s/report.db", m_pSessionData->reportVaultPath ); + LOG( tName ); if( fileExist( tName ) ){ m_pSessionData->m_pDataReport = new SQLite_Connector(); if ( m_pSessionData->m_pDataReport ) { @@ -1398,6 +1422,7 @@ servaVideoComposer::servaVideoComposer( uint64_t session_id ){ free( m_pSessionData ); m_pSessionData = NULL; } else { + LOG("Connected to Report"); DBC_IS_TRACK_DATA* tTD = m_pDBC->getTrackData( m_pSessionData->track_id ); if ( tTD ) { if( tTD->side == 'U' ) { @@ -1409,8 +1434,9 @@ servaVideoComposer::servaVideoComposer( uint64_t session_id ){ }; free( tTD ); }; - if(loadLeftQueue()) m_bStatus |= VIDEO_COMPOSER_LOK; - if(loadRightQueue()) m_bStatus |= VIDEO_COMPOSER_ROK; + LOG("Loading Videos!"); + if(loadLeftQueue()) m_bComposerStatus |= VIDEO_COMPOSER_LOK; + if(loadRightQueue()) m_bComposerStatus |= VIDEO_COMPOSER_ROK; }; } else { LOG_ERROR("Cannot Create Connector to RDB!"); @@ -1431,24 +1457,57 @@ servaVideoComposer::servaVideoComposer( uint64_t session_id ){ LOG_ERROR("Can not get Session Data from Database!"); }; }; - } - if ( m_pSessionData == NULL ){ - m_bStatus = VIDEO_COMPOSER_ERR; - } else { - if( m_bStatus ){ // Have items in Video Queue - if (init()) m_bStatus |= VIDEO_COMPOSER_INIT; + if ( m_pSessionData == NULL ){ + LOG("Error Init Composer!"); + m_bComposerStatus = VIDEO_COMPOSER_ERR; } else { - m_bStatus = VIDEO_COMPOSER_DONE; + if( m_bComposerStatus ){ // Have items in Video Queue + LOG("Have To Compose Videos!"); + if (init()) { + m_bComposerStatus |= VIDEO_COMPOSER_INIT; + return true; + }; + } else { + LOG("No Need to Compose Videos!"); + m_bComposerStatus |= VIDEO_COMPOSER_DONE; + }; + }; + }; + return false; +}; + +void servaVideoComposer::finishupCompose(){ + // Check if Started + if ( (m_bComposerStatus & VIDEO_COMPOSER_INIT ) == VIDEO_COMPOSER_INIT) { + // Check if finished some L-R parts + if ( (m_bComposerStatus & VIDEO_COMPOSER_DONE ) != 0 ) { + //If not Both Parts are finished -> kill thread + uint8_t tChVal = ((( m_bComposerStatus & VIDEO_COMPOSER_LOK ) == VIDEO_COMPOSER_LOK)?VIDEO_COMPOSER_L_DONE:0) | + ((( m_bComposerStatus & VIDEO_COMPOSER_ROK ) == VIDEO_COMPOSER_ROK)?VIDEO_COMPOSER_R_DONE:0); + if ( (m_bComposerStatus & tChVal ) != tChVal ) waitThreadEnd( true ); + + //update session Data to have new video records instead of the partial videos + if ( ( m_bComposerStatus & VIDEO_COMPOSER_L_DONE ) == VIDEO_COMPOSER_L_DONE ) { + }; + if ( ( m_bComposerStatus & VIDEO_COMPOSER_R_DONE ) == VIDEO_COMPOSER_R_DONE ) { + }; + } else { + // Not finished -> Delete unfinished Files and abort the mission! + waitThreadEnd( true ); + }; }; }; bool servaVideoComposer::loadLeftQueue(){ + bool RetVal = false; + LOG("Load Left Size"); if ( m_pSessionData ) { - if ( m_pSessionData->m_pDataReport && m_uLModuleID ) { + if ( m_pSessionData->m_pDataReport && m_uLModuleID && m_pSessionData->db_id ) { char tQBuf[MAX_PATH_LEN]; + AAssoc * result; //Left Module Video - sprintf( tQBuf, "SELECT * FROM `videos` WHERE `session_id`=%"PRIu64" AND `module_id`=%"PRIu64, session_id, m_uLModuleID ); + sprintf( tQBuf, "SELECT * FROM `videos` WHERE `session_id`=%"PRIu64" AND `module_id`=%"PRIu64, m_pSessionData->db_id, m_uLModuleID ); result = m_pSessionData->m_pDataReport->Query(tQBuf); if (result != NULL){ if (result->size() > 0){ @@ -1460,33 +1519,34 @@ bool servaVideoComposer::loadLeftQueue(){ cArr = result->at(i); it = cArr->find("id"); if (it != cArr->end()){ - tVI->id = atoll(it->second.c_str())); + tVI->id = atoll(it->second.c_str()); }; it = cArr->find("uuid"); if (it != cArr->end()) { - strncpy(RetVal->uuid, it->second.c_str(), 64); - RetVal->uuid[64] = (char) 0; + strncpy(tVI->uuid, it->second.c_str(), 64); + tVI->uuid[64] = (char) 0; }; it = cArr->find("ts"); if (it != cArr->end()){ - tVI->sts = atoi(it->second.c_str())); + tVI->sts = atoi(it->second.c_str()); }; it = cArr->find("ts_ms"); if (it != cArr->end()){ - tVI->sms = atoi(it->second.c_str())); + tVI->sms = atoi(it->second.c_str()); }; it = cArr->find("ext"); if (it != cArr->end()) { - strncpy(RetVal->uuid, it->second.c_str(), 5); - RetVal->ext[5] = (char) 0; + strncpy(tVI->ext, it->second.c_str(), 5); + tVI->ext[5] = (char) 0; }; it = cArr->find("fps"); if (it != cArr->end()){ - tVI->fps = atof(it->second.c_str())); + tVI->fps = atof(it->second.c_str()); }; m_vLVideoQueue.push_back(tVI); + RetVal = true; }; }; }; @@ -1494,50 +1554,275 @@ bool servaVideoComposer::loadLeftQueue(){ deleteResult(result); }; }; - return false; + return RetVal; }; -bool servaVideoComposer::loadRightQueue(){ +bool servaVideoComposer::loadRightQueue(){ + bool RetVal = false; + LOG("Load Right Size"); + if ( m_pSessionData ) { + if ( m_pSessionData->m_pDataReport && m_uRModuleID && m_pSessionData->db_id ) { + char tQBuf[MAX_PATH_LEN]; + AAssoc * result; + //Right Module Video + sprintf( tQBuf, "SELECT * FROM `videos` WHERE `session_id`=%"PRIu64" AND `module_id`=%"PRIu64, m_pSessionData->db_id, m_uRModuleID ); + result = m_pSessionData->m_pDataReport->Query(tQBuf); + if (result != NULL){ + if (result->size() > 0){ + Assoc * cArr; + Assoc::iterator it; + for (size_t i = 0; i < result->size(); i++){ + VIDEO_PART_INFO *tVI = (VIDEO_PART_INFO *)malloc(sizeof(VIDEO_PART_INFO )); + if ( tVI ) { + cArr = result->at(i); + it = cArr->find("id"); + if (it != cArr->end()){ + tVI->id = atoll(it->second.c_str()); + }; + it = cArr->find("uuid"); + if (it != cArr->end()) + { + strncpy(tVI->uuid, it->second.c_str(), 64); + tVI->uuid[64] = (char) 0; + }; + it = cArr->find("ts"); + if (it != cArr->end()){ + tVI->sts = atoi(it->second.c_str()); + }; + it = cArr->find("ts_ms"); + if (it != cArr->end()){ + tVI->sms = atoi(it->second.c_str()); + }; + it = cArr->find("ext"); + if (it != cArr->end()) + { + strncpy(tVI->ext, it->second.c_str(), 5); + tVI->ext[5] = (char) 0; + }; + it = cArr->find("fps"); + if (it != cArr->end()){ + tVI->fps = atof(it->second.c_str()); + }; + m_vRVideoQueue.push_back(tVI); + RetVal = true; + }; + }; + }; + }; + deleteResult(result); + }; + }; + return RetVal; }; + void servaVideoComposer::m_fThreadProc(void){ uint8_t operc = 0; - m_bStatus = THREAD_INIT; - #ifdef DEBUG_EXTRA - char tB[1024]; - sprintf( tB, "Converting %s to %s", m_sDecoderVS.m_pFileName, m_sEncoderVS.m_pFileName ); - LOG( tB ); - #endif - cv::VideoCapture cap( m_sDecoderVS.m_pFileName ); - if( cap.isOpened() ) { - cv::Mat mat; - cap >> mat; - if( !mat.empty() ){ - cap.set( cv::VideoCaptureProperties::CAP_PROP_POS_FRAMES, 0.0 ); - float fps = m_sComposerSettings.out_fps; - cv::VideoWriter out(m_sEncoderVS.m_pFileName, cv::VideoWriter::fourcc('a', 'v', 'c', '1'), fps, cv::Size(m_sComposerSettings.out_width, m_sComposerSettings.out_height)); - size_t number_of_frames = 0; - m_bThreadStatus = TH_WORKING; - while( cap.isOpened() && out.isOpened() && m_bThreadStatus < TH_ENDED ){ - cap >> mat; - m_bStatus = ENCODER_ENCODING; - if( mat.empty() ){ - m_bThreadStatus = TH_ENDED; + //m_bThreadStatus = THREAD_INIT; + pthread_setname_np( pthread_self(), "VideoComposer" ); + if ( ( m_bComposerStatus & VIDEO_COMPOSER_LOK ) || ( m_bComposerStatus & VIDEO_COMPOSER_ROK ) ) { + + const uint64_t BeginnhingTS = ((uint64_t)m_pSessionData->sts) * 1000; + const uint64_t EndTS = ((uint64_t)m_pSessionData->lts ) * 1000 + 1000; + uint16_t FramePT = 1000 / m_sComposerSettings.out_fps; + float fps = m_sComposerSettings.out_fps; + + cv::VideoWriter L_out; + char tLSRC[MAX_PATH_LEN]; + cv::VideoCapture L_cap; + size_t L_NOF = 0; + uint32_t L_idx = 0; + uint64_t L_global_sts = 0; + uint32_t L_global_NOF = 0; + + cv::VideoWriter R_out; + char tRSRC[MAX_PATH_LEN]; + cv::VideoCapture R_cap; + size_t R_NOF = 0; + uint32_t R_idx = 0; + + if( ( m_bComposerStatus & VIDEO_COMPOSER_LOK ) == VIDEO_COMPOSER_LOK ){ + LOG("Open Let Output"); + char tUUID[36]; + getUniqID_UUID( tUUID ); + sprintf( m_cLOutPath, "%s/%s.mp4", m_pSessionData->reportVaultPath, tUUID ); + LOG(m_cLOutPath); + L_out.open( m_cLOutPath, cv::VideoWriter::fourcc('a', 'v', 'c', '1'), fps, cv::Size(m_sComposerSettings.out_width, m_sComposerSettings.out_height)); + } + if( ( m_bComposerStatus & VIDEO_COMPOSER_ROK ) == VIDEO_COMPOSER_ROK ){ + LOG("Open Right Output"); + char tUUID[36]; + getUniqID_UUID( tUUID ); + sprintf( m_cROutPath, "%s/%s.mp4", m_pSessionData->reportVaultPath, tUUID ); + LOG(m_cROutPath); + R_out.open( m_cROutPath, cv::VideoWriter::fourcc('a', 'v', 'c', '1'), fps, cv::Size(m_sComposerSettings.out_width, m_sComposerSettings.out_height)); + } + + char tB[256]; + + for ( uint64_t CurrentTS = BeginnhingTS; CurrentTS < EndTS && m_bThreadStatus < TH_ENDED; CurrentTS += FramePT ) { + if( ( m_bComposerStatus & VIDEO_COMPOSER_LOK ) == VIDEO_COMPOSER_LOK ){ + uint64_t csts = ((uint64_t)m_vLVideoQueue[L_idx]->sts ) * 1000 + m_vLVideoQueue[L_idx]->sms; + if ( L_global_sts == 0 ) L_global_sts = csts; + bool have_next_segment = L_idx < (m_vLVideoQueue.size() - 1); + if( have_next_segment ) { + uint64_t nsts = ((uint64_t)m_vLVideoQueue[L_idx+1]->sts ) * 1000 + m_vLVideoQueue[L_idx+1]->sms; + if( CurrentTS > csts && CurrentTS < nsts ){ + // at beginning + if ( L_NOF == 0 ) { + sprintf( tLSRC,"%s/%s.%s", m_pSessionData->reportVaultPath, m_vLVideoQueue[L_idx]->uuid, m_vLVideoQueue[L_idx]->ext ); + LOG(tLSRC); + L_cap.open ( tLSRC ); + if( L_cap.isOpened() ) { + L_cap.set( cv::VideoCaptureProperties::CAP_PROP_POS_FRAMES, 0.0 ); + }; + }; + } else { + if ( CurrentTS > nsts ) { + // Have to switch to the Next Video + L_cap.release(); + L_NOF = 0; + L_idx++; + } else { + if( m_sComposerSettings.prependEmptyFrames ){ + L_global_NOF++; + // Prepend Video with No Video Frames ?? + L_out.write( m_oNoVideoMat ); + }; + }; + }; + if( L_cap.isOpened() ) { + cv::Mat mat; + L_cap >> mat; + if( !mat.empty() ){ + L_NOF++; + L_global_NOF++; + if ( m_sComposerSettings.debugMode ) { + char tsb[64]; + sprintf( tsb,"#%d", L_idx+1 ); + cv::putText( mat, tsb, cv::Point(100, 100), cv::FONT_HERSHEY_DUPLEX, 3.0, cv::Scalar(0, 255, 255), 1, cv::LINE_8 ); + + uint32_t tTS = (CurrentTS / 1000); + time_t t = (time_t) tTS; + struct tm * tmp = localtime(&t); + if( tmp ){ + if (strftime(tsb, sizeof(tsb), "%F %T", tmp) != 0){ + int baseline = 0; + cv::Size textSize = cv::getTextSize( tsb, cv::FONT_HERSHEY_DUPLEX, 1, 1, &baseline ); + int x = (m_sComposerSettings.out_width - textSize.width)>>1; + int y = (m_sComposerSettings.out_height - textSize.height)>>1; + cv::rectangle( mat, cv::Rect(x, y - textSize.height - 4, textSize.width, textSize.height + baseline + 4 ), cv::Scalar(0, 0, 0), cv::FILLED ); + cv::putText( mat, tsb, cv::Point(x, y), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(255, 255, 0), 1, cv::LINE_8 ); + }; + }; + }; + L_out.write( mat ); + } else { + // End of Video but not reached Next Video Start -> Place No Video Frame ? + L_global_NOF++; + L_out.write( m_oNoVideoMat ); + }; + }; } else { - number_of_frames ++; - out.write(mat); - }; - uint8_t perc = ( 100 * number_of_frames ) / 900; - if ( operc!= perc ) { - if ( perc > 100 ) perc = 100; - operc = perc; - m_pMaster->updateEncodeStatus(m_nRefID, MEDIA_ENCODE_PROGRESS, perc); + if( CurrentTS > csts ){ + // Reading From Current Segment + if ( L_NOF == 0 ) { + //Open Source File + sprintf( tLSRC,"%s/%s.%s", m_pSessionData->reportVaultPath, m_vLVideoQueue[L_idx]->uuid, m_vLVideoQueue[L_idx]->ext ); + L_cap.open ( tLSRC ); + if( L_cap.isOpened() ) { + L_cap.set( cv::VideoCaptureProperties::CAP_PROP_POS_FRAMES, 0.0 ); + }; + }; + }; + if( L_cap.isOpened() ) { + cv::Mat mat; + L_cap >> mat; + L_NOF++; + L_global_NOF++; + if( !mat.empty() ){ + if ( m_sComposerSettings.debugMode ) { + char tsb[64]; + sprintf( tsb,"#%d", L_idx+1 ); + cv::putText( mat, tsb, cv::Point(100, 100), cv::FONT_HERSHEY_DUPLEX, 3.0, cv::Scalar(0, 255, 255), 1, cv::LINE_8 ); + + uint32_t tTS = (CurrentTS / 1000); + time_t t = (time_t) tTS; + struct tm * tmp = localtime(&t); + if( tmp ){ + if (strftime(tsb, sizeof(tsb), "%F %T", tmp) != 0){ + int baseline = 0; + cv::Size textSize = cv::getTextSize( tsb, cv::FONT_HERSHEY_DUPLEX, 1, 1, &baseline ); + int x = (m_sComposerSettings.out_width - textSize.width)>>1; + int y = (m_sComposerSettings.out_height - textSize.height)>>1; + cv::rectangle( mat, cv::Rect(x, y - textSize.height - 4, textSize.width, textSize.height + baseline + 4 ), cv::Scalar(0, 0, 0), cv::FILLED ); + cv::putText( mat, tsb, cv::Point(x, y), cv::FONT_HERSHEY_DUPLEX, 1, cv::Scalar(255, 255, 0), 1, cv::LINE_8 ); + }; + }; + }; + L_out.write( mat ); + } else { + // No Next Video -> Finishing + LOG("Finished!"); + L_out.release(); + m_bComposerStatus |= VIDEO_COMPOSER_L_DONE; + //test + m_bThreadStatus=TH_ENDED; + }; + }; }; }; - cap.release(); - // Does it look reasonable?  If so, then we can go ahead and delete the original file. - if( number_of_frames > 100 ){ - unlink( m_sDecoderVS.m_pFileName ); + }; +/* + if( ( m_bComposerStatus & VIDEO_COMPOSER_LOK ) == VIDEO_COMPOSER_LOK ) { + + + + + for ( V_VP_INFO::iterator idx = m_vLVideoQueue.begin(); idx != m_vLVideoQueue.end(); idx++ ) { + sprintf( tSRC, "%s/%s.%s", m_pSessionData->reportVaultPath, (*idx)->uuid, (*idx)->ext ); + #ifdef DEBUG + char tB[1024]; + sprintf( tB, "Composing %s to %s", tSRC, m_cLOutPath ); + LOG( tB ); + #endif + cv::VideoCapture cap( tSRC ); + if( cap.isOpened() ) { + cv::Mat mat; + cap >> mat; + if( !mat.empty() ){ + cap.set( cv::VideoCaptureProperties::CAP_PROP_POS_FRAMES, 0.0 ); + m_bThreadStatus = TH_WORKING; + while( cap.isOpened() && out.isOpened() && m_bThreadStatus < TH_ENDED ){ + cap >> mat; + m_bComposerStatus = ENCODER_ENCODING; + if( mat.empty() ){ + m_bThreadStatus = TH_ENDED; + } else { + number_of_frames ++; + out.write(mat); + }; + uint8_t perc = ( 100 * number_of_frames ) / 900; + if ( operc!= perc ) { + if ( perc > 100 ) perc = 100; + operc = perc; + m_pMaster->updateEncodeStatus(m_nRefID, MEDIA_ENCODE_PROGRESS, perc); + }; + }; + cap.release(); + // Does it look reasonable?  If so, then we can go ahead and delete the original file. + if( number_of_frames > 100 ){ + unlink( m_sDecoderVS.m_pFileName ); + }; + }; + }; }; }; }; -}; + m_bStatus = TH_ENDED; +*/ + }; +} + + +#undef LOG +#undef LOG_ERROR diff --git a/lib/App/serva/servaVideoComposer.h b/lib/App/serva/servaVideoComposer.h index 431593ac..01797d37 100644 --- a/lib/App/serva/servaVideoComposer.h +++ b/lib/App/serva/servaVideoComposer.h @@ -1,14 +1,20 @@ #ifndef __SERVA_VIDEO_COMPOSER_HEADER__ #define __SERVA_VIDEO_COMPOSER_HEADER__ +#include "../common/serverDataBinder.h" #include "../../components/base/basicThread.h" +#include "../../components/base/basicLIBAV.h" + +#include "servaSessionManager.h" #define VIDEO_COMPOSER_NA 0x00 #define VIDEO_COMPOSER_ERR 0xFF #define VIDEO_COMPOSER_INIT 0x01 #define VIDEO_COMPOSER_LOK 0x02 #define VIDEO_COMPOSER_ROK 0x04 -#define VIDEO_COMPOSER_DONE 0xF0 +#define VIDEO_COMPOSER_L_DONE 0x40 +#define VIDEO_COMPOSER_R_DONE 0x80 +#define VIDEO_COMPOSER_DONE 0xC0 #define VIDEO_STAGE_NO_VIDEO 0x00 #define VIDEO_STAGE_BEFORE_VIDEO 0x01 @@ -33,7 +39,8 @@ class servaVideoComposer: public basicThread { basicLogCollection * m_pLog; serverDataBinder * m_pDBC; DBC_MEDIA_COMPOSER_DATA m_sComposerSettings; - uint8_t m_bStatus; + uint8_t m_bComposerStatus; + uint64_t m_nSessionID; uint8_t m_bLStage; uint8_t m_bRStage; uint64_t m_uLModuleID; @@ -42,14 +49,18 @@ class servaVideoComposer: public basicThread { SESSION_DATA * m_pSessionData; V_VP_INFO m_vLVideoQueue; V_VP_INFO m_vRVideoQueue; + char m_cLOutPath[MAX_PATH_LEN]; + char m_cROutPath[MAX_PATH_LEN]; bool loadLeftQueue(); bool loadRightQueue(); + void finishupCompose(); protected: virtual void m_fThreadProc(void); public: explicit servaVideoComposer( uint64_t session_id ); ~servaVideoComposer(); + bool compose(); uint8_t getStatus(); -} +}; #endif \ No newline at end of file diff --git a/lib/components/base/basicCameraInfo.cpp b/lib/components/base/basicCameraInfo.cpp index a18c8b36..161d25a8 100644 --- a/lib/components/base/basicCameraInfo.cpp +++ b/lib/components/base/basicCameraInfo.cpp @@ -29,7 +29,7 @@ float calcMaxDistance_inch(float SensorSize, float MaxFL, int ImageWidth) float tFOV, tt; tFOV = calcFOV_inch(SensorSize, MaxFL); tt = tFOV / ((float) ImageWidth); // 1 pixel - return .01 / tanf(tt / 2.0f); // return Distance in meters to see 1 cm as 1 pixel + return .01f / tanf(tt / 2.0f); // return Distance in meters to see 1 cm as 1 pixel } float calcMaxDistance_mm(float SensorSize, float MaxFL, int ImageWidth) @@ -37,7 +37,8 @@ float calcMaxDistance_mm(float SensorSize, float MaxFL, int ImageWidth) float tFOV, tt; tFOV = calcFOV_mm(SensorSize, MaxFL); tt = tFOV / ((float) ImageWidth); // 1 pixel - return .01 / tanf(tt / 2.0f); // return Distance in meters to see 1 cm as 1 pixel + return .01f / tanf(tt / 2.0f); // return Distance in meters to see 1 cm as 1 pixel + // i.e the (ImageWidth / 100) meters in width will be visible in the frame } float calcMinDistance_mm(float SensorSize, float MaxFL, int ImageWidth) @@ -45,16 +46,23 @@ float calcMinDistance_mm(float SensorSize, float MaxFL, int ImageWidth) float tFOV, tt; tFOV = calcFOV_mm(SensorSize, MaxFL); tt = tFOV / ((float) ImageWidth); // 1 pixel - return (0.01 / tanf(tt / 2.0f)) / 1.5f; // return Distance in meters to see 150 cm as ImageWidth pixel + //There was error of calculating + return (.01f / tanf(tt / 2.0f)) /(ImageWidth/150.0f); // return Distance in meters to see 150 cm as ImageWidth pixels + // i.e 1.5 meters in width will be visible in the frame } float calcFL_deg(float SensorSize, float FOV) { - return SensorSize / (2.0f * tanf(/*deg2rad(*/ FOV /*)*/ / 2.0f)); + return SensorSize / (2.0f * tanf( deg2rad(FOV) / 2.0f)); +} + +float calcFL_rad(float SensorSize, float FOV) +{ + return SensorSize / (2.0f * tanf( FOV / 2.0f)); } float calcCFL(float SensorSize, float Distance ) { - float tFOV = 2.0f * atanf(0.01f / Distance); - return calcFL_deg(SensorSize, tFOV) / 1000.0f; // in mm + float tFOV = 2.0f * atanf(.01f / Distance); + return calcFL_rad(SensorSize, tFOV) / 1000.0f; // in mm } diff --git a/lib/components/base/basicCameraInfo.h b/lib/components/base/basicCameraInfo.h index e8942309..c3fa6324 100644 --- a/lib/components/base/basicCameraInfo.h +++ b/lib/components/base/basicCameraInfo.h @@ -122,6 +122,7 @@ float calcMinDistance_mm(float SensorSize, float MaxFL, int ImageWidth); float calcFOV_inch(float SensorSize, float FN); float calcFOV_mm(float SensorSize, float FN); float calcFL_deg(float SensorSize, float FOV); +float calcFL_rad(float SensorSize, float FOV); float calcCFL(float SensorSize, float Distance ); // bool loadCameraInfo(basicCameraInfo &nfo, ); diff --git a/lib/components/base/basicEventHeap.cpp b/lib/components/base/basicEventHeap.cpp index 5db0da02..649c512b 100644 --- a/lib/components/base/basicEventHeap.cpp +++ b/lib/components/base/basicEventHeap.cpp @@ -77,6 +77,7 @@ void basicEventHeap::m_fThreadProc(void) basicEventHandler * mpHandler = NULL; EVENT_CONTAINER * mpEvent = NULL; m_bThreadStatus = TH_WORKING; + pthread_setname_np( pthread_self(), "EventHeap" ); while (m_bThreadStatus < TH_ENDED) { if (m_bThreadStatus == TH_WORKING) diff --git a/lib/components/base/basicLIBAV.cpp b/lib/components/base/basicLIBAV.cpp index 0aa64e08..c52428b7 100644 --- a/lib/components/base/basicLIBAV.cpp +++ b/lib/components/base/basicLIBAV.cpp @@ -1,3 +1,5 @@ +#ifndef LRF_PROXY_ONLY + #include "basicLIBAV.h" #ifdef WIN32 #pragma comment(lib, "avcodec.lib") @@ -107,3 +109,5 @@ AVFrame * cvmatToAvframe(cv::Mat * image, AVFrame * frame) } #undef LOG + +#endif // !LRF_PROXY_ONLY diff --git a/lib/components/base/basicLIBAV.h b/lib/components/base/basicLIBAV.h index bc2a9a73..d5e0d826 100644 --- a/lib/components/base/basicLIBAV.h +++ b/lib/components/base/basicLIBAV.h @@ -1,6 +1,7 @@ #ifndef __BASICLIBAV_H_INCL__ #define __BASICLIBAV_H_INCL__ +#ifndef LRF_PROXY_ONLY #ifndef __linux__ #include #include @@ -179,5 +180,5 @@ bool initLibAV(void); cv::Mat avframeToCvmat(const AVFrame * frame); AVFrame * cvmatToAvframe(cv::Mat * image, AVFrame * frame); - +#endif // !LRF_PROXY_ONLY #endif // __BASICLIBAV_H_INCL__ diff --git a/lib/components/base/basicNCursesEngine.cpp b/lib/components/base/basicNCursesEngine.cpp index dae95d94..bbd8bb5c 100644 --- a/lib/components/base/basicNCursesEngine.cpp +++ b/lib/components/base/basicNCursesEngine.cpp @@ -165,6 +165,7 @@ void basicNCursesEngine::m_fThreadProc(void) { int counter = 0; int ch; + pthread_setname_np(pthread_self(), "basicNCursesEngine"); m_bThreadStatus = TH_WORKING; while (m_bThreadStatus < TH_ENDED) { diff --git a/lib/components/base/basicPosition.cpp b/lib/components/base/basicPosition.cpp index c2f0f8d7..2859c0b3 100644 --- a/lib/components/base/basicPosition.cpp +++ b/lib/components/base/basicPosition.cpp @@ -6,6 +6,7 @@ position3D::position3D() { x = y = z = lat = lon = rot_x = rot_y = rot_z = speed = 0.f; utmZone = 0; + SouthHemisphere = false; } position3D::position3D(C3D_WGS84_LOC loc, C3D_ORIENT_DEG orient) @@ -14,6 +15,7 @@ position3D::position3D(C3D_WGS84_LOC loc, C3D_ORIENT_DEG orient) lat = loc.lat; lon = loc.lon; z = loc.alt; + SouthHemisphere = (lat < 0.0); #ifdef FLOAT_64 double A, B; CC.LatLonToUTMXY(lat, lon, utmZone, A, B); @@ -33,6 +35,7 @@ position3D::position3D(C3D_WGS84_LOC loc, C3D_ORIENT_RAD orient) lat = loc.lat; lon = loc.lon; z = loc.alt; + SouthHemisphere = (lat < 0.0); #ifdef FLOAT_64 double A, B; CC.LatLonToUTMXY(lat, lon, utmZone, A, B); @@ -46,27 +49,28 @@ position3D::position3D(C3D_WGS84_LOC loc, C3D_ORIENT_RAD orient) rot_z = orient.rot_z; } -position3D::position3D(int UTM_Zone, C3D_DECART loc, C3D_ORIENT_DEG orient) +position3D::position3D( bool shs, int UTM_Zone, C3D_DECART loc, C3D_ORIENT_DEG orient) { coordConverter CC; utmZone = UTM_Zone; x = loc.x; y = loc.y; z = loc.z; + SouthHemisphere = shs; #ifdef FLOAT_64 double A, B; - CC.UTMXYToLatLon(x, y, utmZone, A, B); + CC.UTMXYToLatLon(x, y, utmZone, SouthHemisphere, A, B); lat = A; lon = B; #else - CC.UTMXYToLatLon(x, y, utmZone, false, lat, lon); + CC.UTMXYToLatLon(x, y, utmZone, SouthHemisphere, lat, lon); #endif rot_x = deg2rad(orient.rot_x); rot_y = deg2rad(orient.rot_y); rot_z = deg2rad(orient.rot_z); } -position3D::position3D(int UTM_Zone, C3D_DECART loc, C3D_ORIENT_RAD orient) +position3D::position3D( bool shs, int UTM_Zone, C3D_DECART loc, C3D_ORIENT_RAD orient) { coordConverter CC; utmZone = UTM_Zone; @@ -75,11 +79,11 @@ position3D::position3D(int UTM_Zone, C3D_DECART loc, C3D_ORIENT_RAD orient) z = loc.z; #ifdef FLOAT_64 double A, B; - CC.UTMXYToLatLon(x, y, utmZone, A, B); + CC.UTMXYToLatLon(x, y, utmZone, SouthHemisphere, A, B); lat = A; lon = B; #else - CC.UTMXYToLatLon(x, y, utmZone, false, lat, lon); + CC.UTMXYToLatLon(x, y, utmZone, SouthHemisphere, lat, lon); #endif rot_x = orient.rot_x; rot_y = orient.rot_y; @@ -94,17 +98,18 @@ void position3D::setPositionWGS84(C3D_FLOAT Lat, C3D_FLOAT Lon, C3D_FLOAT Alt) lat = Lat; lon = Lon; z = Alt; + SouthHemisphere = ( Lat < 0.0 ); #ifdef FLOAT_64 double A, B; - CC.LatLonToUTMXY(lat, lon, utmZone, A, B); + utmZone = CC.LatLonToUTMXY(lat, lon, 0, A, B); x = A; y = B; #else - CC.LatLonToUTMXY(lat, lon, utmZone, x, y); + utmZone = CC.LatLonToUTMXY(lat, lon, 0, x, y); #endif } -void position3D::setPositionXYZ(C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, int zone) +void position3D::setPositionXYZ(C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, bool shs, int zone ) { coordConverter CC; if (zone != 0) @@ -114,13 +119,14 @@ void position3D::setPositionXYZ(C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, int zone) x = X; y = Y; z = Z; + SouthHemisphere = shs; #ifdef FLOAT_64 double A, B; - CC.UTMXYToLatLon(x, y, utmZone, false, A, B); + CC.UTMXYToLatLon(x, y, utmZone, SouthHemisphere, A, B); lat = A; lon = B; #else - CC.UTMXYToLatLon(x, y, utmZone, false, lat, lon); + CC.UTMXYToLatLon(x, y, utmZone, SouthHemisphere, lat, lon); #endif } @@ -224,16 +230,16 @@ basicPosition::basicPosition(C3D_WGS84_LOC loc, C3D_ORIENT_RAD orient) : updateMatrix(); } -basicPosition::basicPosition(int UTM_Zone, C3D_DECART loc, C3D_ORIENT_DEG orient) : - position3D(UTM_Zone, loc, orient) +basicPosition::basicPosition(bool shs, int UTM_Zone, C3D_DECART loc, C3D_ORIENT_DEG orient) : + position3D(shs, UTM_Zone, loc, orient) { m_pTransform = NULL; position3D::setSpeed(0.0f); updateMatrix(); } -basicPosition::basicPosition(int UTM_Zone, C3D_DECART loc, C3D_ORIENT_RAD orient) : - position3D(UTM_Zone, loc, orient) +basicPosition::basicPosition(bool shs, int UTM_Zone, C3D_DECART loc, C3D_ORIENT_RAD orient) : + position3D(shs, UTM_Zone, loc, orient) { m_pTransform = NULL; position3D::setSpeed(0.0f); diff --git a/lib/components/base/basicPosition.h b/lib/components/base/basicPosition.h index 9813e31f..fbe084e4 100644 --- a/lib/components/base/basicPosition.h +++ b/lib/components/base/basicPosition.h @@ -18,14 +18,15 @@ class position3D C3D_FLOAT rot_z; /* Orientation rad */ C3D_FLOAT speed; /* AUX meters per second */ int utmZone; + bool SouthHemisphere; public: position3D(); position3D(C3D_WGS84_LOC loc, C3D_ORIENT_DEG orient); position3D(C3D_WGS84_LOC loc, C3D_ORIENT_RAD orient); - position3D(int UTM_Zone, C3D_DECART loc, C3D_ORIENT_DEG orient); - position3D(int UTM_Zone, C3D_DECART loc, C3D_ORIENT_RAD orient); + position3D( bool shs, int UTM_Zone, C3D_DECART loc, C3D_ORIENT_DEG orient); + position3D( bool shs, int UTM_Zone, C3D_DECART loc, C3D_ORIENT_RAD orient); virtual ~position3D(); C3D_FLOAT getLat(void) @@ -99,10 +100,14 @@ class position3D return utmZone; } + bool getSH(){ + return SouthHemisphere; + } + void setPositionWGS84(C3D_FLOAT Lat, C3D_FLOAT Lon, C3D_FLOAT Alt = 0.0f); - void setPositionXYZ(C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, int zone = 0); - void setPosition(C3D_WGS84_LOC pos); - void setPosition(C3D_DECART pos); + void setPositionXYZ(C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, bool shs = false, int zone = 0); + //void setPosition(C3D_WGS84_LOC pos);?? + //void setPosition(C3D_DECART pos);?? // void setPositionRadial( float Azimuth, float Elevation, float Range, int zone = 0 ); void setOrientationDeg(C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ); void setOrientationRad(C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ); @@ -142,8 +147,8 @@ class basicPosition : public position3D basicPosition & operator=(const basicPosition & src); basicPosition(C3D_WGS84_LOC loc, C3D_ORIENT_DEG orient); basicPosition(C3D_WGS84_LOC loc, C3D_ORIENT_RAD orient); - basicPosition(int UTM_Zone, C3D_DECART loc, C3D_ORIENT_DEG orient); - basicPosition(int UTM_Zone, C3D_DECART loc, C3D_ORIENT_RAD orient); + basicPosition(bool shs, int UTM_Zone, C3D_DECART loc, C3D_ORIENT_DEG orient); + basicPosition(bool shs, int UTM_Zone, C3D_DECART loc, C3D_ORIENT_RAD orient); basicPosition(float lat, float lon, float alt = 0.0f, float h_x = 0.0f, float h_y = 0.0f, float h_z = 0.0f, float speed = 0.0f); void setPositionRad(float lat, float lon, float alt = 0.0f, float h_x = 0.0f, float h_y = 0.0f, float h_z = 0.0f, float speed = 0.0f); void setPositionDeg(float lat, float lon, float alt = 0.0f, float h_x = 0.0f, float h_y = 0.0f, float h_z = 0.0f, float speed = 0.0f); diff --git a/lib/components/base/basicTypes.h b/lib/components/base/basicTypes.h index b03fc890..d550071e 100644 --- a/lib/components/base/basicTypes.h +++ b/lib/components/base/basicTypes.h @@ -618,6 +618,29 @@ typedef struct S_SOL_PORT_SETTINGS uint8_t nFlowCtrl; } SOL_PORT_SETTINGS; +#define KAFKA_TPL_SUBST_ID "%%ID%%" +#define KAFKA_TPL_SUBST_UUID "%%UUID%%" +#define KAFKA_TPL_SUBST_TS "%%TIMESTAMP%%" +#define KAFKA_TPL_SUBST_AZ "%%AZIMUTH%%" +#define KAFKA_TPL_SUBST_RANGE "%%RANGE%%" +#define KAFKA_TPL_SUBST_EL "%%ELEVATION%%" +#define KAFKA_TPL_SUBST_WIDTH "%%WIDTH%%" +#define KAFKA_TPL_SUBST_LON "%%LON%%" +#define KAFKA_TPL_SUBST_LAT "%%LAT%%" +#define KAFKA_TPL_SUBST_ALT "%%ALT%%" +#define KAFKA_TPL_SUBST_EXEVTD "%%EXEVTID%%" +#define KAFKA_TPL_SUBST_SRC_LON "%%SRC_LON%%" +#define KAFKA_TPL_SUBST_SRC_LAT "%%SRC_LAT%%" +#define KAFKA_TPL_SUBST_SRC_ALT "%%SRC_ALT%%" +#define KAFKA_TPL_SUBST_SRC_ROT_X "%%SRC_ROT_X%%" +#define KAFKA_TPL_SUBST_SRC_ROT_Y "%%SRC_ROT_Y%%" +#define KAFKA_TPL_SUBST_SRC_ROT_Z "%%SRC_ROT_Z%%" +#define KAFKA_TPL_SUBST_SRC_IP "%%SRC_IP%%" +#define KAFKA_TPL_SUBST_SRV_IP "%%SRV_IP%%" +#define KAFKA_TPL_SUBST_SRV_NAME "%%SRV_NAME%%" +#define KAFKA_TPL_SUBST_SRC_NAME "%%SRC_NAME%%" +#define KAFKA_TPL_SUBST_MSG_UUID "%%MUID%%" + typedef struct S_KAFKA_SETTINGS { char brocker_addr[256]; @@ -639,4 +662,16 @@ typedef struct S_KAFKA_TEMPLATE CSTR tpl; } KAFKA_TEMPLATE; +typedef struct S_REST_SETTINGS{ + char server_ip[48]; + char server_name[48]; + uint16_t port; +}REST_SETTINGS; + +typedef struct S_REST_TEMPLATE +{ + char endpoint[128]; + CSTR tpl; +} REST_TEMPLATE; + #endif diff --git a/lib/components/base/basicVideoAnalyzer.cpp b/lib/components/base/basicVideoAnalyzer.cpp index e06d72bf..abfa35c9 100644 --- a/lib/components/base/basicVideoAnalyzer.cpp +++ b/lib/components/base/basicVideoAnalyzer.cpp @@ -24,6 +24,7 @@ void basicVideoAnalyzer::m_fThreadProc(void) { int RetVal; m_bThreadStatus = TH_WORKING; + pthread_setname_np(pthread_self(), "basicVideoAnalizer"); while (m_bThreadStatus < TH_ENDED) { while (! m_bDataIsActive && m_bThreadStatus < TH_ENDED) diff --git a/lib/components/object/objectCameraPTZ.cpp b/lib/components/object/objectCameraPTZ.cpp index b260030c..44667413 100644 --- a/lib/components/object/objectCameraPTZ.cpp +++ b/lib/components/object/objectCameraPTZ.cpp @@ -680,6 +680,7 @@ void objectCameraPTZ::m_fThreadProc(void) uint32_t counter = 0; m_bThreadStatus = TH_WORKING; m_ePTZDriveStatus = 0; + pthread_setname_np(pthread_self(), "objectCameraPTZ"); while (m_bThreadStatus < TH_ENDED) { if (m_pProtocol != NULL) diff --git a/lib/components/object/objectFlyHunter.cpp b/lib/components/object/objectFlyHunter.cpp index de66fd08..28c60749 100644 --- a/lib/components/object/objectFlyHunter.cpp +++ b/lib/components/object/objectFlyHunter.cpp @@ -220,6 +220,7 @@ void objectFlyHunter::m_fThreadProc(void) FH_COMMAND * pCMD = NULL; m_bThreadStatus = TH_WORKING; + pthread_setname_np(pthread_self(), "objectFlyHunter"); while (m_bThreadStatus < TH_ENDED) { if (m_qQueuedCommands.size()) diff --git a/lib/components/object/objectSystemAnchor.cpp b/lib/components/object/objectSystemAnchor.cpp index 1fde8cb6..ceb7cc79 100644 --- a/lib/components/object/objectSystemAnchor.cpp +++ b/lib/components/object/objectSystemAnchor.cpp @@ -15,26 +15,24 @@ systemAnchor * systemAnchor::_instance = 0; /** * Returns the single instance of the object. */ -systemAnchor * systemAnchor::getInstance(bool SOUTH, C3D_WGS84_LOC * ptr, bool jl) +systemAnchor * systemAnchor::getInstance( C3D_WGS84_LOC * ptr, bool beJustLocal) { // check if the instance has been created yet if (0 == _instance) { // if not, then create it - _instance = new systemAnchor(SOUTH, ptr, jl); + _instance = new systemAnchor( ptr, beJustLocal ); } // return the single instance return _instance; } -systemAnchor::systemAnchor(bool SOUTH, C3D_WGS84_LOC * ptr, bool beJustLocal) : - m_SCC() +systemAnchor::systemAnchor( C3D_WGS84_LOC *ptr, bool beJustLocal ) : + m_SCC(), position3D() { config_setting_t * pSetting; m_pSettings = NULL; - m_bSouthHemisphere = 0; m_bUseJustLocalDiffCoords = beJustLocal; - m_bSouthHemisphere = SOUTH; if (ptr == NULL) { pSetting = basicSettingsProvider::getInstance()->getSubNode(NULL, "APPLICATION_GUI"); @@ -81,18 +79,6 @@ systemAnchor::systemAnchor(bool SOUTH, C3D_WGS84_LOC * ptr, bool beJustLocal) : { z = config_setting_get_float(pSetting); }; - pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_SOUTH_HS); - if (pSetting == NULL) - { - m_bSouthHemisphere = false; - pSetting = config_setting_add(m_pSettings, TAG_POSITION_SOUTH_HS, CONFIG_TYPE_BOOL); - config_setting_set_bool(pSetting, m_bSouthHemisphere); - basicSettingsProvider::getInstance()->compromise(); - } - else - { - m_bSouthHemisphere = config_setting_get_bool(pSetting); - }; pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LOCAL); if (pSetting == NULL) { @@ -105,14 +91,15 @@ systemAnchor::systemAnchor(bool SOUTH, C3D_WGS84_LOC * ptr, bool beJustLocal) : { m_bUseJustLocalDiffCoords = config_setting_get_bool(pSetting); }; -#ifdef FLOAT_64 - double A, B; - utmZone = CC.LatLonToUTMXY(lat, lon, 0, A, B); - x = A; - y = B; -#else - utmZone = m_SCC.LatLonToUTMXY(lat, lon, m_bSouthHemisphere, x, y); -#endif +//#ifdef FLOAT_64 +// double A, B; +// utmZone = CC.LatLonToUTMXY(lat, lon, 0, A, B); +// x = A; +// y = B; +//#else +// utmZone = m_SCC.LatLonToUTMXY(lat, lon, 0, x, y); +//#endif + position3D::setPositionWGS84( lat, lon, z ); basicSettingsProvider::getInstance()->validate(); }; } @@ -129,14 +116,15 @@ systemAnchor::systemAnchor(bool SOUTH, C3D_WGS84_LOC * ptr, bool beJustLocal) : lat = ptr->lat; lon = ptr->lon; z = ptr->alt; -#ifdef FLOAT_64 - double A, B; - utmZone = CC.LatLonToUTMXY(lat, lon, 0, A, B); - x = A; - y = B; -#else - utmZone = m_SCC.LatLonToUTMXY(lat, lon, m_bSouthHemisphere, x, y); -#endif +//#ifdef FLOAT_64 +// double A, B; +// utmZone = CC.LatLonToUTMXY(lat, lon, 0, A, B); +// x = A; +// y = B; +//#else +// utmZone = m_SCC.LatLonToUTMXY(lat, lon, 0, x, y); +//#endif + position3D::setPositionWGS84( lat, lon, z ); }; }; #ifdef DEBUG @@ -147,7 +135,7 @@ systemAnchor::systemAnchor(bool SOUTH, C3D_WGS84_LOC * ptr, bool beJustLocal) : } else { - sprintf(tBuff, "Anchor is WGS84[lat:%0.6f Lon:%0.6f Alt:%0.6f] UMTS[x:%0.4f y:%0.4f z:%0.4f]", lat, lon, z, x, y, z); + sprintf(tBuff, "Anchor is WGS84[lat:%0.6f Lon:%0.6f Alt:%0.6f] UMTS[x:%0.4f y:%0.4f z:%0.4f] HS:%d", lat, lon, z, x, y, z, SouthHemisphere ); }; LOG(tBuff); #endif @@ -220,7 +208,7 @@ systemAnchor::~systemAnchor() */ } -bool systemAnchor::convertToLocal(basicPosition * SP, C3D_WGS84_LOC POS, C3D_SPH_DEGREES & LOC) +bool systemAnchor::convertToLocal( basicPosition * SP, C3D_WGS84_LOC POS, C3D_SPH_DEGREES & LOC) { if (SP == NULL) { @@ -242,7 +230,7 @@ bool systemAnchor::convertToLocal(basicPosition * SP, C3D_WGS84_LOC POS, C3D_SPH return true; } -bool systemAnchor::convertToLocal(basicPosition * SP, C3D_WGS84_LOC POS, C3D_SPH_RADIANS & LOC) +bool systemAnchor::convertToLocal( basicPosition * SP, C3D_WGS84_LOC POS, C3D_SPH_RADIANS & LOC) { if (SP == NULL) { @@ -457,7 +445,7 @@ bool systemAnchor::convertToGlobal(basicPosition * SP, C3D_SPH_DEGREES POS, C3D_ tDec.y = B[1] + SP->getY() - getY(); // tDec.z = B[2] + SP->getZ(); tDec.z = B[2] + SP->getZ() - getZ(); - m_SCC.UTMXYToLatLon(tDec.x, tDec.y, getUTMZone(), m_bSouthHemisphere, LOC.lat, LOC.lon); + m_SCC.UTMXYToLatLon(tDec.x, tDec.y, utmZone, SouthHemisphere, LOC.lat, LOC.lon); LOC.alt = tDec.z; return true; } @@ -482,7 +470,7 @@ bool systemAnchor::convertToGlobal(basicPosition * SP, C3D_SPH_RADIANS POS, C3D_ tDec.y = B[1] + SP->getY() - getY(); // tDec.z = B[2] + SP->getZ(); tDec.z = B[2] + SP->getZ() - getZ(); - m_SCC.UTMXYToLatLon(tDec.x, tDec.y, getUTMZone(), m_bSouthHemisphere, LOC.lat, LOC.lon); + m_SCC.UTMXYToLatLon(tDec.x, tDec.y, utmZone, SouthHemisphere, LOC.lat, LOC.lon); LOC.alt = tDec.z; return true; } @@ -497,7 +485,7 @@ bool systemAnchor::convertToGlobal(basicPosition * SP, C3D_DECART POS, C3D_WGS84 tDec.x = POS.x + getX(); tDec.y = POS.y + getY(); tDec.z = POS.z + getZ(); - m_SCC.UTMXYToLatLon(tDec.x, tDec.y, getUTMZone(), m_bSouthHemisphere, LOC.lat, LOC.lon); + m_SCC.UTMXYToLatLon(tDec.x, tDec.y, utmZone, SouthHemisphere, LOC.lat, LOC.lon); LOC.alt = tDec.z; return true; } diff --git a/lib/components/object/objectSystemAnchor.h b/lib/components/object/objectSystemAnchor.h index c5393099..eec395a5 100644 --- a/lib/components/object/objectSystemAnchor.h +++ b/lib/components/object/objectSystemAnchor.h @@ -21,12 +21,11 @@ class systemAnchor : public position3D config_setting_t * m_pSettings; coordConverter m_SCC; - bool m_bSouthHemisphere; bool m_bUseJustLocalDiffCoords; public: - static systemAnchor * getInstance(bool SOUTH = false, C3D_WGS84_LOC * ptr = NULL, bool jl = false); + static systemAnchor * getInstance( C3D_WGS84_LOC * ptr = NULL, bool just_local = false); virtual ~systemAnchor(void); // local - C3D_SPH_RADIANS/C3D_SPH_DEGREES @@ -56,7 +55,7 @@ class systemAnchor : public position3D protected: - explicit systemAnchor(bool SOUTH, C3D_WGS84_LOC * ptr, bool beJustLocal); + explicit systemAnchor( C3D_WGS84_LOC *ptr, bool beJustLocal); }; #endif diff --git a/lib/data/curl/curlRequestsManager.cpp b/lib/data/curl/curlRequestsManager.cpp index ec9d7bc2..e1310377 100644 --- a/lib/data/curl/curlRequestsManager.cpp +++ b/lib/data/curl/curlRequestsManager.cpp @@ -65,6 +65,7 @@ void curlRequestsManager::m_fThreadProc(void) #ifdef DEBUG LOG("Starting Finished Requests Reaper"); #endif + pthread_setname_np( pthread_self(), "cURL Manager" ); // BugCurl Multi cannot starty if MR = empty .... m_bThreadStatus = TH_WORKING; while ((m_bThreadStatus < TH_ENDED) && ! bProceedThread) diff --git a/lib/data/media/video/videoAVLIBSource.cpp b/lib/data/media/video/videoAVLIBSource.cpp index f545143e..e05c1159 100644 --- a/lib/data/media/video/videoAVLIBSource.cpp +++ b/lib/data/media/video/videoAVLIBSource.cpp @@ -1,5 +1,7 @@ #include "videoAVLIBSource.h" +#ifndef LRF_PROXY_ONLY + #include "libavutil/error.h" #define LOG(X) m_pLog->Log("LibAV_SRC", this, X) @@ -919,7 +921,7 @@ void videoAVLIBSource::m_fThreadProc(void) */ m_bThreadStatus = TH_WORKING; - + pthread_setname_np(pthread_self(), "AVLib Source"); //AVPacket Packet; //av_init_packet(&Packet); // Optional in newer API AVPacket *Packet = av_packet_alloc(); @@ -1170,3 +1172,5 @@ bool videoAVLIBSource::isFinished(void) #undef LOG #undef LOG_ERROR + +#endif //! LRF_PROXY_ONLY diff --git a/lib/data/media/video/videoAVLIBSource.h b/lib/data/media/video/videoAVLIBSource.h index 6b57c985..250c6519 100644 --- a/lib/data/media/video/videoAVLIBSource.h +++ b/lib/data/media/video/videoAVLIBSource.h @@ -1,6 +1,8 @@ #ifndef __VIDEOAVLIBSOURCE_H_INCL__ #define __VIDEOAVLIBSOURCE_H_INCL__ +#ifndef LRF_PROXY_ONLY + #include "../../../alg/generic/md5.h" #include "../../../components/base/basicLIBAV.h" #include "../../../components/base/basicLogCollection.h" @@ -62,4 +64,6 @@ class videoAVLIBSource : public basicMediaSource, public basicThread bool setFrameAspectRatio(FrameAspectRatio AspectRatio); }; +#endif //!LRF_PROXY_ONLY + #endif // __VIDEOAVLIBSOURCE_H_INCL__ diff --git a/lib/data/media/video/videoLive555AVLibSource.cpp b/lib/data/media/video/videoLive555AVLibSource.cpp index ab8a5610..14ca9eee 100644 --- a/lib/data/media/video/videoLive555AVLibSource.cpp +++ b/lib/data/media/video/videoLive555AVLibSource.cpp @@ -1,5 +1,7 @@ #include "videoLive555AVLibSource.h" +#ifndef LRF_PROXY_ONLY + #define FF_DISABLE_DEPRECATION_WARNINGS StreamClientState::StreamClientState() : @@ -746,6 +748,7 @@ void videoLIVE555Source::m_fThreadProc(void) LOG("Start Thread"); _eventLoopWatchVariable = 0; m_bThreadStatus = TH_WORKING; + pthread_setname_np(pthread_self(), "Live555 Source"); // while ( m_bThreadStatus == TH_WORKING ) { m_pScheduler->doEventLoop(&_eventLoopWatchVariable); // streamTimerHandler( m_pRtspClient ); @@ -1282,4 +1285,5 @@ bool videoLIVE555Source::setFrameAspectRatio(FrameAspectRatio AspectRatio) #undef LOG_ERROR #undef FF_DISABLE_DEPRECATION_WARNINGS +#endif //!LRF_PROXY_ONLY diff --git a/lib/data/media/video/videoLive555AVLibSource.h b/lib/data/media/video/videoLive555AVLibSource.h index 14f4888d..3be97002 100644 --- a/lib/data/media/video/videoLive555AVLibSource.h +++ b/lib/data/media/video/videoLive555AVLibSource.h @@ -1,6 +1,8 @@ #ifndef __VIDEOLIVE555AVLIBSOURCE_H_INCL__ #define __VIDEOLIVE555AVLIBSOURCE_H_INCL__ +#ifndef LRF_PROXY_ONLY + #include "../../../alg/generic/md5.h" #include "../../../components/base/basicLIBAV.h" #include "../../../components/base/basicLogCollection.h" @@ -220,4 +222,6 @@ class videoLIVE555Source : public basicMediaSource, public basicThread } }; +#endif //!LRF_PROXY_ONLY + #endif diff --git a/lib/data/media/video/videoV4L2Source.cpp b/lib/data/media/video/videoV4L2Source.cpp index 8561f3e6..a8da5702 100644 --- a/lib/data/media/video/videoV4L2Source.cpp +++ b/lib/data/media/video/videoV4L2Source.cpp @@ -1343,6 +1343,7 @@ void videoV4L2Source::m_fThreadProc(void) char tBuffer[256]; m_bThreadStatus = TH_WORKING; LOG("Reader Thread Started."); + pthread_setname_np(pthread_self(), "V4L2 Source"); // cv::setBreakOnError( true ); m_eMediaStatus = MS_STOPED; while (m_pMediaDestination == NULL && m_bThreadStatus == TH_WORKING) diff --git a/lib/data/net/netServer.cpp b/lib/data/net/netServer.cpp index ea4ca5b5..edb0bd48 100644 --- a/lib/data/net/netServer.cpp +++ b/lib/data/net/netServer.cpp @@ -444,6 +444,7 @@ void networkServer::m_fThreadProc(void) LOG("Core Worker Thread Started"); LOG("Ready to Accept Connections"); #endif + pthread_setname_np(pthread_self(), "networkServer"); m_bThreadStatus = TH_WORKING; while (m_bThreadStatus < TH_ENDED) { diff --git a/lib/data/protocol/protocolBVMS.cpp b/lib/data/protocol/protocolBVMS.cpp new file mode 100644 index 00000000..32147733 --- /dev/null +++ b/lib/data/protocol/protocolBVMS.cpp @@ -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 diff --git a/lib/data/protocol/protocolBVMS.h b/lib/data/protocol/protocolBVMS.h new file mode 100644 index 00000000..ce40db2d --- /dev/null +++ b/lib/data/protocol/protocolBVMS.h @@ -0,0 +1,126 @@ +#ifndef __PROTOCOL_BSCH_VMS_HEADER__ +#define __PROTOCOL_BSCH_VMS_HEADER__ + +#ifdef __linux__ + #include +#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 +#include +#include +#include + +//#include "xmlParser.h" + +#include +#include +#include +#include +#include +#include + +#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 diff --git a/lib/data/ssdp/ssdpAnnouncer.cpp b/lib/data/ssdp/ssdpAnnouncer.cpp index ebe1a16c..6239e284 100644 --- a/lib/data/ssdp/ssdpAnnouncer.cpp +++ b/lib/data/ssdp/ssdpAnnouncer.cpp @@ -916,6 +916,7 @@ void ssdpAnnouncer::m_fThreadProc( void ){ char pidBuf[16]; sprintf(pidBuf,"pid:%d", pid); LOG(pidBuf); + pthread_setname_np(pthread_self(), "SSDP Announcer"); m_bThreadStatus = TH_WORKING; while( m_bThreadStatus < TH_ENDED ) { tCurrentTime = time(NULL);