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.

139 lines
4.8 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
6 years ago
6 years ago
6 years ago
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
6 years ago
7 years ago
6 years ago
​
​
​
​
​
​
​
​
6 years ago
​
6 years ago
​
6 years ago
6 years ago
​
7 years ago
​
​
​
​
​
​
7 years ago
​
​
6 years ago
​
6 years ago
​
​
6 years ago
7 years ago
​
​
​
​
​
​
​
​
​
7 years ago
​
​
  1. //----------------------------------------------------------------------------
  2. // Dr.Frucht Systems Ltd.
  3. // Copyright � 2000-2017. All Rights Reserved.
  4. // Version 2.0 7/20/2017
  5. // Last modification: 7/20/2017
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: LRF_Kernel.h
  9. // AUTHOR: gagua
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of LRF_Kernel.cpp
  13. //----------------------------------------------------------------------------
  14. //
  15. #ifndef __LRF_KERNEL_H_INCL__
  16. #define __LRF_KERNEL_H_INCL__
  17. #include "../../components/base/basicThread.h"
  18. #include "../../components/base/basicEngine.h"
  19. #include "../../components/base/basicSettingsProvider.h"
  20. #include "../../components/base/basicEventHeap.h"
  21. #include "LRF_HardwareManager.h"
  22. #include "LRF_TwinConnector.h"
  23. #include "../../alg/lgs/detectorStructures.h"
  24. #include "../../alg/lgs/detector.h"
  25. #include "../../alg/lgs/mask.h"
  26. #ifndef PRU_SLAVE
  27. #include "../../data/net/netServer.h"
  28. #include "LRF_TargetTracker.h"
  29. #ifdef __EU_PROJECT__
  30. #include "LRF_SafeShoreHandler.h"
  31. #include "LRF_DefenderHandler.h"
  32. #include "LRF_KafkaHandler.h"
  33. #define KNL_SETTINGS_SAFE_SHORE "ENABLE_SAFE_SHORE"
  34. #define KNL_SETTINGS_DEFENDER "ENABLE_DEFENDER"
  35. #define KNL_SETTINGS_KAFKA "ENABLE_INFOSTRESS"
  36. #endif
  37. #endif
  38. //#define DUMP_TH_AFTER_FLIP_ON_DISK
  39. #define MAX_CYCLE_COUNTER_VALUE 0xFFFFFFFF;
  40. #define SLEEP_KERNEL_INTERVAL 10 // 10 millisecond
  41. #define TIME_SYNC_INTERVAL 900000 // 15 minute(s) in 1 millisecond units
  42. #define STATUS_OK_INTERVAL 2000 // 2 Sec in 1 millisecond units
  43. #define KNL_SETTINGS_DETECTOR_WIDTH "DETECTOR_WIDTH"
  44. #define KNL_SETTINGS_FILTER_KERNELS "ENABLED_LRF"
  45. #define KNL_SETTINGS_DETECTOR_SST "DETECTOR_SST"
  46. //#define KNL_SETTINGS_V_MOTOR_SETPOINT "VERTICAL_ENC_FREQ"
  47. /**
  48. * LRF_Kernel class - manages communication between client
  49. * handlers and PRU cores bseide of Event management.
  50. *
  51. *
  52. * @author gagua
  53. */
  54. class LRF_Kernel: public basicThread, public basicEngine{
  55. private:
  56. basicLogCollection * m_pLog;
  57. LRF_HardwareManager * m_pHardwareManager;
  58. basicEventHeap * m_pEventHeap;
  59. config_setting_t * m_pSettings;
  60. basicSettingsProvider * m_pSettingsProvider;
  61. uint32_t m_nKernelFilter;
  62. uint32_t m_lCycleCounter;
  63. uint32_t m_nFlipCounter;
  64. uint32_t m_nFlipSavierID;
  65. uint8_t m_bExitCause;
  66. LRF_WORK_MODE m_eWorkMode;
  67. LRF_TwinConnector * m_pTWIC;
  68. #ifdef PRU_SLAVE
  69. #else
  70. LRF_TargetTracker * m_pTracker;
  71. #ifdef __EU_PROJECT__
  72. bool m_bSafeShoreSupport;
  73. LRF_SafeShoreHandler * m_pSafeShoreHandler;
  74. bool m_bDefenderSupport;
  75. LRF_DefenderHandler * m_pDefenderHandler;
  76. bool m_bKafkaSupport;
  77. LRF_KafkaHandler * m_pKafkaHandler;
  78. #endif
  79. // Argus/LGS proto
  80. networkServer * m_pNetClientsServer;
  81. // Detection Stuff
  82. uint32_t m_nSST;
  83. #endif
  84. uint32_t m_nWidth;
  85. // Shadow
  86. ShadowMask * m_pShadow;
  87. thresholdNode * m_pThreshold;
  88. uint32_t m_nThresholdSize;
  89. protected:
  90. void m_fThreadProc( void );
  91. public:
  92. // Constructor
  93. explicit LRF_Kernel( LRF_HardwareManager *HM = NULL );
  94. // Destructor
  95. virtual ~LRF_Kernel();
  96. bool attachNetServer( networkServer *srvPort );
  97. virtual networkClientHandler * attachNewClient( int SocketID );
  98. virtual bool detachClient( networkClientHandler *ptr );
  99. #ifndef PRU_SLAVE //Just Master Stuff
  100. bool create( LRF_HardwareManager *ptr = NULL, networkServer *srvPort = NULL );
  101. bool stopMotors( void );
  102. bool startMotors( void );
  103. #endif
  104. ShadowMask * getShadowMask( void ){ return m_pShadow; };
  105. bool create( LRF_HardwareManager *ptr = NULL );
  106. void WaitFinish( bool Force = false );
  107. /* functional API */
  108. bool askReset( void );
  109. LRF_WORK_MODE getMode( void ){ return m_eWorkMode; };
  110. bool getParameters( void );
  111. thresholdNode * getTreshold( uint32_t &size, uint8_t kID=0 );
  112. bool setMode( LRF_WORK_MODE nMode );
  113. bool setOffset( uint8_t nOffset );
  114. bool setOrder( uint8_t nOrder );
  115. PLGS_3D_PARAMETERS getDetectionParameters( void );
  116. bool setDetectionParameters( PLGS_3D_PARAMETERS ptr );
  117. bool reset( bool FullRestart = false );
  118. bool shutdown( bool Restart = false );
  119. uint8_t getExitCause( void ){ return m_bExitCause; };
  120. };
  121. #endif // __LRF_KERNEL_H_INCL__