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.

161 lines
4.3 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Dr.Frucht Systems Ltd.
  3. // Copyright � 2000-2022. All Rights Reserved.
  4. // Version 1.0 11/19/2022
  5. // Last modification: 11/19/2022
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: mojoKernel.h
  9. // AUTHOR: gagua
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of mojoKernel.cpp
  13. //----------------------------------------------------------------------------
  14. //
  15. #ifndef __MOJO_KERNEL_H_INCL__
  16. #define __MOJO_KERNEL_H_INCL__
  17. #define LA_METRO 1
  18. #define MER_INC 2
  19. #define NOTARGET_SESSION_CLOSE 120 // sec
  20. #define EMBED_AUTORESET 300 //sec
  21. #define PEREODIC_SENSORS_RESET
  22. #include "../../alg/generic/md5.h"
  23. #include "../../alg/lgs/detector.h"
  24. #include "../../alg/lgs/detectorStructures.h"
  25. #include "../../alg/lgs/mask.h"
  26. #include "../../components/base/basicEvent.h"
  27. #include "../../components/base/basicEventHeap.h"
  28. #include "../../components/base/basicSettingsProvider.h"
  29. #include "../../components/base/basicThread.h"
  30. #include "../../components/object/objectSystemAnchor.h"
  31. #include "../common/kernelPrototype.h"
  32. #include "mojoRemoteClient.h"
  33. #include "../common/kernelHelperMediaMTX.h"
  34. #define MAX_CYCLE_COUNTER_VALUE 0xFFFFFFFF;
  35. #define SLEEP_KERNEL_INTERVAL 10 // 10 millisecond
  36. #define TIME_SYNC_INTERVAL 900000 // 15 minute(s) in 1 millisecond units
  37. #define STATUS_OK_INTERVAL 2000 // 2 Sec in 1 millisecond units
  38. #define KNL_SETTINGS_DETECTOR_WIDTH "DETECTOR_WIDTH"
  39. #define KNL_SETTINGS_FILTER_KERNELS "ENABLED_LRF"
  40. #define KNL_SETTINGS_DETECTOR_SST "DETECTOR_SST"
  41. // #define KNL_SETTINGS_V_MOTOR_SETPOINT "VERTICAL_ENC_FREQ"
  42. #define MOJO_KERNEL_TAG_SITE_ID "SITE_ID"
  43. #define MOJO_KERNEL_TAG_SERVER_IDENTITY "IDENTITY"
  44. #define CRON_JOB_CREATE_BACKUP 20
  45. /**
  46. * LRF_Kernel class - manages communication between client
  47. * handlers and PRU cores bseide of Event management.
  48. *
  49. *
  50. * @author gagua
  51. */
  52. class mojoKernel : public kernelPrototype
  53. {
  54. private:
  55. basicEventHeap * m_pEventHeap;
  56. ShadowMask * m_pShadow;
  57. time_t m_tTimeTSeconds;
  58. bool m_bApplicationFirstRun;
  59. DBC_SYS_LOAD_INFO m_sSysInfo;
  60. DBC_SITE_DATA m_sSiteData;
  61. char m_sIdentity[128];
  62. uint32_t m_nInstanceID;
  63. uint32_t m_nServerID;
  64. uint32_t m_nServerNodeID;
  65. systemAnchor * m_pSystemAnchor;
  66. mojoRemoteClient * m_pRPC;
  67. #ifndef LRF_PROXY_ONLY
  68. kernelHelperMediaMTX * m_pMediaHelper;
  69. #endif
  70. basicMutex m_mSysInfoProtector;
  71. bool m_bDebugMode;
  72. bool m_bKeepLocalReport;
  73. bool m_bWorkWithRemoteServer;
  74. bool m_bSessionStarted;
  75. bool m_bSessionMustPreserve;
  76. bool m_bFirstSession;
  77. uint8_t m_bMediaMode;
  78. uint32_t m_nNoAlarmCounter;
  79. #ifdef EMBED_AUTORESET
  80. bool m_bEnableAutoReset;
  81. uint32_t m_nAutoResetTime;
  82. uint32_t m_nSessionCounter;
  83. #endif
  84. #ifdef PEREODIC_SENSORS_RESET
  85. bool m_bEnablePereodicReset;
  86. uint32_t m_nPereodicResetTime;
  87. uint32_t m_nPereodicResetCounter;
  88. #endif
  89. #ifdef LA_METRO
  90. #endif
  91. void loadFilters();
  92. void unloadFilters();
  93. void validateFilters();
  94. void validateSession();
  95. basicMutex m_mSessionProtector;
  96. void stopSession(bool forced = true);
  97. void preserveSession()
  98. {
  99. m_bSessionMustPreserve = true;
  100. }
  101. static mojoKernel * _instance;
  102. void handleVideo(VIDEO_SEGMENT_INFO * ptr);
  103. bool validateReports(void);
  104. bool createCronJob(uint8_t job, CSTR param_str = NULL, int param_int = 0);
  105. void cleanUpReportDir(uint32_t days);
  106. void backupReports(uint32_t days);
  107. void getSystemUtilization(DBC_SYS_LOAD_INFO * ptr);
  108. protected:
  109. virtual void m_fThreadProc(void);
  110. // Constructor
  111. explicit mojoKernel(config_setting_t * ptr);
  112. public:
  113. static mojoKernel * getInstance(config_setting_t * ptr = NULL);
  114. // Destructor
  115. virtual ~mojoKernel();
  116. virtual bool create();
  117. virtual bool dispatchEvent(EVENT_CONTAINER * Evt);
  118. virtual void startSession();
  119. inline bool getDebugMode()
  120. {
  121. return m_bDebugMode;
  122. }
  123. bool getTrainPresence();
  124. inline uint8_t getMediaMode()
  125. {
  126. return m_bMediaMode;
  127. }
  128. #ifdef __MOJO_REMOTE_CLIENT_HEADER__
  129. bool fillMojoInfo(ARGUS_DATA_MOJO_INFO * ptr);
  130. #endif
  131. virtual void requestExplicitChannel( uint32_t node_id, uint32_t channel_id, uint8_t seconds_to );
  132. virtual void releaseExplicitChannel( uint32_t node_id, uint32_t channel_id );
  133. friend class mojoRemoteClient;
  134. };
  135. #endif // __MOJJO_KERNEL_H_INCL__