You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

177 lines
6.5 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
6 years ago
​
​
​
5 years ago
​
​
​
​
​
5 years ago
​
6 years ago
​
​
6 years ago
​
​
​
6 years ago
​
​
6 years ago
​
​
6 years ago
​
​
​
6 years ago
6 years ago
​
​
6 years ago
​
​
6 years ago
​
6 years ago
​
​
6 years ago
​
​
​
6 years ago
5 years ago
​
​
6 years ago
​
​
6 years ago
​
​
​
​
5 years ago
​
​
​
​
​
5 years ago
​
​
5 years ago
​
5 years ago
​
5 years ago
6 years ago
​
​
6 years ago
​
​
​
  1. /*******************************************************************
  2. *
  3. * DESCRIPTION: ARGUS Kernel Header File
  4. *
  5. * AUTHOR: gagua
  6. *
  7. * HISTORY:
  8. *
  9. * DATE:5/29/2019
  10. *
  11. *******************************************************************/
  12. #ifndef __ARGUS_KERNEL_HEADER__
  13. #define __ARGUS_KERNEL_HEADER__
  14. #include <sys/types.h>
  15. #include <dirent.h>
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <assert.h>
  20. #include <getopt.h> /* getopt_long() */
  21. #include <fcntl.h> /* low-level i/o */
  22. #include <unistd.h>
  23. #include <errno.h>
  24. #include <sys/stat.h>
  25. #include <sys/types.h>
  26. #include <sys/time.h>
  27. #include <sys/mman.h>
  28. #include <sys/ioctl.h>
  29. #include <linux/videodev2.h>
  30. #include <linux/types.h>
  31. struct serial_struct {
  32. int type;
  33. int line;
  34. unsigned int port;
  35. int irq;
  36. int flags;
  37. int xmit_fifo_size;
  38. int custom_divisor;
  39. int baud_base;
  40. unsigned short close_delay;
  41. char io_type;
  42. char reserved_char[1];
  43. int hub6;
  44. unsigned short closing_wait; /* time to wait before closing */
  45. unsigned short closing_wait2; /* no longer used... */
  46. unsigned char *iomem_base;
  47. unsigned short iomem_reg_shift;
  48. unsigned int port_high;
  49. unsigned long iomap_base; /* cookie passed into ioremap */
  50. };
  51. #include "../alg/generic/md5.h"
  52. #include "../components/base/basicThread.h"
  53. #include "../components/base/basicEngine.h"
  54. #include "../components/base/basicSettingsProvider.h"
  55. #include "../components/object/objectSystemAnchor.h"
  56. #include "../components/base/basicEventHeap.h"
  57. #include "rgooseDBConnector.h"
  58. #include "rgooseIPCamera.h"
  59. #include "rgooseNodeFactory.h"
  60. #include "rgooseModuleFactory.h"
  61. #include "rgooseHardwareManager.h"
  62. #include "../data/net/netServer.h"
  63. #include "rgooseTargetFilter.h"
  64. #define SIMULATE_KERNEL_TARGETS
  65. #ifdef SIMULATE_KERNEL_TARGETS
  66. #define SIMULATE_3D_TARGETS 1
  67. #define SIMULATE_LANDING_TO 21
  68. #define SIMULATE_JAMER_TO 6
  69. #define SIMULATE_KERNEL_3D_INTERVAL 2000
  70. //#define SIMULATE_KERNEL_PLS_INTERVAL 1
  71. #define SIMULATE_KERNEL_PLS_INTERVAL 15
  72. #define SIMULATE_KERNEL_MND_INTERVAL 320
  73. //#define SIMULATE_KERNEL_MND_INTERVAL 30
  74. #define SIMULATE_KERNEL_3D_ID 233
  75. #define SIMULATE_KERNEL_PLS_ID 733
  76. #define SIMULATE_KERNEL_MND_ID 707
  77. #endif
  78. #define SLEEP_KERNEL_INTERVAL 10
  79. #define ONVIF_DISCOVERY_INTERVAL 300 // 5 min
  80. #define ONVIF_DISCOVERY_RESULT_TIME 5
  81. #define ARGUS_KERNEL_LAZY_SECONDS 20
  82. #define ARGUS_KERNEL_TAG_SITE_ID "SITE_ID"
  83. #define ARGUS_KERNEL_TAG_SERVER_IDENTITY "IDENTITY"
  84. class argusKernel: public basicThread, public basicEventHandler {
  85. private:
  86. #ifdef SIMULATE_KERNEL_TARGETS
  87. uint32_t m_nEachSec;
  88. uint32_t m_nLastSimRun;
  89. uint8_t m_bLandingTO;
  90. uint8_t m_bJamingTO;
  91. char m_cCurrentMission[40];
  92. #endif
  93. uint32_t m_nSiteID;
  94. uint32_t m_nServerID;
  95. uint32_t m_nServerNodeID;
  96. bool m_bSkipResignComponents;
  97. char m_sIdentity[33];
  98. time_t m_tTimeTSeconds;
  99. basicLogCollection * m_pLog;
  100. basicEventHeap * m_pEventHeap;
  101. systemAnchor * m_pSystemAnchor;
  102. config_setting_t * m_pSettings;
  103. //ssdpAnnouncer * m_pServiceAnnouncer;
  104. uint8_t m_bExitCause;
  105. argusDBC * m_pDBC;
  106. networkServer * m_pNetClientsServer;
  107. //onvifMediaObserver * m_pOnvifMediaObserver;
  108. bool m_bDiscoveryStarted;
  109. //vectorARGUS_Cameras m_vCameras;
  110. //vectorCamRecords m_vCamRecords;
  111. //vectorEventRecords m_vEvtRecords;
  112. argusNodeFactory * m_pNodeFactory;
  113. argusModuleFactory * m_pModuleFactory;
  114. //mediaNginxManager * m_pStreamManager;
  115. argusHardwareManager * m_pHardwareManager;
  116. V_TARGET_FILTERS m_vTargetFilters;
  117. //ARGUS_APF * m_pTEST;
  118. //servletWS * m_pServletWS;
  119. //int isCameraListed( CSTR uid );
  120. //void validateCameras( void );
  121. //void validateEvents( int &lastTSS, int &lastTMS );
  122. void loadFilters();
  123. void unloadFilters();
  124. //void enumerateHardware( void );
  125. void destroyCamCapPicture( uint32_t PicID );
  126. void destroyNode( uint32_t NodeID );
  127. void destroyResource( uint32_t ResID );
  128. protected:
  129. void m_fThreadProc( void );
  130. public:
  131. static argusKernel * getInstance( bool cold_start = true, config_setting_t *Settings = NULL );
  132. // Destructor
  133. virtual ~argusKernel();
  134. bool create( void );
  135. bool signalEvent( void );
  136. void WaitFinish( bool Force = false );
  137. uint8_t getExitCause( void ){ return m_bExitCause;};
  138. int getNetNodes( ARGUS_NODE_TYPE type, argusNetNode **&RA );
  139. argusNetNode * getNetNode( int id );
  140. //int getModules( ARGUS_MODULE_TYPE type, argusKernelModule **&RA );
  141. //argusKernelModule * getModule( int id );
  142. argusModuleFactory * getModuleFactory( void ){ return m_pModuleFactory; };
  143. argusHardwareManager * getHardwareManager( void ){ return m_pHardwareManager; };
  144. uint32_t getSiteId( void ){ return m_nSiteID; };
  145. uint32_t getServerId( void ){ return m_nServerID; };
  146. CSTR getServerIp( void );
  147. CSTR getServerName( void );
  148. uint32_t getServerNodeId( void ){ return m_nServerNodeID; };
  149. CSTR getServerIdentity( void ){ return (CSTR)m_sIdentity; }; // NOTE: DON't FREE THIS MEMORY!!!
  150. ARGUS_TARGET_FILTER * getFilter( uint32_t id );
  151. virtual bool dispatchEvent( EVENT_CONTAINER *Evt );
  152. private:
  153. static argusKernel * _instance;
  154. // Constructor
  155. explicit argusKernel( bool cold_start, config_setting_t *Settings );
  156. };
  157. #endif