Old fashion design for PC-104
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.

230 lines
5.7 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: Filters.h
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Header file of Filters.h
  13. //----------------------------------------------------------------------------
  14. #ifndef __LGS__FILTERS__INCLUDED__
  15. #define __LGS__FILTERS__INCLUDED__
  16. #include "StdAfx.h"
  17. #include "Tracker.h"
  18. #include "..\LgLib\Comm\LgsM.h"
  19. //////////////////////////
  20. // FILTERS COMMON TYPES //
  21. //////////////////////////
  22. enum CEnumSunState
  23. {
  24. E_SUN_STATE_INCREASE,
  25. E_SUN_STATE_DECREASE,
  26. E_SUN_STATE_NORMAL
  27. };
  28. enum CEnumTargetType
  29. {
  30. E_TARGET_TYPE_NONE,
  31. E_TARGET_TYPE_BLACK,
  32. E_TARGET_TYPE_WHITE,
  33. };
  34. #ifndef INCLUDE_WINDOWS_DEFINITIONS
  35. #define private public
  36. #endif
  37. /////////////////////////////////////////////////////
  38. // FILTER "UNRELIABLE POINTS DETECTION BY SUN BIT" //
  39. /////////////////////////////////////////////////////
  40. class CFilterSun
  41. {
  42. public:
  43. CFilterSun();
  44. ~CFilterSun();
  45. public:
  46. BOOL Create( CTracker *pTracker );
  47. void Destroy();
  48. void Reset();
  49. public:
  50. CEnumSunState OnAngle( INT nAngle, BOOL bSun, INT SUN );
  51. void OnFlip();
  52. public:
  53. BOOL GetLastErrorSun() { BOOL bError = m_bErrorSun; m_bErrorSun = FALSE; return bError; }
  54. private:
  55. typedef struct SUN_DATA
  56. {
  57. BYTE bValue;
  58. BOOL bWaitFlip;
  59. }SUN_DATA, far* LPSUN_DATA;
  60. INT m_nSun; // for checking number of sun bits for catching error of lasers
  61. BOOL m_bErrorSun; // error flags
  62. LPSUN_DATA m_lpSunData; // check sun
  63. CTracker *m_pTracker; // holds pointer to target tracker
  64. INT m_nClearLoop;
  65. };
  66. //////////////////////////////////////////////
  67. // FILTER "BLIND DETECTION BY MEDIUM RANGE" //
  68. //////////////////////////////////////////////
  69. class CFilterMediumRange
  70. {
  71. public:
  72. CFilterMediumRange();
  73. ~CFilterMediumRange();
  74. public:
  75. BOOL Create( CTracker *pTracker );
  76. void Destroy();
  77. void Reset();
  78. public:
  79. void OnAngle( INT nMinSAF, BOOL bSun );
  80. void OnFlip();
  81. private:
  82. LONG m_nMedium; // medium range for curent SAF
  83. INT m_nMediumCalculateLoop; // loops remainig for calculation of medium range
  84. BOOL m_bBlind; // holds last BLIND condition
  85. CTracker *m_pTracker; // holds pointer to target tracker
  86. CFastHistorySum< INT, LONG, LGS_DETECTOR_MEDIUM_RANGE_HISTORY_LENGTH> m_MediumHistory;
  87. };
  88. ////////////////////////////////////////////////////////
  89. // FILTER "PD CONDITION DETECTION BY UNSTABLE RANGES" //
  90. ////////////////////////////////////////////////////////
  91. #define LGS_DETECTOR_PD_MIN_DELTA 20
  92. #define LGS_DETECTOR_PD_MIN_UPDATE_VALUE 0
  93. #define LGS_DETECTOR_PD_MAX_UPDATE_VALUE 99
  94. #define LGS_DETECTOR_PD_HISTORY_LENGTH 5 // 2^5=32
  95. #define LGS_DETECTOR_PD_HISTORY_DELTA 2
  96. class CFilterPD
  97. {
  98. public:
  99. CFilterPD();
  100. ~CFilterPD();
  101. public:
  102. BOOL Create( CTracker *pTracker );
  103. void Destroy();
  104. void Reset();
  105. public:
  106. void OnUpdateSAF( INT nAngle, LPBYTE pOffset, LPBYTE pOrder );
  107. void OnBuildSAF( INT nAngle, LPINT pMinSAF, LPINT pMaxSAF );
  108. BOOL OnCalculate( INT nAngle, INT nRange, LPINT pMinSAF, LPINT pMaxSAF, BOOL bSpike );
  109. void OnFlip();
  110. BOOL IsShowBlackTargets() { return m_bMediumShowBlack; }
  111. private:
  112. typedef struct SAF
  113. {
  114. INT nMin; // maximum
  115. INT nMax; // minimum
  116. }SAF, far* LPSAF;
  117. typedef struct PD
  118. {
  119. BYTE nCountMin; // how many ranges near max per last saf
  120. BYTE nCountMax; // how many ranges near min per last saf
  121. BYTE nCountSpikes; // how many spikes per last saf
  122. BYTE nValue; // current PD
  123. }PD, far* LPPD;
  124. typedef struct PDEX
  125. {
  126. BYTE nFlip; // amount of flips remaining to super flip
  127. BYTE nActiveSAF; // current SAF
  128. }PDEX, far* LPPDEX;
  129. private:
  130. LPSAF m_ppSAF[2]; // SAF data
  131. LPPD m_lpPD; // PD data
  132. LPPDEX m_lpPDEX; // PD data
  133. INT m_nSAFUpdateLoop;
  134. CTracker *m_pTracker;
  135. BYTE m_bSmallFlip;
  136. private:
  137. INT m_nMediumPD;
  138. INT m_nMediumLastPD;
  139. BOOL m_bMediumShowBlack;
  140. // fast history calculation
  141. CFastHistorySum< BYTE, WORD, LGS_DETECTOR_PD_HISTORY_LENGTH > m_MediumHistory;
  142. };
  143. ////////////////////////////////////////////////////////
  144. // FILTER "WIDTH" //
  145. ////////////////////////////////////////////////////////
  146. class CFilterWidth
  147. {
  148. public:
  149. CFilterWidth();
  150. ~CFilterWidth();
  151. public:
  152. BOOL Create( CTracker *pTracker, LPCTSTR pFileName );
  153. void Destroy();
  154. public:
  155. LONG GetWidth( INT nTargetRange, INT nWidth );
  156. public:
  157. PLONG GetTable() { return m_pTable; }
  158. private:
  159. LONG m_pTable[LGS::WIDTH_TABLE_SIZE];
  160. };
  161. ////////////////////////////////////////////////////////
  162. // FILTER "LINEARIZATION" //
  163. ////////////////////////////////////////////////////////
  164. class CFilterCalibration
  165. {
  166. public:
  167. CFilterCalibration();
  168. ~CFilterCalibration();
  169. public:
  170. BOOL Create( LPCTSTR pFileName );
  171. void Destroy();
  172. public:
  173. BOOL Load( LPCTSTR pFileName );
  174. BOOL Save( LPCTSTR pFileName );
  175. public:
  176. inline INT Calibrate( INT nA2D ) { return m_lpLookupTable[ nA2D ]; }
  177. public:
  178. void OnCmdGetCalibrationTable( PBYTE& pReadBufferPtr, INT& nReadCount, PBYTE& pSendBufferPtr, INT& nSendCount );
  179. BOOL OnCmdSetCalibrationTable( PBYTE& pReadBufferPtr, INT& nReadCount, PBYTE& pSendBufferPtr, INT& nSendCount );
  180. private:
  181. void UpdateLookupTable();
  182. private:
  183. typedef struct A2DRANGE
  184. {
  185. INT nA2D;
  186. INT nReal;
  187. }A2DRANGE, far*LPA2DRANGE;
  188. LPA2DRANGE m_lpA2DRange;
  189. INT m_nA2DRangeCount;
  190. LPINT m_lpLookupTable;
  191. };
  192. #endif