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.

129 lines
4.2 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
5 years ago
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
​
​
​
​
​
​
​
5 years ago
​
​
​
5 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. //#define TH_USE_PICTURES
  18. #include "../../components/base/basicThread.h"
  19. #include "../../components/base/basicEngine.h"
  20. #include "../../components/base/basicSettingsProvider.h"
  21. #include "../../components/base/basicEventHeap.h"
  22. #include "LRF_HardwareManager.h"
  23. #include "LRF_TwinConnector.h"
  24. #include "../../alg/lgs/detectorStructures.h"
  25. #include "../../alg/lgs/detector.h"
  26. #include "../../alg/lgs/mask.h"
  27. #ifndef PRU_SLAVE
  28. #include "../../data/net/netServer.h"
  29. #include "LRF_TargetTracker.h"
  30. #endif
  31. //#define DUMP_TH_AFTER_FLIP_ON_DISK
  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. /**
  41. * LRF_Kernel class - manages communication between client
  42. * handlers and PRU cores bseide of Event management.
  43. *
  44. *
  45. * @author gagua
  46. */
  47. class LRF_Kernel: public basicThread, public basicEngine{
  48. private:
  49. basicLogCollection * m_pLog;
  50. LRF_HardwareManager * m_pHardwareManager;
  51. basicEventHeap * m_pEventHeap;
  52. config_setting_t * m_pSettings;
  53. basicSettingsProvider * m_pSettingsProvider;
  54. uint32_t m_nKernelFilter;
  55. uint32_t m_lCycleCounter;
  56. uint32_t m_nFlipCounter;
  57. uint32_t m_nFlipSavierID;
  58. uint8_t m_bExitCause;
  59. LRF_WORK_MODE m_eWM;
  60. basicMutex m_mWMProtector;
  61. LRF_TwinConnector * m_pTWIC;
  62. #ifndef PRU_SLAVE
  63. LRF_TargetTracker * m_pTracker;
  64. networkServer * m_pNetClientsServer;
  65. uint32_t m_nSST;
  66. #endif
  67. uint32_t m_nWidth;
  68. ShadowMask * m_pShadow;
  69. thresholdNode * m_pCurrentTH;
  70. uint32_t m_nCurrentTH;
  71. uint8_t m_bCurrentTH;
  72. protected:
  73. void m_fThreadProc( void );
  74. public:
  75. // Constructor
  76. explicit LRF_Kernel( LRF_HardwareManager *HM = NULL );
  77. // Destructor
  78. virtual ~LRF_Kernel();
  79. #ifdef PRU_SLAVE
  80. bool create( LRF_HardwareManager *ptr = NULL );
  81. #else
  82. bool attachNetServer( networkServer *srvPort );
  83. virtual networkClientHandler * attachNewClient( int SocketID );
  84. virtual bool detachClient( networkClientHandler *ptr );
  85. bool create( LRF_HardwareManager *ptr = NULL, networkServer *srvPort = NULL );
  86. bool stopMotors( void );
  87. bool startMotors( void );
  88. #endif
  89. void WaitFinish( bool Force = false );
  90. /* functional API */
  91. bool askReset( void );
  92. PLGS_3D_PARAMETERS getDetectionParameters( void );
  93. LRF_WORK_MODE getWM( void );
  94. bool getParameters( void );
  95. thresholdNode * getTreshold( uint32_t &size, uint8_t kID=0 );
  96. ShadowMask * getShadowMask( void ){ return m_pShadow; };
  97. void setWM( LRF_WORK_MODE nMode );
  98. bool setOffset( uint8_t nOffset );
  99. bool setOrder( uint8_t nOrder );
  100. bool setDetectionParameters( PLGS_3D_PARAMETERS ptr );
  101. bool reset( bool FullRestart = false );
  102. bool shutdown( bool Restart = false );
  103. uint8_t getExitCause( void ){ return m_bExitCause; };
  104. };
  105. #endif // __LRF_KERNEL_H_INCL__