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.

163 lines
4.4 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. unsigned long long m_mDateOfToday;
  72. bool m_bForceCloseSessionOnEndOfTheDay;
  73. bool m_bDebugMode;
  74. bool m_bKeepLocalReport;
  75. bool m_bWorkWithRemoteServer;
  76. bool m_bSessionStarted;
  77. bool m_bSessionMustPreserve;
  78. bool m_bFirstSession;
  79. uint8_t m_bMediaMode;
  80. uint32_t m_nNoAlarmCounter;
  81. #ifdef EMBED_AUTORESET
  82. bool m_bEnableAutoReset;
  83. uint32_t m_nAutoResetTime;
  84. uint32_t m_nSessionCounter;
  85. #endif
  86. #ifdef PEREODIC_SENSORS_RESET
  87. bool m_bEnablePereodicReset;
  88. uint32_t m_nPereodicResetTime;
  89. uint32_t m_nPereodicResetCounter;
  90. #endif
  91. #ifdef LA_METRO
  92. #endif
  93. void loadFilters();
  94. void unloadFilters();
  95. void validateFilters();
  96. void validateSession();
  97. basicMutex m_mSessionProtector;
  98. void stopSession(bool forced = true);
  99. void preserveSession()
  100. {
  101. m_bSessionMustPreserve = true;
  102. }
  103. static mojoKernel * _instance;
  104. void handleVideo(VIDEO_SEGMENT_INFO * ptr);
  105. bool validateReports(void);
  106. bool createCronJob(uint8_t job, CSTR param_str = NULL, int param_int = 0);
  107. void cleanUpReportDir(uint32_t days);
  108. void backupReports(uint32_t days);
  109. void getSystemUtilization(DBC_SYS_LOAD_INFO * ptr);
  110. protected:
  111. virtual void m_fThreadProc(void);
  112. // Constructor
  113. explicit mojoKernel(config_setting_t * ptr);
  114. public:
  115. static mojoKernel * getInstance(config_setting_t * ptr = NULL);
  116. // Destructor
  117. virtual ~mojoKernel();
  118. virtual bool create();
  119. virtual bool dispatchEvent(EVENT_CONTAINER * Evt);
  120. virtual void startSession();
  121. inline bool getDebugMode()
  122. {
  123. return m_bDebugMode;
  124. }
  125. bool getTrainPresence();
  126. inline uint8_t getMediaMode()
  127. {
  128. return m_bMediaMode;
  129. }
  130. #ifdef __MOJO_REMOTE_CLIENT_HEADER__
  131. bool fillMojoInfo(ARGUS_DATA_MOJO_INFO * ptr);
  132. #endif
  133. virtual void requestExplicitChannel( uint32_t node_id, uint32_t channel_id, uint8_t seconds_to );
  134. virtual void releaseExplicitChannel( uint32_t node_id, uint32_t channel_id );
  135. friend class mojoRemoteClient;
  136. };
  137. #endif // __MOJJO_KERNEL_H_INCL__