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.

142 lines
4.9 KiB

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