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.

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