diff --git a/Projects/la_mojo/la_mojo.vpj b/Projects/la_mojo/la_mojo.vpj index 9598f69a..a5cd2c47 100644 --- a/Projects/la_mojo/la_mojo.vpj +++ b/Projects/la_mojo/la_mojo.vpj @@ -560,6 +560,7 @@ + @@ -632,6 +633,7 @@ + diff --git a/Projects/la_mojo/makefile b/Projects/la_mojo/makefile index 496bd8a2..26074241 100644 --- a/Projects/la_mojo/makefile +++ b/Projects/la_mojo/makefile @@ -55,10 +55,11 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.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)/kernelEventFilterTrain.o \ - $(OUTDIR)/kernelModule.o $(OUTDIR)/kernelModuleEmbedVideo.o \ - $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ - $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.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)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -107,10 +108,11 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.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)/kernelEventFilterTrain.o \ - $(OUTDIR)/kernelModule.o $(OUTDIR)/kernelModuleEmbedVideo.o \ - $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ - $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.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)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -250,10 +252,11 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.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)/kernelEventFilterTrain.o \ - $(OUTDIR)/kernelModule.o $(OUTDIR)/kernelModuleEmbedVideo.o \ - $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ - $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.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)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -302,10 +305,11 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.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)/kernelEventFilterTrain.o \ - $(OUTDIR)/kernelModule.o $(OUTDIR)/kernelModuleEmbedVideo.o \ - $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ - $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.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)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -445,10 +449,11 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.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)/kernelEventFilterTrain.o \ - $(OUTDIR)/kernelModule.o $(OUTDIR)/kernelModuleEmbedVideo.o \ - $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ - $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.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)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -497,10 +502,11 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.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)/kernelEventFilterTrain.o \ - $(OUTDIR)/kernelModule.o $(OUTDIR)/kernelModuleEmbedVideo.o \ - $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ - $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.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)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -645,10 +651,11 @@ COMMON_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.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)/kernelEventFilterTrain.o \ - $(OUTDIR)/kernelModule.o $(OUTDIR)/kernelModuleEmbedVideo.o \ - $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ - $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.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)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -697,10 +704,11 @@ ALL_OBJ=$(OUTDIR)/base64.o $(OUTDIR)/basicCameraInfo.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)/kernelEventFilterTrain.o \ - $(OUTDIR)/kernelModule.o $(OUTDIR)/kernelModuleEmbedVideo.o \ - $(OUTDIR)/kernelModuleFactory.o $(OUTDIR)/kernelModuleFlyHunter.o \ - $(OUTDIR)/kernelModuleKafka.o $(OUTDIR)/kernelModuleModemManager.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)/kernelModuleOnvifObserver.o \ $(OUTDIR)/kernelModuleReportBackupper.o $(OUTDIR)/kernelModuleSSDP.o \ $(OUTDIR)/kernelModuleUSBRelay.o $(OUTDIR)/kernelPrototype.o \ @@ -841,7 +849,7 @@ $(OUTDIR)/deviceNodeEthernet2Serial.o: ../../lib/App/common/deviceNodeEthernet2S $(OUTDIR)/deviceNodeFactory.o: ../../lib/App/common/deviceNodeFactory.cpp ../../lib/App/common/deviceNodeFactory.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h ../../lib/App/common/deviceNode3D.h ../../lib/App/common/deviceNode2D.h ../../lib/App/common/deviceNodePTZCamControl.h ../../lib/App/common/deviceNodePresetCamControl.h ../../lib/App/common/deviceNodeStaticCamControl.h ../../lib/App/common/deviceNodeEthernet2Serial.h $(OUTDIR)/deviceNodePresetCamControl.o: ../../lib/App/common/deviceNodePresetCamControl.cpp ../../lib/App/common/deviceNodePresetCamControl.h ../../lib/App/mojo/mojoKernel.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/components/base/basicSettingsProvider.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.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/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/detector.h ../../lib/components/base/basicObject.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicValidatable.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/mask.h ../../lib/components/base/basicTypes.h ../../lib/hardware/soc/general/3DLRF.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/gui/gui.h ../../lib/alg/generic/md5.h ../../lib/App/common/kernelPrototype.h ../../lib/App/mojo/mojoRemoteClient.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/data/net/clientPort.h ../../lib/data/transport/transportSocket.h ../../lib/components/base/basicDualThread.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/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/data/protocol/protocolARGUS_DATA.h ../../lib/App/common/dataBinder.h ../../lib/App/common/dataBinder_structures.h ../../lib/App/common/dataBinder_ReportAux.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h $(OUTDIR)/deviceNodePTZCamControl.o: ../../lib/App/common/deviceNodePTZCamControl.cpp ../../lib/App/common/deviceNodePTZCamControl.h ../../lib/App/mojo/mojoKernel.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/components/base/basicSettingsProvider.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.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/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/detector.h ../../lib/components/base/basicObject.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicValidatable.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/mask.h ../../lib/components/base/basicTypes.h ../../lib/hardware/soc/general/3DLRF.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/gui/gui.h ../../lib/alg/generic/md5.h ../../lib/App/common/kernelPrototype.h ../../lib/App/mojo/mojoRemoteClient.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/data/net/clientPort.h ../../lib/data/transport/transportSocket.h ../../lib/components/base/basicDualThread.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/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/data/protocol/protocolARGUS_DATA.h ../../lib/App/common/dataBinder.h ../../lib/App/common/dataBinder_structures.h ../../lib/App/common/dataBinder_ReportAux.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h -$(OUTDIR)/deviceNodeSensor.o: ../../lib/App/common/deviceNodeSensor.cpp ../../lib/App/common/deviceNodeSensor.h ../../lib/components/object/objectSystemAnchor.h +$(OUTDIR)/deviceNodeSensor.o: ../../lib/App/common/deviceNodeSensor.cpp ../../lib/App/common/deviceNodeSensor.h ../../lib/components/object/objectSystemAnchor.h ../../lib/App/common/kernelPrototype.h $(OUTDIR)/deviceNodeStaticCamControl.o: ../../lib/App/common/deviceNodeStaticCamControl.cpp ../../lib/App/common/deviceNodeStaticCamControl.h $(OUTDIR)/fs_helper.o: ../../lib/data/rfs/fs_helper.cpp ../../lib/data/rfs/fs_helper.h $(OUTDIR)/FSClient.o: ../../lib/data/rfs/FSClient.cpp ../../lib/data/rfs/FSClient.h @@ -858,9 +866,10 @@ $(OUTDIR)/json_value.o: ../../lib/data/json/json_value.cpp ../../lib/data/json/j $(OUTDIR)/json_writer.o: ../../lib/data/json/json_writer.cpp ../../lib/data/json/json_tool.h $(OUTDIR)/kernelEventFilter.o: ../../lib/App/common/kernelEventFilter.cpp ../../lib/App/common/kernelEventFilter.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h $(OUTDIR)/kernelEventFilterAPF.o: ../../lib/App/common/kernelEventFilterAPF.cpp ../../lib/App/common/kernelEventFilterAPF.h +$(OUTDIR)/kernelEventFilterBubble.o: ../../lib/App/common/kernelEventFilterBubble.cpp ../../lib/App/common/kernelEventFilterBubble.h ../../lib/App/common/kernelEventFilter.h ../../lib/App/common/kernelPrototype.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/components/base/basicMutex.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)/kernelModuleEmbedVideo.o: ../../lib/App/common/kernelModuleEmbedVideo.cpp ../../lib/App/common/kernelModuleEmbedVideo.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/kernelModuleUSBRelay.h ../../lib/App/common/kernelModuleKafka.h ../../lib/App/common/kernelModuleFlyHunter.h ../../lib/App/common/kernelModuleSSDP.h ../../lib/App/common/kernelModuleOnvifObserver.h ../../lib/App/common/kernelModuleEmbedVideo.h ../../lib/App/common/kernelModuleModemManager.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 @@ -875,7 +884,7 @@ $(OUTDIR)/mask.o: ../../lib/alg/lgs/mask.cpp ../../lib/alg/lgs/mask.h ../../lib/ $(OUTDIR)/md5.o: ../../lib/alg/generic/md5.cpp ../../lib/alg/generic/md5.h $(OUTDIR)/mojoBackend.o: ../../lib/App/mojo/mojoBackend.cpp ../../lib/App/mojo/mojoBackend.h ../../lib/components/base/basicSettings.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicMemoryOperation.h ../../lib/components/object/objectFileLoggingService.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/App/mojo/mojoKernel.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/components/base/basicSettingsProvider.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.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/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/detector.h ../../lib/components/base/basicObject.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicValidatable.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/mask.h ../../lib/components/base/basicTypes.h ../../lib/hardware/soc/general/3DLRF.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/gui/gui.h ../../lib/alg/generic/md5.h ../../lib/App/common/kernelPrototype.h ../../lib/App/mojo/mojoRemoteClient.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/data/net/clientPort.h ../../lib/data/transport/transportSocket.h ../../lib/components/base/basicDualThread.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/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/data/protocol/protocolARGUS_DATA.h ../../lib/App/common/dataBinder.h ../../lib/App/common/dataBinder_structures.h ../../lib/App/common/dataBinder_ReportAux.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h $(OUTDIR)/mojoKernel.o: ../../lib/App/mojo/mojoKernel.cpp ../../lib/App/mojo/mojoKernel.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/components/base/basicSettingsProvider.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.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/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/detector.h ../../lib/components/base/basicObject.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicValidatable.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/mask.h ../../lib/components/base/basicTypes.h ../../lib/hardware/soc/general/3DLRF.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/gui/gui.h ../../lib/alg/generic/md5.h ../../lib/App/common/kernelPrototype.h ../../lib/App/mojo/mojoRemoteClient.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/data/net/clientPort.h ../../lib/data/transport/transportSocket.h ../../lib/components/base/basicDualThread.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/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/data/protocol/protocolARGUS_DATA.h ../../lib/App/common/dataBinder.h ../../lib/App/common/dataBinder_structures.h ../../lib/App/common/dataBinder_ReportAux.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/App/common/kernelEventFilterAPF.h ../../lib/App/common/kernelEventFilterTrain.h ../../lib/App/common/kernelModuleEmbedVideo.h ../../lib/App/common/MySQL_dataBinder.h ../../lib/App/common/SQLite_dataBinder.h -$(OUTDIR)/mojoRemoteClient.o: ../../lib/App/mojo/mojoRemoteClient.cpp ../../lib/App/mojo/mojoRemoteClient.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/data/net/clientPort.h ../../lib/data/transport/transportSocket.h ../../lib/components/base/basicDualThread.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/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/data/protocol/protocolARGUS_DATA.h ../../lib/App/common/dataBinder.h ../../lib/App/common/dataBinder_structures.h ../../lib/App/common/dataBinder_ReportAux.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/App/mojo/mojoKernel.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/components/base/basicSettingsProvider.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.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/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/detector.h ../../lib/components/base/basicObject.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicValidatable.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/mask.h ../../lib/components/base/basicTypes.h ../../lib/hardware/soc/general/3DLRF.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/gui/gui.h ../../lib/alg/generic/md5.h ../../lib/App/common/kernelPrototype.h ../../lib/App/mojo/mojoRemoteClient.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/data/net/clientPort.h ../../lib/data/transport/transportSocket.h ../../lib/components/base/basicDualThread.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/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/data/protocol/protocolARGUS_DATA.h ../../lib/App/common/dataBinder.h ../../lib/App/common/dataBinder_structures.h ../../lib/App/common/dataBinder_ReportAux.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h +$(OUTDIR)/mojoRemoteClient.o: ../../lib/App/mojo/mojoRemoteClient.cpp ../../lib/App/mojo/mojoRemoteClient.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/data/net/clientPort.h ../../lib/data/transport/transportSocket.h ../../lib/components/base/basicDualThread.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/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/data/protocol/protocolARGUS_DATA.h ../../lib/App/common/dataBinder.h ../../lib/App/common/dataBinder_structures.h ../../lib/App/common/dataBinder_ReportAux.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/App/mojo/mojoKernel.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/components/base/basicSettingsProvider.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/components/base/basicFunctionality.h ../../lib/components/base/basicBuildTimeStamp.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicEventHeap.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.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/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/detector.h ../../lib/components/base/basicObject.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicValidatable.h ../../lib/alg/lgs/detectorStructures.h ../../lib/components/base/basicTypes.h ../../lib/alg/lgs/mask.h ../../lib/components/base/basicTypes.h ../../lib/hardware/soc/general/3DLRF.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/gui/gui.h ../../lib/alg/generic/md5.h ../../lib/App/common/kernelPrototype.h ../../lib/App/mojo/mojoRemoteClient.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/data/net/clientPort.h ../../lib/data/transport/transportSocket.h ../../lib/components/base/basicDualThread.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/components/base/basicTransport.h ../../lib/data/protocol/protocol.h ../../lib/data/protocol/protocolARGUS_DATA.h ../../lib/App/common/dataBinder.h ../../lib/App/common/dataBinder_structures.h ../../lib/App/common/dataBinder_ReportAux.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/App/common/deviceNodeCamera.h ../../lib/App/common/deviceNodeSensor.h ../../lib/App/common/deviceNodeFactory.h $(OUTDIR)/mysql_class.o: ../../lib/data/mysql/mysql_class.cpp ../../lib/data/mysql/mysql_class.h $(OUTDIR)/MySQL_dataBinder.o: ../../lib/App/common/MySQL_dataBinder.cpp ../../lib/App/common/MySQL_dataBinder.h $(OUTDIR)/netClientHandler.o: ../../lib/data/net/netClientHandler.cpp ../../lib/data/net/netClientHandler.h ../../lib/data/protocol/protocol.h ../../lib/components/base/basicEventHandler.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicEvent.h ../../lib/components/base/basicTypes.h ../../lib/components/base/basicPosition.h ../../lib/alg/generic/Transform.h ../../lib/components/base/basicLogCollection.h ../../lib/components/base/basicLoggingService.h ../../lib/components/base/basicRing.h ../../lib/components/base/basicMutex.h ../../lib/data/net/serverPort.h ../../lib/data/transport/transportSocket.h ../../lib/components/base/basicDualThread.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/components/base/basicTransport.h ../../lib/data/net/netServiceEngine.h diff --git a/lib/App/common/dataBinder.h b/lib/App/common/dataBinder.h index 7afcc767..64bb1b4f 100644 --- a/lib/App/common/dataBinder.h +++ b/lib/App/common/dataBinder.h @@ -80,6 +80,7 @@ class dataBinder{ //virtual DBC_INT_LIST * listSockets( uint32_t NodeID ){ return NULL;}; virtual DBC_INT_LIST * listPhonebook( ){ return NULL;}; virtual DBC_INT_LIST * listResources( uint32_t NodeID = 0 ){ return NULL;}; + virtual DBC_INT_LIST * listSensorFilters( uint32_t NodeID = 0 ){ return NULL;}; virtual DBC_INT_LIST * listOlderReportStat( CSTR Y, CSTR M, CSTR D ){ return NULL;}; virtual DBC_INT_LIST * listOlderReportStat( uint32_t TS ){ return NULL;}; virtual simplePolygone * loadLRFMaskVertex( uint32_t vid ){ return NULL;}; diff --git a/lib/App/common/dataBinder_structures.h b/lib/App/common/dataBinder_structures.h index 849a5b4a..c8f7d1da 100644 --- a/lib/App/common/dataBinder_structures.h +++ b/lib/App/common/dataBinder_structures.h @@ -584,7 +584,8 @@ typedef struct S_DBC_FH_DATA{ typedef enum E_TARGET_FILTER_TYPE{ TF_UNDEFINED_FILTER = 0, TF_LA_METRO_TRAIN_FILTER = 1, - TF_AUTHORISED_PEOPLE_FILTER = 2 + TF_AUTHORISED_PEOPLE_FILTER = 2, + TF_BUBBLE_SEGMENTATION_FILTER = 3 }TARGET_FILTER_TYPE; typedef struct S_DBC_TARGET_FLITER_DATA{ @@ -751,10 +752,17 @@ typedef struct S_TRAIN_FILTER_DATA{ uint32_t nUpperSensorRestartTO; #endif #ifdef EFT_MINIMAL_RANGE_SUSPICIOUS - float fMinimalRange; + float fLeftMinimalRange; + float fRightMinimalRange; #endif }TRAIN_FILTER_DATA; +typedef struct S_BUBBLE_FILTER_DATA{ + uint8_t bZoneCount; + uint32_t nUpperSensorID; + uint32_t nBottomSensorID; +}BUBBLE_FILTER_DATA; + typedef struct S_VIDEO_SEGMENT_INFO{ uint32_t stream_id; uint32_t streamTSS; diff --git a/lib/App/common/deviceNode2D.cpp b/lib/App/common/deviceNode2D.cpp index 78237192..dc98795f 100644 --- a/lib/App/common/deviceNode2D.cpp +++ b/lib/App/common/deviceNode2D.cpp @@ -140,6 +140,7 @@ bool device2DSensor::startService() { return false; }; }; +/* if( m_sLRF_DATA.filter_id > 0 ) { #ifdef DEBUG LOG("DEFINED FILTER"); @@ -151,6 +152,8 @@ bool device2DSensor::startService() { }; m_pTargetFilter = AK->getFilter( m_sLRF_DATA.filter_id ); }; +*/ + loadFilters(); LOG("Set Device Status!"); updateDataStatus( ARGUS_DS_DISCONNECTED ); //m_pFSHelper = new FS_IO_HELPER(); @@ -2867,6 +2870,7 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){ #endif EVENT_CONTAINER * bEVT = NULL; TARGET_DATA * tData = prepareTargetData( AZ, RANGE, WIDTH, LRFID ); + /* if( m_pTargetFilter != NULL ) { if( m_pTargetFilter->validateTarget( m_sNodeData.node_id, tData ) ){ free( tData ); @@ -2874,6 +2878,13 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){ cIDX += 6; break; }; + }; + */ + if( filterTargetData( tData ) ){ + free( tData ); + if ( LRF_WM_ALARM != getWM() ) setWM(LRF_WM_ALARM); + cIDX += 6; + break; }; #ifndef SKIP_REAL_TARGETS bEVT = createBasicEvent( m_sNodeData.node_id, m_eEventClass, EVT_TARGET_2D_WHITE, NULL, NULL, tData ); @@ -3034,6 +3045,7 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){ #endif EVENT_CONTAINER * bEVT = NULL; TARGET_DATA * tData = prepareTargetData( AZ, RANGE, WIDTH ); + /* if( m_pTargetFilter != NULL ) { if( m_pTargetFilter->validateTarget( m_sNodeData.node_id, tData ) ){ free( tData ); @@ -3041,6 +3053,13 @@ bool device2DSensor::packetHandler( protocolPackage *Package ){ cIDX += 10; break; }; + }; + */ + if( filterTargetData( tData ) ){ + free( tData ); + if ( LRF_WM_ALARM != getWM() ) setWM(LRF_WM_ALARM); + cIDX += 10; + break; }; #ifndef SKIP_REAL_TARGETS bEVT = createBasicEvent( m_sNodeData.node_id, m_eEventClass, EVT_TARGET_2D_WHITE, NULL, NULL, tData ); @@ -3383,13 +3402,18 @@ void device2DSensor::simulateTarget( void ){ TARGET_DATA * tData = prepareTargetData( AZ, RANGE, WIDTH ); if( tData != NULL ){ + /* if( m_pTargetFilter != NULL ) { if( !m_pTargetFilter->validateTarget( m_sNodeData.node_id, tData ) ){ free( tData ); return; }; + }; + */ + if( filterTargetData( tData ) ){ + free( tData ); + return; }; - EVENT_CONTAINER * bEVT = createBasicEvent( m_sNodeData.node_id, m_eEventClass, EVT_TARGET_2D_WHITE, NULL, NULL, tData ); if (bEVT != NULL) { if( m_sLRF_DATA.prefered_camera_id ) { diff --git a/lib/App/common/deviceNodeSensor.cpp b/lib/App/common/deviceNodeSensor.cpp index a19be371..89514d7e 100644 --- a/lib/App/common/deviceNodeSensor.cpp +++ b/lib/App/common/deviceNodeSensor.cpp @@ -1,5 +1,6 @@ #include "deviceNodeSensor.h" #include "../../components/object/objectSystemAnchor.h" +#include "kernelPrototype.h" #include @@ -202,7 +203,7 @@ deviceNodeSensor::deviceNodeSensor( uint32_t id ):deviceNode( id ),m_oPosition() }; }; - m_pTargetFilter = NULL; + //m_pTargetFilter = NULL; systemAnchor *SA = systemAnchor::getInstance(); if( SA ){ if ( SA->beLocal() ) { @@ -238,7 +239,7 @@ deviceNodeSensor::deviceNodeSensor( DBC_NODE_DATA *Data ):deviceNode( Data ),m_o m_nCommErrorsStatTO = COMMUNICATION_ERROR_STATISTIC_HARVEST_INTERVAL_IN_SECONDS; m_pEventHeap = basicEventHeap::getInstance(); memset( &m_sLRF_DATA, 0, sizeof(DBC_LRF_DATA)); - m_pTargetFilter = NULL; + //m_pTargetFilter = NULL; if( m_pDBC ){ reloadDeviceNodeFromDB(); m_pDBC->updateLRFUnfinishedUploads( m_sLRF_DATA.id ); @@ -249,7 +250,44 @@ deviceNodeSensor::deviceNodeSensor( DBC_NODE_DATA *Data ):deviceNode( Data ),m_o deviceNodeSensor::~deviceNodeSensor(){ - LOG("Finish Destructor!"); + m_vTargetFilters.clear(); +}; + +bool deviceNodeSensor::filterTargetData( TARGET_DATA *ptr ){ + bool RetVal = false; + if ( m_vTargetFilters.size() ) { + for (vectorKernelEventFilters::iterator idx = m_vTargetFilters.begin(); idx != m_vTargetFilters.end(); idx++) { + if( (*idx)->isActive() ) { + if( (*idx)->validateTarget( m_sNodeData.node_id, ptr ) ) { + RetVal = true; + break; + }; + }; + }; + }; + return RetVal; +}; + +bool deviceNodeSensor::loadFilters(){ + if( m_pDBC ){ + kernelPrototype *AK = kernelPrototype::getInstance(); + if( AK==NULL ){ + LOG_ERROR("KERNEL <<< GRAB >>> Failure!"); + return false; + }; + DBC_INT_LIST *IDS = m_pDBC->listSensorFilters(m_sNodeData.aux_id); + if ( IDS ) { + if ( IDS->size() ) { + for ( DBC_INT_LIST::iterator idx = IDS->begin(); idx != IDS->end(); idx++ ) { + kernelEventFilter * tFilter = AK->getFilter( *idx ); + if( tFilter ) m_vTargetFilters.push_back( tFilter ); + }; + }; + delete(IDS); + return true; + }; + }; + return false; }; bool deviceNodeSensor::reloadDeviceNodeFromDB(){ diff --git a/lib/App/common/deviceNodeSensor.h b/lib/App/common/deviceNodeSensor.h index f9cbd83c..d1b99012 100644 --- a/lib/App/common/deviceNodeSensor.h +++ b/lib/App/common/deviceNodeSensor.h @@ -168,7 +168,8 @@ class deviceNodeSensor: public deviceNode, public basicThread{ basicPosition m_oPosition; basicEventHeap * m_pEventHeap; basicEventClassID m_eEventClass; - kernelEventFilter * m_pTargetFilter; + //kernelEventFilter * m_pTargetFilter; + vectorKernelEventFilters m_vTargetFilters; uint8_t m_bOpRetryCnt; uint16_t m_bTimeOutCounter; E_MODES m_bActualDeviceWM; @@ -236,6 +237,8 @@ class deviceNodeSensor: public deviceNode, public basicThread{ void broadcastConnected( void ); void broadcastDisconnected( void ); void broadcastFlip( uint16_t flipCount ); + bool loadFilters(); + bool filterTargetData( TARGET_DATA *ptr ); protected: virtual void m_fThreadProc( void ); public: diff --git a/lib/App/common/kernelEventFilterBubble.cpp b/lib/App/common/kernelEventFilterBubble.cpp new file mode 100644 index 00000000..e77b283e --- /dev/null +++ b/lib/App/common/kernelEventFilterBubble.cpp @@ -0,0 +1,150 @@ +#include "kernelEventFilterBubble.h" + +kernelEventFilterBubble::kernelEventFilterBubble( uint32_t id ):kernelEventFilter( id, TF_BUBBLE_SEGMENTATION_FILTER ){ + m_pLog = basicLogCollection::getInstance(); + BUBBLE_FILTER_DATA *tData = m_pDBC->LoadBubbleFilterData( id ); + if ( tData ) { + memcpy( m_sBubbleFilterData, tData, sizeof(BUBBLE_FILTER_DATA) ); + free( tData ); + }; +}; + +kernelEventFilterBubble::~kernelEventFilterBubble(){ + if ( m_vTargetBubbles.size() ) { + for (V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); idx++) free(*idx); + m_vTargetBubbles.clear(); + }; +}; + +bool kernelEventFilterBubble::createBubble( TARGET_DATA *ptr ){ + TARGET_SEGMENT *tData =(TARGET_SEGMENT*) malloc(sizeof(TARGET_SEGMENT)); + if ( tData ) { + memset( tData, 0, sizeof(TARGET_SEGMENT) ); + tData->boundary = m_sBubbleFilterData.beginning_range; + tData->system_center.x = ptr->system_target.x; + tData->system_center.y = ptr->system_target.y; + tData->system_center.z = ptr->system_target.z; + tData->id = m_pDBC->addRegisteredBubble( tData ); + if( createBubble( tData ) ) return true; + free( tData ); + }; + return false; +}; + +bool kernelEventFilterBubble::createBubble( TARGET_SEGMENT *ptr ){ + if ( ptr == NULL ) return false; + ptr->ttl = getMilliseconds() + m_sBubbleFilterData.ttl; + m_mDataProtector.lock(); + m_vTargetBubbles.push_back( ptr ); + m_mDataProtector.unlock(); + return true; +}; + +bool kernelEventFilterBubble::validate(){ + m_mDataProtector.lock(); + if( m_vTargetBubbles.size() ) { + uint64_t ctx = getMilliseconds(); + for( V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); idx++ ) { + if( !(*idx)->blocked_count < m_sBubbleFilterData.min_block_counts ) { + if ((*idx)->ttl < ctx) { + TARGET_SEGMENT *tData = *idx; + m_vTargetBubbles.erase(idx); + }; + }; + }; + }; + m_mDataProtector.unlock(); +}; + +bool kernelEventFilterBubble::initFilter(){ + tList = m_pDBC->LoadListRegisteredBubbles(); + if ( tList ) { + if ( tList->size() ) { + for ( DBC_INT_LIST::iterator idx = tList->begin(); idx != tList->end(); idx++ ) { + tBubble = m_pDBC->getRegisteredBubble( *idx ); + if ( tBubble ) { + if ( !createBubble( tBubble ) ) { + free( tBubble ); + }; + }; + }; + }; + delete( tList ); + }; +}; + +bool kernelEventFilterBubble::checkBubble( TARGET_SEGMENT *bubble, TARGET_DATA *target ){ + if ( bubble == NULL ) return false; + if ( target == NULL ) return false; + if ( getDistance( bubble->system_center, target->system_target ) > bubble->boundary ) return false; + return true; +}; + +bool kernelEventFilterBubble::updateBubble( TARGET_SEGMENT *bubble, TARGET_DATA *target ){ + if ( bubble == NULL ) return false; + if ( target == NULL ) return false; + bubble->ttl = getMilliseconds() + m_sBubbleFilterData.ttl; + if (bubble->blocked_count < m_sBubbleFilterData.min_block_counts ) { + switch ( m_sBubbleFilterData.method ) { + case TF_BUBBLE_METHOD_FIXED:{ + break; + }; + case TF_BUBBLE_METHOD_FIXED_GROW:{ + break; + }; + case TF_BUBBLE_METHOD_BOUNCE:{ + + break; + }; + case TF_BUBBLE_METHOD_EXTENT:{ + break; + }; + }; + } + return true;//m_pDBC->updateRegisteredBubble(bubble); +}; + +bool kernelEventFilterBubble::blockCurrentActiveBubbles(){ + m_mDataProtector.lock(); + for( V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); idx++ ) { + if( (*idx)->blocked_count < m_sBubbleFilterData.min_block_counts ){ + (*idx)->blocked = true; + (*idx)->blocked_count++; + m_pDBC->updateRegisteredBubble((*idx)); + }; + }; + m_mDataProtector.unlock(); +}; + +bool kernelEventFilterBubble::resetAllBubbles(){ + m_mDataProtector.lock(); + m_pDBC->cleanRegisteredBubbles(); + if ( m_vTargetBubbles.size() ) { + for (V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); idx++) free(*idx); + m_vTargetBubbles.clear(); + }; + m_mDataProtector.unlock(); +}; + +bool kernelEventFilterBubble::validateTarget( uint32_t DevID, TARGET_DATA *ptr ){ + bool RetValue = false; + m_mDataProtector.lock(); + if ( m_vTargetBubbles.size() ) { + for( V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); idx++ ){ + if ( checkBubble ( *idx, ptr ) ) { + updateBubble( *idx, ptr ); + break; + }; + }; + }; + m_mDataProtector.unlock(); + if ( !RetValue ) { + + }; + return RetValue; +}; + +//westlaike 203 +//Nov 8 +//10.134.2.203 + diff --git a/lib/App/common/kernelEventFilterBubble.h b/lib/App/common/kernelEventFilterBubble.h new file mode 100644 index 00000000..598e8f5d --- /dev/null +++ b/lib/App/common/kernelEventFilterBubble.h @@ -0,0 +1,40 @@ +#ifndef __KERNEL_EVENT_FILTER_BUBBLE__ +#define __KERNEL_EVENT_FILTER_BUBBLE__ + +#include "kernelEventFilter.h" +#include "kernelPrototype.h" +#include "../../components/base/basicThread.h" +#include "../../components/base/basicMutex.h" + + +typedef std::vector< TARGET_SEGMENT *> V_TARGET_SEGMENTS; + +#define TF_BUBBLE_METHOD_FIXED 0 +#define TF_BUBBLE_METHOD_FIXED_GROW 1 +#define TF_BUBBLE_METHOD_BOUNCE 2 +#define TF_BUBBLE_METHOD_EXTENT 3 + + +class kernelEventFilterBubble: public kernelEventFilter{ + private: + basicLogCollection * m_pLog; + BUBBLE_FILTER_DATA m_sBubbleFilterData; + basicMutex m_mStateProtector; + basicMutex m_mDataProtector; + V_TARGET_SEGMENTS m_vTargetBubbles; + bool createBubble( TARGET_DATA *ptr ); // From Target First Time + bool createBubble( TARGET_SEGMENT *data ); // From Loaded Data + bool checkBubble( TARGET_SEGMENT *bubble, TARGET_DATA *target ); + bool updateBubble( TARGET_SEGMENT *bubble, TARGET_DATA *target ); + public: + explicit kernelEventFilterBubble( uint32_t id ); + virtual ~kernelEventFilterBubble(); + virtual bool validateTarget( uint32_t DevID, TARGET_DATA *ptr ); + virtual bool initFilter(); + virtual bool stopFilter(); + virtual bool validate(); + bool blockCurrentActiveBubbles(); + bool resetAllBubbles(); +}; + +#endif \ No newline at end of file diff --git a/lib/App/common/kernelEventFilterTrain.cpp b/lib/App/common/kernelEventFilterTrain.cpp index bb643745..60cde865 100644 --- a/lib/App/common/kernelEventFilterTrain.cpp +++ b/lib/App/common/kernelEventFilterTrain.cpp @@ -215,7 +215,15 @@ bool kernelEventFilterTrain::validateTarget( uint32_t DevID, TARGET_DATA *ptr ){ if( m_sBottomZone.SuspiciousUnconfirmed == false ){ // Check New Suspicious #ifdef EFT_MINIMAL_RANGE_SUSPICIOUS - if ( ptr->local_target.r > m_sTrainFilterData.fMinimalRange ) { + float a = sinf( ( ptr->local_target.fi * PI_UTM ) / 360.0f ); + float b = cosf( ( ptr->local_target.fi * PI_UTM ) / 360.0f ); + float cfr; + if( ptr->local_target.fi > 90.0f ) { + cfr = sqrtf( powf( a*(m_sTrainFilterData.fRightMinimalRange+m_sTrainFilterData.fRightMinimalRange)/2.0f, 2.0f) + powf(b*m_sTrainFilterData.fLeftMinimalRange, 2.0f) ); + } else { + cfr = sqrtf( powf( a*(m_sTrainFilterData.fRightMinimalRange+m_sTrainFilterData.fRightMinimalRange)/2.0f, 2.0f) + powf(b*m_sTrainFilterData.fRightMinimalRange, 2.0f) ); + }; + if ( ptr->local_target.r > cfr ) { #endif if ( ptr->area > m_sTrainFilterData.nTrainWidth ) { m_sBottomZone.SuspiciousObject = true; diff --git a/lib/App/common/serverDataBinder.h b/lib/App/common/serverDataBinder.h index 16cd9006..17f8fef7 100644 --- a/lib/App/common/serverDataBinder.h +++ b/lib/App/common/serverDataBinder.h @@ -13,7 +13,7 @@ #define ARGUS_CLOUD_STATUS_NA 0 #define ARGUS_CLOUD_STATUS_REG 1 #define ARGUS_CLOUD_STATUS_ONLINE 2 -#define ARGUS_CLOUD_STATUS_BUSY 3 +#define ARGUS_CLOUD_STATUS_TRAIN 3 #define ARGUS_CLOUD_STATUS_MAINTENENCE 4 #define ARGUS_CLOUD_STATUS_ALARM 5 /*----------- ERRORS -----------------------*/ @@ -165,6 +165,7 @@ class serverDataBinder { virtual uint64_t getBottomLRF( uint64_t id ){ return 0; }; virtual uint32_t getCloudLTS( uint8_t Obj, uint64_t id ){ return 0; }; virtual uint8_t getCloudStatus( uint8_t Obj, uint64_t id ){ return 0; }; + virtual bool getDBLoggingSettings( void ){ return false; }; virtual CSTR getMediaUUID( uint64_t id ){ return NULL; }; virtual MODBUS_MANAGER_DATA * getModBusManagerData(){ return NULL; }; virtual MODBUS_RTU_INFO * getModBusRTU( uint64_t id ){ return NULL; }; @@ -179,6 +180,7 @@ class serverDataBinder { virtual uint64_t getSessionOldest( uint8_t min_lvl = 2 ){ return 0; }; virtual uint64_t getSessionTrackId( uint64_t id ){ return 0; }; virtual DBC_SERVA_CONFIG * getServaConfig( ){ return NULL; }; + virtual uint16_t getSessionTimeOut(){ return 120;}; virtual uint64_t getTrackIdByMojo( uint64_t id ){ return 0;}; virtual SCADA_TRACK_INFO * getTrackSCADA( uint64_t id ){ return NULL;}; virtual uint64_t getUpperLRF( uint64_t id ){ return 0; }; diff --git a/lib/App/common/serverMySQL_dataBinder.cpp b/lib/App/common/serverMySQL_dataBinder.cpp index 8f19f2e7..664d0574 100644 --- a/lib/App/common/serverMySQL_dataBinder.cpp +++ b/lib/App/common/serverMySQL_dataBinder.cpp @@ -530,6 +530,32 @@ uint8_t servaMySQLDBC::getCloudStatus( uint8_t Obj, uint64_t id ){ return RetVal; }; +bool servaMySQLDBC::getDBLoggingSettings( void ){ + bool RetVal = false; + if( m_bIsConnected ){ + char tQBuf[MAX_PATH_LEN]; + AAssoc *result; + sprintf( tQBuf, "SELECT `use_db_logging` 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; + cArr = result->at(0); + it = cArr->find("use_db_logging"); + if( it != cArr->end() ){ + RetVal = (bool) atoi( it->second.c_str() ); + }; + }; + }; + deleteResult( result ); + }; + return RetVal; +}; + uint64_t servaMySQLDBC::getRecentMediaId(){ uint64_t RetVal = 0; if( m_bIsConnected ){ @@ -825,7 +851,34 @@ uint64_t servaMySQLDBC::getSessionOldest( uint8_t min_lvl ){ }; return RetVal; }; - +uint16_t servaMySQLDBC::getSessionTimeOut(){ + uint16_t RetVal = 120; + if( m_bIsConnected ){ + char tQBuf[MAX_PATH_LEN]; + AAssoc *result; + sprintf( tQBuf, "SELECT `session_end` 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; + cArr = result->at(0); + it = cArr->find("session_end"); + if( it != cArr->end() ){ + RetVal = atoi( it->second.c_str() ) - 1; + if ( RetVal ) { + RetVal *=60; + } else RetVal = 30; + }; + }; + }; + deleteResult( result ); + }; + return RetVal; +}; uint64_t servaMySQLDBC::getSessionTrackId( uint64_t id ){ uint64_t RetVal = 0; if( m_bIsConnected ){ diff --git a/lib/App/common/serverMySQL_dataBinder.h b/lib/App/common/serverMySQL_dataBinder.h index 2aebe5ae..76c571ea 100644 --- a/lib/App/common/serverMySQL_dataBinder.h +++ b/lib/App/common/serverMySQL_dataBinder.h @@ -34,6 +34,7 @@ class servaMySQLDBC: public serverDataBinder { virtual uint64_t getBottomLRF( uint64_t id ); 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 CSTR getMediaUUID( uint64_t id ); virtual MODBUS_MANAGER_DATA * getModBusManagerData(); virtual MODBUS_RTU_INFO * getModBusRTU( uint64_t id ); @@ -47,6 +48,7 @@ class servaMySQLDBC: public serverDataBinder { virtual SESSION_DATA * getSessionData( uint64_t id ); virtual uint64_t getSessionOlderThan( uint32_t ts, uint8_t min_lvl = 2 ); virtual uint64_t getSessionOldest( uint8_t min_lvl = 2 ); + virtual uint16_t getSessionTimeOut(); virtual uint64_t getSessionTrackId( uint64_t id ); virtual uint64_t getTrackIdByMojo( uint64_t id ); virtual SCADA_TRACK_INFO * getTrackSCADA( uint64_t id ); diff --git a/lib/App/mojo/mojoRemoteClient.cpp b/lib/App/mojo/mojoRemoteClient.cpp index ca03d223..7e286801 100644 --- a/lib/App/mojo/mojoRemoteClient.cpp +++ b/lib/App/mojo/mojoRemoteClient.cpp @@ -31,7 +31,7 @@ mojoRemoteClient::mojoRemoteClient( mojoKernel * ptr ):protocolParser(){ }; mojoRemoteClient::~mojoRemoteClient(){ - LOG("Destructor"); + LOG("Destructor"); if( m_bRegisteredWithRemotePeer ) { LOG("Flushing"); while ( m_bRegisteredWithRemotePeer ) { @@ -53,6 +53,7 @@ mojoRemoteClient::~mojoRemoteClient(){ }; m_mCurrentVTRProtector.unlock(); }; + setAutomationStage( ARGUS_RPC_STAGE_DISCONNECT ); LOG("Flushing Done!"); waitThreadEnd( true ); flushTransactions(); diff --git a/lib/App/serva/servaBackend.cpp b/lib/App/serva/servaBackend.cpp index 811b0d0e..10303847 100644 --- a/lib/App/serva/servaBackend.cpp +++ b/lib/App/serva/servaBackend.cpp @@ -390,10 +390,13 @@ int main( int argc, char *argv[] ){ //m_pLog->addHandler((_Core_Logging_Service *) new _Core_CLUI()); }; + + uint8_t ExitCode = 0; + SettingsProvider = basicSettingsProvider::getInstance( DCF_NAME ); - Settings = SettingsProvider->getSubNode( NULL, "GENERAL" ); + Settings = SettingsProvider->getSubNode( NULL, "GENERAL" ); - uint8_t ExitCode = 0; + /* bool SSDP_ENABLE = false; config_setting_t * pSetting = NULL; @@ -403,7 +406,9 @@ int main( int argc, char *argv[] ){ config_setting_set_bool( pSetting, SSDP_ENABLE ); basicSettingsProvider::getInstance()->compromise(); LOG("Manufacturer not set - using default"); - }; + }; + */ + /* if(!config_setting_lookup_bool( Settings, "DB_LOG_ENABLE", (int*) &DLE )){ pSetting = config_setting_add( Settings, "DB_LOG_ENABLE", CONFIG_TYPE_BOOL ); DLE = false; @@ -411,6 +416,7 @@ int main( int argc, char *argv[] ){ basicSettingsProvider::getInstance()->compromise(); LOG("DB Logging not set - using default"); }; + */ SettingsProvider->validate(); @@ -425,7 +431,7 @@ int main( int argc, char *argv[] ){ delete( m_pLog ); return -1; }; - if ( DLE ) { + if ( DBC->getDBLoggingSettings() ) { LOG("Adding Database Log Service!"); m_pLog->addHandler((basicLoggingService *) new objectMySQLLoggingService( DBC )); }; diff --git a/lib/App/serva/servaModBusManager.h b/lib/App/serva/servaModBusManager.h index ca99fd47..e6ceaec1 100644 --- a/lib/App/serva/servaModBusManager.h +++ b/lib/App/serva/servaModBusManager.h @@ -28,11 +28,20 @@ class servaKernel; #define IMMIDIATE_ACTION 0 -typedef struct S_MODBUS_ACION_ITEM{ +typedef struct S_MODBUS_MODULE_ITEM{ uint64_t module_id; - uint64_t scheduled_on; uint8_t value; uint8_t mask; +}MODBUS_MODULE_ITEM; + +typedef std::vector V_MODBUS_MODULES_GROUP; + +typedef struct S_MODBUS_ACION_ITEM{ + uint64_t module_id; + //V_MODBUS_MODULES_GROUP ctl_group; + uint64_t scheduled_on; + uint8_t value; + uint8_t mask; }MODBUS_ACION_ITEM; typedef std::vector V_MODBUS_ACION_ITEMS; diff --git a/lib/App/serva/servaRemoteClientHandler.cpp b/lib/App/serva/servaRemoteClientHandler.cpp index c345d342..e7c0e90a 100644 --- a/lib/App/serva/servaRemoteClientHandler.cpp +++ b/lib/App/serva/servaRemoteClientHandler.cpp @@ -1,552 +1,583 @@ -#include "servaRemoteClientHandler.h" -#include "servaRemoteClient.h" -#include "servaKernel.h" - -#define LOG( X ) m_pLog->Log( "RPCH", this, X ) -#ifdef DEBUG - #define LOG_ERROR( X ) {\ - char _tBfrErrMSG234[256];\ - sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ - m_pLog->Log( "RPCH", this, _LOG_ERROR, _tBfrErrMSG234 );\ - } -#else - #define LOG_ERROR( X ) m_pLog->Log( "RPCH", this, _LOG_ERROR, X ); -#endif - -servaRPCHadnler::servaRPCHadnler( int SocketFD, networkServiceEngine *ptr ):basicThread(),networkClientHandler( SocketFD, ptr ),protocolParser(){ - m_pEngine = ptr; - m_pMaster = (servaRemoteClient *)ptr; - m_pLog = basicLogCollection::getInstance(); - m_dMojoDBID = 0; - m_dTrackDBID = 0; - m_nInbondSerial = 0; - m_nOutbondSerial = 0; - m_dSessionDBID = 0; - m_nCloudStatus = ARGUS_CLOUD_STATUS_NA; - m_pDBC = servaMySQLDBC::getInstance(); - m_pSM = servaSessionManager::getInstance(); - m_pEventHeap = basicEventHeap::getInstance(); - m_pPort = new serverPort( SocketFD ); - if ( m_pPort ) { - if ( m_pPort->create() ) { - setTransport(m_pPort); - init(); - } else { - delete( m_pPort ); - m_pPort = NULL; - }; - }; -}; - -servaRPCHadnler::~servaRPCHadnler(){ - waitThreadEnd( true ); - if( m_pPort ) delete( m_pPort ); -}; - -bool servaRPCHadnler::attachEngine( networkServiceEngine *ptr ){ - m_pEngine = ptr; - m_pMaster = (servaRemoteClient *) ptr; - return true; -}; - -bool servaRPCHadnler::dispatchEvent( EVENT_CONTAINER *Evt ){ - //LOG("EVT"); - return true; -}; - -bool servaRPCHadnler::getStatus( void ){ - if ( m_pPort ) { - if( getConnectionStatus() != CS_DISCONNECTED ) return true; - }; - return false; -}; - -bool servaRPCHadnler::setRemotePeerIP( CSTR ptr ){ - if ( ptr == NULL ) return false; -#ifdef DEBUG - char tB[64]; - sprintf(tB,"Remote Peer: %s", ptr ); - LOG( tB ); -#endif - strncpy( m_cRemoteIP, ptr, 64 ); - return true; -}; - -/********************PROTOCOL**************************/ - -int servaRPCHadnler::packetChecker( U8 *Buffer, size_t BufferSize ){ - char tB[64]; - if ( Buffer[0] == ARGUS_START_CLIENT_FLAG ) { - if( BufferSize > ARGUS_DATA_MSG_MIN_SIZE ){ - uint32_t SIZE = Buffer[5]; - SIZE = ( SIZE << 8 ) | Buffer[6]; - SIZE = ( SIZE << 8 ) | Buffer[7]; - SIZE = ( SIZE << 8 ) | Buffer[8]; - if ( ( SIZE + ARGUS_HEADER_SIZE + ARGUS_CHECKSUM_SIZE ) <= BufferSize ) { - uint16_t tCRC = checksum16( Buffer, SIZE + ARGUS_HEADER_SIZE ); - uint16_t cCRC = Buffer[SIZE + ARGUS_HEADER_SIZE]; - cCRC = ( cCRC << 8 ) | Buffer[SIZE + ARGUS_HEADER_SIZE+1]; - if ( tCRC == cCRC ) return 0; - } else return 1; // to grou - } else return 1; //to grow - }; - return -1; // to skip -}; - -protocolPackage *servaRPCHadnler::packetExtractor(U8 *Buffer, size_t BufferSize){ - protocolPackage *tPack = (protocolPackage*) malloc( sizeof(protocolPackage)); - if ( tPack ) { - tPack->m_nCode = Buffer[ARGUS_HEADER_SIZE]; - tPack->m_nSize = Buffer[5]; - tPack->m_nSize = ( tPack->m_nSize << 8 ) | Buffer[6]; - tPack->m_nSize = ( tPack->m_nSize << 8 ) | Buffer[7]; - tPack->m_nSize = ( tPack->m_nSize << 8 ) | Buffer[8]; - tPack->m_nSize = tPack->m_nSize + ARGUS_HEADER_SIZE + ARGUS_CHECKSUM_SIZE; - tPack->m_pData = (U8 *) malloc( tPack->m_nSize ); - if ( tPack->m_pData ) { - memcpy( tPack->m_pData, Buffer, tPack->m_nSize ); - } else { - free( tPack ); - tPack = NULL; - }; - }; - return tPack; -}; - -bool servaRPCHadnler::packetHandler( protocolPackage *Package ){ - - m_nInbondSerial = Package->m_pData[1]; - m_nInbondSerial = ( m_nInbondSerial << 8 ) | Package->m_pData[2]; - m_nInbondSerial = ( m_nInbondSerial << 8 ) | Package->m_pData[3]; - m_nInbondSerial = ( m_nInbondSerial << 8 ) | Package->m_pData[4]; -#ifdef DEBUG_EXTRA - char bB[129]; - sprintf( bB, "Code: %02X", Package->m_nCode ); - LOG( bB ); -#endif - switch( Package->m_nCode ){ - case ARGUS_DATA_MSG_REGISTER:{ - ARGUS_DATA_MOJO_REGISTRATION *tM = (ARGUS_DATA_MOJO_REGISTRATION *) (Package->m_pData+ARGUS_HEADER_SIZE+1); - strncpy( m_cRemoteIdentity, tM->identity, 32); - strncpy( m_cRemoteIP, tM->peer, 22); - m_cRemoteIdentity[32] = (char)0; -#ifdef DEBUG - char tB[128]; - sprintf(tB,"Registration request from[%s][%s]", m_cRemoteIP, m_cRemoteIdentity ); - LOG(tB); -#endif - m_dMojoDBID = m_pMaster->requestMojoRegistration( m_cRemoteIP, m_cRemoteIdentity ); - if ( m_dMojoDBID ) { - char WM = m_pMaster->getMojoWorkMode( m_dMojoDBID ); - if ( WM == 'E') { - m_dTrackDBID = m_pDBC->getTrackIdByMojo( m_dMojoDBID ); -#ifdef DEBUG - sprintf(tB,"Module:[%" PRIu64 "] Track:[%" PRIu64 "]", m_dMojoDBID, m_dTrackDBID ); - LOG(tB); -#endif - - //m_dRemoteBottomDBID = m_pDBC->getBottomLRF( m_dRemoteMojoDBID ); - //uint32_t lts = m_pDBC->getCloudLTS( ARGUS_OBJECT_MODULE, m_dMojoDBID ); - //uint32_t cts = time(NULL); - m_mCloudProtector.lock(); - m_nCloudStatus = ARGUS_CLOUD_STATUS_ONLINE; - m_mCloudProtector.unlock(); - m_pDBC->setCloudStatus( ARGUS_OBJECT_MODULE, m_dMojoDBID, ARGUS_CLOUD_STATUS_REG ); - //if( m_dRemoteUpperDBID ) m_pDBC->setCloudStatus( ARGUS_OBJECT_SENSOR, m_dRemoteUpperDBID, ARGUS_CLOUD_STATUS_REG ); - //if( m_dRemoteBottomDBID ) m_pDBC->setCloudStatus( ARGUS_OBJECT_SENSOR, m_dRemoteBottomDBID, ARGUS_CLOUD_STATUS_REG ); - peer_send_reg_status( ARGUS_DATA_MSG_REGISTER ); - //if ( ( cts - lts ) > ARGUS_SECONDS_TO_IGNORE_MODULE_COMMUNICATION_DROP ) { - // LOG("Download All Info From Module!"); - // peer_send_reg_status( ARGUS_DATA_MSG_GET_INFO ); - //}; - } else { -#ifdef DEBUG - LOG("Module is Disabled!"); -#endif - peer_send_reg_status( ARGUS_DATA_MSG_DISABLED ); - setConnectionStatus( CS_DISCONNECTED ); - }; - } else { -#ifdef DEBUG - LOG("Module Not Registered with System"); -#endif - peer_send_reg_status( ARGUS_DATA_MSG_ACCESS_DENIED ); - setConnectionStatus( CS_DISCONNECTED ); - }; - break; - }; - case ARGUS_DATA_MSG_INFO:{ - ARGUS_DATA_MOJO_INFO *tINFO = (ARGUS_DATA_MOJO_INFO *) (Package->m_pData+ARGUS_HEADER_SIZE+1); -#ifdef DEBUG - LOG("Module Info Received!"); - char tB[128]; - sprintf( tB, "Upper Sensor Node: %d", tINFO->UPPER_ID ); - LOG( tB ); - sprintf( tB, "Bottom Sensor Node: %d", tINFO->BOTTOM_ID ); - LOG( tB ); - sprintf( tB, "Camera Node: %d", tINFO->CAM_ID); - LOG( tB ); - sprintf( tB, "Camera Stream ID: %d", tINFO->CAM_STREAM_ID ); - LOG( tB ); -#endif - m_pDBC->updateModuleData( m_dMojoDBID, tINFO->UPPER_ID, tINFO->BOTTOM_ID, tINFO->CAM_ID, tINFO->CAM_STREAM_ID, tINFO->TLS_VERSION, tINFO->LLS_VERSION ); - peer_send_reg_status( ARGUS_DATA_MSG_INFO ); - break; - }; - case ARGUS_DATA_MSG_KEEP_ALIVE: - case ARGUS_DATA_MSG_STAT:{ - ARGUS_DATA_MOJO_STATUS *tSTATUS = (ARGUS_DATA_MOJO_STATUS *) (Package->m_pData+ARGUS_HEADER_SIZE+1); - m_mCloudProtector.lock(); - if( tSTATUS->STATUSES == 0 ) { - //LOG("Generic Error [0]"); - m_nCloudStatus = ARGUS_CLOUD_STATUS_E_GENERIC; - } else { - if ( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_MASK_OK ) == ARGUS_RPC_STATUS_OK ){ - //LOG("Status Ok"); - m_nCloudStatus = ARGUS_CLOUD_STATUS_ONLINE; - } else { - if( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_CAM_OK ) != ARGUS_RPC_STATUS_CAM_OK ){ - //LOG("Cam Err"); - switch( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_MASK_CAM ) >> ARGUS_RPC_STATUS_SHIFT_CAM ){ - case 1: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_CAM_NC; break; - case 2: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_CAM_NIM; break; - case 3: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_CAM_NPTZ; break; - default: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_CAM_GENERIC; - }; - }; - if( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_BS_OK ) != ARGUS_RPC_STATUS_BS_OK ){ - //LOG("BS Err"); - switch( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_MASK_BS ) >> ARGUS_RPC_STATUS_SHIFT_BS ){ - case 1: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_BS_NC; break; - case 2: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_BS_LRF; break; - default: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_SEN_GENERIC; - }; - }; - if( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_US_OK ) != ARGUS_RPC_STATUS_US_OK ){ - //LOG("US Err"); - switch( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_MASK_US ) >> ARGUS_RPC_STATUS_SHIFT_US ){ - case 1: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_US_NC; break; - case 2: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_US_LRF; break; - default: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_SEN_GENERIC; - }; - }; - }; - }; - m_mCloudProtector.unlock(); - peer_send_reg_status( ARGUS_DATA_MSG_STAT ); - break; - }; - case ARGUS_DATA_MSG_EVT:{ - ARGUS_DATA_EVENT *tEVT = (ARGUS_DATA_EVENT *) (Package->m_pData+ARGUS_HEADER_SIZE+1); - peer_send_reg_status( ARGUS_DATA_MSG_EVT ); - if ( tEVT->TYPE == EVT_ROI_ACTIVE || tEVT->TYPE == EVT_TARGET_3D_WHITE || tEVT->TYPE == EVT_TARGET_3D_BLACK || tEVT->TYPE == EVT_TARGET_2D_WHITE || tEVT->TYPE == EVT_TARGET_2D_BLACK ) { -#ifdef DEBUG_EXTRA - char tB[128]; - sprintf(tB, "EVT[%d] SRC[%d] %d.%d", tEVT->TYPE, tEVT->SRC, tEVT->TS, tEVT->MS ); - LOG( tB ); - sprintf(tB, "AZ[%d] RANGE[%d] ELV[%d] AREA[%d]", tEVT->AZIMUTH, tEVT->RANGE, tEVT->ELEVATION, tEVT->AREA ); - LOG( tB ); - strncpy( tB, tEVT->UUID, 64 ); - tB[64] = (char)0; - LOG( tB ); -#endif - - tEVT->MODULE_ID = m_dMojoDBID; - if ( m_dSessionDBID ) { - if ( m_pSM->validateSession( m_dSessionDBID ) ) { - m_pSM->addEvent( m_dSessionDBID, tEVT ); - } else { - m_dSessionDBID = m_pSM->addEvent( m_dTrackDBID, m_dMojoDBID, tEVT ); - }; - } else { - m_dSessionDBID = m_pSM->addEvent( m_dTrackDBID, m_dMojoDBID, tEVT ); - }; - } - break; - }; - case ARGUS_DATA_MSG_REQ_TIME_SYNC:{ - peer_send_reg_status( ARGUS_DATA_MSG_REQ_TIME_SYNC ); - break; - }; - case ARGUS_DATA_MSG_TIME_SYNC:{ -#ifdef DEBUG - LOG( "Time Synchronization Request" ); -#endif - ARGUS_DATA_TIME_SYNC_REQ *tTSR = ( ARGUS_DATA_TIME_SYNC_REQ *) (Package->m_pData+ARGUS_HEADER_SIZE+1); - ARGUS_DATA_TIME_SYNC_ACK tTSA; - tTSA.STS = tTSR->STS; - tTSA.ATS = getMilliseconds(); - peer_send_time_sync_ack( &tTSA ); - break; - }; - case ARGUS_DATA_MSG_VIDEO_INFO:{ -#ifdef DEBUG - LOG( "Received Video Record Info" ); -#endif +#include "servaRemoteClientHandler.h" +#include "servaRemoteClient.h" +#include "servaKernel.h" + +#define LOG( X ) m_pLog->Log( "RPCH", this, X ) +#ifdef DEBUG + #define LOG_ERROR( X ) {\ + char _tBfrErrMSG234[256];\ + sprintf( _tBfrErrMSG234, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\ + m_pLog->Log( "RPCH", this, _LOG_ERROR, _tBfrErrMSG234 );\ + } +#else + #define LOG_ERROR( X ) m_pLog->Log( "RPCH", this, _LOG_ERROR, X ); +#endif + +servaRPCHadnler::servaRPCHadnler( int SocketFD, networkServiceEngine *ptr ):basicThread(),networkClientHandler( SocketFD, ptr ),protocolParser(){ + m_pEngine = ptr; + m_pMaster = (servaRemoteClient *)ptr; + m_pLog = basicLogCollection::getInstance(); + m_dMojoDBID = 0; + m_dTrackDBID = 0; + m_nInbondSerial = 0; + m_nOutbondSerial = 0; + m_dSessionDBID = 0; + m_nPreTrainCloudStatus = m_nCloudStatus = ARGUS_CLOUD_STATUS_NA; + m_pDBC = servaMySQLDBC::getInstance(); + m_pSM = servaSessionManager::getInstance(); + m_pEventHeap = basicEventHeap::getInstance(); + m_pPort = new serverPort( SocketFD ); + if ( m_pPort ) { + if ( m_pPort->create() ) { + setTransport(m_pPort); + init(); + } else { + delete( m_pPort ); + m_pPort = NULL; + }; + }; +}; + +bool servaRPCHadnler::setTrainPresense( bool st ){ + if( m_dSessionDBID ){ + //m_pSM->setTrainStatus( m_dSessionDBID, st ); + }; + if( !st && ( m_nPreTrainCloudStatus != ARGUS_CLOUD_STATUS_NA ) ){ + m_nCloudStatus = m_nPreTrainCloudStatus; + } else { + m_nPreTrainCloudStatus = m_nCloudStatus; + m_nCloudStatus = ARGUS_CLOUD_STATUS_TRAIN; + }; + return m_pDBC->setCloudStatus(ARGUS_OBJECT_MODULE, m_dMojoDBID, m_nCloudStatus ); +}; + +servaRPCHadnler::~servaRPCHadnler(){ + waitThreadEnd( true ); + if( m_pPort ) delete( m_pPort ); +}; + +bool servaRPCHadnler::attachEngine( networkServiceEngine *ptr ){ + m_pEngine = ptr; + m_pMaster = (servaRemoteClient *) ptr; + return true; +}; + +bool servaRPCHadnler::dispatchEvent( EVENT_CONTAINER *Evt ){ + //LOG("EVT"); + return true; +}; + +bool servaRPCHadnler::getStatus( void ){ + if ( m_pPort ) { + if( getConnectionStatus() != CS_DISCONNECTED ) return true; + }; + return false; +}; + +bool servaRPCHadnler::setRemotePeerIP( CSTR ptr ){ + if ( ptr == NULL ) return false; +#ifdef DEBUG + char tB[64]; + sprintf(tB,"Remote Peer: %s", ptr ); + LOG( tB ); +#endif + strncpy( m_cRemoteIP, ptr, 64 ); + return true; +}; + +/********************PROTOCOL**************************/ + +int servaRPCHadnler::packetChecker( U8 *Buffer, size_t BufferSize ){ + char tB[64]; + if ( Buffer[0] == ARGUS_START_CLIENT_FLAG ) { + if( BufferSize > ARGUS_DATA_MSG_MIN_SIZE ){ + uint32_t SIZE = Buffer[5]; + SIZE = ( SIZE << 8 ) | Buffer[6]; + SIZE = ( SIZE << 8 ) | Buffer[7]; + SIZE = ( SIZE << 8 ) | Buffer[8]; + if ( ( SIZE + ARGUS_HEADER_SIZE + ARGUS_CHECKSUM_SIZE ) <= BufferSize ) { + uint16_t tCRC = checksum16( Buffer, SIZE + ARGUS_HEADER_SIZE ); + uint16_t cCRC = Buffer[SIZE + ARGUS_HEADER_SIZE]; + cCRC = ( cCRC << 8 ) | Buffer[SIZE + ARGUS_HEADER_SIZE+1]; + if ( tCRC == cCRC ) return 0; + } else return 1; // to grou + } else return 1; //to grow + }; + return -1; // to skip +}; + +protocolPackage *servaRPCHadnler::packetExtractor(U8 *Buffer, size_t BufferSize){ + protocolPackage *tPack = (protocolPackage*) malloc( sizeof(protocolPackage)); + if ( tPack ) { + tPack->m_nCode = Buffer[ARGUS_HEADER_SIZE]; + tPack->m_nSize = Buffer[5]; + tPack->m_nSize = ( tPack->m_nSize << 8 ) | Buffer[6]; + tPack->m_nSize = ( tPack->m_nSize << 8 ) | Buffer[7]; + tPack->m_nSize = ( tPack->m_nSize << 8 ) | Buffer[8]; + tPack->m_nSize = tPack->m_nSize + ARGUS_HEADER_SIZE + ARGUS_CHECKSUM_SIZE; + tPack->m_pData = (U8 *) malloc( tPack->m_nSize ); + if ( tPack->m_pData ) { + memcpy( tPack->m_pData, Buffer, tPack->m_nSize ); + } else { + free( tPack ); + tPack = NULL; + }; + }; + return tPack; +}; + +bool servaRPCHadnler::packetHandler( protocolPackage *Package ){ + + m_nInbondSerial = Package->m_pData[1]; + m_nInbondSerial = ( m_nInbondSerial << 8 ) | Package->m_pData[2]; + m_nInbondSerial = ( m_nInbondSerial << 8 ) | Package->m_pData[3]; + m_nInbondSerial = ( m_nInbondSerial << 8 ) | Package->m_pData[4]; +#ifdef DEBUG_EXTRA + char bB[129]; + sprintf( bB, "Code: %02X", Package->m_nCode ); + LOG( bB ); +#endif + switch( Package->m_nCode ){ + case ARGUS_DATA_MSG_REGISTER:{ + ARGUS_DATA_MOJO_REGISTRATION *tM = (ARGUS_DATA_MOJO_REGISTRATION *) (Package->m_pData+ARGUS_HEADER_SIZE+1); + strncpy( m_cRemoteIdentity, tM->identity, 32); + strncpy( m_cRemoteIP, tM->peer, 22); + m_cRemoteIdentity[32] = (char)0; +#ifdef DEBUG + char tB[128]; + sprintf(tB,"Registration request from[%s][%s]", m_cRemoteIP, m_cRemoteIdentity ); + LOG(tB); +#endif + m_dMojoDBID = m_pMaster->requestMojoRegistration( m_cRemoteIP, m_cRemoteIdentity ); + if ( m_dMojoDBID ) { + char WM = m_pMaster->getMojoWorkMode( m_dMojoDBID ); + if ( WM == 'E') { + m_dTrackDBID = m_pDBC->getTrackIdByMojo( m_dMojoDBID ); +#ifdef DEBUG + sprintf(tB,"Module:[%" PRIu64 "] Track:[%" PRIu64 "]", m_dMojoDBID, m_dTrackDBID ); + LOG(tB); +#endif + + //m_dRemoteBottomDBID = m_pDBC->getBottomLRF( m_dRemoteMojoDBID ); + //uint32_t lts = m_pDBC->getCloudLTS( ARGUS_OBJECT_MODULE, m_dMojoDBID ); + //uint32_t cts = time(NULL); + m_mCloudProtector.lock(); + m_nCloudStatus = ARGUS_CLOUD_STATUS_ONLINE; + m_mCloudProtector.unlock(); + m_pDBC->setCloudStatus( ARGUS_OBJECT_MODULE, m_dMojoDBID, ARGUS_CLOUD_STATUS_REG ); + //if( m_dRemoteUpperDBID ) m_pDBC->setCloudStatus( ARGUS_OBJECT_SENSOR, m_dRemoteUpperDBID, ARGUS_CLOUD_STATUS_REG ); + //if( m_dRemoteBottomDBID ) m_pDBC->setCloudStatus( ARGUS_OBJECT_SENSOR, m_dRemoteBottomDBID, ARGUS_CLOUD_STATUS_REG ); + peer_send_reg_status( ARGUS_DATA_MSG_REGISTER ); + //if ( ( cts - lts ) > ARGUS_SECONDS_TO_IGNORE_MODULE_COMMUNICATION_DROP ) { + // LOG("Download All Info From Module!"); + // peer_send_reg_status( ARGUS_DATA_MSG_GET_INFO ); + //}; + } else { +#ifdef DEBUG + LOG("Module is Disabled!"); +#endif + peer_send_reg_status( ARGUS_DATA_MSG_DISABLED ); + setConnectionStatus( CS_DISCONNECTED ); + }; + } else { +#ifdef DEBUG + LOG("Module Not Registered with System"); +#endif + peer_send_reg_status( ARGUS_DATA_MSG_ACCESS_DENIED ); + setConnectionStatus( CS_DISCONNECTED ); + }; + break; + }; + case ARGUS_DATA_MSG_INFO:{ + ARGUS_DATA_MOJO_INFO *tINFO = (ARGUS_DATA_MOJO_INFO *) (Package->m_pData+ARGUS_HEADER_SIZE+1); +#ifdef DEBUG + LOG("Module Info Received!"); + char tB[128]; + sprintf( tB, "Upper Sensor Node: %d", tINFO->UPPER_ID ); + LOG( tB ); + sprintf( tB, "Bottom Sensor Node: %d", tINFO->BOTTOM_ID ); + LOG( tB ); + sprintf( tB, "Camera Node: %d", tINFO->CAM_ID); + LOG( tB ); + sprintf( tB, "Camera Stream ID: %d", tINFO->CAM_STREAM_ID ); + LOG( tB ); +#endif + m_pDBC->updateModuleData( m_dMojoDBID, tINFO->UPPER_ID, tINFO->BOTTOM_ID, tINFO->CAM_ID, tINFO->CAM_STREAM_ID, tINFO->TLS_VERSION, tINFO->LLS_VERSION ); + peer_send_reg_status( ARGUS_DATA_MSG_INFO ); + break; + }; + case ARGUS_DATA_MSG_KEEP_ALIVE: + case ARGUS_DATA_MSG_STAT:{ + ARGUS_DATA_MOJO_STATUS *tSTATUS = (ARGUS_DATA_MOJO_STATUS *) (Package->m_pData+ARGUS_HEADER_SIZE+1); + m_mCloudProtector.lock(); + if( tSTATUS->STATUSES == 0 ) { + //LOG("Generic Error [0]"); + m_nCloudStatus = ARGUS_CLOUD_STATUS_E_GENERIC; + } else { + if ( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_MASK_OK ) == ARGUS_RPC_STATUS_OK ){ + //LOG("Status Ok"); + m_nCloudStatus = ARGUS_CLOUD_STATUS_ONLINE; + } else { + if( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_CAM_OK ) != ARGUS_RPC_STATUS_CAM_OK ){ + //LOG("Cam Err"); + switch( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_MASK_CAM ) >> ARGUS_RPC_STATUS_SHIFT_CAM ){ + case 1: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_CAM_NC; break; + case 2: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_CAM_NIM; break; + case 3: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_CAM_NPTZ; break; + default: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_CAM_GENERIC; + }; + }; + if( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_BS_OK ) != ARGUS_RPC_STATUS_BS_OK ){ + //LOG("BS Err"); + switch( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_MASK_BS ) >> ARGUS_RPC_STATUS_SHIFT_BS ){ + case 1: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_BS_NC; break; + case 2: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_BS_LRF; break; + default: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_SEN_GENERIC; + }; + }; + if( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_US_OK ) != ARGUS_RPC_STATUS_US_OK ){ + //LOG("US Err"); + switch( ( tSTATUS->STATUSES & ARGUS_RPC_STATUS_MASK_US ) >> ARGUS_RPC_STATUS_SHIFT_US ){ + case 1: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_US_NC; break; + case 2: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_US_LRF; break; + default: m_nCloudStatus = ARGUS_CLOUD_STATUS_E_SEN_GENERIC; + }; + }; + }; + }; + m_mCloudProtector.unlock(); + peer_send_reg_status( ARGUS_DATA_MSG_STAT ); + break; + }; + case ARGUS_DATA_MSG_EVT:{ + ARGUS_DATA_EVENT *tEVT = (ARGUS_DATA_EVENT *) (Package->m_pData+ARGUS_HEADER_SIZE+1); + peer_send_reg_status( ARGUS_DATA_MSG_EVT ); + switch ( tEVT->TYPE ) { + case EVT_ROI_ACTIVE: + case EVT_TARGET_3D_WHITE: + case EVT_TARGET_3D_BLACK: + case EVT_TARGET_2D_WHITE: + case EVT_TARGET_2D_BLACK:{ +#ifdef DEBUG_EXTRA + char tB[128]; + sprintf(tB, "EVT[%d] SRC[%d] %d.%d", tEVT->TYPE, tEVT->SRC, tEVT->TS, tEVT->MS ); + LOG( tB ); + sprintf(tB, "AZ[%d] RANGE[%d] ELV[%d] AREA[%d]", tEVT->AZIMUTH, tEVT->RANGE, tEVT->ELEVATION, tEVT->AREA ); + LOG( tB ); + strncpy( tB, tEVT->UUID, 64 ); + tB[64] = (char)0; + LOG( tB ); +#endif + tEVT->MODULE_ID = m_dMojoDBID; + if ( m_dSessionDBID ) { + if ( m_pSM->validateSession( m_dSessionDBID ) ) { + m_pSM->addEvent( m_dSessionDBID, tEVT ); + } else { + m_dSessionDBID = m_pSM->addEvent( m_dTrackDBID, m_dMojoDBID, tEVT ); + }; + } else { + m_dSessionDBID = m_pSM->addEvent( m_dTrackDBID, m_dMojoDBID, tEVT ); + }; + break; + }; + case EVT_FLT_LATF_TRP_DET: + case EVT_FLT_LATF_TRP_UPDT: + case EVT_FLT_LATF_OP_TD:{ + // Train Presence + setTrainPresense( TRAIN_ON_TRACK ); + break; + }; + case EVT_FLT_LATF_TRP_EXP:{ + //Train is Gone + setTrainPresense( TRAIN_IS_GONE ); + break; + }; + }; + break; + }; + case ARGUS_DATA_MSG_REQ_TIME_SYNC:{ + peer_send_reg_status( ARGUS_DATA_MSG_REQ_TIME_SYNC ); + break; + }; + case ARGUS_DATA_MSG_TIME_SYNC:{ +#ifdef DEBUG + LOG( "Time Synchronization Request" ); +#endif + ARGUS_DATA_TIME_SYNC_REQ *tTSR = ( ARGUS_DATA_TIME_SYNC_REQ *) (Package->m_pData+ARGUS_HEADER_SIZE+1); + ARGUS_DATA_TIME_SYNC_ACK tTSA; + tTSA.STS = tTSR->STS; + tTSA.ATS = getMilliseconds(); + peer_send_time_sync_ack( &tTSA ); + break; + }; + case ARGUS_DATA_MSG_VIDEO_INFO:{ +#ifdef DEBUG + LOG( "Received Video Record Info" ); +#endif m_pVideoHelper.clear(); CSTR BASE = m_pSM->getSessionBase( m_dSessionDBID ); if( BASE ){ - if (m_pVideoHelper.init( BASE, m_dMojoDBID, m_dSessionDBID, (ARGUS_DATA_VIDEO_INFO *)(Package->m_pData + ARGUS_HEADER_SIZE + 1))) { - LOG("Helper Init Ok"); - peer_send_vinfo_ack( m_pVideoHelper.getReferenceID() ); - } else { - LOG("Helper Init Failure"); - peer_send_vinfo_ack( 0 ); + if (m_pVideoHelper.init( BASE, m_dMojoDBID, m_dSessionDBID, (ARGUS_DATA_VIDEO_INFO *)(Package->m_pData + ARGUS_HEADER_SIZE + 1))) { + LOG("Helper Init Ok"); + peer_send_vinfo_ack( m_pVideoHelper.getReferenceID() ); + } else { + LOG("Helper Init Failure"); + peer_send_vinfo_ack( 0 ); }; free( BASE ); } else { - LOG("Helper Init Failure (NO SESSION)"); - peer_send_vinfo_ack( 0 ); + LOG("Helper Init Failure (NO SESSION)"); + peer_send_vinfo_ack( 0 ); }; - break; - }; - case ARGUS_DATA_MSG_VIDEO_DATA:{ - uint32_t tt = m_pVideoHelper.saveNextChunk( Package->m_pData+ARGUS_HEADER_SIZE+1 ); -#ifdef DEBUG_EXTRA - char tK[128]; - sprintf( tK, "Saved %d Bytes of Video!", tt ); - LOG( tK ); -#endif - peer_send_vdata_ack( tt ); - break; - }; - case ARGUS_DATA_MSG_RESTART_SW:{ - LOG("Module Restarts control Software"); - break; - }; - case ARGUS_DATA_MSG_RESTART_PLATFORM:{ - LOG("Module Restart HOST OS"); - break; - }; - }; - return true; -}; - -void servaRPCHadnler::m_fThreadProc( void ){ - time_t tTimeTSeconds = 0; - time_t cTimeTSeconds = 0; - uint32_t tSecondsCounter = 0; - - m_bThreadStatus = TH_WORKING; -#ifdef DEBUG - LOG("Connector Thread Started"); -#endif - while ( m_bThreadStatus < TH_ENDED ) { - // seconds Counter (for internal purposes) - cTimeTSeconds = time( NULL ); - //Process each second - if ( cTimeTSeconds != tTimeTSeconds ) { - tSecondsCounter++; - tTimeTSeconds = cTimeTSeconds; - // update clowd status - m_mCloudProtector.lock(); - m_pDBC->setCloudStatus( ARGUS_OBJECT_MODULE, m_dMojoDBID, m_nCloudStatus ); - m_mCloudProtector.unlock(); - }; - DBC_RPC_WEB_CMD *tCMD = m_pDBC->fetchWebCmd( m_dMojoDBID ); - if ( tCMD ) { - //LOG( "Have Web CMD!"); - ARGUS_DATA_RPC RPC_PACK; - RPC_PACK.CMD = tCMD->cmd; - RPC_PACK.NODE_ID = tCMD->aux_id; - strncpy( RPC_PACK.DATA, tCMD->param, 64 ); - //if( peer_send_rpc( &RPC_PACK ) ) m_pDBC->updateWebCmdStatus( tCMD->id, 200 ); // Set Finished - if( peer_send_rpc( &RPC_PACK ) ) m_pDBC->removeWebCmd( tCMD->id ); // Instant Clear - free( tCMD ); - }; - SLEEP(DEFAULT_THREAD_SLEEP_TIME); - }; -#ifdef DEBUG_EXTRA - LOG("Connector Thread Ended!"); -#endif -}; - -bool servaRPCHadnler::peer_send_vdata_ack( uint8_t status ){ - uint8_t Buffer[64]; - Buffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_VIDEO_DATA; - Buffer[ARGUS_HEADER_SIZE+1] = status; - m_nOutbondSerial++; - return m_pPort->sendData( Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+2 ) ); -}; - -bool servaRPCHadnler::peer_send_vinfo_ack( uint64_t pid ){ - uint8_t Buffer[64]; - Buffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_VIDEO_INFO; - Buffer[ARGUS_HEADER_SIZE+1] = ( pid >> 56 ) & 0xff; - Buffer[ARGUS_HEADER_SIZE+2] = ( pid >> 48 ) & 0xff; - Buffer[ARGUS_HEADER_SIZE+3] = ( pid >> 40 ) & 0xff; - Buffer[ARGUS_HEADER_SIZE+4] = ( pid >> 32 ) & 0xff; - Buffer[ARGUS_HEADER_SIZE+5] = ( pid >> 24 ) & 0xff; - Buffer[ARGUS_HEADER_SIZE+6] = ( pid >> 16 ) & 0xff; - Buffer[ARGUS_HEADER_SIZE+7] = ( pid >> 8 ) & 0xff; - Buffer[ARGUS_HEADER_SIZE+8] = pid & 0xff; - m_nOutbondSerial++; - return m_pPort->sendData( Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+9 ) ); -}; - -bool servaRPCHadnler::peer_send_reg_status( uint8_t status ){ - uint8_t Buffer[64]; - Buffer[ARGUS_HEADER_SIZE] = status; - m_nOutbondSerial++; - return m_pPort->sendData( Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+1 ) ); -}; - -bool servaRPCHadnler::peer_send_req_draw( uint8_t sensor, uint8_t draw_type, bool getexisted ){ - if ( sensor == ARGUS_RPC_MOJO_ITSELF ) return false; - uint8_t Buffer[64]; - Buffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_GET_DRAW; - Buffer[ARGUS_HEADER_SIZE+1] = sensor; - if( !getexisted ) { - Buffer[ARGUS_HEADER_SIZE+2] = draw_type | 0x80; - } else { - Buffer[ARGUS_HEADER_SIZE+2] = draw_type; - }; - return m_pPort->sendData( Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+3 ) ); -}; - -bool servaRPCHadnler::peer_send_ack_evt( uint64_t evt_dbid, CSTR uuid ){ - uint8_t Buffer[128]; - Buffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_EVT; - Buffer[ARGUS_HEADER_SIZE+1] = ( evt_dbid >> 56 ) & 0xFF; - Buffer[ARGUS_HEADER_SIZE+2] = ( evt_dbid >> 48 ) & 0xFF; - Buffer[ARGUS_HEADER_SIZE+3] = ( evt_dbid >> 40 ) & 0xFF; - Buffer[ARGUS_HEADER_SIZE+4] = ( evt_dbid >> 32 ) & 0xFF; - Buffer[ARGUS_HEADER_SIZE+5] = ( evt_dbid >> 24 ) & 0xFF; - Buffer[ARGUS_HEADER_SIZE+6] = ( evt_dbid >> 16 ) & 0xFF; - Buffer[ARGUS_HEADER_SIZE+7] = ( evt_dbid >> 8 ) & 0xFF; - Buffer[ARGUS_HEADER_SIZE+8] = evt_dbid & 0xFF; - Buffer[ARGUS_HEADER_SIZE+9] = strlen( uuid ); - uint8_t i = 0; - for( ; i< Buffer[ARGUS_HEADER_SIZE+9]; i++ ) Buffer[ARGUS_HEADER_SIZE+10+i] = (uint8_t)uuid[i]; - return m_pPort->sendData(Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+11+i )); -}; - -bool servaRPCHadnler::peer_send_rpc( ARGUS_DATA_RPC *ptr ){ - uint8_t tBuffer[1024]; - tBuffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_RPC; - uint16_t i = 0; - for(; i < sizeof(ARGUS_DATA_RPC); i++) tBuffer[ARGUS_HEADER_SIZE+1+i] = ((uint8_t*)ptr)[i]; - return m_pPort->sendData(tBuffer, argus_rpc_finishupPackage(tBuffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+1+i )); -}; - -bool servaRPCHadnler::peer_send_time_sync_ack( ARGUS_DATA_TIME_SYNC_ACK *ptr ){ - uint8_t tBuffer[1024]; - tBuffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_TIME_SYNC; - uint16_t i = 0; - for(; i < sizeof(ARGUS_DATA_TIME_SYNC_ACK); i++) tBuffer[ARGUS_HEADER_SIZE+1+i] = ((uint8_t*)ptr)[i]; - return m_pPort->sendData(tBuffer, argus_rpc_finishupPackage(tBuffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+1+i )); -}; - -servaVideoTransferHelper::servaVideoTransferHelper(){ - m_pLog = basicLogCollection::getInstance(); - m_pEventHeap = basicEventHeap::getInstance(); - m_pFD = NULL; - clear(); -}; - -servaVideoTransferHelper::~servaVideoTransferHelper(){ - clear(); -}; - -bool servaVideoTransferHelper::init( CSTR base, uint64_t MID, uint64_t SID, ARGUS_DATA_VIDEO_INFO *ptr ){ - m_nRemoteRefID = 0; - if ( ptr ) { - memcpy( &m_sIn, ptr, sizeof(ARGUS_DATA_VIDEO_INFO) ); - if ( ptr->REF_ID ) { - servaMySQLDBC * m_pDBC = servaMySQLDBC::getInstance(); - CSTR tUUID = getUniqID_UUID(); //m_pDBC->getMediaUUID( ptr->REF_ID ); - if ( tUUID ) { -#ifdef DEBUG - char tB[256]; - sprintf(tB, "Update VideoData: %s, %d.%d, [%dx%d@%d] <%s>", tUUID, m_sIn.DTS, m_sIn.DMS, m_sIn.WIDTH, m_sIn.HEIGHT, m_sIn.FPS, m_sIn.FMT); - LOG( tB ); -#endif - sprintf( m_cCurrentFile, "%s/%s.%s", base, tUUID, m_sIn.FMT ); - m_pFD = fopen( m_cCurrentFile, "wb" ); - free( tUUID ); - m_nRemoteRefID = ptr->REF_ID; - return true; - }; - } else { - //ToDo Set File Access to web user - CSTR tUUID = getUniqID_UUID(); - if ( tUUID ) { -#ifdef DEBUG - char tB[256]; - sprintf(tB, "VideoData: %s, %d.%d, [%dx%d@%d] <%s>", tUUID, m_sIn.DTS, m_sIn.DMS, m_sIn.WIDTH, m_sIn.HEIGHT, m_sIn.FPS, m_sIn.FMT); - LOG( tB ); -#endif - servaMySQLDBC * m_pDBC = servaMySQLDBC::getInstance(); - //servaSessionManager * m_pSM = servaSessionManager::getInstance(); - if ( m_nRemoteRefID = m_pDBC->addMediaQueueRecord( tUUID, MID, SID, m_sIn.DTS, m_sIn.DMS, m_sIn.WIDTH, m_sIn.HEIGHT, m_sIn.FPS, m_sIn.FMT ) ) { - sprintf( m_cCurrentFile, "%s/%s.%s", base, tUUID, m_sIn.FMT ); - m_pFD = fopen( m_cCurrentFile, "wb" ); - free( tUUID ); - return true; - }; - free( tUUID ); - }; - } - }; - memset( m_cCurrentFile, 0, MAX_PATH ); - memset( &m_sIn, 0, sizeof(ARGUS_DATA_VIDEO_INFO) ); - return false; -}; - -void servaVideoTransferHelper::clear(){ - if( m_pFD ) fclose( m_pFD ); - m_pFD = NULL; - m_nRemoteRefID = 0; - m_nSAVED = 0; - m_bOPerc = 0; - memset( m_cCurrentFile, 0, MAX_PATH ); - memset( &m_sIn, 0, sizeof(ARGUS_DATA_VIDEO_INFO) ); -}; - -uint32_t servaVideoTransferHelper::saveNextChunk( uint8_t *ptr ){ - if ( ptr ){ - uint64_t tDBID = ptr[0]; - tDBID = ( tDBID << 8 ) | ptr[1]; - tDBID = ( tDBID << 8 ) | ptr[2]; - tDBID = ( tDBID << 8 ) | ptr[3]; - tDBID = ( tDBID << 8 ) | ptr[4]; - tDBID = ( tDBID << 8 ) | ptr[5]; - tDBID = ( tDBID << 8 ) | ptr[6]; - tDBID = ( tDBID << 8 ) | ptr[7]; - uint32_t chusz = ptr[8]; - chusz = ( chusz << 8 ) | ptr[9]; - chusz = ( chusz << 8 ) | ptr[10]; - chusz = ( chusz << 8 ) | ptr[11]; - if ( m_pFD ) { - if ( chusz ) { - int rv = fwrite( ptr+12, 1, chusz, m_pFD ); - if ( rv != chusz ) { - fclose( m_pFD ); - m_pFD = NULL; - unlink( m_cCurrentFile ); - return 0; - }; - m_nSAVED += chusz; - if ( chusz < ARGUS_RPC_DEFAULT_MEDIA_CHUNK ) { - LOG("Video File Reception Done"); - fclose( m_pFD ); - m_pFD = NULL; - servaKernel::getInstance()->updateEncodeStatus(tDBID, MEDIA_STORED, 100); - } else { - if ( m_sIn.DATA_SIZE ) { - uint8_t perc = (uint8_t)((m_nSAVED * 100) / m_sIn.DATA_SIZE); - if ( m_bOPerc != perc ) { - m_bOPerc = perc; - servaKernel::getInstance()->updateEncodeStatus(tDBID, MEDIA_TRANSFERING, perc ); - }; - } else servaKernel::getInstance()->updateEncodeStatus( tDBID, MEDIA_TRANSFERING, 50 ); - }; - return chusz; - }; - }; - }; - return 0; -}; - -#undef LOG -#undef LOG_ERROR + break; + }; + case ARGUS_DATA_MSG_VIDEO_DATA:{ + uint32_t tt = m_pVideoHelper.saveNextChunk( Package->m_pData+ARGUS_HEADER_SIZE+1 ); +#ifdef DEBUG_EXTRA + char tK[128]; + sprintf( tK, "Saved %d Bytes of Video!", tt ); + LOG( tK ); +#endif + peer_send_vdata_ack( tt ); + break; + }; + case ARGUS_DATA_MSG_RESTART_SW:{ + LOG("Module Restarts control Software"); + break; + }; + case ARGUS_DATA_MSG_RESTART_PLATFORM:{ + LOG("Module Restart HOST OS"); + break; + }; + }; + return true; +}; + +void servaRPCHadnler::m_fThreadProc( void ){ + time_t tTimeTSeconds = 0; + time_t cTimeTSeconds = 0; + uint32_t tSecondsCounter = 0; + + m_bThreadStatus = TH_WORKING; +#ifdef DEBUG + LOG("Connector Thread Started"); +#endif + while ( m_bThreadStatus < TH_ENDED ) { + // seconds Counter (for internal purposes) + cTimeTSeconds = time( NULL ); + //Process each second + if ( cTimeTSeconds != tTimeTSeconds ) { + tSecondsCounter++; + tTimeTSeconds = cTimeTSeconds; + // update clowd status + m_mCloudProtector.lock(); + m_pDBC->setCloudStatus( ARGUS_OBJECT_MODULE, m_dMojoDBID, m_nCloudStatus ); + m_mCloudProtector.unlock(); + }; + DBC_RPC_WEB_CMD *tCMD = m_pDBC->fetchWebCmd( m_dMojoDBID ); + if ( tCMD ) { + //LOG( "Have Web CMD!"); + ARGUS_DATA_RPC RPC_PACK; + RPC_PACK.CMD = tCMD->cmd; + RPC_PACK.NODE_ID = tCMD->aux_id; + strncpy( RPC_PACK.DATA, tCMD->param, 64 ); + //if( peer_send_rpc( &RPC_PACK ) ) m_pDBC->updateWebCmdStatus( tCMD->id, 200 ); // Set Finished + if( peer_send_rpc( &RPC_PACK ) ) m_pDBC->removeWebCmd( tCMD->id ); // Instant Clear + free( tCMD ); + }; + SLEEP(DEFAULT_THREAD_SLEEP_TIME); + }; +#ifdef DEBUG_EXTRA + LOG("Connector Thread Ended!"); +#endif +}; + +bool servaRPCHadnler::peer_send_vdata_ack( uint8_t status ){ + uint8_t Buffer[64]; + Buffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_VIDEO_DATA; + Buffer[ARGUS_HEADER_SIZE+1] = status; + m_nOutbondSerial++; + return m_pPort->sendData( Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+2 ) ); +}; + +bool servaRPCHadnler::peer_send_vinfo_ack( uint64_t pid ){ + uint8_t Buffer[64]; + Buffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_VIDEO_INFO; + Buffer[ARGUS_HEADER_SIZE+1] = ( pid >> 56 ) & 0xff; + Buffer[ARGUS_HEADER_SIZE+2] = ( pid >> 48 ) & 0xff; + Buffer[ARGUS_HEADER_SIZE+3] = ( pid >> 40 ) & 0xff; + Buffer[ARGUS_HEADER_SIZE+4] = ( pid >> 32 ) & 0xff; + Buffer[ARGUS_HEADER_SIZE+5] = ( pid >> 24 ) & 0xff; + Buffer[ARGUS_HEADER_SIZE+6] = ( pid >> 16 ) & 0xff; + Buffer[ARGUS_HEADER_SIZE+7] = ( pid >> 8 ) & 0xff; + Buffer[ARGUS_HEADER_SIZE+8] = pid & 0xff; + m_nOutbondSerial++; + return m_pPort->sendData( Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+9 ) ); +}; + +bool servaRPCHadnler::peer_send_reg_status( uint8_t status ){ + uint8_t Buffer[64]; + Buffer[ARGUS_HEADER_SIZE] = status; + m_nOutbondSerial++; + return m_pPort->sendData( Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+1 ) ); +}; + +bool servaRPCHadnler::peer_send_req_draw( uint8_t sensor, uint8_t draw_type, bool getexisted ){ + if ( sensor == ARGUS_RPC_MOJO_ITSELF ) return false; + uint8_t Buffer[64]; + Buffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_GET_DRAW; + Buffer[ARGUS_HEADER_SIZE+1] = sensor; + if( !getexisted ) { + Buffer[ARGUS_HEADER_SIZE+2] = draw_type | 0x80; + } else { + Buffer[ARGUS_HEADER_SIZE+2] = draw_type; + }; + return m_pPort->sendData( Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+3 ) ); +}; + +bool servaRPCHadnler::peer_send_ack_evt( uint64_t evt_dbid, CSTR uuid ){ + uint8_t Buffer[128]; + Buffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_EVT; + Buffer[ARGUS_HEADER_SIZE+1] = ( evt_dbid >> 56 ) & 0xFF; + Buffer[ARGUS_HEADER_SIZE+2] = ( evt_dbid >> 48 ) & 0xFF; + Buffer[ARGUS_HEADER_SIZE+3] = ( evt_dbid >> 40 ) & 0xFF; + Buffer[ARGUS_HEADER_SIZE+4] = ( evt_dbid >> 32 ) & 0xFF; + Buffer[ARGUS_HEADER_SIZE+5] = ( evt_dbid >> 24 ) & 0xFF; + Buffer[ARGUS_HEADER_SIZE+6] = ( evt_dbid >> 16 ) & 0xFF; + Buffer[ARGUS_HEADER_SIZE+7] = ( evt_dbid >> 8 ) & 0xFF; + Buffer[ARGUS_HEADER_SIZE+8] = evt_dbid & 0xFF; + Buffer[ARGUS_HEADER_SIZE+9] = strlen( uuid ); + uint8_t i = 0; + for( ; i< Buffer[ARGUS_HEADER_SIZE+9]; i++ ) Buffer[ARGUS_HEADER_SIZE+10+i] = (uint8_t)uuid[i]; + return m_pPort->sendData(Buffer, argus_rpc_finishupPackage( Buffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+11+i )); +}; + +bool servaRPCHadnler::peer_send_rpc( ARGUS_DATA_RPC *ptr ){ + uint8_t tBuffer[1024]; + tBuffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_RPC; + uint16_t i = 0; + for(; i < sizeof(ARGUS_DATA_RPC); i++) tBuffer[ARGUS_HEADER_SIZE+1+i] = ((uint8_t*)ptr)[i]; + return m_pPort->sendData(tBuffer, argus_rpc_finishupPackage(tBuffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+1+i )); +}; + +bool servaRPCHadnler::peer_send_time_sync_ack( ARGUS_DATA_TIME_SYNC_ACK *ptr ){ + uint8_t tBuffer[1024]; + tBuffer[ARGUS_HEADER_SIZE] = ARGUS_DATA_MSG_TIME_SYNC; + uint16_t i = 0; + for(; i < sizeof(ARGUS_DATA_TIME_SYNC_ACK); i++) tBuffer[ARGUS_HEADER_SIZE+1+i] = ((uint8_t*)ptr)[i]; + return m_pPort->sendData(tBuffer, argus_rpc_finishupPackage(tBuffer, m_nOutbondSerial, ARGUS_HEADER_SIZE+1+i )); +}; + +servaVideoTransferHelper::servaVideoTransferHelper(){ + m_pLog = basicLogCollection::getInstance(); + m_pEventHeap = basicEventHeap::getInstance(); + m_pFD = NULL; + clear(); +}; + +servaVideoTransferHelper::~servaVideoTransferHelper(){ + clear(); +}; + +bool servaVideoTransferHelper::init( CSTR base, uint64_t MID, uint64_t SID, ARGUS_DATA_VIDEO_INFO *ptr ){ + m_nRemoteRefID = 0; + if ( ptr ) { + memcpy( &m_sIn, ptr, sizeof(ARGUS_DATA_VIDEO_INFO) ); + if ( ptr->REF_ID ) { + servaMySQLDBC * m_pDBC = servaMySQLDBC::getInstance(); + CSTR tUUID = getUniqID_UUID(); //m_pDBC->getMediaUUID( ptr->REF_ID ); + if ( tUUID ) { +#ifdef DEBUG + char tB[256]; + sprintf(tB, "Update VideoData: %s, %d.%d, [%dx%d@%d] <%s>", tUUID, m_sIn.DTS, m_sIn.DMS, m_sIn.WIDTH, m_sIn.HEIGHT, m_sIn.FPS, m_sIn.FMT); + LOG( tB ); +#endif + sprintf( m_cCurrentFile, "%s/%s.%s", base, tUUID, m_sIn.FMT ); + m_pFD = fopen( m_cCurrentFile, "wb" ); + free( tUUID ); + m_nRemoteRefID = ptr->REF_ID; + return true; + }; + } else { + //ToDo Set File Access to web user + CSTR tUUID = getUniqID_UUID(); + if ( tUUID ) { +#ifdef DEBUG + char tB[256]; + sprintf(tB, "VideoData: %s, %d.%d, [%dx%d@%d] <%s>", tUUID, m_sIn.DTS, m_sIn.DMS, m_sIn.WIDTH, m_sIn.HEIGHT, m_sIn.FPS, m_sIn.FMT); + LOG( tB ); +#endif + servaMySQLDBC * m_pDBC = servaMySQLDBC::getInstance(); + //servaSessionManager * m_pSM = servaSessionManager::getInstance(); + if ( m_nRemoteRefID = m_pDBC->addMediaQueueRecord( tUUID, MID, SID, m_sIn.DTS, m_sIn.DMS, m_sIn.WIDTH, m_sIn.HEIGHT, m_sIn.FPS, m_sIn.FMT ) ) { + sprintf( m_cCurrentFile, "%s/%s.%s", base, tUUID, m_sIn.FMT ); + m_pFD = fopen( m_cCurrentFile, "wb" ); + free( tUUID ); + return true; + }; + free( tUUID ); + }; + } + }; + memset( m_cCurrentFile, 0, MAX_PATH ); + memset( &m_sIn, 0, sizeof(ARGUS_DATA_VIDEO_INFO) ); + return false; +}; + +void servaVideoTransferHelper::clear(){ + if( m_pFD ) fclose( m_pFD ); + m_pFD = NULL; + m_nRemoteRefID = 0; + m_nSAVED = 0; + m_bOPerc = 0; + memset( m_cCurrentFile, 0, MAX_PATH ); + memset( &m_sIn, 0, sizeof(ARGUS_DATA_VIDEO_INFO) ); +}; + +uint32_t servaVideoTransferHelper::saveNextChunk( uint8_t *ptr ){ + if ( ptr ){ + uint64_t tDBID = ptr[0]; + tDBID = ( tDBID << 8 ) | ptr[1]; + tDBID = ( tDBID << 8 ) | ptr[2]; + tDBID = ( tDBID << 8 ) | ptr[3]; + tDBID = ( tDBID << 8 ) | ptr[4]; + tDBID = ( tDBID << 8 ) | ptr[5]; + tDBID = ( tDBID << 8 ) | ptr[6]; + tDBID = ( tDBID << 8 ) | ptr[7]; + uint32_t chusz = ptr[8]; + chusz = ( chusz << 8 ) | ptr[9]; + chusz = ( chusz << 8 ) | ptr[10]; + chusz = ( chusz << 8 ) | ptr[11]; + if ( m_pFD ) { + if ( chusz ) { + int rv = fwrite( ptr+12, 1, chusz, m_pFD ); + if ( rv != chusz ) { + fclose( m_pFD ); + m_pFD = NULL; + unlink( m_cCurrentFile ); + return 0; + }; + m_nSAVED += chusz; + if ( chusz < ARGUS_RPC_DEFAULT_MEDIA_CHUNK ) { + LOG("Video File Reception Done"); + fclose( m_pFD ); + m_pFD = NULL; + servaKernel::getInstance()->updateEncodeStatus(tDBID, MEDIA_STORED, 100); + } else { + if ( m_sIn.DATA_SIZE ) { + uint8_t perc = (uint8_t)((m_nSAVED * 100) / m_sIn.DATA_SIZE); + if ( m_bOPerc != perc ) { + m_bOPerc = perc; + servaKernel::getInstance()->updateEncodeStatus(tDBID, MEDIA_TRANSFERING, perc ); + }; + } else servaKernel::getInstance()->updateEncodeStatus( tDBID, MEDIA_TRANSFERING, 50 ); + }; + return chusz; + }; + }; + }; + return 0; +}; + +#undef LOG +#undef LOG_ERROR diff --git a/lib/App/serva/servaRemoteClientHandler.h b/lib/App/serva/servaRemoteClientHandler.h index 45a6679e..8badf8d6 100644 --- a/lib/App/serva/servaRemoteClientHandler.h +++ b/lib/App/serva/servaRemoteClientHandler.h @@ -47,6 +47,8 @@ class servaVideoTransferHelper{ bool init( CSTR base, uint64_t MID, uint64_t SID, ARGUS_DATA_VIDEO_INFO *ptr ); uint64_t getReferenceID(){ return m_nRemoteRefID; }; }; +#define TRAIN_ON_TRACK true +#define TRAIN_IS_GONE false class servaRPCHadnler: public basicThread, public networkClientHandler, public protocolParser{ private: @@ -67,6 +69,8 @@ class servaRPCHadnler: public basicThread, public networkClientHandler, public p servaVideoTransferHelper m_pVideoHelper; basicMutex m_mCloudProtector; uint32_t m_nCloudStatus; + uint32_t m_nPreTrainCloudStatus; + bool m_bTrainOnTrack; bool peer_send_ack_evt( uint64_t evt_dbid, CSTR uuid ); bool peer_send_req_draw( uint8_t sensor, uint8_t draw_type = ARGUS_RPC_DRAW_TYPE_FAST, bool getexisted = true ); bool peer_send_reg_status( uint8_t status ); @@ -74,6 +78,7 @@ class servaRPCHadnler: public basicThread, public networkClientHandler, public p bool peer_send_time_sync_ack( ARGUS_DATA_TIME_SYNC_ACK *ptr ); bool peer_send_vdata_ack( uint8_t status ); bool peer_send_vinfo_ack( uint64_t pid ); + bool setTrainPresense( bool TST ); protected: virtual int packetChecker(U8 *Buffer, size_t BufferSize); virtual protocolPackage * packetExtractor(U8 *Buffer, size_t BufferSize); @@ -86,6 +91,7 @@ class servaRPCHadnler: public basicThread, public networkClientHandler, public p virtual bool dispatchEvent( EVENT_CONTAINER *Evt ); virtual bool getStatus( void ); bool setRemotePeerIP( CSTR ptr ); + bool getTrainStatus(){ return m_bTrainOnTrack; }; }; diff --git a/lib/App/serva/servaSessionManager.cpp b/lib/App/serva/servaSessionManager.cpp index ec5f0a3f..45342136 100644 --- a/lib/App/serva/servaSessionManager.cpp +++ b/lib/App/serva/servaSessionManager.cpp @@ -38,7 +38,7 @@ servaSessionManager::servaSessionManager( config_setting_t * Settings ){ int tVal; const char * tBuf; char tBuffer[128]; - + /* if(!config_setting_lookup_int(m_pSettings, "SESSION_TIMEOUT", &tVal )){ pSetting = config_setting_add(m_pSettings, "SESSION_TIMEOUT", CONFIG_TYPE_INT); m_nSessionTO = DEFAULT_SESSION_TIMEOUT; @@ -50,6 +50,9 @@ servaSessionManager::servaSessionManager( config_setting_t * Settings ){ sprintf( tBuffer, "Session Timeout Read From Settings: %d sec.", m_nSessionTO ); LOG( tBuffer ); }; + */ + m_nSessionTO = m_pDBC->getSessionTimeOut(); + if(!config_setting_lookup_string(m_pSettings, "REPORTS_DIR_NAME", &tBuf )){ pSetting = config_setting_add(m_pSettings, "REPORTS_DIR_NAME", CONFIG_TYPE_STRING); sprintf( m_pDbReportBase, "data/reports" ); @@ -247,6 +250,7 @@ bool servaSessionManager::addVideo( DBC_RPC_MEDIA_INFO_EX *ptr ){//uint32_t modu bool bExpiredSession = false; SESSION_DATA *sp = validateSession( ptr->session_id ); if ( sp == NULL ) { + LOG("Session Allredy Closed"); sp = reopenSession( ptr->session_id ); if ( sp == NULL ) { LOG_ERROR( "Session Data ptr is null!"); @@ -270,14 +274,11 @@ bool servaSessionManager::addVideo( DBC_RPC_MEDIA_INFO_EX *ptr ){//uint32_t modu ptr->fmt, ptr->fps ); -#ifdef DEBUG_EXTRA +#ifdef DEBUG LOG( tQBuf ); #endif bool rv = sp->m_pDataReport->SilentQuery( tQBuf ); - if( bExpiredSession ){ - delete( sp->m_pDataReport ); - free( sp ); - }; + if( bExpiredSession ) dropSession( ptr->session_id ); return rv; } else { LOG_ERROR( "Report DB is closed!"); @@ -295,18 +296,23 @@ CSTR servaSessionManager::getReportDir( uint64_t track_id, uint32_t ts ){ REPORT_DIRINFO tRDF; fillRDF( ts, tRDF ); sprintf( retVal, "%s/%" PRIu64 "/%s/%s/%s", m_pDbReportBase, track_id, tRDF.YEAR, tRDF.MONTH, tRDF.DAY ); +#ifdef DEBUG_EXTRA LOG( retVal ); +#endif return strdup( retVal ); }; CSTR servaSessionManager::getSessionBase( uint64_t sid ){ + CSTR rData = NULL; SESSION_DATA *sp = validateSession( sid ); if ( sp ) return strdup( sp->reportVaultPath ); - //Get Session Base from Database then - LOG("Reopen Session!"); + //TODO: Get Session Base from Database then (not open/close session) sp = reopenSession( sid ); - if ( sp ) return strdup( sp->reportVaultPath ); - return NULL; + if ( sp ) { + rData = strdup( sp->reportVaultPath ); + dropSession( sid ); + }; + return rData; }; SESSION_DATA *servaSessionManager::reopenSession( uint64_t session_id ){ @@ -391,7 +397,9 @@ SESSION_DATA *servaSessionManager::reopenSession( uint64_t session_id ){ if ( tData ){ LOG("Assign Session To Vector!"); + m_mSessionProtector.lock(); m_mSessions[tData->track_id] = tData; + m_mSessionProtector.unlock(); }; return tData; }; @@ -399,11 +407,14 @@ SESSION_DATA *servaSessionManager::reopenSession( uint64_t session_id ){ SESSION_DATA *servaSessionManager::updateSession( uint64_t tack_id, uint64_t module_id ){ SESSION_DATA * tData = NULL; try { + m_mSessionProtector.lock(); tData = m_mSessions.at( tack_id ); + m_mSessionProtector.unlock(); #ifdef DEBUG LOG("Have Opened Session"); #endif } catch ( ... ) { + m_mSessionProtector.unlock(); // No Session -> Create one tData = (SESSION_DATA*) malloc( sizeof(SESSION_DATA) ); if ( tData ) { @@ -497,7 +508,9 @@ SESSION_DATA *servaSessionManager::updateSession( uint64_t tack_id, uint64_t mod free( tData ); tData = NULL; } else { + m_mSessionProtector.lock(); m_mSessions[tack_id] = tData; + m_mSessionProtector.unlock(); //Propogate Event ->Session Start EVENT_CONTAINER *tEvt = createBasicEvent( tack_id, EVT_CLASS_SYSTEM, EVT_SRV_SESSION_STARTED ); if ( tEvt ) basicEventHeap::getInstance()->broadcast( tEvt ); @@ -524,6 +537,7 @@ bool servaSessionManager::validate(){ uint32_t cts = time( NULL ); M_SESSIONS::iterator dE; bool bMustDelete = false; + m_mSessionProtector.lock(); for( M_SESSIONS::iterator idx = m_mSessions.begin(); idx != m_mSessions.end(); idx++ ){ if ( (*idx).second ) { #ifdef DEBUG_EXTRA @@ -553,6 +567,7 @@ bool servaSessionManager::validate(){ (*dE).second = NULL; m_mSessions.erase( dE ); }; + m_mSessionProtector.unlock(); return true; }; @@ -563,30 +578,25 @@ SESSION_DATA *servaSessionManager::validateSession( uint64_t sid ){ }; bool servaSessionManager::dropSession( uint64_t session_id ){ - M_SESSIONS::iterator dE; - bool bMustDelete = false; -#ifdef DEBUG_EXTRA +#ifdef DEBUG LOG("Drop Session!"); #endif for( M_SESSIONS::iterator idx = m_mSessions.begin(); idx != m_mSessions.end(); idx++ ){ - if ( (*idx).second ) { - if( (*idx).second->db_id == session_id ) { - bMustDelete = true; - break; - }; - }; - }; - if ( bMustDelete ) { - // Remove Session - delete( (*dE).second->m_pDataReport ); - free( (*dE).second ); - (*dE).second = NULL; - m_mSessions.erase( dE ); - return true; - }; + if ( (*idx).second ) if ((*idx).second->db_id == session_id) return dropSession( idx ); + }; return false; }; +bool servaSessionManager::dropSession( M_SESSIONS::iterator idx ){ + m_mSessionProtector.lock(); + delete( (*idx).second->m_pDataReport ); + free( (*idx).second ); + (*idx).second = NULL; + m_mSessions.erase( idx ); + m_mSessionProtector.unlock(); + return true; +}; + bool servaSessionManager::eraseSession( uint64_t session_id ){ //Erase just not important sessions // In case The session is Opened! diff --git a/lib/App/serva/servaSessionManager.h b/lib/App/serva/servaSessionManager.h index 9fae8df9..e41a3e03 100644 --- a/lib/App/serva/servaSessionManager.h +++ b/lib/App/serva/servaSessionManager.h @@ -7,6 +7,7 @@ #include "../common/dataBinder_ReportAux.h" #include "../../components/base/basicSettingsProvider.h" #include "../../components/base/basicEvent.h" +#include "../../components/base/basicMutex.h" #include "../common/serverDataBinder.h" #include "../../data/protocol/protocolARGUS_DATA.h" @@ -24,10 +25,12 @@ class servaSessionManager{ bool m_bRepIsConnected; char web_access_user[64]; char web_access_group[64]; + basicMutex m_mSessionProtector; char m_pDbReportBase[MAX_PATH]; bool addEvent( SESSION_DATA *sp, ARGUS_DATA_EVENT *ptr ); //DBC_EVT_RECORD *ptr ); SESSION_DATA * reopenSession( uint64_t session_id ); bool dropSession( uint64_t session_id ); + bool dropSession( M_SESSIONS::iterator idx ); protected: explicit servaSessionManager( config_setting_t * Settings ); public: diff --git a/lib/alg/generic/Transform.cpp b/lib/alg/generic/Transform.cpp index 444aa6a5..390c892a 100644 --- a/lib/alg/generic/Transform.cpp +++ b/lib/alg/generic/Transform.cpp @@ -25,6 +25,12 @@ } #endif +C3D_FLOAT getDistance( C3D_DECART B, C3D_DECART B ){ + C3D_FLOAT dx2 = C3D_POW( B.x - B.x, 2.0f); + C3D_FLOAT dy2 = C3D_POW( B.y - B.y, 2.0f); + C3D_FLOAT dz2 = C3D_POW( B.z - B.z, 2.0f); + return C3D_SQRT( dx2 + dy2 + dz2 ); +}; void spherical2decart(C3D_SPH_DEGREES in, C3D_DECART &out){ C3D_FLOAT tT, tF; diff --git a/lib/alg/generic/Transform.h b/lib/alg/generic/Transform.h index a1127ffc..72b2e54d 100644 --- a/lib/alg/generic/Transform.h +++ b/lib/alg/generic/Transform.h @@ -126,6 +126,8 @@ void translate2local(S_TRANS_MATRIX mat, C3D_DECART world, C3D_DECART &local); void translate2world(S_TRANS_MATRIX mat, C3D_DECART local, C3D_DECART &world); void transponeMatrix(S_TRANS_MATRIX in, S_TRANS_MATRIX &out); +C3D_FLOAT getDistance( C3D_DECART B, C3D_DECART B ); + struct ptz_params { float pan; float tilt; diff --git a/lib/components/base/basicEvent.h b/lib/components/base/basicEvent.h index a7de417e..ff0d6548 100644 --- a/lib/components/base/basicEvent.h +++ b/lib/components/base/basicEvent.h @@ -191,11 +191,22 @@ typedef struct S_TARGET_DATA { C3D_SPH_DEGREES local_target; C3D_DECART system_target; C3D_WGS84_LOC global_target; - uint32_t digital; - uint8_t lrf_id; + uint16_t digital; + uint32_t segment_id; /* Systemwide ID */ + uint8_t lrf_id; /* Sensorwide ID */ float area; }TARGET_DATA; +typedef struct S_TARGET_SEGMENT{ + uint32_t id; + C3D_DECART system_center; + float boundary; + uint64_t ttl; // milliseconds + bool blocked; + uint8_t hit_count; + uint8_t blocked_count; +}TARGET_SEGMENT; + typedef struct S_CLIENT_EVENT{ uint8_t type; //basicEventTypeID uint32_t uts; //Time Stamp Seconds diff --git a/lib/rgoose/rgooseTargetFilter.h b/lib/rgoose/rgooseTargetFilter.h index bce154ae..98654cee 100644 --- a/lib/rgoose/rgooseTargetFilter.h +++ b/lib/rgoose/rgooseTargetFilter.h @@ -6,9 +6,10 @@ #include "rgooseDBConnector.h" typedef enum E_TARGET_FILTER_TYPE{ - TR_UDEFINED_FILTER = 0, + TF_UDEFINED_FILTER = 0, TF_LA_METRO_TRAIN_FILTER = 1, - TF_AUTHORISED_PEOPLE_FILTER = 2 + TF_AUTHORISED_PEOPLE_FILTER = 2, + TF_BUBBLE_SEGMENTATION_FILTER = 3 }TARGET_FILTER_TYPE; class ARGUS_TARGET_FILTER{