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.

155 lines
5.4 KiB

6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
​
​
​
​
​
​
6 years ago
​
​
6 years ago
​
​
​
​
​
​
6 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 "../data/ponvif/ponvif.h"
  57. #include "../data/protocol/onvifMediaObserver.h"
  58. #include "../data/ssdp/ssdpAnnouncer.h"
  59. #include "../data/NginxMediaServer/mediaNginxStreamingProxyManager.h"
  60. #include "../components/base/basicEventHeap.h"
  61. #include "rgooseDBConnector.h"
  62. #include "rgooseIPCamera.h"
  63. #include "rgooseNodeFactory.h"
  64. #include "rgooseModuleFactory.h"
  65. #include "rgooseHardwareManager.h"
  66. #include "../data/net/netServer.h"
  67. #include "../data/servletWS/servletWS.h"
  68. //#define SIMULATE_KERNEL_TARGETS
  69. #ifdef SIMULATE_KERNEL_TARGETS
  70. #define SIMULATE_LANDING_TO 21
  71. #define SIMULATE_JAMER_TO 6
  72. #define SIMULATE_KERNEL_INTERVAL 240
  73. #define SIMULATE_KERNEL_NODE_ID 233
  74. #endif
  75. #define SLEEP_KERNEL_INTERVAL 10
  76. #define ONVIF_DISCOVERY_INTERVAL 300 // 5 min
  77. #define ONVIF_DISCOVERY_RESULT_TIME 5
  78. #define ARGUS_KERNEL_TAG_SITE_ID "SITE_ID"
  79. #define ARGUS_KERNEL_TAG_SERVER_IDENTITY "IDENTITY"
  80. class argusKernel: public basicThread, public basicEventHandler {
  81. private:
  82. #ifdef SIMULATE_KERNEL_TARGETS
  83. uint32_t m_nEachSec;
  84. uint32_t m_nLastSimRun;
  85. uint8_t m_bLandingTO;
  86. uint8_t m_bJamingTO;
  87. char m_cCurrentMission[40];
  88. #endif
  89. uint32_t m_nSiteID;
  90. uint32_t m_nServerID;
  91. uint32_t m_nServerNodeID;
  92. char m_sIdentity[33];
  93. time_t m_tTimeTSeconds;
  94. basicLogCollection * m_pLog;
  95. basicEventHeap * m_pEventHeap;
  96. systemAnchor * m_pSystemAnchor;
  97. config_setting_t * m_pSettings;
  98. ssdpAnnouncer * m_pServiceAnnouncer;
  99. uint8_t m_bExitCause;
  100. argusDBC * m_pDBC;
  101. networkServer * m_pNetClientsServer;
  102. onvifMediaObserver * m_pOnvifMediaObserver;
  103. bool m_bDiscoveryStarted;
  104. vectorARGUS_Cameras m_vCameras;
  105. vectorCamRecords m_vCamRecords;
  106. vectorEventRecords m_vEvtRecords;
  107. argusNodeFactory * m_pNodeFactory;
  108. argusModuleFactory * m_pModuleFactory;
  109. mediaNginxManager * m_pStreamManager;
  110. argusHardwareManager * m_pHardwareManager;
  111. //servletWS * m_pServletWS;
  112. int isCameraListed( CSTR uid );
  113. void validateCameras( void );
  114. void validateEvents( int &lastTSS, int &lastTMS );
  115. //void enumerateHardware( void );
  116. protected:
  117. void m_fThreadProc( void );
  118. public:
  119. static argusKernel * getInstance( config_setting_t *Settings = NULL );
  120. // Destructor
  121. virtual ~argusKernel();
  122. bool create( void );
  123. bool signalEvent( void );
  124. void WaitFinish( bool Force = false );
  125. uint8_t getExitCause( void ){ return m_bExitCause;};
  126. int getNetNodes( ARGUS_NODE_TYPE type, argusNetNode **&RA );
  127. argusNetNode * getNetNode( int id );
  128. int getModules( ARGUS_MODULE_TYPE type, argusKernelModule **&RA );
  129. argusKernelModule * getModule( int id );
  130. uint32_t getSiteId( void ){ return m_nSiteID; };
  131. uint32_t getServerId( void ){ return m_nServerID; };
  132. uint32_t getServerNodeId( void ){ return m_nServerNodeID; };
  133. CSTR getServerIdentity( void ){ return (CSTR)m_sIdentity; }; // NOTE: DON't FREE THIS MEMORY!!!
  134. virtual void dispatchEvent( EVENT_CONTAINER *Evt );
  135. private:
  136. static argusKernel * _instance;
  137. // Constructor
  138. explicit argusKernel( config_setting_t *Settings = NULL );
  139. };
  140. #endif