diff --git a/Projects/argus/Debug/default.conf b/Projects/argus/Debug/default.conf
index a82e9ee6..67edd92e 100644
--- a/Projects/argus/Debug/default.conf
+++ b/Projects/argus/Debug/default.conf
@@ -36,13 +36,3 @@ KERNEL :
IDENTITY = "d7d823703f68ba05c04efdb7474c2de5";
SITE_ID = 1;
};
-APPLICATION_GUI :
-{
- SYSTEM_ANCHOR :
- {
- POSITION_LATITUDE = 0.0;
- POSITION_LONGITUDE = 0.0;
- POSITION_ALT = 0.0;
- SOUTH_HEMISPHERE = false;
- };
-};
diff --git a/Projects/argus/argus.vpj b/Projects/argus/argus.vpj
index 0c7413e3..31d8f47c 100644
--- a/Projects/argus/argus.vpj
+++ b/Projects/argus/argus.vpj
@@ -326,6 +326,7 @@
+
@@ -390,6 +391,7 @@
+
diff --git a/Projects/argus/makefile b/Projects/argus/makefile
index ef8a6881..7425bbaa 100644
--- a/Projects/argus/makefile
+++ b/Projects/argus/makefile
@@ -59,9 +59,9 @@ COMMON_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/rgooseModule.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseNode.o $(OUTDIR)/rgooseNode2D.o \
$(OUTDIR)/rgooseNode3D.o $(OUTDIR)/rgooseNodeFactory.o \
- $(OUTDIR)/rgooseServerModule.o $(OUTDIR)/rgooseUSBRelayModule.o \
- $(OUTDIR)/rgooseZLMediaModule.o $(OUTDIR)/serialPort.o \
- $(OUTDIR)/serialSOL.o $(OUTDIR)/serverPort.o \
+ $(OUTDIR)/rgoosePelcoCamera.o $(OUTDIR)/rgooseServerModule.o \
+ $(OUTDIR)/rgooseUSBRelayModule.o $(OUTDIR)/rgooseZLMediaModule.o \
+ $(OUTDIR)/serialPort.o $(OUTDIR)/serialSOL.o $(OUTDIR)/serverPort.o \
$(OUTDIR)/servletChannelWS.o $(OUTDIR)/servletClientHandlerWS.o \
$(OUTDIR)/servletWS.o $(OUTDIR)/ssdpAnnouncer.o \
$(OUTDIR)/Transform.o $(OUTDIR)/transportSerial.o \
@@ -100,9 +100,9 @@ ALL_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/rgooseModule.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseNode.o $(OUTDIR)/rgooseNode2D.o \
$(OUTDIR)/rgooseNode3D.o $(OUTDIR)/rgooseNodeFactory.o \
- $(OUTDIR)/rgooseServerModule.o $(OUTDIR)/rgooseUSBRelayModule.o \
- $(OUTDIR)/rgooseZLMediaModule.o $(OUTDIR)/serialPort.o \
- $(OUTDIR)/serialSOL.o $(OUTDIR)/serverPort.o \
+ $(OUTDIR)/rgoosePelcoCamera.o $(OUTDIR)/rgooseServerModule.o \
+ $(OUTDIR)/rgooseUSBRelayModule.o $(OUTDIR)/rgooseZLMediaModule.o \
+ $(OUTDIR)/serialPort.o $(OUTDIR)/serialSOL.o $(OUTDIR)/serverPort.o \
$(OUTDIR)/servletChannelWS.o $(OUTDIR)/servletClientHandlerWS.o \
$(OUTDIR)/servletWS.o $(OUTDIR)/ssdpAnnouncer.o \
$(OUTDIR)/Transform.o $(OUTDIR)/transportSerial.o \
@@ -236,9 +236,9 @@ COMMON_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/rgooseModule.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseNode.o $(OUTDIR)/rgooseNode2D.o \
$(OUTDIR)/rgooseNode3D.o $(OUTDIR)/rgooseNodeFactory.o \
- $(OUTDIR)/rgooseServerModule.o $(OUTDIR)/rgooseUSBRelayModule.o \
- $(OUTDIR)/rgooseZLMediaModule.o $(OUTDIR)/serialPort.o \
- $(OUTDIR)/serialSOL.o $(OUTDIR)/serverPort.o \
+ $(OUTDIR)/rgoosePelcoCamera.o $(OUTDIR)/rgooseServerModule.o \
+ $(OUTDIR)/rgooseUSBRelayModule.o $(OUTDIR)/rgooseZLMediaModule.o \
+ $(OUTDIR)/serialPort.o $(OUTDIR)/serialSOL.o $(OUTDIR)/serverPort.o \
$(OUTDIR)/servletChannelWS.o $(OUTDIR)/servletClientHandlerWS.o \
$(OUTDIR)/servletWS.o $(OUTDIR)/ssdpAnnouncer.o \
$(OUTDIR)/Transform.o $(OUTDIR)/transportSerial.o \
@@ -277,9 +277,9 @@ ALL_OBJ=$(OUTDIR)/ArgusBackend.o $(OUTDIR)/base64.o \
$(OUTDIR)/rgooseModule.o $(OUTDIR)/rgooseModuleFactory.o \
$(OUTDIR)/rgooseNode.o $(OUTDIR)/rgooseNode2D.o \
$(OUTDIR)/rgooseNode3D.o $(OUTDIR)/rgooseNodeFactory.o \
- $(OUTDIR)/rgooseServerModule.o $(OUTDIR)/rgooseUSBRelayModule.o \
- $(OUTDIR)/rgooseZLMediaModule.o $(OUTDIR)/serialPort.o \
- $(OUTDIR)/serialSOL.o $(OUTDIR)/serverPort.o \
+ $(OUTDIR)/rgoosePelcoCamera.o $(OUTDIR)/rgooseServerModule.o \
+ $(OUTDIR)/rgooseUSBRelayModule.o $(OUTDIR)/rgooseZLMediaModule.o \
+ $(OUTDIR)/serialPort.o $(OUTDIR)/serialSOL.o $(OUTDIR)/serverPort.o \
$(OUTDIR)/servletChannelWS.o $(OUTDIR)/servletClientHandlerWS.o \
$(OUTDIR)/servletWS.o $(OUTDIR)/ssdpAnnouncer.o \
$(OUTDIR)/Transform.o $(OUTDIR)/transportSerial.o \
diff --git a/Projects/custom_cam/custom_raylib.cpp b/Projects/custom_cam/custom_raylib.cpp
new file mode 100644
index 00000000..e62c1136
--- /dev/null
+++ b/Projects/custom_cam/custom_raylib.cpp
@@ -0,0 +1,169 @@
+/*******************************************************************************************
+*
+* raylib [textures] example - Image processing
+*
+* NOTE: Images are loaded in CPU memory (RAM); textures are loaded in GPU memory (VRAM)
+*
+* This example has been created using raylib 3.5 (www.raylib.com)
+* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
+*
+* Copyright (c) 2016 Ramon Santamaria (@raysan5)
+*
+********************************************************************************************/
+
+#include "raylib.h"
+
+#include // Required for: free()
+
+#define NUM_PROCESSES 8
+
+typedef enum {
+ NONE = 0,
+ COLOR_GRAYSCALE,
+ COLOR_TINT,
+ COLOR_INVERT,
+ COLOR_CONTRAST,
+ COLOR_BRIGHTNESS,
+ FLIP_VERTICAL,
+ FLIP_HORIZONTAL
+} ImageProcess;
+
+static const char *processText[] = {
+ "NO PROCESSING",
+ "COLOR GRAYSCALE",
+ "COLOR TINT",
+ "COLOR INVERT",
+ "COLOR CONTRAST",
+ "COLOR BRIGHTNESS",
+ "FLIP VERTICAL",
+ "FLIP HORIZONTAL"
+};
+
+int main(void)
+{
+ // Initialization
+ //--------------------------------------------------------------------------------------
+ const int screenWidth = 800;
+ const int screenHeight = 450;
+
+ InitWindow(screenWidth, screenHeight, "raylib [textures] example - image processing");
+
+ // NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
+
+ Image imOrigin = LoadImage("resources/parrots.png"); // Loaded in CPU memory (RAM)
+ ImageFormat(&imOrigin, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update) <-- ISSUE
+ Texture2D texture = LoadTextureFromImage(imOrigin); // Image converted to texture, GPU memory (VRAM)
+
+ Image imCopy = ImageCopy(imOrigin);
+
+ int currentProcess = NONE;
+ bool textureReload = false;
+
+ Rectangle toggleRecs[NUM_PROCESSES] = { 0 };
+ int mouseHoverRec = -1;
+
+ for (int i = 0; i < NUM_PROCESSES; i++) toggleRecs[i] = (Rectangle){ 40.0f, (float)(50 + 32*i), 150.0f, 30.0f };
+
+ SetTargetFPS(60);
+ //---------------------------------------------------------------------------------------
+
+ // Main game loop
+ while (!WindowShouldClose()) // Detect window close button or ESC key
+ {
+ // Update
+ //----------------------------------------------------------------------------------
+
+ // Mouse toggle group logic
+ for (int i = 0; i < NUM_PROCESSES; i++)
+ {
+ if (CheckCollisionPointRec(GetMousePosition(), toggleRecs[i]))
+ {
+ mouseHoverRec = i;
+
+ if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
+ {
+ currentProcess = i;
+ textureReload = true;
+ }
+ break;
+ }
+ else mouseHoverRec = -1;
+ }
+
+ // Keyboard toggle group logic
+ if (IsKeyPressed(KEY_DOWN))
+ {
+ currentProcess++;
+ if (currentProcess > (NUM_PROCESSES - 1)) currentProcess = 0;
+ textureReload = true;
+ }
+ else if (IsKeyPressed(KEY_UP))
+ {
+ currentProcess--;
+ if (currentProcess < 0) currentProcess = 7;
+ textureReload = true;
+ }
+
+ // Reload texture when required
+ if (textureReload)
+ {
+ UnloadImage(imCopy); // Unload image-copy data
+ imCopy = ImageCopy(imOrigin); // Restore image-copy from image-origin
+
+ // NOTE: Image processing is a costly CPU process to be done every frame,
+ // If image processing is required in a frame-basis, it should be done
+ // with a texture and by shaders
+ switch (currentProcess)
+ {
+ case COLOR_GRAYSCALE: ImageColorGrayscale(&imCopy); break;
+ case COLOR_TINT: ImageColorTint(&imCopy, GREEN); break;
+ case COLOR_INVERT: ImageColorInvert(&imCopy); break;
+ case COLOR_CONTRAST: ImageColorContrast(&imCopy, -40); break;
+ case COLOR_BRIGHTNESS: ImageColorBrightness(&imCopy, -80); break;
+ case FLIP_VERTICAL: ImageFlipVertical(&imCopy); break;
+ case FLIP_HORIZONTAL: ImageFlipHorizontal(&imCopy); break;
+ default: break;
+ }
+
+ Color *pixels = LoadImageColors(imCopy); // Load pixel data from image (RGBA 32bit)
+ UpdateTexture(texture, pixels); // Update texture with new image data
+ UnloadImageColors(pixels); // Unload pixels data from RAM
+
+ textureReload = false;
+ }
+ //----------------------------------------------------------------------------------
+
+ // Draw
+ //----------------------------------------------------------------------------------
+ BeginDrawing();
+
+ ClearBackground(RAYWHITE);
+
+ DrawText("IMAGE PROCESSING:", 40, 30, 10, DARKGRAY);
+
+ // Draw rectangles
+ for (int i = 0; i < NUM_PROCESSES; i++)
+ {
+ DrawRectangleRec(toggleRecs[i], ((i == currentProcess) || (i == mouseHoverRec)) ? SKYBLUE : LIGHTGRAY);
+ DrawRectangleLines((int)toggleRecs[i].x, (int) toggleRecs[i].y, (int) toggleRecs[i].width, (int) toggleRecs[i].height, ((i == currentProcess) || (i == mouseHoverRec)) ? BLUE : GRAY);
+ DrawText( processText[i], (int)( toggleRecs[i].x + toggleRecs[i].width/2 - MeasureText(processText[i], 10)/2), (int) toggleRecs[i].y + 11, 10, ((i == currentProcess) || (i == mouseHoverRec)) ? DARKBLUE : DARKGRAY);
+ }
+
+ DrawTexture(texture, screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, WHITE);
+ DrawRectangleLines(screenWidth - texture.width - 60, screenHeight/2 - texture.height/2, texture.width, texture.height, BLACK);
+
+ EndDrawing();
+ //----------------------------------------------------------------------------------
+ }
+
+ // De-Initialization
+ //--------------------------------------------------------------------------------------
+ UnloadTexture(texture); // Unload texture from VRAM
+ UnloadImage(imOrigin); // Unload image-origin from RAM
+ UnloadImage(imCopy); // Unload image-copy from RAM
+
+ CloseWindow(); // Close window and OpenGL context
+ //--------------------------------------------------------------------------------------
+
+ return 0;
+}
diff --git a/Projects/custom_cam/custom_sdl.cpp b/Projects/custom_cam/custom_sdl.cpp
new file mode 100644
index 00000000..ac27de6a
--- /dev/null
+++ b/Projects/custom_cam/custom_sdl.cpp
@@ -0,0 +1,75 @@
+#include
+#include
+
+int main(){
+ int nVDrvNumber = 0;
+ //if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
+ // printf( "SDL_Init Error: %s \n", SDL_GetError() );
+ // return EXIT_FAILURE;
+ //}
+ SDL_Init( 0 );
+
+ std::vector< bool > drivers( SDL_GetNumVideoDrivers() );
+
+ for( int i = 0; i < drivers.size(); ++i ){
+ drivers[ i ] = ( 0 == SDL_VideoInit( SDL_GetVideoDriver( i ) ) );
+ SDL_VideoQuit();
+ };
+
+ printf( "SDL_VIDEODRIVER usable: " );
+ for( int i = 0; i < drivers.size(); ++i ){
+ if( !drivers[ i ] ) continue;
+ printf( " %s", SDL_GetVideoDriver( i ) );
+ };
+ printf( "\n" );
+
+ nVDrvNumber = SDL_GetNumVideoDrivers();
+ printf( "Number of Video Drivers: %d\n", nVDrvNumber );
+ if( nVDrvNumber ){
+ for( int j = 0; j < nVDrvNumber; j++ ){
+ printf( "Driver[%d]:%s\n", j, SDL_GetVideoDriver( j ) );
+ };
+ };
+
+ if (SDL_GL_ExtensionSupported("GL_EXT_framebuffer_blit")) {
+ printf( "Use Blit\n" );
+ //draw_to_the_screen_with_framebuffer_blit(); // faster!
+ } else {
+ printf( "No Blit!\n" );
+ //draw_to_the_screen_with_a_textured_quad(); // slower!
+ };
+
+
+ if( SDL_VideoInit("directfb") != 0 ){
+ printf("Error initializing SDL video: %s\n", SDL_GetError());
+ return 2;
+ };
+
+ static int display_in_use = 0; /* Only using first display */
+
+ int i, display_mode_count;
+ SDL_DisplayMode mode;
+ Uint32 f;
+
+ SDL_Log("SDL_GetNumVideoDisplays(): %i", SDL_GetNumVideoDisplays());
+
+ display_mode_count = SDL_GetNumDisplayModes(display_in_use);
+ if (display_mode_count < 1) {
+ SDL_Log("SDL_GetNumDisplayModes failed: %s", SDL_GetError());
+ return 1;
+ }
+ SDL_Log("SDL_GetNumDisplayModes: %i", display_mode_count);
+
+ for (i = 0; i < display_mode_count; ++i) {
+ if (SDL_GetDisplayMode(display_in_use, i, &mode) != 0) {
+ SDL_Log("SDL_GetDisplayMode failed: %s", SDL_GetError());
+ return 1;
+ }
+ f = mode.format;
+
+ SDL_Log("Mode %i\tbpp %i\t%s\t%i x %i", i,
+ SDL_BITSPERPIXEL(f), SDL_GetPixelFormatName(f), mode.w, mode.h);
+ }
+ SDL_Quit();
+ return 0;
+};
\ No newline at end of file
diff --git a/Projects/custom_cam/popo b/Projects/custom_cam/popo
new file mode 100755
index 00000000..35b7601d
Binary files /dev/null and b/Projects/custom_cam/popo differ
diff --git a/Projects/custom_cam/runtest b/Projects/custom_cam/runtest
new file mode 100755
index 00000000..24f1797a
--- /dev/null
+++ b/Projects/custom_cam/runtest
@@ -0,0 +1,2 @@
+g++ ./custom_sdl.cpp -o popo `pkg-config --cflags --libs sdl2`
+#g++ ./custom_raylib.cpp -o popo -lGL -L/opt/vc/lib `pkg-config --cflags --libs bcm_host brcmegl raylib`
\ No newline at end of file
diff --git a/Projects/custom_cam/start_params b/Projects/custom_cam/start_params
new file mode 100755
index 00000000..7af90f65
--- /dev/null
+++ b/Projects/custom_cam/start_params
@@ -0,0 +1 @@
+./popo --dfb:pixelformat=ARGB,system=fbdev,depth=16,mode=480x320
diff --git a/lib/components/base/basicEvent.cpp b/lib/components/base/basicEvent.cpp
index 15f59e17..15eaed9f 100644
--- a/lib/components/base/basicEvent.cpp
+++ b/lib/components/base/basicEvent.cpp
@@ -13,9 +13,10 @@
//----------------------------------------------------------------------------
//
#include "basicEvent.h"
+#include "basicFunctionality.h"
-void utilizeBasicEvent( basicEvent &Evt ){
+void utilizeBasicEvent( EVENT_CONTAINER &Evt ){
if( Evt.m_pHumanReadableMsg != NULL ) {
delete( Evt.m_pHumanReadableMsg );
};
@@ -36,7 +37,7 @@ void utilizeBasicEvent( basicEvent &Evt ){
Evt.m_pEvtData = NULL;
Evt.m_eType = EVT_NOINIT;
};
-void utilizeBasicEvent( basicEvent *Evt ){
+void utilizeBasicEvent( EVENT_CONTAINER *Evt ){
if( Evt == NULL ) return;
if( Evt->m_pHumanReadableMsg != NULL ) {
delete( Evt->m_pHumanReadableMsg );
@@ -56,40 +57,64 @@ void utilizeBasicEvent( basicEvent *Evt ){
};
delete( Evt );
};
-basicEvent *createBasicEvent(unsigned int SRC, basicEventClassID Class, basicEventTypeID Type, char *Msg, void *Data){
- basicEvent *tEvent;
- tEvent =(basicEvent *) malloc( sizeof( basicEvent));
+EVENT_CONTAINER *createBasicEvent(unsigned int SRC, basicEventClassID Class, basicEventTypeID Type, char *Msg, void *Data){
+ EVENT_CONTAINER *tEvent;
+ tEvent =(EVENT_CONTAINER *) malloc(sizeof(EVENT_CONTAINER));
if( tEvent ){
time_t t = time(NULL);
tEvent->sTS = *localtime(&t);
+ tEvent->m_UMSTS = getMilliseconds();
tEvent->m_eClass = Class;
- tEvent->m_eType = Type;
+ CSTR tUUID = getUniqID_UUID();
+ if( tUUID ) {
+ sprintf( tEvent->m_UUID, "%s", tUUID );
+ free( tUUID );
+ } else {
+ memset( tEvent->m_UUID, 0, 65 );
+ };
+ tEvent->m_eType = Type;
tEvent->m_nDestinationUID = 0; // Broadcast
tEvent->m_nSourceUID = SRC;
tEvent->m_pEvtData = Data;
- tEvent->m_pHumanReadableMsg = (char *) malloc(strlen(Msg)+1);
- if( tEvent->m_pHumanReadableMsg ) {
- strcpy( tEvent->m_pHumanReadableMsg, Msg );
- };
+ if( Msg != NULL ) {
+ tEvent->m_pHumanReadableMsg = (char *) malloc(strlen(Msg)+1);
+ if( tEvent->m_pHumanReadableMsg ) {
+ strcpy( tEvent->m_pHumanReadableMsg, Msg );
+ };
+ } else {
+ tEvent->m_pHumanReadableMsg = NULL;
+ };
};
return tEvent;
};
-basicEvent *createBasicTargetedEvent(unsigned int SRC, unsigned int DST, basicEventClassID Class, basicEventTypeID Type, char *Msg, void *Data){
- basicEvent *tEvent;
- tEvent = (basicEvent *)malloc(sizeof(basicEvent));
+EVENT_CONTAINER *createBasicTargetedEvent(unsigned int SRC, unsigned int DST, basicEventClassID Class, basicEventTypeID Type, char *Msg, void *Data){
+ EVENT_CONTAINER *tEvent;
+ tEvent = (EVENT_CONTAINER *)malloc(sizeof(EVENT_CONTAINER));
if (tEvent){
time_t t = time(NULL);
tEvent->sTS = *localtime(&t);
+ tEvent->m_UMSTS = getMilliseconds();
tEvent->m_eClass = Class;
+ CSTR tUUID = getUniqID_UUID();
+ if( tUUID ) {
+ sprintf( tEvent->m_UUID, "%s", tUUID );
+ free( tUUID );
+ } else {
+ memset( tEvent->m_UUID, 0, 65 );
+ };
tEvent->m_eType = Type;
tEvent->m_nDestinationUID = DST;
tEvent->m_nSourceUID = SRC;
tEvent->m_pEvtData = Data;
- tEvent->m_pHumanReadableMsg = (char *)malloc(strlen(Msg) + 1);
- if (tEvent->m_pHumanReadableMsg) {
- strcpy(tEvent->m_pHumanReadableMsg, Msg);
- };
+ if( Msg != NULL ) {
+ tEvent->m_pHumanReadableMsg = (char *) malloc(strlen(Msg)+1);
+ if( tEvent->m_pHumanReadableMsg ) {
+ strcpy( tEvent->m_pHumanReadableMsg, Msg );
+ };
+ } else {
+ tEvent->m_pHumanReadableMsg = NULL;
+ };
};
return tEvent;
};
\ No newline at end of file
diff --git a/lib/components/base/basicEvent.h b/lib/components/base/basicEvent.h
index 65c15ac8..e0cf8d00 100644
--- a/lib/components/base/basicEvent.h
+++ b/lib/components/base/basicEvent.h
@@ -20,6 +20,7 @@
#include
#include
#include "basicTypes.h"
+#include "basicPosition.h"
typedef enum E_basicEventTypeID {
EVT_NOINIT = 0,
@@ -41,14 +42,20 @@ typedef enum E_basicEventTypeID {
EVT_CAPTURE_END = 14,
EVT_CAPTURE_DONE = 15,
EVT_ERROR = 16,
- EVT_FH_TAKE_OFF = 17,
- EVT_FH_DEST_REACHED = 18,
- EVT_FH_TARGET_LOCKED= 19,
- EVT_FH_INTERCEPT_OK = 20,
- EVT_FH_INTERCEPT_NOK= 21,
- EVT_FH_MISSION_END = 22,
- EVT_FH_LANDED = 23,
- EVT_COUNT = 24
+ EVT_FH_MISSION_BEGIN = 17,
+ EVT_FH_FLY_TO = 18,
+ EVT_FH_JAMER_ON = 19,
+ EVT_FH_JAMER_OFF = 20,
+ EVT_FH_INTERCEPT_BEGIN = 21,
+ EVT_FH_INTERCEPT_END = 22,
+ EVT_FH_DEST_REACHED = 23,
+ EVT_FH_TARGET_LOCKED= 24,
+ EVT_FH_INTERCEPT_OK = 25,
+ EVT_FH_INTERCEPT_NOK= 26,
+ EVT_FH_MISSION_END = 27,
+ EVT_FH_LANDED = 28,
+ EVT_CAMERA_DM = 29,
+ EVT_COUNT = 30
} basicEventTypeID;
//#define MAX_EVENT_ID 17
@@ -67,19 +74,39 @@ typedef enum E_basicEventClassID{
EVT_CLASS_SENSOR_3D = 11,
EVT_CLASS_SENSOR_ACC = 12,
EVT_CLASS_FLY_HUNTER = 13,
- EVT_CLASS_EXTERNAL_CMD = 14,
- EVT_CLASS_COUNT = 15
+ EVT_CLASS_CAMERA_CTRL = 14,
+ EVT_CLASS_EXTERNAL_CMD = 15,
+ EVT_CLASS_COUNT = 16
} basicEventClassID;
-typedef struct S_basicEvent{
+typedef struct S_EVENT_CONTAINER{
int m_nSourceUID;
int m_nDestinationUID;
+ char m_UUID[65];
basicEventClassID m_eClass;
basicEventTypeID m_eType;
+ long long m_UMSTS;
struct tm sTS;
char *m_pHumanReadableMsg;
void *m_pEvtData;
-} basicEvent;
+} EVENT_CONTAINER;
+
+typedef struct S_CAMERA_CTRL_DATA {
+ uint32_t cam_id;
+ uint8_t moveMask;
+ float spdPAN;
+ float spdTILT;
+ float spdZOOM;
+ float absPAN;
+ float absTILT;
+ float absZOOM;
+} CAMERA_CTRL_DATA;
+
+typedef struct S_FH_CTRL_DATA{
+ char cmdUUID[38];
+ char targetUUID[38];
+}FH_CTRL_DATA;
+
/*
typedef struct S_alarmDataEvent{
uint32_t mRange;
@@ -92,6 +119,7 @@ typedef struct S_alarmDataEvent{
} alarmDataEvent;
*/
#include "../../alg/generic/Transform.h"
+
typedef struct S_TARGET_DATA {
C3D_WGS84_LOC source_position;
C3D_SPH_DEGREES local_target;
@@ -113,15 +141,15 @@ typedef struct S_CLIENT_EVENT{
typedef std::queue EventsFIFO;
-void utilizeBasicEvent( basicEvent &Evt );
-void utilizeBasicEvent( basicEvent *Evt );
+void utilizeBasicEvent( EVENT_CONTAINER &Evt );
+void utilizeBasicEvent( EVENT_CONTAINER *Evt );
-basicEvent *createBasicEvent(unsigned int SRC, basicEventClassID Class, basicEventTypeID Type, char *Msg = NULL, void *Data = NULL);
-basicEvent *createBasicTargetedEvent(unsigned int SRC, unsigned int DST, basicEventClassID Class, basicEventTypeID Type, char *Msg = NULL, void *Data = NULL);
+EVENT_CONTAINER *createBasicEvent(unsigned int SRC, basicEventClassID Class, basicEventTypeID Type, char *Msg = NULL, void *Data = NULL);
+EVENT_CONTAINER *createBasicTargetedEvent(unsigned int SRC, unsigned int DST, basicEventClassID Class, basicEventTypeID Type, char *Msg = NULL, void *Data = NULL);
-typedef std::queue< basicEvent > EventQueue;
-typedef std::queue< basicEvent *> pEventQueue;
-typedef std::vector< basicEvent > EventVector;
-typedef std::vector< basicEvent *> pEventVector;
+typedef std::queue< EVENT_CONTAINER > EventQueue;
+typedef std::queue< EVENT_CONTAINER *> pEventQueue;
+typedef std::vector< EVENT_CONTAINER > EventVector;
+typedef std::vector< EVENT_CONTAINER *> pEventVector;
#endif
diff --git a/lib/components/base/basicEventHandler.h b/lib/components/base/basicEventHandler.h
index 6e8eeb27..61c48e8f 100644
--- a/lib/components/base/basicEventHandler.h
+++ b/lib/components/base/basicEventHandler.h
@@ -14,34 +14,9 @@ class basicEventHandler {
explicit basicEventHandler( bool atBottom = false );
// Destructor
virtual ~basicEventHandler();
- virtual void dispatchEvent( basicEvent *Evt ){};
- // Copy constructor
- // TODO: Uncomment the copy constructor when you need it.
- //basicEventHandler(const basicEventHandler& src);
-
- // Assignment operator
- // TODO: Uncomment the assignment operator when you need it.
- //basicEventHandler& operator=(const basicEventHandler& src);
+ virtual void dispatchEvent( EVENT_CONTAINER *Evt ){};
};
-// TODO: Uncomment the copy constructor when you need it.
-//inline basicEventHandler::basicEventHandler(const basicEventHandler& src)
-//{
-// // TODO: copy
-//}
-
-// TODO: Uncomment the assignment operator when you need it.
-//inline basicEventHandler& basicEventHandler::operator=(const basicEventHandler& rhs)
-//{
-// if (this == &rhs) {
-// return *this;
-// }
-//
-// // TODO: assignment
-//
-// return *this;
-//}
-
typedef basicRingElement< basicEventHandler > EventHandlerIterator;
typedef basicRing< basicEventHandler > EventHandlerRing;
diff --git a/lib/components/base/basicEventHeap.cpp b/lib/components/base/basicEventHeap.cpp
index 8cb6847b..a18cad64 100644
--- a/lib/components/base/basicEventHeap.cpp
+++ b/lib/components/base/basicEventHeap.cpp
@@ -34,7 +34,7 @@ void basicEventHeap::removeHandler( basicEventHandler *handler ){
void basicEventHeap::m_fThreadProc( void ){
basicEventHandler *mpHandler;
- basicEvent *mpEvent;
+ EVENT_CONTAINER *mpEvent;
EventHandlerIterator *mpIterator;
//pthread_t pid = pthread_self();
//char pidBuf[16];
@@ -70,7 +70,7 @@ void basicEventHeap::m_fThreadProc( void ){
};
};
-void basicEventHeap::broadcast( basicEvent *Evt ){
+void basicEventHeap::broadcast( EVENT_CONTAINER *Evt ){
m_pDispatchingMutex->lock();
m_vEventQueue.push( Evt );
m_pDispatchingMutex->unlock();
diff --git a/lib/components/base/basicEventHeap.h b/lib/components/base/basicEventHeap.h
index 3a09ddb7..190efeab 100644
--- a/lib/components/base/basicEventHeap.h
+++ b/lib/components/base/basicEventHeap.h
@@ -27,7 +27,7 @@ class basicEventHeap: public basicThread{
virtual ~basicEventHeap();
void addHandler( basicEventHandler *handler, bool atBottom = false );
void removeHandler( basicEventHandler *handler );
- void broadcast( basicEvent *Evt );
+ void broadcast( EVENT_CONTAINER *Evt );
protected:
// Constructor - protected so users cannot call it.
basicEventHeap();
diff --git a/lib/components/base/basicFunctionality.cpp b/lib/components/base/basicFunctionality.cpp
index 8ce5cd0d..289347c5 100644
--- a/lib/components/base/basicFunctionality.cpp
+++ b/lib/components/base/basicFunctionality.cpp
@@ -193,13 +193,17 @@ CSTR getTimeStamp( void ){
CSTR getUniqID_MD5( void ){
CSTR tVal = NULL;
- char buf[34];
+ CSTR tMD5 = NULL;
+ char buf[33];
tVal = getTimeStamp();
+ buf[0] = (char)0;
if( tVal ){
- sprintf( buf, "%s", MD5String( tVal ) );
+ tMD5 = MD5String( tVal );
+ if( tMD5 ) {
+ sprintf( buf, "%s", tMD5 );
+ free( tMD5 );
+ };
free( tVal );
- } else {
- buf[0] = (char)0;
};
#ifdef __linux__
return strdup( buf );
@@ -210,23 +214,52 @@ CSTR getUniqID_MD5( void ){
CSTR getUniqID_SHA256(void){ return NULL;};
CSTR getUniqID_UUID( uint32_t SEED ){
+ /*
char buf[46];
if( SEED ) {
srand( SEED );
} else {
- srand( time(NULL) );
+ srand( getMilliseconds() );// time(NULL) );
};
snprintf( buf, 42, "%8.8x-%4.4x-%4.4x-%4.4x-%6.6x%6.6x",
rand() & 0xFFFFFFFF,
rand() & 0xFFFF,
- (rand() & 0x0FFF) | 0x4000, /* M 4 MSB version => version 4 */
- (rand() & 0x1FFF) | 0x8000, /* N: 3 MSB variant => variant 1 */
+ (rand() & 0x0FFF) | 0x4000, // M 4 MSB version => version 4
+ (rand() & 0x1FFF) | 0x8000, // N: 3 MSB variant => variant 1
rand() & 0xFFFFFF, rand() & 0xFFFFFF
);
#ifdef __linux__
return strdup( buf );
#else
return _strdup( buf );
+#endif
+*/
+ CSTR tVal = NULL;
+ CSTR tMD5 = NULL;
+ char buf[37];
+ tVal = getTimeStamp();
+ buf[0] = (char)0;
+ if( tVal ){
+ tMD5 = MD5String( tVal );
+ if( tMD5 ) {
+ memcpy( buf, tMD5, 8 );
+ buf[8] = '-';
+ memcpy( buf+9, tMD5+8, 4 );
+ buf[13] = '-';
+ memcpy( buf+14, tMD5+12, 4 );
+ buf[18] = '-';
+ memcpy( buf+19, tMD5+16, 4 );
+ buf[23] = '-';
+ memcpy( buf+24, tMD5+20, 12 );
+ buf[36] = (char)0;
+ free( tMD5 );
+ };
+ free( tVal );
+ };
+#ifdef __linux__
+ return strdup( buf );
+#else
+ return _strdup( buf );
#endif
};
diff --git a/lib/components/base/basicPosition.cpp b/lib/components/base/basicPosition.cpp
index 653f2556..94b39a63 100644
--- a/lib/components/base/basicPosition.cpp
+++ b/lib/components/base/basicPosition.cpp
@@ -5,6 +5,73 @@ position3D::position3D() {
utmZone = 0;
};
+position3D::position3D( C3D_WGS84_LOC loc, C3D_SPH_DEGREES orient ){
+ coordConverter CC;
+ lat = loc.lat;
+ lon = loc.lon;
+ z = loc.alt;
+#ifdef FLOAT_64
+ double A, B;
+ CC.LatLonToUTMXY(lat, lon, utmZone, A, B);
+ x = A;
+ y = B;
+#else
+ CC.LatLonToUTMXY(lat, lon, utmZone, x, y);
+#endif
+};
+position3D::position3D( C3D_WGS84_LOC loc, C3D_SPH_RADIANS orient ){
+ coordConverter CC;
+ lat = loc.lat;
+ lon = loc.lon;
+ z = loc.alt;
+#ifdef FLOAT_64
+ double A, B;
+ CC.LatLonToUTMXY(lat, lon, utmZone, A, B);
+ x = A;
+ y = B;
+#else
+ CC.LatLonToUTMXY(lat, lon, utmZone, x, y);
+#endif
+ rot_x = orient.r;
+ rot_y = orient.fi;
+ rot_z = orient.tetta;
+};
+
+position3D::position3D( int UTM_Zone, C3D_DECART loc, C3D_SPH_DEGREES orient ){
+ coordConverter CC;
+ utmZone = UTM_Zone;
+ x = loc.x;
+ y = loc.y;
+ z = loc.z;
+#ifdef FLOAT_64
+ double A, B;
+ CC.UTMXYToLatLon(x, y, utmZone, A, B);
+ lat = A;
+ lon = B;
+#else
+ CC.UTMXYToLatLon(x, y, utmZone, false, lat, lon);
+#endif
+ rot_x = deg2rad(orient.r);
+ rot_y = deg2rad(orient.fi);
+ rot_z = deg2rad(orient.tetta);
+};
+
+position3D::position3D( int UTM_Zone, C3D_DECART loc, C3D_SPH_RADIANS orient ){
+ coordConverter CC;
+ utmZone = UTM_Zone;
+ x = loc.x;
+ y = loc.y;
+ z = loc.z;
+#ifdef FLOAT_64
+ double A, B;
+ CC.UTMXYToLatLon(x, y, utmZone, A, B);
+ lat = A;
+ lon = B;
+#else
+ CC.UTMXYToLatLon(x, y, utmZone, false, lat, lon);
+#endif
+};
+
position3D::~position3D() {
};
@@ -40,6 +107,22 @@ void position3D::setPositionXYZ(C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, int zone)
#endif
};
+C3D_WGS84_LOC position3D::getWGS84( void ){
+ C3D_WGS84_LOC retVal;
+ retVal.lat = lat;
+ retVal.lon = lon;
+ retVal.alt = z;
+ return retVal;
+};
+
+C3D_DECART position3D::getXYZ( void ){
+ C3D_DECART retVal;
+ retVal.x = x;
+ retVal.y = y;
+ retVal.z = z;
+ return retVal;
+};
+
void position3D::setOrientationRad(C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ) {
rot_x = RotX;
rot_y = RotY;
@@ -75,7 +158,24 @@ basicPosition& basicPosition::operator=(const basicPosition& src){
return *this;
};
-basicPosition::basicPosition(float Lat, float Lon, float Alt, float h_lat, float h_lon, float h_alt, float Speed) : position3D() {
+basicPosition::basicPosition( C3D_WGS84_LOC loc, C3D_SPH_DEGREES orient ): position3D( loc, orient ){
+ position3D::setSpeed( 0.0f );
+ updateMatrix();
+};
+basicPosition::basicPosition( C3D_WGS84_LOC loc, C3D_SPH_RADIANS orient ): position3D( loc, orient ){
+ position3D::setSpeed( 0.0f );
+ updateMatrix();
+};
+basicPosition::basicPosition( int UTM_Zone, C3D_DECART loc, C3D_SPH_DEGREES orient ): position3D( UTM_Zone, loc, orient ){
+ position3D::setSpeed( 0.0f );
+ updateMatrix();
+};
+basicPosition::basicPosition( int UTM_Zone, C3D_DECART loc, C3D_SPH_RADIANS orient ): position3D( UTM_Zone, loc, orient ){
+ position3D::setSpeed( 0.0f );
+ updateMatrix();
+};
+
+basicPosition::basicPosition( float Lat, float Lon, float Alt, float h_lat, float h_lon, float h_alt, float Speed ) : position3D() {
position3D::setPositionWGS84( Lat, Lon, Alt );
position3D::setOrientationRad( h_lat, h_lon, h_alt );
position3D::setSpeed( Speed );
diff --git a/lib/components/base/basicPosition.h b/lib/components/base/basicPosition.h
index 6628041a..6c596ee8 100644
--- a/lib/components/base/basicPosition.h
+++ b/lib/components/base/basicPosition.h
@@ -4,6 +4,7 @@
#include "../../alg/generic/utm.h"
#include "../../alg/generic/Transform.h"
+
class position3D {
protected:
C3D_FLOAT x; /* Position meters */
@@ -18,26 +19,41 @@ class position3D {
int utmZone;
public:
position3D();
- virtual ~position3D();
- C3D_FLOAT getLat(void) { return lat; };
- C3D_FLOAT getLon(void) { return lon; };
- C3D_FLOAT getAlt(void) { return z; };
- C3D_FLOAT getX(void) { return x; };
- C3D_FLOAT getY(void) { return y; };
- C3D_FLOAT getZ(void) { return z; };
- C3D_FLOAT getRotZ_rad(void) { return rot_z; };
- C3D_FLOAT getRotX_rad(void) { return rot_x; };
- C3D_FLOAT getRotY_rad(void) { return rot_y; };
- C3D_FLOAT getRotZ_deg(void) { return rad2deg(rot_z); };
- C3D_FLOAT getRotX_deg(void) { return rad2deg(rot_x); };
- C3D_FLOAT getRotY_deg(void) { return rad2deg(rot_y); };
- int getUTMZone(void) { return utmZone; };
- void setPositionWGS84(C3D_FLOAT Lat, C3D_FLOAT Lon, C3D_FLOAT Alt = 0.0f);
- void setPositionXYZ(C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, int zone = 0);
- //void setPositionRadial( float Azimuth, float Elevation, float Range, int zone = 0 );
- void setOrientationDeg(C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ);
- void setOrientationRad(C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ);
- void setSpeed(C3D_FLOAT Speed);
+ position3D( C3D_WGS84_LOC loc, C3D_SPH_DEGREES orient );
+ position3D( C3D_WGS84_LOC loc, C3D_SPH_RADIANS orient );
+ position3D( int UTM_Zone, C3D_DECART loc, C3D_SPH_DEGREES orient );
+ position3D( int UTM_Zone, C3D_DECART loc, C3D_SPH_RADIANS orient );
+ virtual ~position3D();
+ C3D_FLOAT getLat(void) { return lat; };
+ C3D_FLOAT getLon(void) { return lon; };
+ C3D_FLOAT getAlt(void) { return z; };
+ C3D_FLOAT getX(void) { return x; };
+ C3D_FLOAT getY(void) { return y; };
+ C3D_FLOAT getZ(void) { return z; };
+ C3D_FLOAT getRotZ_rad(void) { return rot_z; };
+ C3D_FLOAT getRotX_rad(void) { return rot_x; };
+ C3D_FLOAT getRotY_rad(void) { return rot_y; };
+ C3D_FLOAT getRotZ_deg(void) { return rad2deg(rot_z); };
+ C3D_FLOAT getRotX_deg(void) { return rad2deg(rot_x); };
+ C3D_FLOAT getRotY_deg(void) { return rad2deg(rot_y); };
+
+ C3D_WGS84_LOC getWGS84( void );
+ C3D_DECART getXYZ( void );
+
+ C3D_SPH_DEGREES getRotDec( void );
+ C3D_SPH_RADIANS getRotRad( void );
+
+ int getUTMZone(void) { return utmZone; };
+ void setPositionWGS84( C3D_FLOAT Lat, C3D_FLOAT Lon, C3D_FLOAT Alt = 0.0f );
+ void setPositionXYZ( C3D_FLOAT X, C3D_FLOAT Y, C3D_FLOAT Z, int zone = 0 );
+ void setPosition( C3D_WGS84_LOC pos );
+ void setPosition( C3D_DECART pos );
+ //void setPositionRadial( float Azimuth, float Elevation, float Range, int zone = 0 );
+ void setOrientationDeg( C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ);
+ void setOrientationRad( C3D_FLOAT RotX, C3D_FLOAT RotY, C3D_FLOAT RotZ );
+ void setOrientation( C3D_SPH_DEGREES orient );
+ void setOrientation( C3D_SPH_RADIANS orient );
+ void setSpeed(C3D_FLOAT Speed);
};
@@ -65,7 +81,11 @@ class basicPosition: public position3D{
// Assignment operator
basicPosition& operator=(const basicPosition& src);
- basicPosition( float lat, float lon, float alt = 0.0f, float h_x = 0.0f, float h_y = 0.0f, float h_z = 0.0f, float speed = 0.0f);
+ basicPosition( C3D_WGS84_LOC loc, C3D_SPH_DEGREES orient );
+ basicPosition( C3D_WGS84_LOC loc, C3D_SPH_RADIANS orient );
+ basicPosition( int UTM_Zone, C3D_DECART loc, C3D_SPH_DEGREES orient );
+ basicPosition( int UTM_Zone, C3D_DECART loc, C3D_SPH_RADIANS orient );
+ basicPosition( float lat, float lon, float alt = 0.0f, float h_x = 0.0f, float h_y = 0.0f, float h_z = 0.0f, float speed = 0.0f);
void setPositionRad(float lat, float lon, float alt = 0.0f, float h_x = 0.0f, float h_y = 0.0f, float h_z = 0.0f, float speed = 0.0f);
void setPositionDeg(float lat, float lon, float alt = 0.0f, float h_x = 0.0f, float h_y = 0.0f, float h_z = 0.0f, float speed = 0.0f);
S_TRANS_MATRIX *getTransMatrix(void){ return &m_sMatrix; };
diff --git a/lib/components/object/objectSystemAnchor.cpp b/lib/components/object/objectSystemAnchor.cpp
index 2f251c9a..bdf2462c 100644
--- a/lib/components/object/objectSystemAnchor.cpp
+++ b/lib/components/object/objectSystemAnchor.cpp
@@ -1,79 +1,103 @@
#include "objectSystemAnchor.h"
+#ifdef DEBUG
+ #include "../base/basicLogCollection.h"
+#endif
systemAnchor* systemAnchor::_instance = 0;
/**
* Returns the single instance of the object.
*/
-systemAnchor* systemAnchor::getInstance() {
+systemAnchor* systemAnchor::getInstance( bool SOUTH, C3D_WGS84_LOC *ptr ) {
// check if the instance has been created yet
if (0 == _instance) {
// if not, then create it
- _instance = new systemAnchor;
+ _instance = new systemAnchor( SOUTH, ptr );
}
// return the single instance
return _instance;
};
-systemAnchor::systemAnchor(): m_SCC(){
+systemAnchor::systemAnchor( bool SOUTH, C3D_WGS84_LOC *ptr ): m_SCC(){
config_setting_t *pSetting;
m_pSettings = NULL;
m_bSouthHemisphere = 0;
- pSetting = basicSettingsProvider::getInstance()->getSubNode( NULL, "APPLICATION_GUI" );
- if( pSetting != NULL ){
- m_pSettings = basicSettingsProvider::getInstance()->getSubNode( pSetting, "SYSTEM_ANCHOR" );
- };
- // Read Config
- if( m_pSettings != NULL ){
- pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LAT );
- if (pSetting == NULL){
- lat = 0.f;
- pSetting = config_setting_add(m_pSettings, TAG_POSITION_LAT, CONFIG_TYPE_FLOAT );
- config_setting_set_float( pSetting, lat );
- basicSettingsProvider::getInstance()->compromise();
- } else {
- lat = (float)config_setting_get_float(pSetting);
- };
- pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LON );
- if (pSetting == NULL){
- lon = 0.f;
- pSetting = config_setting_add(m_pSettings, TAG_POSITION_LON, CONFIG_TYPE_FLOAT );
- config_setting_set_float( pSetting, lon );
- basicSettingsProvider::getInstance()->compromise();
- } else {
- lon = config_setting_get_float(pSetting);
- };
- pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ALT );
- if (pSetting == NULL){
- z = 0.f;
- pSetting = config_setting_add(m_pSettings, TAG_POSITION_ALT, CONFIG_TYPE_FLOAT );
- config_setting_set_float( pSetting, z );
- basicSettingsProvider::getInstance()->compromise();
- } else {
- z = config_setting_get_float(pSetting);
- };
- pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_SOUTH_HS);
- if (pSetting == NULL){
- m_bSouthHemisphere = false;
- pSetting = config_setting_add(m_pSettings, TAG_POSITION_SOUTH_HS, CONFIG_TYPE_BOOL );
- config_setting_set_bool(pSetting, m_bSouthHemisphere);
- basicSettingsProvider::getInstance()->compromise();
- } else {
- m_bSouthHemisphere = config_setting_get_bool(pSetting);
- };
+ if( ptr == NULL ) {
+ pSetting = basicSettingsProvider::getInstance()->getSubNode( NULL, "APPLICATION_GUI" );
+ if( pSetting != NULL ){
+ m_pSettings = basicSettingsProvider::getInstance()->getSubNode( pSetting, "SYSTEM_ANCHOR" );
+ };
+ // Read Config
+ if( m_pSettings != NULL ){
+ pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LAT );
+ if (pSetting == NULL){
+ lat = 0.f;
+ pSetting = config_setting_add(m_pSettings, TAG_POSITION_LAT, CONFIG_TYPE_FLOAT );
+ config_setting_set_float( pSetting, lat );
+ basicSettingsProvider::getInstance()->compromise();
+ } else {
+ lat = (float)config_setting_get_float(pSetting);
+ };
+ pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_LON );
+ if (pSetting == NULL){
+ lon = 0.f;
+ pSetting = config_setting_add(m_pSettings, TAG_POSITION_LON, CONFIG_TYPE_FLOAT );
+ config_setting_set_float( pSetting, lon );
+ basicSettingsProvider::getInstance()->compromise();
+ } else {
+ lon = config_setting_get_float(pSetting);
+ };
+ pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_ALT );
+ if (pSetting == NULL){
+ z = 0.f;
+ pSetting = config_setting_add(m_pSettings, TAG_POSITION_ALT, CONFIG_TYPE_FLOAT );
+ config_setting_set_float( pSetting, z );
+ basicSettingsProvider::getInstance()->compromise();
+ } else {
+ z = config_setting_get_float(pSetting);
+ };
+ pSetting = config_setting_get_member(m_pSettings, TAG_POSITION_SOUTH_HS);
+ if (pSetting == NULL){
+ m_bSouthHemisphere = false;
+ pSetting = config_setting_add(m_pSettings, TAG_POSITION_SOUTH_HS, CONFIG_TYPE_BOOL );
+ config_setting_set_bool(pSetting, m_bSouthHemisphere);
+ basicSettingsProvider::getInstance()->compromise();
+ } else {
+ m_bSouthHemisphere = config_setting_get_bool(pSetting);
+ };
+ #ifdef FLOAT_64
+ double A, B;
+ utmZone = CC.LatLonToUTMXY( lat, lon, 0 , A, B );
+ x = A;
+ y = B;
+ #else
+ utmZone = m_SCC.LatLonToUTMXY(lat, lon, m_bSouthHemisphere, x, y);
+ #endif
+ basicSettingsProvider::getInstance()->validate();
+ };
+ } else {
+ m_bSouthHemisphere = SOUTH;
+ lat = ptr->lat;
+ lon = ptr->lon;
+ z = ptr->alt;
#ifdef FLOAT_64
- double A, B;
- utmZone = CC.LatLonToUTMXY( lat, lon, 0 , A, B );
- x = A;
- y = B;
+ double A, B;
+ utmZone = CC.LatLonToUTMXY( lat, lon, 0 , A, B );
+ x = A;
+ y = B;
#else
- utmZone = m_SCC.LatLonToUTMXY(lat, lon, m_bSouthHemisphere, x, y);
+ utmZone = m_SCC.LatLonToUTMXY(lat, lon, m_bSouthHemisphere, x, y);
+#endif
+ };
+#ifdef DEBUG
+ char tBuff[256];
+ sprintf( tBuff, "WGS84[lat:%0.6f Lon:%0.6f Alt:%0.6f] UMTS[x:%0.4f y:%0.4f z:%0.4f]", lat, lon, z, x, y, z );
+ basicLogCollection::getInstance()->Log("System Anchor", this, tBuff );
#endif
- basicSettingsProvider::getInstance()->validate();
- };
};
systemAnchor::~systemAnchor(){
+ /*
config_setting_t *pSetting;
C3D_FLOAT tVal;
bool tBool;
@@ -135,7 +159,7 @@ systemAnchor::~systemAnchor(){
};
basicSettingsProvider::getInstance()->validate();
};
-
+ */
};
bool systemAnchor::convertToLocal(basicPosition *SP, C3D_WGS84_LOC POS, C3D_SPH_DEGREES& LOC) {
@@ -228,9 +252,12 @@ bool systemAnchor::convertToSystem(basicPosition *SP, C3D_SPH_DEGREES POS, C3D_D
A[1] = tDec.y;
A[2] = tDec.z;
pTF->get_vector_world(A, B);
- LOC.x = SP->getX() + B[0] - getX();
- LOC.y = SP->getY() + B[1] - getY();
- LOC.z = SP->getZ() + B[2] - getZ();
+ //LOC.x = SP->getX() + B[0] - getX();
+ //LOC.y = SP->getY() + B[1] - getY();
+ //LOC.z = SP->getZ() + B[2] - getZ();
+ LOC.x = B[0] - getX();
+ LOC.y = B[1] - getY();
+ LOC.z = B[2] - getZ();
return true;
};
@@ -244,9 +271,12 @@ bool systemAnchor::convertToSystem(basicPosition *SP, C3D_SPH_RADIANS POS, C3D_D
A[1] = tDec.y;
A[2] = tDec.z;
pTF->get_vector_world(A, B);
- LOC.x = SP->getX() + B[0] - getX();
- LOC.y = SP->getY() + B[1] - getY();
- LOC.z = SP->getZ() + B[2] - getZ();
+ //LOC.x = SP->getX() + B[0] - getX();
+ //LOC.y = SP->getY() + B[1] - getY();
+ //LOC.z = SP->getZ() + B[2] - getZ();
+ LOC.x = B[0] - getX();
+ LOC.y = B[1] - getY();
+ LOC.z = B[2] - getZ();
return true;
};
@@ -260,9 +290,9 @@ bool systemAnchor::convertToGlobal(basicPosition *SP, C3D_SPH_DEGREES POS, C3D_W
A[1] = tDec.y;
A[2] = tDec.z;
pTF->get_vector_world(A, B);
- tDec.x = B[0] + SP->getX();
- tDec.y = B[1] + SP->getY();
- tDec.z = B[2] + SP->getZ();
+ tDec.x = B[0];// + SP->getX();
+ tDec.y = B[1];// + SP->getY();
+ tDec.z = B[2];// + SP->getZ();
m_SCC.UTMXYToLatLon(tDec.x, tDec.y, getUTMZone(), m_bSouthHemisphere, LOC.lat, LOC.lon);
LOC.alt = tDec.z;
return true;
@@ -278,9 +308,9 @@ bool systemAnchor::convertToGlobal(basicPosition *SP, C3D_SPH_RADIANS POS, C3D_W
A[1] = tDec.y;
A[2] = tDec.z;
pTF->get_vector_world(A, B);
- tDec.x = B[0] + SP->getX();
- tDec.y = B[1] + SP->getY();
- tDec.z = B[2] + SP->getZ();
+ tDec.x = B[0];// + SP->getX();
+ tDec.y = B[1];// + SP->getY();
+ tDec.z = B[2];// + SP->getZ();
m_SCC.UTMXYToLatLon(tDec.x, tDec.y, getUTMZone(), m_bSouthHemisphere, LOC.lat, LOC.lon);
LOC.alt = tDec.z;
return true;
diff --git a/lib/components/object/objectSystemAnchor.h b/lib/components/object/objectSystemAnchor.h
index 8cdaf773..46253db5 100644
--- a/lib/components/object/objectSystemAnchor.h
+++ b/lib/components/object/objectSystemAnchor.h
@@ -20,7 +20,7 @@ class systemAnchor: public position3D {
coordConverter m_SCC;
bool m_bSouthHemisphere;
public:
- static systemAnchor *getInstance(void);
+ static systemAnchor *getInstance( bool SOUTH = false, C3D_WGS84_LOC *ptr = NULL );
virtual ~systemAnchor( void );
// local - C3D_SPH_RADIANS/C3D_SPH_DEGREES
@@ -42,7 +42,7 @@ class systemAnchor: public position3D {
private:
static systemAnchor *_instance;
protected:
- systemAnchor( void );
+ explicit systemAnchor( bool SOUTH = false, C3D_WGS84_LOC *ptr = NULL );
};
#endif
\ No newline at end of file
diff --git a/lib/data/net/netClientHandler.h b/lib/data/net/netClientHandler.h
index f2a2720d..0ece9515 100644
--- a/lib/data/net/netClientHandler.h
+++ b/lib/data/net/netClientHandler.h
@@ -16,7 +16,7 @@ class networkClientHandler: public basicEventHandler{
explicit networkClientHandler( int SocketFD, basicEngine *ptr = NULL );
virtual ~networkClientHandler();
virtual bool attachEngine( basicEngine *ptr );
- virtual void dispatchEvent( basicEvent *Evt ){};
+ virtual void dispatchEvent( EVENT_CONTAINER *Evt ){};
virtual bool getStatus( void ){ return false; };
};
diff --git a/lib/data/net/netServer.h b/lib/data/net/netServer.h
index 679ac3de..598a165e 100644
--- a/lib/data/net/netServer.h
+++ b/lib/data/net/netServer.h
@@ -88,7 +88,7 @@ class networkServer: public basicThread, public basicEventHandler{
bool BootUp( CSTR UNIX_SOCKET_NAME );
#endif
bool attachEngine( basicEngine *ptr );
- void dispatchEvent( basicEvent *Evt );
+ void dispatchEvent( EVENT_CONTAINER *Evt );
CSTR getAddress( void ){ return m_pHostName; };
uint16_t getPort( void ){ return m_nPortNumber; };
};
diff --git a/lib/data/protocol/protocolKAFKA.cpp b/lib/data/protocol/protocolKAFKA.cpp
index 93902bec..7837396e 100644
--- a/lib/data/protocol/protocolKAFKA.cpp
+++ b/lib/data/protocol/protocolKAFKA.cpp
@@ -218,7 +218,7 @@ void protocolKAFKA::dr_cb( RdKafka::Message &message ){
sprintf(tBuffer,"Message delivery failed: %s", message.errstr().c_str() );
LOG_ERROR( tBuffer );
}
-#ifdef DEBUG
+#ifdef DEBUG_KAFKA
else {
sprintf(tBuffer,"Message delivered to topic: %s [%d] at offset %d", message.topic_name().c_str(), message.partition(), message.offset() );
LOG( tBuffer );
@@ -231,8 +231,9 @@ bool protocolKAFKA::init(){
RdKafka::Conf * tGlobalConf;
std::string tBuffer;
std::string brokers = m_pKafkaBrokerSTR;
-
+#ifdef DEBUG_KAFKA
LOG("INIT Begin");
+#endif
if( strlen( m_pKafkaBrokerSTR ) == 0 ) {
LOG_ERROR("No Kafka Brokers are defined!");
return false;
@@ -242,22 +243,26 @@ bool protocolKAFKA::init(){
LOG_ERROR("Eror Creating Producer Conf!");
return false;
};
+#ifdef DEBUG_KAFKA
LOG("RdKafka::Conf::CONF_GLOBAL Created");
-
+#endif
if( tGlobalConf->set( "bootstrap.servers", brokers, tBuffer ) != RdKafka::Conf::CONF_OK ){
LOG_ERROR( tBuffer.c_str() );
delete( tGlobalConf );
return false;
};
+#ifdef DEBUG_KAFKA
LOG( m_pKafkaBrokerSTR );
LOG("bootstrap.servers is SET");
-
+#endif
if( tGlobalConf->set("metadata.broker.list", brokers, tBuffer ) != RdKafka::Conf::CONF_OK ){
LOG_ERROR( tBuffer.c_str() );
delete( tGlobalConf );
return false;
};
+#ifdef DEBUG_KAFKA
LOG("metadata.broker.list is SET");
+#endif
/* Set the delivery report callback.
* This callback will be called once per message to inform
* the application if delivery succeeded or failed.
@@ -271,7 +276,9 @@ bool protocolKAFKA::init(){
delete( tGlobalConf );
return false;
};
+#ifdef DEBUG_KAFKA
LOG("dr_cb is SET");
+#endif
//if( tProducerConf->set("default_topic_conf", tTopicConf, tBuffer ) != RdKafka::Conf::CONF_OK ){
// LOG_ERROR( tBuffer.c_str() );
// delete( tProducerConf );
@@ -294,16 +301,18 @@ bool protocolKAFKA::init(){
delete( tGlobalConf );
return false;
};
+#ifdef DEBUG_KAFKA
LOG("RdKafka::Producer Created");
-
+#endif
if( tGlobalConf->set( "enable.partition.eof", "true", tBuffer ) != RdKafka::Conf::CONF_OK ){
delete( n_pProducer );
delete( tGlobalConf );
LOG_ERROR( tBuffer.c_str() );
return false;
};
+#ifdef DEBUG_KAFKA
LOG("enable.partition.eof is SET");
-
+#endif
m_pConsumer = RdKafka::Consumer::create( tGlobalConf, tBuffer );
if( m_pConsumer == NULL ){
delete( n_pProducer );
@@ -312,8 +321,10 @@ bool protocolKAFKA::init(){
LOG_ERROR( tBuffer.c_str() );
return false;
}
+#ifdef DEBUG_KAFKA
LOG("RdKafka::Consumer Created");
LOG("INIT Complete");
+#endif
delete( tGlobalConf );
return true;
};
@@ -335,7 +346,7 @@ bool protocolKAFKA::issuePost( CSTR tpc, CSTR Buffer, int BufferSize ){
LOG_ERROR("Eror Creating Topic Conf!");
return false;
};
-#ifdef DEBUG
+#ifdef DEBUG_KAFKA
LOG("RdKafka::Conf::CONF_TOPIC Created");
#endif
tKafkaTopic = RdKafka::Topic::create( n_pProducer, topic, tTopicConf, tBuffer );
@@ -346,7 +357,7 @@ bool protocolKAFKA::issuePost( CSTR tpc, CSTR Buffer, int BufferSize ){
delete( tTopicConf );
return false;
};
-#ifdef DEBUG
+#ifdef DEBUG_KAFKA
LOG("RdKafka::Topic Created");
#endif
/*
@@ -391,7 +402,7 @@ retry:
if( rCnt-- ) goto retry;
};
}
-#ifdef DEBUG
+#ifdef DEBUG_KAFKA
else {
sprintf( tBuf, "Enqueued message (%d bytes) for topic %s", BufferSize, topic.c_str() );
LOG( tBuf );
@@ -466,7 +477,7 @@ void protocolKAFKA::consume_cb( RdKafka::Message& A, void* B ){
}; */
};
-bool protocolKAFKA::receivePost( CSTR Channel, int32_t Partition, int64_t Offset, CSTR Buffer, int &BufferSize ){
+bool protocolKAFKA::receivePost( CSTR Channel, int32_t Partition, int64_t &Offset, CSTR Buffer, int &BufferSize ){
uint8_t rCnt = 3;
char tBuf[128];
RdKafka::ErrorCode err;
@@ -483,7 +494,7 @@ bool protocolKAFKA::receivePost( CSTR Channel, int32_t Partition, int64_t Offset
LOG_ERROR("Eror Creating Consumer Topic Conf!");
return false;
};
-#ifdef DEBUG
+#ifdef DEBUG_KAFKA
LOG("Consumer RdKafka::Conf::CONF_TOPIC Created");
#endif
@@ -493,11 +504,19 @@ bool protocolKAFKA::receivePost( CSTR Channel, int32_t Partition, int64_t Offset
delete( tTopicConf );
return false;
};
-
+#ifdef DEBUG_KAFKA
+ LOG("Consumer RdKafka::Topic Created");
+#endif
/*
* Start consumer for topic+partition at start offset
*/
- RdKafka::ErrorCode resp = m_pConsumer->start( tKafkaTopic, Partition, Offset );
+ //Get To Last Message
+ if( Offset == 0 ) {
+ LOG("Correcting Offset");
+ int64_t bOff = m_pConsumer->OffsetTail( Offset );
+ Offset += bOff - 1;
+ };
+ RdKafka::ErrorCode resp = m_pConsumer->start( tKafkaTopic, Partition, Offset );//Partition, Offset );
if (resp != RdKafka::ERR_NO_ERROR) {
LOG_ERROR( "Failed to start consumer!" );
LOG_ERROR( RdKafka::err2str(resp).c_str() );
@@ -507,26 +526,34 @@ bool protocolKAFKA::receivePost( CSTR Channel, int32_t Partition, int64_t Offset
};
RdKafka::Message *message = m_pConsumer->consume( tKafkaTopic, Partition, 1000 );
if( message == NULL ) {
+ LOG_ERROR( "FAILURE" );
delete( tKafkaTopic );
delete( tTopicConf );
return false;
} else {
- switch (message->err()) {
- case RdKafka::ERR__TIMED_OUT: break;
+ switch ( message->err() ) {
+ case RdKafka::ERR__TIMED_OUT: LOG("TIME OUT"); break;
case RdKafka::ERR_NO_ERROR:
/* Real message */
- sprintf( tBuf, "Read msg at offset %dd ", message->offset() );
+ Offset = message->offset();
+#ifdef DEBUG_KAFKA
+ sprintf( tBuf, "Read msg at offset %d ", Offset );
LOG( tBuf );
if( message->key() ){
sprintf( tBuf, "Key: %s ", *message->key()->c_str() );
LOG( tBuf );
};
+#endif
//printf("%.*s\n", static_cast(message->len()), static_cast(message->payload()));
BufferSize = message->len();
memcpy( Buffer, message->payload(), BufferSize );
+ Buffer[BufferSize] = (char)0;
break;
- case RdKafka::ERR__PARTITION_EOF:
-
+ case RdKafka::ERR__PARTITION_EOF:
+#ifdef DEBUG_KAFKA
+ sprintf( tBuf, "EOF Read msg at partition %d and offset %d ", Partition, Offset );
+ LOG( tBuf );
+#endif
break;
case RdKafka::ERR__UNKNOWN_TOPIC:
case RdKafka::ERR__UNKNOWN_PARTITION:
@@ -540,7 +567,7 @@ bool protocolKAFKA::receivePost( CSTR Channel, int32_t Partition, int64_t Offset
};
}
delete( message );
- m_pConsumer->stop( tKafkaTopic, Partition );
+ m_pConsumer->stop( tKafkaTopic, 0 );
m_pConsumer->poll( 1000 );
delete( tKafkaTopic );
delete( tTopicConf );
diff --git a/lib/data/protocol/protocolKAFKA.h b/lib/data/protocol/protocolKAFKA.h
index a0c545a3..41668b41 100644
--- a/lib/data/protocol/protocolKAFKA.h
+++ b/lib/data/protocol/protocolKAFKA.h
@@ -18,6 +18,9 @@
#include "../../components/base/basicLogCollection.h"
#include "../../components/base/basicSettingsProvider.h"
+#ifdef DEBUG
+ //#define DEBUG_KAFKA
+#endif
/**
* TODO: Add class description
*
@@ -45,7 +48,7 @@ class protocolKAFKA: public RdKafka::DeliveryReportCb, public RdKafka::ConsumeCb
virtual ~protocolKAFKA();
bool init();
bool issuePost( CSTR Channel, CSTR Buffer, int BufferSize );
- bool receivePost( CSTR Channel, int32_t Partition, int64_t Offset, CSTR Buffer, int &BufferSize );
+ bool receivePost( CSTR Channel, int32_t Partition, int64_t &Offset, CSTR Buffer, int &BufferSize );
/* Implementation of RdKafka::EventCb */
virtual void event_cb( RdKafka::Event &event );
virtual void consume_cb( RdKafka::Message& A, void* B );
diff --git a/lib/hardware/sensors/lrf/lrf_3d.cpp b/lib/hardware/sensors/lrf/lrf_3d.cpp
index 801ba399..6f75ae6d 100644
--- a/lib/hardware/sensors/lrf/lrf_3d.cpp
+++ b/lib/hardware/sensors/lrf/lrf_3d.cpp
@@ -150,7 +150,7 @@ void sensorLGS3D::m_fThreadProc(void){
case CWM_CONNECT:{
m_mStatusMutex.unlock();
if( CS_CONNECTED == m_pTransport->getConnectionStatus() ) {
- basicEvent *tEVT;
+ EVENT_CONTAINER *tEVT;
tEVT = createBasicEvent( getObjectId(), EVT_CLASS_SENSOR_3D, EVT_READY, "Device is connected");
m_pEventHeap->broadcast(tEVT);
m_eWorkMode = CWM_INITIAL_GET_PARAM;
@@ -159,7 +159,7 @@ void sensorLGS3D::m_fThreadProc(void){
// After Initial Connection
// Each time Disconnection Event must be generated
if( m_eStatus != OS_STATUS_INIT ) {
- basicEvent *tEVT;
+ EVENT_CONTAINER *tEVT;
//ToDo: Change Device Name!
tEVT = createBasicEvent( getObjectId(), EVT_CLASS_SENSOR_3D, EVT_ERROR, "Device is Not Connected");
m_pEventHeap->broadcast( tEVT );
@@ -319,18 +319,27 @@ TARGET_DATA *sensorLGS3D::prepareTargetData(CLIENT_EVENT* CE) {
if (tVal != NULL) {
systemAnchor* tSystem = systemAnchor::getInstance();
uint16_t cX, cY;
- //memset(tVal, 0, sizeof(TARGET_DATA));
+ memset(tVal, 0, sizeof(TARGET_DATA));
tVal->source_position.lat = m_oPosition.getLat();
tVal->source_position.lon = m_oPosition.getLon();
tVal->source_position.alt = m_oPosition.getAlt();
makeXY(CE->th_id, cX, cY, (CE->k_id < 8));
+
tVal->local_target.r = 300.0f / 4095.0f * (float)CE->range;
tVal->local_target.fi = 360.0f - (360.0f / (float)TH_LINE_NODES) * (float)cX;
tVal->local_target.tetta = 90.0f - (Q_DEGREE_FOV / (float)Q_SCAN_COUNT) * (float)cY + Q_SHIFT_DOWN_FOV;
- //CE->w_cnt * CE->range
+ if( tVal->local_target.tetta > 90.0f ) {
+ tVal->local_target.tetta = 180.0f - tVal->local_target.tetta;
+ tVal->local_target.fi = tVal->local_target.fi + 180.0f;
+ if( tVal->local_target.fi > 360.0f ) tVal->local_target.fi = tVal->local_target.fi - 360.0f;
+ };
+ //CE->w_cnt * CE->range
tVal->area = CE->w_cnt * tVal->local_target.r;
- tSystem->convertToSystem( &m_oPosition, tVal->local_target, tVal->system_target );
- tSystem->convertToGlobal( &m_oPosition, tVal->system_target, tVal->global_target );
+ // local - C3D_SPH_RADIANS/C3D_SPH_DEGREES
+ // system - C3D_DECART
+ // global - C3D_WGS84_LOC
+ tSystem->convertToSystem( &m_oPosition, tVal->local_target, tVal->system_target );
+ tSystem->convertToGlobal( &m_oPosition, tVal->local_target, tVal->global_target );
};
};
return tVal;
@@ -347,7 +356,7 @@ bool sensorLGS3D::packetHandler( protocolPackage* Package ) {
uint8_t * pReceivedPackage = NULL;
size_t nReceivedPackageSize = 0;
bool bPackageIsArived = false;
- basicEvent * tEVT;
+ EVENT_CONTAINER * tEVT;
CLIENT_EVENT * tData;
if( Package == NULL ) return true;
if( Package->m_pData == NULL ) return true;
@@ -609,21 +618,21 @@ bool sensorLGS3D::packetHandler( protocolPackage* Package ) {
switch( m_sDeviceStatus.Status ){
case STG_STUDY: {
m_mStatusMutex.unlock();
- basicEvent* tEVT;
+ //EVENT_CONTAINER * tEVT;
tEVT = createBasicEvent( getObjectId(), EVT_CLASS_SENSOR_3D, EVT_STUDY, "Device in STUDY mode");
m_pEventHeap->broadcast(tEVT);
break;
};
case STG_REDY: {
m_mStatusMutex.unlock();
- basicEvent* tEVT;
+ //basicEvent* tEVT;
tEVT = createBasicEvent( getObjectId(), EVT_CLASS_SENSOR_3D, EVT_READY, "Device in DETECTION mode");
m_pEventHeap->broadcast(tEVT);
break;
};
case STG_BUSY: {
m_mStatusMutex.unlock();
- basicEvent* tEVT;
+ //basicEvent* tEVT;
tEVT = createBasicEvent( getObjectId(), EVT_CLASS_SENSOR_3D, EVT_ERROR, "Device in BUSY mode");
m_pEventHeap->broadcast(tEVT);
break;
@@ -634,34 +643,34 @@ bool sensorLGS3D::packetHandler( protocolPackage* Package ) {
if( pReceivedPackage[DATA_BEGIN_IDX] > 0 ){
uint8_t tCount = pReceivedPackage[DATA_BEGIN_IDX];
- CLIENT_EVENT *tEVT = (CLIENT_EVENT*)& pReceivedPackage[DATA_BEGIN_IDX + 1];
+ CLIENT_EVENT *cEVT = (CLIENT_EVENT*)& pReceivedPackage[DATA_BEGIN_IDX + 1];
for (uint8_t xindex = 0; xindex < tCount; xindex++) {
- switch (tEVT[xindex].type) {
+ switch (cEVT[xindex].type) {
case EVT_TARGET_3D_BLACK:
case EVT_TARGET_3D_WHITE: {
TARGET_DATA *tData;
- tData = prepareTargetData(tEVT+xindex);
+ tData = prepareTargetData(cEVT+xindex);
if(tData != NULL){
char tBuffer[256];
- basicEvent * bEVT = NULL;
+ EVENT_CONTAINER * bEVT = NULL;
bool bIsMaster;
uint8_t bKernelID;
- bKernelID = tEVT[xindex].k_id & 0x07;
- bIsMaster = !((tEVT[xindex].k_id & 0x08) == 0x08);
+ bKernelID = cEVT[xindex].k_id & 0x07;
+ bIsMaster = !((cEVT[xindex].k_id & 0x08) == 0x08);
sprintf(tBuffer, "%s[%d] %s target \tRange: %.2fm. \tAzimuth: %.2f \tElevation: %.2f \tTS: %d@%d W:%.2f",
(bIsMaster ? "M" : "S"),
bKernelID,
- ((tEVT[xindex].type == EVT_TARGET_3D_WHITE) ? "White" : "Black"),
+ ((cEVT[xindex].type == EVT_TARGET_3D_WHITE) ? "White" : "Black"),
tData->local_target.r,
tData->local_target.fi,
tData->local_target.tetta,
- tEVT[xindex].uts,
- tEVT[xindex].ums,
+ cEVT[xindex].uts,
+ cEVT[xindex].ums,
tData->area
);
- bEVT = createBasicEvent( getObjectId(), EVT_CLASS_SENSOR_3D, (basicEventTypeID)tEVT[xindex].type, tBuffer, tData);
+ bEVT = createBasicEvent( getObjectId(), EVT_CLASS_SENSOR_3D, (basicEventTypeID)cEVT[xindex].type, tBuffer, tData);
if (bEVT != NULL) {
m_pEventHeap->broadcast(bEVT);
} else {
diff --git a/lib/hardware/sensors/lrf/lrf_3d.h b/lib/hardware/sensors/lrf/lrf_3d.h
index 86364050..580fa1b8 100644
--- a/lib/hardware/sensors/lrf/lrf_3d.h
+++ b/lib/hardware/sensors/lrf/lrf_3d.h
@@ -87,12 +87,13 @@ class sensorLGS3D : public basicObject, basicThread, protocolLGS3D_Client{
void comSetBusy( bool useMutex = true );
bool comIsIdle( void );
void cleanDataTH( void );
- TARGET_DATA * prepareTargetData(CLIENT_EVENT* CE);
+
protected:
virtual void m_fThreadProc( void );
virtual bool packetHandler( protocolPackage* Package );
public:
+ TARGET_DATA * prepareTargetData(CLIENT_EVENT* CE);
explicit sensorLGS3D( LGS_PARAMETERS *ptr = NULL, bool Master = true );
virtual ~sensorLGS3D();
bool create( void );
diff --git a/lib/rgoose/rgooseCamera.cpp b/lib/rgoose/rgooseCamera.cpp
index ba7a6eab..253d4e87 100644
--- a/lib/rgoose/rgooseCamera.cpp
+++ b/lib/rgoose/rgooseCamera.cpp
@@ -1,12 +1,19 @@
#include "rgooseCamera.h"
ARGUS_Camera::ARGUS_Camera( DBC_NODE_DATA *Data ): argusNetNode( Data ), basicEventHandler() {
+ m_pEvtHeap = basicEventHeap::getInstance();
m_tTimeTSeconds = 0;
if( m_pDBC != NULL ) {
DBC_CAM_DATA * tData = NULL;
tData = m_pDBC->getCamData( m_sNodeData.aux_id );
+ if( tData != NULL ) {
+ memcpy( &m_sCamData, tData, sizeof(DBC_CAM_DATA) );
+ free( tData );
+ };
} else {
memset( &m_sCamData, 0, sizeof(DBC_CAM_DATA) );
};
+ memset( &m_sCtrlData, 0, sizeof(CAMERA_CTRL_DATA) );
+ m_pPosition = new basicPosition( m_sCamData.lat, m_sCamData.lon, m_sCamData.alt, m_sCamData.roll, m_sCamData.pitch, m_sCamData.yaw );
};
ARGUS_Camera::ARGUS_Camera( uint32_t id, DBC_CAM_DATA *Data ): argusNetNode( id ), basicEventHandler() {
@@ -19,5 +26,245 @@ ARGUS_Camera::ARGUS_Camera( uint32_t id, DBC_CAM_DATA *Data ): argusNetNode( id
};
ARGUS_Camera::~ARGUS_Camera(){
+ if( m_pPosition != NULL ) delete( m_pPosition );
+};
+
+void ARGUS_Camera::dispatchEvent( EVENT_CONTAINER *E ){
+ if( E == NULL ) return;
+ if( !m_sCamData.online ) return;
+ switch( E->m_eClass ) {
+ case EVT_CLASS_SENSOR_CLD:
+ case EVT_CLASS_SENSOR_LGS:
+ case EVT_CLASS_SENSOR_LFS:
+ case EVT_CLASS_SENSOR_MND:
+ case EVT_CLASS_SENSOR_PLS_210:
+ case EVT_CLASS_SENSOR_PLS_360:
+ case EVT_CLASS_SENSOR_ALS:
+ case EVT_CLASS_SENSOR_3D:
+ case EVT_CLASS_SENSOR_ACC:{
+ switch( E->m_eType ) {
+ case EVT_TARGET_1D:
+ case EVT_TARGET_2D_BLACK:
+ case EVT_TARGET_2D_WHITE:
+ case EVT_TARGET_3D_BLACK:
+ case EVT_TARGET_3D_WHITE:{
+ TARGET_DATA *tDATA;
+ tDATA = (TARGET_DATA *)E->m_pEvtData;
+ if( tDATA ) {
+ if( inTheFOV( tDATA->global_target.lat, tDATA->global_target.lon, tDATA->global_target.alt ) ){
+ if( lookAt( tDATA->global_target.lat, tDATA->global_target.lon, tDATA->global_target.alt ) ){
+ EVENT_CONTAINER *tEVT;
+ DBC_INT_LIST *tStreams;
+ tStreams = m_pDBC->listCamMediaStreams( m_nDBID );
+ if( tStreams!= NULL ) {
+ for( uint32_t idx = 0; idx < tStreams->size(); idx++ ) {
+ tEVT = createBasicTargetedEvent( m_nDBID, tStreams->at(idx), EVT_CLASS_VIDEO, EVT_CAPTURE_START );
+ if( tEVT != NULL ) {
+ m_pEvtHeap->broadcast( tEVT );
+ };
+ };
+ delete( tStreams );
+ };
+ };
+ };
+ };
+ break;
+ };
+ };
+ break;
+ };
+ case EVT_CLASS_CAMERA_CTRL:{
+ if( E->m_nDestinationUID == m_sCamData.node_id ) {
+ switch( E->m_eType ) {
+ case EVT_CAMERA_DM:{
+ CAMERA_CTRL_DATA *tDATA = (CAMERA_CTRL_DATA *)E->m_pEvtData;
+ if( tDATA != NULL ) {
+ if( tDATA->moveMask & 0x08 == 0x08 ){
+ //Relative Move cmd
+ if( tDATA->moveMask & 0x07 == 0 ){
+ relativeStop();
+ } else {
+ relativeMove( tDATA->spdPAN, tDATA->spdTILT, tDATA->spdZOOM );
+ };
+ } else {
+ if( tDATA->moveMask & 0xF0 != 0x00 ) {
+ absoluteMove( tDATA->absPAN, tDATA->absTILT, tDATA->absZOOM );
+ };
+ };
+ };
+ break;
+ };
+ };
+ };
+ break;
+ };
+ };
+};
+
+float calcFOV(float SensorSize, float FN){
+ /*
+ The calculator below converts between the focal length f and the field of view (FOV) of a rectilinear lens.
+ The formula that it implements is FOV = 2 arctan (x / (2 f)), where x is the diagonal of the film.
+ The FOV is measured across the frame's diagonal, and is therefore smaller across the horizontal dimension,
+ and even smaller across the vertical dimension.
+ */
+ return 2.f * atanf((SensorSize * 25.4f) / (2.f * FN));
+};
+
+float calcMaxDistance(float SensorSize, float MaxFL, int ImageWidth ){
+ double tFOV, tt;
+ tFOV = calcFOV(SensorSize, MaxFL);
+ tt = tFOV / ((float)ImageWidth); // 1 pixel
+ return .01 / tan(tt / 2.0); // return Distance in meters to see 1 cm as 1 pixel
+};
+
+
+bool ARGUS_Camera::inTheFOV( float lat, float lon, float alt ){
+ bool RetVal = false;
+ if( m_pPosition == NULL ) return RetVal;
+
+ position3D * tPOS;
+ transform_3 * tTrans = NULL;
+
+ tPOS = new position3D();
+ if( tPOS == NULL ) return RetVal;
+ tPOS->setPositionWGS84( lat, lon, alt );
+ tTrans = m_pPosition->getTransform();
+ if(tTrans == NULL ){
+ delete( tPOS );
+ return RetVal;
+ };
+
+ vector_3 A, B;
+ C3D_SPH_DEGREES tSph;
+ C3D_DECART tLoc;
+ tLoc = tPOS->getXYZ();
+ A[0]= tLoc.x; A[1]= tLoc.y; A[2]= tLoc.z;
+ tTrans->get_vector_local(A, B);
+ tLoc.x = B[0]; tLoc.y = B[1]; tLoc.z = B[2];
+ decart2spherical( tLoc, tSph );
+
+ // return Distance in meters to see 1 cm as 1 pixel
+ float MR = calcMaxDistance( m_sCamData.imager_size, m_sCamData.max_f, 1280 );
+ RetVal = ( tSph.r < MR );
+ if( RetVal ) {
+ //Checking if FOV is OK
+ bool pOK = false;
+ bool tOK = false;
+ switch( m_sCamData.pan_model ) {
+ case 0: {
+ //Fixed Camera
+ double Hsize = sqrt(
+ ( m_sCamData.imager_size * m_sCamData.imager_size * m_sCamData.imager_ratio * m_sCamData.imager_ratio ) /
+ ( m_sCamData.imager_ratio * m_sCamData.imager_ratio + 1.0 )
+ );
+ double tFOV = calcFOV( Hsize, m_sCamData.max_f );
+ pOK = ( tSph.fi < ( tFOV / 2.0 ) );
+ break;
+ };
+ case 1:{
+ // Partial Pan
+ double Hsize = sqrt(
+ ( m_sCamData.imager_size * m_sCamData.imager_size * m_sCamData.imager_ratio * m_sCamData.imager_ratio ) /
+ ( m_sCamData.imager_ratio * m_sCamData.imager_ratio + 1.0 )
+ );
+ double tFOV = calcFOV( Hsize, m_sCamData.max_f );
+ pOK = ( tSph.fi > ( -1.0 * tFOV / 2.0 ) ) && ( tSph.fi < ( deg2rad( m_sCamData.pan_angles ) + tFOV / 2.0 ) ) ;
+ break;
+ };
+ case 2:{
+ // Endless Pan
+ pOK = true;
+ break;
+ };
+ };
+ switch( m_sCamData.tilt_model ) {
+ case 0: {
+ //Fixed Camera
+ double Vsize = sqrt(
+ ( m_sCamData.imager_size * m_sCamData.imager_size ) /
+ ( m_sCamData.imager_ratio * m_sCamData.imager_ratio + 1.0 )
+ );
+ double tFOV = calcFOV( Vsize, m_sCamData.max_f );
+ tOK = ( tSph.tetta < ( tFOV / 2.0 ) );
+ break;
+ };
+ case 1:{
+ // Partial Tilt
+ double Vsize = sqrt(
+ ( m_sCamData.imager_size * m_sCamData.imager_size ) /
+ ( m_sCamData.imager_ratio * m_sCamData.imager_ratio + 1.0 )
+ );
+ double tFOV = calcFOV( Vsize, m_sCamData.max_f );
+ tOK = ( tSph.tetta > ( -1.0 * tFOV / 2.0 ) ) && ( tSph.tetta < ( deg2rad( m_sCamData.tilt_angles ) + tFOV / 2.0 ) ) ;
+ break;
+ };
+ case 2:{
+ // Endless Tilt
+ tOK = true;
+ break;
+ };
+ };
+ RetVal = ( pOK && tOK );
+ };
+ delete( tPOS );
+ return RetVal;
+};
+
+bool ARGUS_Camera::lookAt( float lat, float lon, float alt ){
+ vector_3 A, B;
+ C3D_SPH_DEGREES tSph;
+ C3D_DECART tLoc;
+ position3D * tPOS;
+ transform_3 * tTrans = NULL;
+ // Exit for fixed Cam
+ if( ( m_sCamData.pan_model == 0 ) && ( m_sCamData.tilt_model == 0 ) ) return true;
+ if( m_pPosition == NULL ) return false;
+
+ tPOS = new position3D();
+ if( tPOS == NULL ) return false;
+ tPOS->setPositionWGS84( lat, lon, alt );
+
+ tTrans = m_pPosition->getTransform();
+ if(tTrans == NULL ){
+ delete( tPOS );
+ return false;
+ };
+
+ tLoc = tPOS->getXYZ();
+ A[0]= tLoc.x; A[1]= tLoc.y; A[2]= tLoc.z;
+ tTrans->get_vector_local(A, B);
+ tLoc.x = B[0]; tLoc.y = B[1]; tLoc.z = B[2];
+ delete( tPOS );
+ decart2spherical( tLoc, tSph );
+ float MR = calcMaxDistance( m_sCamData.imager_size, m_sCamData.max_f, 1280 );
+ float fZ, fT, fP;
+ if( MR > 0 ) {
+ if( tSph.r > MR ) {
+ fZ = 1;
+ } else {
+ fZ = tSph.r / MR;
+ };
+ } else fZ = 0.f;
+ switch( m_sCamData.pan_model ){
+ case 1:{
+ fP = ( 2.0 / m_sCamData.pan_angles ) * rad2deg( tSph.fi ) - 1.0;
+ break;
+ };
+ case 2:{
+ fP = ( 2.0 / 360.0 ) * rad2deg( tSph.fi ) - 1.0;
+ };
+ };
+ switch( m_sCamData.pan_model ) {
+ case 1:{
+ fT = ( 2.0 / m_sCamData.tilt_angles ) * rad2deg( tSph.tetta ) - 1.0;
+ break;
+ };
+ case 2:{
+ fT = ( 2.0 / 180 ) * rad2deg( tSph.tetta ) - 1.0;
+ break;
+ };
+ };
+ return absoluteMove( fP, fT, fZ );
};
diff --git a/lib/rgoose/rgooseCamera.h b/lib/rgoose/rgooseCamera.h
index 4b447871..c0173618 100644
--- a/lib/rgoose/rgooseCamera.h
+++ b/lib/rgoose/rgooseCamera.h
@@ -18,6 +18,7 @@
#include
#include "rgooseNode.h"
#include "../components/base/basicEventHandler.h"
+#include "../components/base/basicEventHeap.h"
//https://www.ebay.com/itm/Professional-Rolling-Makeup-Case-Bulb-Mirror-Cosmetic-Artist-Dressing-Train-Case/233264525474
@@ -30,12 +31,21 @@ class ARGUS_Camera: public argusNetNode, public basicEventHandler {
basicLogCollection * m_pLog;
protected:
time_t m_tTimeTSeconds;
+ basicEventHeap * m_pEvtHeap;
DBC_CAM_DATA m_sCamData;
+ basicPosition * m_pPosition;
+ CAMERA_CTRL_DATA m_sCtrlData;
+ /* Methotds Sutable to Control Camera */
+ virtual bool relativeMove( float PanSPD, float TiltSPD, float ZoomSPD ){ return false; };
+ virtual bool relativeStop(){ return false; };
+ virtual bool absoluteMove( float PanPOS, float TiltPOS, float ZoomPOS ){ return false; };
+ virtual bool inTheFOV( float lat, float lon, float alt );
+ virtual bool lookAt( float lat, float lon, float alt );
public:
explicit ARGUS_Camera( DBC_NODE_DATA *Data );
explicit ARGUS_Camera( uint32_t id, DBC_CAM_DATA *Data = NULL );
virtual ~ARGUS_Camera();
- virtual void dispatchEvent( basicEvent *Evt ){};
+ virtual void dispatchEvent( EVENT_CONTAINER *Evt );
};
diff --git a/lib/rgoose/rgooseDBConnector.cpp b/lib/rgoose/rgooseDBConnector.cpp
index 2f9f0da8..57ad89da 100644
--- a/lib/rgoose/rgooseDBConnector.cpp
+++ b/lib/rgoose/rgooseDBConnector.cpp
@@ -241,14 +241,26 @@ bool argusDBC::getLastEvents( vectorEventRecords &VR, uint32_t tss, uint32_t tsm
sprintf(tQBuf, "SELECT * FROM events_cloud WHERE `ts`>%d AND `ts_ms`>%d", tss, tsms );
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
- EventRecordDBC *tPtr;
+ DBC_EVT_DATA *tPtr;
Assoc *cArr;
for(int i=0;isize();i++) {
cArr = result->at(i);
- tPtr = (EventRecordDBC*)malloc(sizeof(EventRecordDBC));
+ tPtr = (DBC_EVT_DATA*)malloc(sizeof(DBC_EVT_DATA));
if( tPtr!= NULL ) {
Assoc::iterator it;
- memset(tPtr,0,sizeof(EventRecordDBC));
+ memset(tPtr,0,sizeof(DBC_EVT_DATA));
+ it = cArr->find("id");
+ if( it != cArr->end() ){
+ tPtr->id = atoi( it->second.c_str() );
+ };
+ it = cArr->find("node_id");
+ if( it != cArr->end() ){
+ tPtr->node_id = atoi( it->second.c_str() );
+ };
+ it = cArr->find("uuid");
+ if( it != cArr->end() ){
+ strncpy( tPtr->uuid, it->second.c_str(),64 );
+ };
it = cArr->find("ts");
if( it != cArr->end() ){
tPtr->ts_s = atoi( it->second.c_str() );
@@ -261,13 +273,47 @@ bool argusDBC::getLastEvents( vectorEventRecords &VR, uint32_t tss, uint32_t tsm
if( it != cArr->end() ){
tPtr->type = atoi( it->second.c_str() );
};
+ it = cArr->find("range_digital");
+ if( it != cArr->end() ){
+ tPtr->range_digital = atoi( it->second.c_str() );
+ };
+ it = cArr->find("azimuth");
+ if( it != cArr->end() ){
+ tPtr->az = atof( it->second.c_str() );
+ };
+ it = cArr->find("elevation");
+ if( it != cArr->end() ){
+ tPtr->el = atof( it->second.c_str() );
+ };
+ it = cArr->find("range");
+ if( it != cArr->end() ){
+ tPtr->ra = atof( it->second.c_str() );
+ };
+ it = cArr->find("area");
+ if( it != cArr->end() ){
+ tPtr->area = atof( it->second.c_str() );
+ };
+ it = cArr->find("lat");
+ if( it != cArr->end() ){
+ tPtr->lat = atof( it->second.c_str() );
+ };
+ it = cArr->find("lon");
+ if( it != cArr->end() ){
+ tPtr->lon = atof( it->second.c_str() );
+ };
+ it = cArr->find("alt");
+ if( it != cArr->end() ){
+ tPtr->alt = atof( it->second.c_str() );
+ };
+ it = cArr->find("custom");
+ if( it != cArr->end() ){
+ strncpy( tPtr->uuid, it->second.c_str(),64 );
+ };
char tBuf[CLOG];
sprintf(tBuf,"Evt: %d %d %d", tPtr->type, tPtr->ts_s, tPtr->ts_ms );
LOG(tBuf);
VR.push_back(tPtr);
};
- //??
- //delete(cArr);
};
};
deleteResult( result );
@@ -440,7 +486,7 @@ DBC_INT_LIST *argusDBC::listNodes( uint32_t SiteID ){
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM nodes WHERE `site_id`=%d AND `type` > 0", SiteID );
#ifdef DEBUG
- LOG(tQBuf);
+ //LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
@@ -481,7 +527,7 @@ DBC_INT_LIST *argusDBC::listNewNodes( uint32_t SiteID, DBC_INT_LIST *old_ids ){
AAssoc *result;
sprintf(tQBuf, "SELECT id FROM nodes WHERE `site_id`=%d AND `type` > 0 AND `id` NOT IN(%s)", SiteID, tParam );
#ifdef DEBUG
- LOG(tQBuf);
+ //LOG(tQBuf);
#endif
result = m_pDatabase->Query( tQBuf );
if( result!= NULL ) {
@@ -505,6 +551,36 @@ DBC_INT_LIST *argusDBC::listNewNodes( uint32_t SiteID, DBC_INT_LIST *old_ids ){
return tVal;
};
+DBC_INT_LIST *argusDBC::listCamMediaStreams( uint32_t CAMID ){
+ DBC_INT_LIST * tVal = NULL;
+ if(m_bIsConnected){
+ char tQBuf[CTEXT];
+ AAssoc *result;
+ sprintf(tQBuf, "SELECT id FROM media_streams WHERE `source_id`=%d AND `valid` > 0", CAMID );
+#ifdef DEBUG
+ LOG(tQBuf);
+#endif
+ result = m_pDatabase->Query( tQBuf );
+ if( result!= NULL ) {
+ if( result->size() > 0 ) {
+ Assoc *cArr;
+ tVal = new DBC_INT_LIST();
+ if( tVal != NULL ) {
+ Assoc::iterator it;
+ for(int i=0;isize();i++) {
+ cArr = result->at(i);
+ it = cArr->find("id");
+ if( it != cArr->end() ){
+ tVal->push_back( atoi( it->second.c_str() ));
+ };
+ };
+ };
+ };
+ };
+ deleteResult( result );
+ };
+ return tVal;
+};
DBC_NODE_DATA *argusDBC::getNodeData( uint32_t ID ){
DBC_NODE_DATA * tVal = NULL;
@@ -559,8 +635,65 @@ DBC_NODE_DATA *argusDBC::getNodeData( uint32_t ID ){
return tVal;
};
-DBC_LRF3D_DATA *argusDBC::getNode3DData( uint32_t ID ){
- DBC_LRF3D_DATA * tVal = NULL;
+DBC_SITE_DATA *argusDBC::getSiteData( uint32_t ID ){
+ DBC_SITE_DATA * tVal = NULL;
+ if(m_bIsConnected){
+ char tQBuf[CTEXT];
+ AAssoc *result;
+ sprintf(tQBuf, "SELECT * FROM sites WHERE `id`=%d", ID );
+#ifdef DEBUG
+ LOG(tQBuf);
+#endif
+ result = m_pDatabase->Query( tQBuf );
+ if( result!= NULL ) {
+ if( result->size() > 0 ) {
+ Assoc *cArr;
+ tVal = (DBC_SITE_DATA*) malloc(sizeof(DBC_SITE_DATA));
+ if( tVal != NULL ) {
+ memset( tVal, 0 , sizeof(DBC_SITE_DATA));
+ Assoc::iterator it;
+ cArr = result->at(0);
+ it = cArr->find("account_id");
+ if( it != cArr->end() ){
+ tVal->account_id = atoi( it->second.c_str() );
+ };
+ it = cArr->find("name");
+ if( it != cArr->end() ){
+ sprintf( tVal->name, it->second.c_str() );
+ };
+ it = cArr->find("server_ident");
+ if( it != cArr->end() ){
+ sprintf( tVal->ident, it->second.c_str() );
+ };
+ it = cArr->find("anchor_lat");
+ if( it != cArr->end() ){
+ tVal->lat = atof( it->second.c_str() );
+ };
+ it = cArr->find("anchor_lon");
+ if( it != cArr->end() ){
+ tVal->lon = atof( it->second.c_str() );
+ };
+ it = cArr->find("anchor_alt");
+ if( it != cArr->end() ){
+ tVal->alt = atof( it->second.c_str() );
+ };
+ it = cArr->find("hemisphere");
+ if( it != cArr->end() ){
+ tVal->SH = ( it->second.c_str()[0] == 'S' );
+ };
+ it = cArr->find("map_id");
+ if( it != cArr->end() ){
+ tVal->map_id = atoi( it->second.c_str() );
+ };
+ };
+ };
+ };
+ deleteResult( result );
+ };
+ return tVal;
+};
+DBC_LRF_DATA *argusDBC::getLRFData( uint32_t ID ){
+ DBC_LRF_DATA * tVal = NULL;
if(m_bIsConnected){
char tQBuf[CTEXT];
AAssoc *result;
@@ -572,31 +705,51 @@ DBC_LRF3D_DATA *argusDBC::getNode3DData( uint32_t ID ){
if( result!= NULL ) {
if( result->size() > 0 ) {
Assoc *cArr;
- tVal = (DBC_LRF3D_DATA*) malloc(sizeof(DBC_LRF3D_DATA));
+ tVal = (DBC_LRF_DATA*) malloc(sizeof(DBC_LRF_DATA));
if( tVal != NULL ) {
- memset( tVal, 0 , sizeof(DBC_LRF3D_DATA));
+ memset( tVal, 0 , sizeof(DBC_LRF_DATA));
Assoc::iterator it;
cArr = result->at(0);
+ it = cArr->find("lat");
+ if( it != cArr->end() ){
+ tVal->lat = atof( it->second.c_str() );
+ };
+ it = cArr->find("lon");
+ if( it != cArr->end() ){
+ tVal->lon = atof( it->second.c_str() );
+ };
+ it = cArr->find("alt");
+ if( it != cArr->end() ){
+ tVal->alt = atof( it->second.c_str() );
+ };
+ it = cArr->find("pitch");
+ if( it != cArr->end() ){
+ tVal->pitch = atof( it->second.c_str() );
+ };
+ it = cArr->find("yaw");
+ if( it != cArr->end() ){
+ tVal->yaw = atof( it->second.c_str() );
+ };
+ it = cArr->find("roll");
+ if( it != cArr->end() ){
+ tVal->roll = atof( it->second.c_str() );
+ };
it = cArr->find("ip_address");
if( it != cArr->end() ){
sprintf( tVal->master_host, it->second.c_str() );
};
- LOG("1 OK");
it = cArr->find("aux_ip_address");
if( it != cArr->end() ){
sprintf( tVal->slave_host, it->second.c_str() );
};
- LOG("2 OK");
it = cArr->find("port");
if( it != cArr->end() ){
tVal->master_port = atoi( it->second.c_str() );
};
- LOG("3 OK");
it = cArr->find("aux_port");
if( it != cArr->end() ){
tVal->slave_port = atoi( it->second.c_str() );
};
- LOG("4 OK");
};
};
};
@@ -867,6 +1020,22 @@ DBC_CAM_DATA *argusDBC::getCamData( uint32_t ID ){
if( it != cArr->end() ){
tVal->max_f = atof( it->second.c_str() );
};
+ it = cArr->find("pan_model");
+ if( it != cArr->end() ){
+ tVal->pan_model = atoi( it->second.c_str() );
+ };
+ it = cArr->find("pan_angles");
+ if( it != cArr->end() ){
+ tVal->pan_angles = atoi( it->second.c_str() );
+ };
+ it = cArr->find("tilt_model");
+ if( it != cArr->end() ){
+ tVal->tilt_model = atoi( it->second.c_str() );
+ };
+ it = cArr->find("tilt_angles");
+ if( it != cArr->end() ){
+ tVal->tilt_angles = atoi( it->second.c_str() );
+ };
it = cArr->find("access_login");
if( it != cArr->end() ){
strncpy( tVal->username, it->second.c_str(), 16 );
@@ -1560,6 +1729,140 @@ bool argusDBC::updateMediaServerStream( uint32_t id, CSTR mrl, CSTR key ){
};
return false;
};
+
+bool argusDBC::addEvent( uint32_t SRC, CSTR UUID, uint32_t tss, uint32_t tsms, uint8_t evt_type, uint16_t dig_r, float AZ, float EL, float RANGE, float AREA, float lat, float lon, float alt, CSTR BUUID ){
+ if( m_bIsConnected ) {
+ char tQBuf[MAX_PATH_LEN];
+ if( BUUID == NULL ) {
+ sprintf( tQBuf,"INSERT INTO events_cloud SET node_id=%d, uuid='%s', ts=%d, ts_ms=%d, evt_type=%d, range_digital=%d, azimuth=%0.6f, elevation=%0.6f, `range`=%0.2f, area=%0.3f, lat=%0.6f, lon=%0.6f, alt=%0.3f",
+ SRC,
+ UUID,
+ tss,
+ tsms,
+ evt_type,
+ dig_r,
+ AZ,
+ EL,
+ RANGE,
+ AREA,
+ lat,
+ lon,
+ alt
+ );
+ } else {
+ sprintf( tQBuf,"INSERT INTO events_cloud SET node_id=%d, uuid='%s', ts=%d, ts_ms=%d, evt_type=%d, range_digital=%d, azimuth=%0.6f, elevation=%0.6f, `range`=%0.2f, area=%0.3f, lat=%0.6f, lon=%0.6f, alt=%0.3f, custom='%s'",
+ SRC,
+ UUID,
+ tss,
+ tsms,
+ evt_type,
+ dig_r,
+ AZ,
+ EL,
+ RANGE,
+ AREA,
+ lat,
+ lon,
+ alt,
+ BUUID
+ );
+ };
+#ifdef DEBUG
+ // LOG(tQBuf);
+#endif
+ m_pDatabase->SilentQuery( tQBuf );
+ return true;
+ };
+ return false;
+};
+
+DBC_EVT_DATA *argusDBC::getEventByUUID( CSTR UUID ){
+ DBC_EVT_DATA *tPtr = NULL;
+ if( m_bIsConnected ) {
+ char tQBuf[MAX_PATH_LEN];
+ AAssoc *result;
+ sprintf( tQBuf, "SELECT * FROM events_cloud WHERE uuid = '%s'", UUID );
+#ifdef DEBUG
+ LOG(tQBuf);
+#endif
+ result = m_pDatabase->Query( tQBuf );
+ if( result!= NULL ) {
+ if( result->size() > 0 ) {
+ Assoc *cArr;
+ tPtr = (DBC_EVT_DATA*)malloc(sizeof(DBC_EVT_DATA));
+ if( tPtr!= NULL ) {
+ Assoc::iterator it;
+ memset(tPtr,0,sizeof(DBC_EVT_DATA));
+ cArr = result->at(0);
+ it = cArr->find("id");
+ if( it != cArr->end() ){
+ tPtr->id = atoi( it->second.c_str() );
+ };
+ it = cArr->find("node_id");
+ if( it != cArr->end() ){
+ tPtr->node_id = atoi( it->second.c_str() );
+ };
+ it = cArr->find("uuid");
+ if( it != cArr->end() ){
+ strncpy( tPtr->uuid, it->second.c_str(),64 );
+ };
+ it = cArr->find("ts");
+ if( it != cArr->end() ){
+ tPtr->ts_s = atoi( it->second.c_str() );
+ };
+ it = cArr->find("ts_ms");
+ if( it != cArr->end() ){
+ tPtr->ts_ms = atoi( it->second.c_str() );
+ };
+ it = cArr->find("evt_type");
+ if( it != cArr->end() ){
+ tPtr->type = atoi( it->second.c_str() );
+ };
+ it = cArr->find("range_digital");
+ if( it != cArr->end() ){
+ tPtr->range_digital = atoi( it->second.c_str() );
+ };
+ it = cArr->find("azimuth");
+ if( it != cArr->end() ){
+ tPtr->az = atof( it->second.c_str() );
+ };
+ it = cArr->find("elevation");
+ if( it != cArr->end() ){
+ tPtr->el = atof( it->second.c_str() );
+ };
+ it = cArr->find("range");
+ if( it != cArr->end() ){
+ tPtr->ra = atof( it->second.c_str() );
+ };
+ it = cArr->find("area");
+ if( it != cArr->end() ){
+ tPtr->area = atof( it->second.c_str() );
+ };
+ it = cArr->find("lat");
+ if( it != cArr->end() ){
+ tPtr->lat = atof( it->second.c_str() );
+ };
+ it = cArr->find("lon");
+ if( it != cArr->end() ){
+ tPtr->lon = atof( it->second.c_str() );
+ };
+ it = cArr->find("alt");
+ if( it != cArr->end() ){
+ tPtr->alt = atof( it->second.c_str() );
+ };
+ it = cArr->find("custom");
+ if( it != cArr->end() ){
+ strncpy( tPtr->custom, it->second.c_str(),64 );
+ };
+ };
+ };
+ };
+ deleteResult( result );
+ LOG("PUNG 17");
+ };
+ return tPtr;
+};
+
#undef LOG
#undef LOG_ERROR
diff --git a/lib/rgoose/rgooseDBConnector.h b/lib/rgoose/rgooseDBConnector.h
index 093f18f9..2a02723f 100644
--- a/lib/rgoose/rgooseDBConnector.h
+++ b/lib/rgoose/rgooseDBConnector.h
@@ -69,6 +69,10 @@ typedef struct S_DBC_CAM_DATA{
float imager_ratio;
float min_f;
float max_f;
+ uint8_t pan_model;
+ uint16_t pan_angles;
+ uint8_t tilt_model;
+ uint8_t tilt_angles;
char username[33];
char password[33];
char uuid[65];
@@ -80,12 +84,6 @@ typedef struct S_DBC_CAM_DATA{
char ptz_token[65];
}DBC_CAM_DATA;
-typedef struct S_EventRecordDBC{
- int ts_s;
- int ts_ms;
- int type;
-}EventRecordDBC;
-
typedef struct S_DBC_NODE_DATA{
uint32_t node_id;
uint32_t aux_id;
@@ -146,19 +144,41 @@ typedef struct S_DBC_MEDIA_SERVER_STREAM_DATA{
char mrl[128];
} DBC_MEDIA_SERVER_STREAM_DATA;
-typedef struct S_DBC_LRF3D_DATA{
+typedef struct S_DBC_LRF_DATA{
+ char serial[33];
+ char label[33];
+ float lat;
+ float lon;
+ float alt;
+ float pitch;
+ float yaw;
+ float roll;
char master_host[64];
- char slave_host[64];
uint16_t master_port;
- uint16_t slave_port;
-}DBC_LRF3D_DATA;
-
-typedef struct S_DBC_LRF2D_DATA{
- char master_host[64];
char slave_host[64];
- uint16_t master_port;
uint16_t slave_port;
-}DBC_LRF2D_DATA;
+ uint16_t enabled_lrf;
+ uint32_t base_shift;
+ uint32_t mirror_shift;
+ uint16_t m_order;
+ uint16_t m_offset;
+ uint16_t m_delta;
+ uint16_t m_flip;
+ uint32_t m_width;
+ uint16_t m_sst;
+ uint16_t m_sun;
+ uint16_t m_gp;
+ uint16_t m_spikes;
+ uint16_t s_order;
+ uint16_t s_offset;
+ uint16_t s_delta;
+ uint16_t s_flip;
+ uint32_t s_width;
+ uint16_t s_sst;
+ uint16_t s_sun;
+ uint16_t s_gp;
+ uint16_t s_spikes;
+}DBC_LRF_DATA;
typedef struct S_DBC_UART_DATA{
uint8_t type;
@@ -170,9 +190,38 @@ typedef struct S_DBC_UART_DATA{
uint8_t flow_ctrl;
}DBC_UART_DATA;
+typedef struct S_DBC_EVT_DATA{
+ uint32_t id;
+ uint32_t node_id;
+ char uuid[65];
+ uint32_t ts_s;
+ uint32_t ts_ms;
+ uint8_t type;
+ uint32_t range_digital;
+ float az;
+ float el;
+ float ra;
+ float area;
+ float lat;
+ float lon;
+ float alt;
+ char custom[65];
+}DBC_EVT_DATA;
+
+typedef struct S_DBC_SITE_DATA{
+ uint32_t account_id;
+ char name[129];
+ char ident[33];
+ float lat;
+ float lon;
+ float alt;
+ bool SH;
+ uint8_t map_id;
+}DBC_SITE_DATA;
+
typedef std::vector DBC_INT_LIST;
typedef std::vector vectorCamRecords;
-typedef std::vector vectorEventRecords;
+typedef std::vector vectorEventRecords;
class argusDBC{
private:
@@ -197,6 +246,7 @@ class argusDBC{
bool updateIPCam( uint32_t SiteID, CSTR uuid, CSTR Addr );
bool updateIPCam( uint32_t SiteID, uint32_t CamID, CSTR Addr );
bool addIPCam( uint32_t SiteID, resultWoWo *tPtr );
+ bool addEvent( uint32_t SRC, CSTR UUID, uint32_t tss, uint32_t tsms, uint8_t evt_type, uint16_t dig_r, float AZ, float EL, float RANGE, float AREA, float lat, float lon, float alt, CSTR BUUID = NULL );
uint64_t addLocalMediaSource( uint32_t SiteID, CSTR path, uint32_t width, uint32_t height );
bool updateNetworkNode( bool OnlineStatus );
bool updateMediaServerStream( uint32_t id, CSTR mrl=NULL, CSTR key = NULL );
@@ -208,16 +258,18 @@ class argusDBC{
DBC_INT_LIST * listNewNodes( uint32_t SiteID, DBC_INT_LIST * old_ids );
DBC_INT_LIST * listNodes( uint32_t SiteID );
DBC_INT_LIST * listSockets( uint32_t NodeID );
+ DBC_INT_LIST * listCamMediaStreams( uint32_t CAMID );
DBC_CAM_DATA * getCamData( uint32_t CamID );
uint32_t getCamId( CSTR UUID );
+ DBC_EVT_DATA * getEventByUUID( CSTR UUID );
DBC_NODE_DATA * getNodeData( uint32_t ID );
- DBC_LRF3D_DATA * getNode3DData( uint32_t ID );
- DBC_LRF2D_DATA * getNode2DData( uint32_t ID );
+ DBC_LRF_DATA * getLRFData( uint32_t ID );
DBC_MODULE_DATA * getModuleData( uint32_t ID );
DBC_SOCKET_DATA * getSocketData( uint32_t ID );
DBC_MEDIA_STREAM_DATA * getMediaStreamData( uint32_t ID );
DBC_MEDIA_SERVER_DATA * getMediaServerData( uint32_t ID );
+ DBC_SITE_DATA * getSiteData( uint32_t ID );
DBC_MEDIA_SERVER_STREAM_DATA * getMediaServerStreamData( uint32_t ID );
void registerServer(uint32_t SiteID, CSTR identity );
diff --git a/lib/rgoose/rgooseIPCamera.cpp b/lib/rgoose/rgooseIPCamera.cpp
index ff77cf76..60452f83 100644
--- a/lib/rgoose/rgooseIPCamera.cpp
+++ b/lib/rgoose/rgooseIPCamera.cpp
@@ -1,39 +1,66 @@
#include "rgooseIPCamera.h"
-#define LOG( X ) m_pLog->Log( "ARGUS_IPCAM", this, X )
-#define LOG_ERROR( X ) m_pLog->Log( "ARGUS_IPCAM", this, _LOG_ERROR, X )
+#define LOG( X ) m_pLog->Log( "ONVIFCAM", this, X )
+#define LOG_ERROR( X ) m_pLog->Log( "ONVIFCAM", this, _LOG_ERROR, X )
-ARGUS_IPCAM::ARGUS_IPCAM( uint32_t id ): ARGUS_Camera( id ), basicThread(){
+ARGUS_IPCAM::ARGUS_IPCAM( uint32_t id ): ARGUS_Camera( id ) /*, basicThread() */{
m_pLog = basicLogCollection::getInstance();
m_pOnVif = NULL;
- m_pPosition = NULL;
- m_bOnline = false;
+ //m_pPosition = NULL;
+ //m_bOnline = false;
};
ARGUS_IPCAM::~ARGUS_IPCAM(){
- waitThreadEnd( true );
- if(m_pOnVif != NULL) delete(m_pOnVif);
+ //waitThreadEnd( true );
+ if( m_pOnVif != NULL ) delete( m_pOnVif );
};
-bool ARGUS_IPCAM::create( CSTR ip, CSTR username, CSTR password ){
- m_pOnVif = new pOnvif();
- if(m_pOnVif != NULL) {
- m_pOnVif->setIPAddress( ip );
- m_pOnVif->setUsername( username );
- m_pOnVif->setPassword( password );
+bool ARGUS_IPCAM::startService(){//create( ){//CSTR ip, CSTR username, CSTR password ){
+ if( m_pOnVif == NULL ) return false;
+ m_pOnVif = new pOnvif();
+
+ if( m_pOnVif != NULL ){
+ m_pOnVif->setIPAddress( m_sCamData.ip );// ip );
+ m_pOnVif->setUsername( m_sCamData.username );// username );
+ m_pOnVif->setPassword( m_sCamData.password );// password );
if( m_pOnVif->create() ){
- videoSourceProfile *tPtr;
- tPtr = m_pOnVif->getProfiles()->at(0);
- sprintf( m_pProfileToken, "%s", tPtr->profiletoken );
- LOG( m_pProfileToken );
- sprintf( m_pDevToken, "%s", tPtr->sourcetoken );
- LOG( m_pDevToken );
- return basicThread::init();
+ //videoSourceProfile *tPtr;
+ m_pProfile = m_pOnVif->getProfiles()->at(0);
+ //sprintf( m_pProfileToken, "%s", tPtr->profiletoken );
+ //LOG( m_pProfileToken );
+ //sprintf( m_pDevToken, "%s", tPtr->sourcetoken );
+ //LOG( m_pDevToken );
+ //return basicThread::init();
+ return m_sCamData.online = true;
};
};
return false;
};
+bool ARGUS_IPCAM::relativeMove( float PanSPD, float TiltSPD, float ZoomSPD ){
+ if( m_sCamData.online ) {
+ if( m_pOnVif->ptz_ContinuousMove( m_pProfile->profiletoken, PanSPD , TiltSPD ) ){
+ return m_pOnVif->ptz_ContinuousMoveZoom( m_pProfile->profiletoken, ZoomSPD );
+ };
+ };
+ return false;
+};
+
+bool ARGUS_IPCAM::relativeStop(){
+ if( m_sCamData.online ) {
+ return m_pOnVif->ptz_Stop( m_pProfile->profiletoken, true, true );
+ };
+ return false;
+};
+
+bool ARGUS_IPCAM::absoluteMove( float PanPOS, float TiltPOS, float ZoomPOS ){
+ if( m_sCamData.online ) {
+ return m_pOnVif->ptz_AbsoluteMove( m_pProfile->profiletoken, PanPOS, TiltPOS, ZoomPOS );
+ };
+ return false;
+};
+
+/*
void ARGUS_IPCAM::m_fThreadProc( void ){
pid_t pid = gettid();
char pidBuf[16];
@@ -56,11 +83,11 @@ void ARGUS_IPCAM::m_fThreadProc( void ){
};
};
-void ARGUS_IPCAM::dispatchEvent( basicEvent *Evt ){
+void ARGUS_IPCAM::dispatchEvent( EVENT_CONTAINER *Evt ){
if( m_bOnline ) {
LOG("EVENT!");
};
};
-
+*/
#undef LOG
#undef LOG_ERROR
diff --git a/lib/rgoose/rgooseIPCamera.h b/lib/rgoose/rgooseIPCamera.h
index dde75e49..583b1686 100644
--- a/lib/rgoose/rgooseIPCamera.h
+++ b/lib/rgoose/rgooseIPCamera.h
@@ -17,7 +17,7 @@
#include
#include "rgooseCamera.h"
-#include "../components/base/basicThread.h"
+//#include "../components/base/basicThread.h"
#include "../data/ponvif/ponvif.h"
//https://www.ebay.com/itm/Professional-Rolling-Makeup-Case-Bulb-Mirror-Cosmetic-Artist-Dressing-Train-Case/233264525474
@@ -26,26 +26,32 @@
//ffmpeg -i input.mp4 -af loudnorm=I=-23:LRA=7:tp=-2:measured_I=-30:measured_LRA=1.1:measured_tp=-11 04:measured_thresh=-40.21:offset=-0.47 -ar 48k -y output.mp4
-class ARGUS_IPCAM: public ARGUS_Camera, public basicThread{
+class ARGUS_IPCAM: public ARGUS_Camera /*, public basicThread */{
private:
basicLogCollection * m_pLog;
pOnvif * m_pOnVif;
- bool m_bOnline;
- bool m_bPtzCapable;
- char m_pIP[16];
- time_t m_tTimeTSeconds;
- char m_pPassword[CTEXT];
- char m_pUserName[CTEXT];
- char m_pDevToken[CTEXT];
- char m_pProfileToken[CTEXT];
- char m_pPtzToken[CTEXT];
+ videoSourceProfile * m_pProfile;
+ //bool m_bOnline;
+ //bool m_bPtzCapable;
+ //char m_pIP[16];
+ //time_t m_tTimeTSeconds;
+ //char m_pPassword[CTEXT];
+ //char m_pUserName[CTEXT];
+ //char m_pDevToken[CTEXT];
+ //char m_pProfileToken[CTEXT];
+ //char m_pPtzToken[CTEXT];
protected:
- void m_fThreadProc( void );
+ virtual bool relativeMove( float PanSPD, float TiltSPD, float ZoomSPD );
+ virtual bool relativeStop();
+ virtual bool absoluteMove( float PanPOS, float TiltPOS, float ZoomPOS );
+ //void m_fThreadProc( void );
public:
explicit ARGUS_IPCAM( uint32_t id );
~ARGUS_IPCAM();
- bool create( CSTR ip, CSTR username, CSTR password );
- virtual void dispatchEvent( basicEvent *Evt );
+ //bool create( );// CSTR ip, CSTR username, CSTR password );
+ //virtual void dispatchEvent( EVENT_CONTAINER *Evt );
+ virtual bool startService();
+ //virtual bool stopService();
};
diff --git a/lib/rgoose/rgooseKafkaModule.cpp b/lib/rgoose/rgooseKafkaModule.cpp
index d8805911..5ec317a0 100644
--- a/lib/rgoose/rgooseKafkaModule.cpp
+++ b/lib/rgoose/rgooseKafkaModule.cpp
@@ -1,5 +1,10 @@
#include "rgooseKafkaModule.h"
#include "../hardware/soc/general/3DLRF.h"
+#include "../data/json/json_tool.h"
+#include
+#include
+#include
+#include
#define LOG( X ) argusKernelModule::m_pLog->Log( "KM", this, X )
@@ -16,9 +21,11 @@
argusKafkaModule::argusKafkaModule( uint32_t ModuleID ): argusKernelModule( ModuleID, ARGUS_MODULE_KAFKA ){
m_pProtocol = NULL;
m_bConsumerEnabled = false;
-
- partition = RdKafka::Topic::PARTITION_UA;
- start_offset = RdKafka::Topic::OFFSET_BEGINNING;
+ m_pEventHeap = basicEventHeap::getInstance();
+ partition = 0; //RdKafka::Topic::PARTITION_UA;
+ //start_offset = RdKafka::Topic::OFFSET_END;// OFFSET_BEGINNING;
+ start_offset = 0;//RdKafka::Topic::OFFSET_BEGINNING;
+ //start_offset = RdKafka::Topic::OFFSET_STORED;
m_pEvtTemplates = (KAFKA_TEMPLATE***) calloc(EVT_CLASS_COUNT, sizeof(KAFKA_TEMPLATE**));
if( m_pEvtTemplates!= NULL ) {
@@ -72,9 +79,9 @@ void argusKafkaModule::m_fThreadProc( void ){
};
while( m_bThreadStatus < TH_ENDED ) {
m_llTicks ++;//= getMilliseconds();
- if( m_llTicks % 20 == 0 ) { // each 2 seconds
+ if( m_llTicks % 20 == 0 ) { // each 2 seconds
+#ifdef SIMULATOR
sim_Az += tr_Az_step;
-#ifdef SIMULATOR
for(int i=0; i < EVT_CLASS_COUNT; i++ ) {
if( m_pEvtTemplates[i] != NULL ){
for( int j=0; j< EVT_COUNT; j++ ) {
@@ -116,7 +123,78 @@ void argusKafkaModule::m_fThreadProc( void ){
char BUF[1024];
int len;
if( m_pProtocol->receivePost( m_pEvtTemplates[EVT_CLASS_EXTERNAL_CMD][idx]->topic, partition, start_offset, BUF, len ) ){
- LOG(" HAVE MESSAGE ");
+ if( len > 0 ) {
+ start_offset++;
+#ifdef DEBUG
+ char ttt[64];
+ LOG(" HAVE MESSAGE ");
+ sprintf( ttt, " MSG Len: %d", len );
+ LOG( ttt );
+#endif
+ if( len > 0 ){
+ LOG ( BUF );
+ try{
+ Json::Value root;
+ Json::Reader reader;
+ if( !reader.parse( BUF, root ) ){
+ LOG_ERROR( "Error parsing the string" );
+ } else {
+ if (root.size()) {
+ FH_CTRL_DATA * tData;
+ basicEventTypeID evtID = EVT_NOINIT;
+ Json::Value tVal;
+ tData =(FH_CTRL_DATA *)malloc( sizeof(FH_CTRL_DATA));
+ if( tData ) {
+ memset( tData, 0, sizeof(FH_CTRL_DATA));
+ tVal = root["id"];
+
+ if (tVal != NULL) {
+ #ifdef DEBUG
+ LOG(tVal.asString().c_str());
+ #endif
+ sprintf( tData->cmdUUID, "%s", tVal.asString().c_str() );
+ };
+ tVal = root["action"];
+ if (tVal != NULL) {
+ #ifdef DEBUG
+ LOG( tVal.asString().c_str() );
+ #endif
+ if ( strcasecmp(tVal.asString().c_str(), "intercept_target") == 0) {
+ evtID = EVT_FH_MISSION_BEGIN;
+ };
+ if ( strcasecmp(tVal.asString().c_str(), "jam_target") == 0) {
+ evtID = EVT_FH_JAMER_ON;
+ };
+ if ( strcasecmp(tVal.asString().c_str(), "cancel") == 0) {
+ evtID = EVT_FH_MISSION_END;
+ };
+ };
+ tVal = root["target_id"];
+ if (tVal != NULL) {
+ #ifdef DEBUG
+ LOG( tVal.asString().c_str() );
+ #endif
+ sprintf( tData->targetUUID, "%s", tVal.asString().c_str() );
+ };
+ if( evtID ) {
+ EVENT_CONTAINER * tEVT;
+ tEVT = createBasicEvent( 0, EVT_CLASS_EXTERNAL_CMD, evtID, NULL, tData );
+ if( tEVT ) {
+ m_pEventHeap->broadcast( tEVT );
+ } else {
+ free( tData );
+ };
+ } else {
+ free( tData );
+ };
+ };
+ };
+ };
+ } catch( exception e ){
+ LOG_ERROR("EXCEPTION");
+ };
+ };
+ };
};
};
};
@@ -131,13 +209,7 @@ bool argusKafkaModule::startService(){
if( m_pSettings!= NULL ){
m_pProtocol = new protocolKAFKA( m_pSettings );
if( m_pProtocol->init() ){
- // No need pereodical jobs unless SIMULATOR
-#ifdef SIMULATOR
- LOG("Start PJ");
return init();
-#else
- return true;
-#endif
};
};
};
@@ -179,10 +251,7 @@ bool argusKafkaModule::reloadSettings(){
memset( m_pEvtTemplates[i], 0, EVT_COUNT * sizeof(KAFKA_TEMPLATE*));
if( i == EVT_CLASS_EXTERNAL_CMD ) {
m_bConsumerEnabled = true;
-#ifdef DEBUG
- LOG( "Consumer Enabled" );
-#endif
- }
+ };
};
m_pEvtTemplates[i][j] = tT;
};
@@ -203,7 +272,8 @@ CSTR argusKafkaModule::buildTemplate(
CSTR width,
CSTR el,
CSTR lat,
- CSTR lon
+ CSTR lon,
+ CSTR alt
){
CSTR ct1, ct2;
char sid[64];
@@ -265,82 +335,127 @@ CSTR argusKafkaModule::buildTemplate(
ct1 = ct2;
};
};
+ if( alt ){
+ ct2 = strReplace( ct1, KAFKA_TPL_SUBST_ALT, alt );
+ if( ct2 ) {
+ free( ct1 );
+ ct1 = ct2;
+ };
+ };
return ct1;
};
}
return NULL;
};
-void argusKafkaModule::dispatchEvent( basicEvent *Evt ){
+void argusKafkaModule::dispatchEvent( EVENT_CONTAINER *Evt ){
+ if( Evt == NULL ) return;
+ if( !m_bEnabled ) return;
#ifdef DEBUG
- LOG( "EVT DISPATCHER");
+ char tBuffer[256];
+ sprintf( tBuffer, "Event Class %d Type %d ", Evt->m_eClass , Evt->m_eType );
+ LOG( tBuffer );
#endif
- if( Evt == NULL ) {
- LOG( "Evt NULL");
- return;
- };
- if( !m_bEnabled )return;
if( m_pEvtTemplates[ Evt->m_eClass ]!= NULL ) {
// We have defined Channel for that class Events
+ // Skip Event Handling by flags
+ if( !m_bEvtFlags[ Evt->m_eType ] ){
#ifdef DEBUG
- char tBuffer[256];
- sprintf( tBuffer, "Event Class %d Type %d ", Evt->m_eClass , Evt->m_eType );
- LOG( tBuffer );
+ //LOG("Disabled By FLAG!");
#endif
- // Skip Event Handling by flags
- if( !m_bEvtFlags[ Evt->m_eType ] ) return;
+ //return;
+ }
// Hadle Event
CSTR tDATA;
if( m_pEvtTemplates[ Evt->m_eClass ][ Evt->m_eType ] != NULL ) {
- CLIENT_EVENT *tCEVT;
- tCEVT = ( CLIENT_EVENT *) Evt->m_pEvtData;
- tDATA = buildTemplate( m_pEvtTemplates[ Evt->m_eClass ][ Evt->m_eType ]->tpl,
- Evt->m_nSourceUID,
- getUniqID_MD5()
- );
-
+ switch( Evt->m_eType ) {
+ case EVT_TARGET_2D_BLACK:
+ case EVT_TARGET_2D_WHITE:
+ case EVT_TARGET_3D_BLACK:
+ case EVT_TARGET_3D_WHITE:{
+ TARGET_DATA * tTARGET = ( TARGET_DATA *) Evt->m_pEvtData;
+ if(tTARGET!=NULL){
+ char AZ[10];
+ char EL[10];
+ char RA[10];
+ char WID[10];
+ char LAT[10];
+ char LON[10];
+ char ALT[10];
+ char TS[64];
+ sprintf( AZ,"%0.3f", tTARGET->local_target.fi );
+ sprintf( EL,"%0.3f", tTARGET->local_target.tetta );
+ sprintf( RA,"%0.3f", tTARGET->local_target.r );
+ sprintf( WID,"%0.3f", tTARGET->area );
+ sprintf( LAT,"%0.3f", tTARGET->global_target.lat );
+ sprintf( LON,"%0.3f", tTARGET->global_target.lon );
+ sprintf( ALT,"%0.3f", tTARGET->global_target.alt );
+ sprintf( TS, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
+ ( Evt->sTS.tm_year+1900),
+ (Evt->sTS.tm_mon+1),
+ Evt->sTS.tm_mday,
+ Evt->sTS.tm_hour,
+ Evt->sTS.tm_min,
+ Evt->sTS.tm_sec,
+ (Evt->m_UMSTS%1000)
+ );
+ tDATA = buildTemplate( m_pEvtTemplates[ Evt->m_eClass ][ Evt->m_eType ]->tpl,
+ Evt->m_nSourceUID,
+ TS,
+ Evt->m_UUID,
+ AZ,
+ RA,
+ WID,
+ EL,
+ LAT,
+ LON,
+ ALT
+ );
+ };
+ break;
+ };
+ case EVT_FH_MISSION_BEGIN:
+ case EVT_FH_LANDED:{
+ C3D_WGS84_LOC * tPOINT=(C3D_WGS84_LOC *) Evt->m_pEvtData;
+ if( tPOINT ) {
+ char TS[64];
+ char LAT[10];
+ char LON[10];
+ char ALT[10];
+ sprintf( LAT,"%0.3f", tPOINT->lat );
+ sprintf( LON,"%0.3f", tPOINT->lon );
+ sprintf( ALT,"%0.3f", tPOINT->alt );
+ sprintf( TS, "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
+ ( Evt->sTS.tm_year+1900),
+ (Evt->sTS.tm_mon+1),
+ Evt->sTS.tm_mday,
+ Evt->sTS.tm_hour,
+ Evt->sTS.tm_min,
+ Evt->sTS.tm_sec,
+ (Evt->m_UMSTS%1000)
+ );
+ tDATA = buildTemplate( m_pEvtTemplates[ Evt->m_eClass ][ Evt->m_eType ]->tpl,
+ Evt->m_nSourceUID,
+ TS,
+ Evt->m_UUID,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ LAT,
+ LON,
+ ALT
+ );
+ };
+ break;
+ };
+ };
if( tDATA!= NULL ) {
m_pProtocol->issuePost( m_pEvtTemplates[ Evt->m_eClass ][ Evt->m_eType ]->topic, tDATA, strlen( tDATA ) );
+ } else {
+ LOG_ERROR("Cant Build Template!");
};
};
- /*
- switch( Evt->m_eType ) {
- case EVT_TARGET_1D:
- case EVT_TARGET_2D_WHITE:
- case EVT_TARGET_2D_BLACK:
- case EVT_TARGET_3D_WHITE:
- case EVT_TARGET_3D_BLACK:{
- CLIENT_EVENT *tCEVT;
- tCEVT = ( CLIENT_EVENT *) Evt->m_pEvtData;
- if( tCEVT != NULL ){
- float Az, El;
- uint32_t cRange;
- cRange = (uint32_t)(((float) tCEVT->range ) * 0.0732421875f ) ; // To meters
- #ifdef PRU_SLAVE
- make3Ddeg( tCEVT->th_id, Az, El, false );
- #else
- make3Ddeg( tCEVT->th_id, Az, El, true );
- #endif
- m_pProtocol->Alarm3D( (int)Az, (int)El, cRange , tCEVT->k_id );
- };
- };
- break;
- case EVT_ERROR:
- m_pProtocol->SetStatus( false );
- break;
- case EVT_SCAN:
- //StatusUpdate();
- //break;
- case EVT_FLIP:
- m_pProtocol->SetStatus( true );
- //StatusUpdate();
- break;
- case EVT_COMMAND:
- break;
- default:
- LOG_ERROR("Unknown Event!");
- };
- */
};
};
diff --git a/lib/rgoose/rgooseKafkaModule.h b/lib/rgoose/rgooseKafkaModule.h
index 7e7bce46..737bbfaa 100644
--- a/lib/rgoose/rgooseKafkaModule.h
+++ b/lib/rgoose/rgooseKafkaModule.h
@@ -4,9 +4,10 @@
#include "rgooseModule.h"
#include "../components/base/basicThread.h"
+#include "../components/base/basicEventHeap.h"
#include "../data/protocol/protocolKAFKA.h"
-#define SIMULATOR
+//#define SIMULATOR
#define KAFKA_TPL_SUBST_ID "%%ID%%"
#define KAFKA_TPL_SUBST_UUID "%%UUID%%"
@@ -17,12 +18,14 @@
#define KAFKA_TPL_SUBST_WIDTH "%%WIDTH%%"
#define KAFKA_TPL_SUBST_LON "%%LON%%"
#define KAFKA_TPL_SUBST_LAT "%%LAT%%"
+#define KAFKA_TPL_SUBST_ALT "%%ALT%%"
class argusKafkaModule: public basicThread, public argusKernelModule {
private:
KAFKA_SETTINGS *m_pSettings;
protocolKAFKA *m_pProtocol;
bool m_bConsumerEnabled;
+ basicEventHeap *m_pEventHeap;
KAFKA_TEMPLATE ***m_pEvtTemplates;
int32_t partition;
@@ -38,7 +41,8 @@ class argusKafkaModule: public basicThread, public argusKernelModule {
CSTR width = NULL,
CSTR el = NULL,
CSTR lat = NULL,
- CSTR lon = NULL
+ CSTR lon = NULL,
+ CSTR alt = NULL
);
protected:
virtual void m_fThreadProc( void );
@@ -49,7 +53,7 @@ class argusKafkaModule: public basicThread, public argusKernelModule {
virtual bool reloadSettings();
virtual bool startService();
virtual bool stopService();
- virtual void dispatchEvent(basicEvent *Evt);
+ virtual void dispatchEvent(EVENT_CONTAINER *Evt);
};
diff --git a/lib/rgoose/rgooseKernel.cpp b/lib/rgoose/rgooseKernel.cpp
index bd0b3589..6150af9e 100644
--- a/lib/rgoose/rgooseKernel.cpp
+++ b/lib/rgoose/rgooseKernel.cpp
@@ -39,7 +39,7 @@ argusKernel* argusKernel::getInstance( config_setting_t *Settings ) {
return _instance;
};
-argusKernel::argusKernel( config_setting_t *Settings ):basicThread(){
+argusKernel::argusKernel( config_setting_t *Settings ):basicThread(), basicEventHandler(){
m_bExitCause = 0;
m_nServerID = 0;
m_nSiteID = 0;
@@ -134,6 +134,17 @@ bool argusKernel::create( void ){
m_nServerID = m_pDBC->getServerID( m_sIdentity );
m_nServerNodeID = m_pDBC->getServerNode( m_nServerID );
+ DBC_SITE_DATA *tSiteData = m_pDBC->getSiteData( m_nSiteID );
+ if( tSiteData ) {
+ C3D_WGS84_LOC t;
+ t.lat = tSiteData->lat;
+ t.lon = tSiteData->lon;
+ t.alt = tSiteData->alt;
+ m_pSystemAnchor = systemAnchor::getInstance( tSiteData->SH, &t );
+ free( tSiteData );
+ } else {
+ LOG_ERROR("Error Loading Site DATA!");
+ };
//Init Subcomponents
m_pHardwareManager = argusHardwareManager::getInstance();
if( m_pHardwareManager!= NULL ) {
@@ -264,11 +275,14 @@ void argusKernel::m_fThreadProc( void ){
time_t tTimeTSeconds;
int lastTSS = 0;
int lastTMS = 0;
- EventRecordDBC * tEvtPtr;
+ DBC_EVT_DATA * tEvtPtr;
pid_t pid = gettid();
char pidBuf[16];
- sprintf(pidBuf,"pid:%d", pid);
- LOG(pidBuf);
+ sprintf(pidBuf,"KERNEL pid:%d", pid);
+ LOG( pidBuf );
+#ifdef SIMULATE_KERNEL_TARGETS
+ LOG("SIMULATION ENABLED");
+#endif
m_bThreadStatus = TH_WORKING;
while( m_bThreadStatus < TH_ENDED ){
m_tTimeTSeconds = time( NULL );
@@ -319,6 +333,22 @@ void argusKernel::m_fThreadProc( void ){
validateEvents( lastTSS, lastTMS );
// SLEEP( 2 ); // short loop if had an events
} else SLEEP( SLEEP_KERNEL_INTERVAL );
+
+
+#ifdef SIMULATE_KERNEL_TARGETS
+ //Target Simulation To Test Events - Database
+ if(( m_tTimeTSeconds%SIMULATE_KERNEL_INTERVAL)==(SIMULATE_KERNEL_INTERVAL>>1)){
+ if( m_tTimeTSeconds!= m_nLastSimRun ){
+ m_nLastSimRun = m_tTimeTSeconds;
+ if( m_pNodeFactory != NULL ) {
+ argusNetNode *tNode = m_pNodeFactory->getNode( SIMULATE_KERNEL_NODE_ID );
+ if( tNode!= NULL ) {
+ tNode->simulateTarget();
+ };
+ };
+ };
+ };
+#endif
};
};
@@ -364,8 +394,8 @@ void argusKernel::validateCameras( void ){
};
void argusKernel::validateEvents( int &lastTSS, int &lastTMS ){
- EventRecordDBC *tPtr = NULL;
- basicEvent *tEvt = NULL;
+ DBC_EVT_DATA *tPtr = NULL;
+ EVENT_CONTAINER *tEvt = NULL;
if(m_vEvtRecords.size()) {
lastTSS = m_vEvtRecords.at(m_vEvtRecords.size()-1)->ts_s;
lastTMS = m_vEvtRecords.at(m_vEvtRecords.size()-1)->ts_ms;
@@ -436,6 +466,151 @@ argusKernelModule *argusKernel::getModule( int id ){
return NULL;
};
+void argusKernel::dispatchEvent( EVENT_CONTAINER *Evt ){
+ // Register all events in Database;
+ LOG( "New EVENT!!" );
+ if( m_pDBC == NULL ) return;
+ if( Evt == NULL ) return;
+ switch( Evt->m_eClass ) {
+ case EVT_CLASS_EXTERNAL_CMD:
+ switch( Evt->m_eType ){
+ case EVT_FH_MISSION_BEGIN:{
+ FH_CTRL_DATA * tData = (FH_CTRL_DATA *) Evt->m_pEvtData;
+ if( tData ) {
+ DBC_EVT_DATA * tEVT = m_pDBC->getEventByUUID( tData->targetUUID );
+ if( tEVT ) {
+ uint32_t TS_A, TS_B;
+ TS_A = Evt->m_UMSTS / 1000;
+ TS_B = Evt->m_UMSTS % 1000;
+ if( m_pDBC->addEvent(
+ 0,
+ Evt->m_UUID,
+ TS_A,
+ TS_B,
+ EVT_FH_FLY_TO,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ tEVT->lat,
+ tEVT->lon,
+ tEVT->alt,
+ tEVT->uuid
+ ) ){
+ //Simulate FH Module Event;
+ EVENT_CONTAINER *ttt;
+ C3D_WGS84_LOC * nnn = (C3D_WGS84_LOC *) malloc( sizeof(C3D_WGS84_LOC));
+ if( nnn ){
+ nnn->lat = tEVT->lat;
+ nnn->lon = tEVT->lon;
+ nnn->alt = tEVT->alt;
+ ttt = createBasicEvent( 0, EVT_CLASS_FLY_HUNTER, EVT_FH_MISSION_BEGIN, NULL, nnn );
+ if( ttt ) {
+ m_pEventHeap->broadcast( ttt );
+ } else {
+ free( nnn );
+ };
+ };
+ };
+ free( tEVT );
+ } else {
+ LOG_ERROR("Linked Event Was Not Found!");
+ };
+ };
+ break;
+ };
+ };
+ break;
+ case EVT_CLASS_SENSOR_CLD:
+ case EVT_CLASS_SENSOR_LGS:
+ case EVT_CLASS_SENSOR_LFS:
+ case EVT_CLASS_SENSOR_MND:
+ case EVT_CLASS_SENSOR_PLS_210:
+ case EVT_CLASS_SENSOR_PLS_360:
+ case EVT_CLASS_SENSOR_ALS:
+ case EVT_CLASS_SENSOR_3D:
+ case EVT_CLASS_SENSOR_ACC:
+ switch( Evt->m_eType ) {
+ case EVT_TARGET_1D:{
+ TARGET_DATA *tDATA =(TARGET_DATA *) Evt->m_pEvtData;
+ if( tDATA != NULL ) {
+ uint32_t TS_A, TS_B;
+ TS_A = Evt->m_UMSTS / 1000;
+ TS_B = Evt->m_UMSTS % 1000;
+ m_pDBC->addEvent(
+ Evt->m_nSourceUID,
+ Evt->m_UUID,
+ TS_A,
+ TS_B,
+ Evt->m_eType,
+ 0,
+ 0,
+ 0,
+ tDATA->local_target.r,
+ tDATA->area,
+ tDATA->global_target.lat,
+ tDATA->global_target.lon,
+ tDATA->global_target.alt
+ );
+ };
+ break;
+ };
+ case EVT_TARGET_2D_BLACK:
+ case EVT_TARGET_2D_WHITE:{
+ TARGET_DATA *tDATA = (TARGET_DATA *)Evt->m_pEvtData;
+ if( tDATA != NULL ) {
+ uint32_t TS_A, TS_B;
+ TS_A = Evt->m_UMSTS / 1000;
+ TS_B = Evt->m_UMSTS % 1000;
+ m_pDBC->addEvent(
+ Evt->m_nSourceUID,
+ Evt->m_UUID,
+ TS_A,
+ TS_B,
+ Evt->m_eType,
+ 0,
+ tDATA->local_target.fi,
+ 0,
+ tDATA->local_target.r,
+ tDATA->area,
+ tDATA->global_target.lat,
+ tDATA->global_target.lon,
+ tDATA->global_target.alt
+ );
+ };
+ break;
+ };
+ case EVT_TARGET_3D_BLACK:
+ case EVT_TARGET_3D_WHITE:{
+ TARGET_DATA *tDATA = (TARGET_DATA *) Evt->m_pEvtData;
+ if( tDATA != NULL ) {
+ uint32_t TS_A, TS_B;
+ TS_A = Evt->m_UMSTS / 1000;
+ TS_B = Evt->m_UMSTS % 1000;
+ m_pDBC->addEvent(
+ Evt->m_nSourceUID,
+ Evt->m_UUID,
+ TS_A,
+ TS_B,
+ Evt->m_eType,
+ 0,
+ tDATA->local_target.fi,
+ tDATA->local_target.tetta,
+ tDATA->local_target.r,
+ tDATA->area,
+ tDATA->global_target.lat,
+ tDATA->global_target.lon,
+ tDATA->global_target.alt
+ );
+ };
+ break;
+ };
+ };
+ break;
+ };
+};
+
#undef LOG
#undef LOG_ERROR
diff --git a/lib/rgoose/rgooseKernel.h b/lib/rgoose/rgooseKernel.h
index 02e87e48..157a5d5c 100644
--- a/lib/rgoose/rgooseKernel.h
+++ b/lib/rgoose/rgooseKernel.h
@@ -59,6 +59,7 @@ struct serial_struct {
#include "../components/base/basicThread.h"
#include "../components/base/basicEngine.h"
#include "../components/base/basicSettingsProvider.h"
+#include "../components/object/objectSystemAnchor.h"
#include "../data/ponvif/ponvif.h"
#include "../data/protocol/onvifMediaObserver.h"
#include "../data/ssdp/ssdpAnnouncer.h"
@@ -72,6 +73,14 @@ struct serial_struct {
#include "../data/net/netServer.h"
#include "../data/servletWS/servletWS.h"
+
+#define SIMULATE_KERNEL_TARGETS
+
+#ifdef SIMULATE_KERNEL_TARGETS
+ #define SIMULATE_KERNEL_INTERVAL 6
+ #define SIMULATE_KERNEL_NODE_ID 233
+#endif
+
#define SLEEP_KERNEL_INTERVAL 10
#define ONVIF_DISCOVERY_INTERVAL 300 // 5 min
#define ONVIF_DISCOVERY_RESULT_TIME 5
@@ -79,8 +88,11 @@ struct serial_struct {
#define ARGUS_KERNEL_TAG_SITE_ID "SITE_ID"
#define ARGUS_KERNEL_TAG_SERVER_IDENTITY "IDENTITY"
-class argusKernel: public basicThread {
+class argusKernel: public basicThread, public basicEventHandler {
private:
+#ifdef SIMULATE_KERNEL_TARGETS
+ uint32_t m_nLastSimRun;
+#endif
uint32_t m_nSiteID;
uint32_t m_nServerID;
uint32_t m_nServerNodeID;
@@ -88,6 +100,7 @@ class argusKernel: public basicThread {
time_t m_tTimeTSeconds;
basicLogCollection * m_pLog;
basicEventHeap * m_pEventHeap;
+ systemAnchor * m_pSystemAnchor;
config_setting_t * m_pSettings;
ssdpAnnouncer * m_pServiceAnnouncer;
uint8_t m_bExitCause;
@@ -125,6 +138,7 @@ class argusKernel: public basicThread {
uint32_t getServerId( void ){ return m_nServerID; };
uint32_t getServerNodeId( void ){ return m_nServerNodeID; };
CSTR getServerIdentity( void ){ return (CSTR)m_sIdentity; }; // NOTE: DON't FREE THIS MEMORY!!!
+ virtual void dispatchEvent( EVENT_CONTAINER *Evt );
private:
static argusKernel * _instance;
// Constructor
diff --git a/lib/rgoose/rgooseModule.h b/lib/rgoose/rgooseModule.h
index d95f8049..a078b6ea 100644
--- a/lib/rgoose/rgooseModule.h
+++ b/lib/rgoose/rgooseModule.h
@@ -44,7 +44,7 @@ class argusKernelModule: public basicEventHandler, basicObject{
virtual bool startService(){ return false; };
virtual bool stopService(){ return true; };
virtual bool validate(){ return false; };
- virtual void dispatchEvent( basicEvent *Evt ){};
+ virtual void dispatchEvent( EVENT_CONTAINER *Evt ){};
};
diff --git a/lib/rgoose/rgooseNode.h b/lib/rgoose/rgooseNode.h
index f2b60686..0ad2df67 100644
--- a/lib/rgoose/rgooseNode.h
+++ b/lib/rgoose/rgooseNode.h
@@ -23,6 +23,7 @@ class argusNetNode: public basicObject{
virtual bool startService(){ return false; };
virtual bool stopService(){ return true; };
virtual bool validate(){ return false; };
+ virtual void simulateTarget( void ){};
};
#endif
\ No newline at end of file
diff --git a/lib/rgoose/rgooseNode2D.cpp b/lib/rgoose/rgooseNode2D.cpp
index e69de29b..fe98c6e8 100644
--- a/lib/rgoose/rgooseNode2D.cpp
+++ b/lib/rgoose/rgooseNode2D.cpp
@@ -0,0 +1,8 @@
+#include "rgooseNode2D.h"
+
+ARGUS_2DSensor::ARGUS_2DSensor( uint32_t id ):argusNetNode(id){
+};
+
+ARGUS_2DSensor::~ARGUS_2DSensor(){
+};
+
diff --git a/lib/rgoose/rgooseNode2D.h b/lib/rgoose/rgooseNode2D.h
index abb0135f..e597d21a 100644
--- a/lib/rgoose/rgooseNode2D.h
+++ b/lib/rgoose/rgooseNode2D.h
@@ -17,26 +17,14 @@
class ARGUS_2DSensor: public argusNetNode{
public:
- ARGUS_2DSensor();
+ explicit ARGUS_2DSensor( uint32_t id );
~ARGUS_2DSensor();
- virtual bool isAttached() {
- }
- virtual bool isDetached() {
- }
virtual bool startService() {
}
virtual bool stopService() {
}
virtual bool validate() {
}
- virtual objectCaps getCaps(void) {
- }
- virtual int getID(void) {
- }
- virtual objectStatus getStatus(void) {
- }
- virtual CSTR getUID(void) {
- }
};
#endif
diff --git a/lib/rgoose/rgooseNode3D.cpp b/lib/rgoose/rgooseNode3D.cpp
index 084c0569..70a824d2 100644
--- a/lib/rgoose/rgooseNode3D.cpp
+++ b/lib/rgoose/rgooseNode3D.cpp
@@ -7,8 +7,8 @@ argus3DLIDAR::argus3DLIDAR( uint32_t ID ): argusNetNode( ID ){
m_pLog = basicLogCollection::getInstance();
m_pMasterNode = NULL;
m_pSlaveNode = NULL;
- m_pEventHeap = NULL;
- memset( &m_sDATA, 0, sizeof(DBC_LRF3D_DATA) );
+ m_pEventHeap = basicEventHeap::getInstance();
+ memset( &m_sDATA, 0, sizeof(DBC_LRF_DATA) );
};
argus3DLIDAR::~argus3DLIDAR(){
@@ -23,15 +23,16 @@ bool argus3DLIDAR::startService(){
LOG_ERROR("No Database Connector Defined!");
return false;
};
- DBC_LRF3D_DATA *tData;
- tData = m_pDBC->getNode3DData( m_sNodeData.aux_id );
+ DBC_LRF_DATA *tData;
+ tData = m_pDBC->getLRFData( m_sNodeData.aux_id );
if( tData == NULL ) {
LOG_ERROR("No Database Data!!");
return false;
};
LOG("DATA OK");
- memcpy( &m_sDATA, tData, sizeof(DBC_LRF3D_DATA));
+ memcpy( &m_sDATA, tData, sizeof(DBC_LRF_DATA));
LOG("CPY OK");
+ free( tData );
m_pMasterNode = new sensorLGS3D( NULL, true );
if( m_pMasterNode != NULL ) {
LOG("Before SH");
@@ -39,6 +40,8 @@ bool argus3DLIDAR::startService(){
LOG("SH OK");
m_pMasterNode->setPort( m_sDATA.master_port );
LOG("SP OK");
+ basicPosition *pos = m_pMasterNode->getPosition();
+ pos->setPositionDeg( m_sDATA.lat, m_sDATA.lon, m_sDATA.alt, m_sDATA.roll, m_sDATA.pitch, m_sDATA.yaw, 0.f );
if(!m_pMasterNode->create() ){
LOG_ERROR("CANNOT CREATE MASTER DEVICE!");
delete( m_pMasterNode );
@@ -53,7 +56,9 @@ bool argus3DLIDAR::startService(){
m_pSlaveNode = new sensorLGS3D( NULL, false );
if( m_pSlaveNode != NULL ) {
m_pSlaveNode->setHost( m_sDATA.slave_host );
- m_pSlaveNode->setPort( m_sDATA.slave_port );
+ m_pSlaveNode->setPort( m_sDATA.slave_port );
+ basicPosition *pos = m_pSlaveNode->getPosition();
+ pos->setPositionDeg( m_sDATA.lat, m_sDATA.lon, m_sDATA.alt, m_sDATA.roll, m_sDATA.pitch, m_sDATA.yaw, 0.f );
if(!m_pSlaveNode->create() ){
LOG_ERROR("CANNOT CREATE SLAVE DEVICE!");
delete( m_pSlaveNode );
@@ -81,6 +86,26 @@ bool argus3DLIDAR::validate(){
return true;
};
+void argus3DLIDAR::simulateTarget( void ){
+ TARGET_DATA * tData;
+ CLIENT_EVENT cEVT;
+
+ cEVT.range = 1050;
+ cEVT.type = EVT_TARGET_3D_WHITE;
+ cEVT.th_id = 1211;
+ cEVT.a_th_node = 1211;
+ cEVT.k_id = 5;
+ cEVT.w_cnt = 5;
+
+ tData = m_pMasterNode->prepareTargetData( &cEVT );
+
+ if( tData != NULL ){
+ EVENT_CONTAINER * bEVT = createBasicEvent( getDbId(), EVT_CLASS_SENSOR_3D, (basicEventTypeID)cEVT.type, NULL, tData );
+ if (bEVT != NULL) {
+ m_pEventHeap->broadcast( bEVT );
+ };
+ };
+};
// Local Funcs
diff --git a/lib/rgoose/rgooseNode3D.h b/lib/rgoose/rgooseNode3D.h
index e4b4ecd2..f00fbf15 100644
--- a/lib/rgoose/rgooseNode3D.h
+++ b/lib/rgoose/rgooseNode3D.h
@@ -17,13 +17,14 @@ class argus3DLIDAR: public argusNetNode{
sensorLGS3D * m_pMasterNode;
sensorLGS3D * m_pSlaveNode;
basicEventHeap * m_pEventHeap;
- DBC_LRF3D_DATA m_sDATA;
+ DBC_LRF_DATA m_sDATA;
public:
explicit argus3DLIDAR( uint32_t dbID );
virtual ~argus3DLIDAR();
virtual bool startService();
virtual bool stopService();
virtual bool validate();
+ virtual void simulateTarget( void );
};
#endif
diff --git a/lib/rgoose/rgooseNodeFactory.cpp b/lib/rgoose/rgooseNodeFactory.cpp
index 82261ee0..c2cb514f 100644
--- a/lib/rgoose/rgooseNodeFactory.cpp
+++ b/lib/rgoose/rgooseNodeFactory.cpp
@@ -1,6 +1,7 @@
#include "rgooseNodeFactory.h"
#include "rgooseIPCamera.h"
#include "rgooseNode3D.h"
+#include "rgooseNode2D.h"
#ifdef MEM_DEBUG
#include "../alg/generic/heapDebug.h"
@@ -82,46 +83,89 @@ argusNetNode *argusNodeFactory::createNode( uint32_t id ){
tCamera = new ARGUS_IPCAM( id );
if( tCamera ) {
LOG("Success");
+ tCamera->startService();
tVal = ( argusNetNode *) tCamera;
};
+ break;
};
- break;
- case ARGUS_IP_PTZ_CAMERA:
+ case ARGUS_IP_PTZ_CAMERA:{
+
#ifdef DEBUG
LOG("Creating Network PTZ Camera");
#endif
- break;
- case ARGUS_IP_UART_GATEWAY:
+ ARGUS_IPCAM *tCamera;
+ tCamera = new ARGUS_IPCAM( id );
+ if( tCamera ) {
+ LOG("Success");
+ tCamera->startService();
+ tVal = ( argusNetNode *) tCamera;
+ };
+ break;
+ };
+ case ARGUS_IP_UART_GATEWAY:{
#ifdef DEBUG
LOG("Creating Ethernet to UART Gateway");
#endif
+ tVal = new argusNetNode( id );
+ };
break;
case ARGUS_IP_VIDEO_SERVER:
#ifdef DEBUG
LOG("Creating Network Video Encoder");
#endif
break;
- case ARGUS_LFS_SENSOR:
+ case ARGUS_LFS_SENSOR:{
#ifdef DEBUG
LOG("Creating LFS Sensor");
#endif
- break;
+ ARGUS_2DSensor *tSensor;
+ tSensor = new ARGUS_2DSensor( id );
+ if( tSensor ) {
+ LOG("Success");
+ tSensor->startService();
+ tVal = ( argusNetNode *) tSensor;
+ };
+ break;
+ };
case ARGUS_ALS_SENSOR:{
#ifdef DEBUG
LOG("Creating ALS Sensor");
#endif
+ ARGUS_2DSensor *tSensor;
+ tSensor = new ARGUS_2DSensor( id );
+ if( tSensor ) {
+ LOG("Success");
+ tSensor->startService();
+ tVal = ( argusNetNode *) tSensor;
+ };
break;
};
- case ARGUS_PLS_200_SENSOR:
+ case ARGUS_PLS_200_SENSOR:{
#ifdef DEBUG
LOG("Creating PLS200 Sensor");
#endif
- break;
- case ARGUS_PLS_360_SENSOR:
+ ARGUS_2DSensor *tSensor;
+ tSensor = new ARGUS_2DSensor( id );
+ if( tSensor ) {
+ LOG("Success");
+ tSensor->startService();
+ tVal = ( argusNetNode *) tSensor;
+ };
+ break;
+ };
+ case ARGUS_PLS_360_SENSOR:{
#ifdef DEBUG
LOG("Creating PLS360 Sensor");
#endif
- break;
+ ARGUS_2DSensor *tSensor;
+ tSensor = new ARGUS_2DSensor( id );
+ if( tSensor ) {
+ LOG("Success");
+ tSensor->startService();
+ tVal = ( argusNetNode *) tSensor;
+ };
+ break;
+ };
case ARGUS_3D_SENSOR:{
#ifdef DEBUG
LOG("Creating 3D Sensor");
diff --git a/lib/rgoose/rgoosePelcoCamera.cpp b/lib/rgoose/rgoosePelcoCamera.cpp
new file mode 100644
index 00000000..d214f535
--- /dev/null
+++ b/lib/rgoose/rgoosePelcoCamera.cpp
@@ -0,0 +1,41 @@
+#include "rgoosePelcoCamera.h"
+
+#define LOG( X ) m_pLog->Log( "PELCO_PCAM", this, X )
+#define LOG_ERROR( X ) m_pLog->Log( "PELCO_PCAM", this, _LOG_ERROR, X )
+
+ARGUS_PELCOCAM::ARGUS_PELCOCAM( uint32_t id ): ARGUS_Camera( id ){
+ m_pLog = basicLogCollection::getInstance();
+};
+
+ARGUS_PELCOCAM::~ARGUS_PELCOCAM(){
+};
+
+bool ARGUS_PELCOCAM::startService(){
+ return false;
+};
+
+bool ARGUS_PELCOCAM::relativeMove( float PanSPD, float TiltSPD, float ZoomSPD ){
+ if( m_sCamData.online ) {
+ //if( m_pOnVif->ptz_ContinuousMove( m_pProfile->profiletoken, PanSPD , TiltSPD ) ){
+ // return m_pOnVif->ptz_ContinuousMoveZoom( m_pProfile->profiletoken, ZoomSPD );
+ //};
+ };
+ return false;
+};
+
+bool ARGUS_PELCOCAM::relativeStop(){
+ if( m_sCamData.online ) {
+ //return m_pOnVif->ptz_Stop( m_pProfile->profiletoken, true, true );
+ };
+ return false;
+};
+
+bool ARGUS_PELCOCAM::absoluteMove( float PanPOS, float TiltPOS, float ZoomPOS ){
+ if( m_sCamData.online ) {
+ //return m_pOnVif->ptz_AbsoluteMove( m_pProfile->profiletoken, PanPOS, TiltPOS, ZoomPOS );
+ };
+ return false;
+};
+
+#undef LOG
+#undef LOG_ERROR
diff --git a/lib/rgoose/rgoosePelcoCamera.h b/lib/rgoose/rgoosePelcoCamera.h
new file mode 100644
index 00000000..15bcaa78
--- /dev/null
+++ b/lib/rgoose/rgoosePelcoCamera.h
@@ -0,0 +1,48 @@
+//----------------------------------------------------------------------------
+// Dr.Frucht Systems Ltd.
+// Copyright © 2000-2017. All Rights Reserved.
+// Version 2.0 6/11/2019
+// Last modification: 6/11/2019
+// PROJECT:
+// SUBSYSTEM:
+// FILE: rgooseIPCamera.h
+// AUTHOR: gagua
+// OVERVIEW
+// ~~~~~~~~
+// Header file of rgooseIPCamera.h
+//----------------------------------------------------------------------------
+//
+#ifndef __ARGUS_PELCO_CAMERA_HEADER__
+#define __ARGUS_PELCO_CAMERA_HEADER__
+
+#include
+#include "rgooseCamera.h"
+//#include "../components/base/basicThread.h"
+//#include "../data/ponvif/ponvif.h"
+
+//https://www.ebay.com/itm/Professional-Rolling-Makeup-Case-Bulb-Mirror-Cosmetic-Artist-Dressing-Train-Case/233264525474
+
+//ffmpeg -i input.mp4 -af loudnorm=I=-23:LRA=7:tp=-2:print_format=json -f null -
+//ffmpeg -i input.mp4 -af loudnorm=I=-23:LRA=7:tp=-2:measured_I=-30:measured_LRA=1.1:measured_tp=-11 04:measured_thresh=-40.21:offset=-0.47 -ar 48k -y output.mp4
+
+
+class ARGUS_PELCOCAM: public ARGUS_Camera /*, public basicThread */{
+ private:
+ basicLogCollection * m_pLog;
+ //videoSourceProfile * m_pProfile;
+ protected:
+ virtual bool relativeMove( float PanSPD, float TiltSPD, float ZoomSPD );
+ virtual bool relativeStop();
+ virtual bool absoluteMove( float PanPOS, float TiltPOS, float ZoomPOS );
+ //void m_fThreadProc( void );
+ public:
+ explicit ARGUS_PELCOCAM( uint32_t id );
+ ~ARGUS_PELCOCAM();
+ //bool create( );// CSTR ip, CSTR username, CSTR password );
+ //virtual void dispatchEvent( EVENT_CONTAINER *Evt );
+ virtual bool startService();
+ //virtual bool stopService();
+
+};
+
+#endif
diff --git a/lib/rgoose/rgooseServerModule.cpp b/lib/rgoose/rgooseServerModule.cpp
index 3e21e353..95b768ec 100644
--- a/lib/rgoose/rgooseServerModule.cpp
+++ b/lib/rgoose/rgooseServerModule.cpp
@@ -5,4 +5,4 @@ argusServerModule::argusServerModule( uint32_t ModuleID ):argusKernelModule( Mod
argusServerModule::~argusServerModule(){};
-void argusServerModule::dispatchEvent( basicEvent *Evt ){};
+void argusServerModule::dispatchEvent( EVENT_CONTAINER *Evt ){};
diff --git a/lib/rgoose/rgooseServerModule.h b/lib/rgoose/rgooseServerModule.h
index 157c6826..c0cfd29a 100644
--- a/lib/rgoose/rgooseServerModule.h
+++ b/lib/rgoose/rgooseServerModule.h
@@ -8,7 +8,7 @@ class argusServerModule: public argusKernelModule{
public:
explicit argusServerModule( uint32_t ModuleID );
virtual ~argusServerModule();
- virtual void dispatchEvent( basicEvent *Evt );
+ virtual void dispatchEvent( EVENT_CONTAINER *Evt );
};
#endif
diff --git a/lib/rgoose/rgooseUSBRelayModule.cpp b/lib/rgoose/rgooseUSBRelayModule.cpp
index 19184ea3..e96d3d9e 100644
--- a/lib/rgoose/rgooseUSBRelayModule.cpp
+++ b/lib/rgoose/rgooseUSBRelayModule.cpp
@@ -293,5 +293,5 @@ argusUSBRelayModule::argusUSBRelayModule( uint32_t ModuleID ) : argusKernelModul
argusUSBRelayModule::~argusUSBRelayModule(){};
-void argusUSBRelayModule::dispatchEvent( basicEvent *Evt ){};
+void argusUSBRelayModule::dispatchEvent( EVENT_CONTAINER *Evt ){};
diff --git a/lib/rgoose/rgooseUSBRelayModule.h b/lib/rgoose/rgooseUSBRelayModule.h
index ec27b01b..df50378d 100644
--- a/lib/rgoose/rgooseUSBRelayModule.h
+++ b/lib/rgoose/rgooseUSBRelayModule.h
@@ -35,6 +35,6 @@ class argusUSBRelayModule: public argusKernelModule {
public:
explicit argusUSBRelayModule( uint32_t ModuleID );
virtual ~argusUSBRelayModule();
- virtual void dispatchEvent( basicEvent *Evt );
+ virtual void dispatchEvent( EVENT_CONTAINER *Evt );
};
#endif
\ No newline at end of file