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.

202 lines
7.0 KiB

4 years ago
​
​
​
​
​
4 years ago
4 years ago
​
​
​
​
​
​
​
4 years ago
4 years ago
4 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
4 years ago
​
​
​
​
4 years ago
​
​
​
4 years ago
4 years ago
​
​
4 years ago
4 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
4 years ago
​
4 years ago
​
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
​
​
​
4 years ago
4 years ago
​
​
​
​
4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
4 years ago
​
3 years ago
4 years ago
​
​
​
​
​
4 years ago
​
​
4 years ago
4 years ago
​
​
4 years ago
​
​
​
​
3 years ago
4 years ago
​
​
​
​
4 years ago
​
​
​
​
3 years ago
4 years ago
4 years ago
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __OBJECT_NET_NODE_2D_HEADERS__
  2. #define __OBJECT_NET_NODE_2D_HEADERS__
  3. #include "deviceNodeSensor.h"
  4. #include <cfloat> //For DBL_MAX
  5. #include <stdlib.h>
  6. #include <sys/stat.h>
  7. #include "../../components/base/basicObject.h"
  8. #include "../../components/base/basicMutex.h"
  9. #include "../../components/base/basicThread.h"
  10. #include "../../components/base/basicLogCollection.h"
  11. #include "../../components/base/basicSettingsProvider.h"
  12. #include "../../alg/lgs/mask.h"
  13. #include "../../data/protocol/protocolLGS2D.h"
  14. #include "../../data/rfs/fs_helper.h"
  15. //To Save rasterized masks
  16. #ifdef DEBUG
  17. #include <opencv2/opencv.hpp>
  18. #endif
  19. typedef enum E_WORKING_STATE_LRF2D{
  20. WS_2D_BEFORE_START = 0,
  21. WS_2D_CREATE_PORT = 1,
  22. WS_2D_CONNECT,
  23. WS_2D_WAIT_CONNECT,
  24. WS_2D_SET_BORDER_MODE,
  25. WS_2D_SET_DETECTION_MODE,
  26. WS_2D_SET_GETFILE_MODE,
  27. WS_2D_SET_FILESYSTEM_MODE,
  28. WS_2D_GET_SERIAL_NUM,
  29. WS_2D_GET_VERSION,
  30. WS_2D_GET_DETECTION_PROFILE,
  31. WS_2D_GET_MASTER_PARAM,
  32. WS_2D_GET_SLAVE_PARAM,
  33. WS_2D_GET_MASK_INFO,
  34. WS_2D_SET_MASK_INFO,
  35. WS_2D_GET_FAST_DRAW,
  36. WS_2D_SET_SHADOW_DONE,
  37. WS_2D_GET_SHADOW_POLY_INFO,
  38. WS_2D_GET_SHADOW_POLY_POINT,
  39. WS_2D_SET_SHADOW_POLY_INFO,
  40. WS_2D_SET_SHADOW_POLY_POINT,
  41. WS_2D_SET_SHADOW_RAY_LINE,
  42. WS_2D_SET_SHADOW_RAY,
  43. WS_2D_SEND_GETFILE_MODE,
  44. WS_2D_SET_MASTER_PARAM,
  45. WS_2D_SET_SLAVE_PARAM,
  46. WS_2D_ISSUE_FULL_RESET,
  47. WS_2D_ISSUE_RESET,
  48. WS_2D_FS_READY,
  49. WS_2D_GET_FS_CURDIR,
  50. WS_2D_READ_FILE,
  51. WS_2D_SAVE_FILE,
  52. WS_2D_FS_FETCH_NEXT_PART,
  53. WS_2D_FS_OPERATION_FINISHED,
  54. WS_2D_FS_OPERATION_ABORTED,
  55. WS_2D_PING,
  56. WS_2D_PONG,
  57. WS_2D_SLEEP_AND_RECONNECT,
  58. WS_2D_WAIT_DEVICE_REPLAY,
  59. WS_2D_WAIT_CHECK_REPLAY
  60. } WORKING_STATE_LRF2D;
  61. typedef struct S_SHADOW_IO_HELPER{
  62. uint16_t m_nCurrentPolygon;
  63. uint16_t m_nCurrentPoint;
  64. uint16_t m_nCurrentRayLine;
  65. uint16_t m_nCurrentRay;
  66. uint8_t m_bSequence;
  67. }SHADOW_IO_HELPER;
  68. typedef struct S_GETFILE_IO_HELPER{
  69. uint32_t fileSize;
  70. uint8_t index;
  71. char destName[33];
  72. char sourceName[33];
  73. uint8_t state;
  74. uint32_t db_id;
  75. FILE * fd;
  76. uint8_t data[250];
  77. uint8_t data_size;
  78. }GETFILE_IO_HELPER;
  79. typedef std::vector<GETFILE_IO_HELPER *> VECTOR_GF_HELPERS;
  80. typedef enum E_GF_ENDING_MODE{
  81. GF_EM_DO_NOTHING = 0,
  82. GF_EM_ISSUE_RESET = 1,
  83. GF_EM_ISSUE_SAVE_FW = 2,
  84. }GF_ENDING_MODE;
  85. typedef struct S_GF_HELPER_STRUCT{
  86. VECTOR_GF_HELPERS helpers;
  87. uint8_t current;
  88. uint8_t transfer_ending_mode;
  89. }GF_HELPER_STRUCT;
  90. typedef struct S_TEST_POINT{
  91. float x;
  92. float y;
  93. }TEST_POINT;
  94. typedef enum E_COMMAND_SEQUENCE_TYPE{
  95. NO_SEQUENCE = 0,
  96. SET_DEVICE_ID = 1,
  97. SET_DEVCOM_SPEED,
  98. SET_DETECTION_PARAMETERS,
  99. SET_SHADOWS,
  100. SET_HW_PARAMS,
  101. FREEZE_TH,
  102. SAVE_ALL_TO_FLESH
  103. } COMMAND_SEQUENCE_TYPE;
  104. class device2DSensor: public deviceNodeSensor, public protocolLGS_2D{
  105. private:
  106. uint8_t m_bPortType;
  107. basicTransport * m_pPort;
  108. uint32_t m_nSleepTime;
  109. uint8_t m_bInitialFlips;
  110. uint16_t m_nCurrentAngle;
  111. uint8_t m_bDrawType;
  112. uint32_t m_nProcessingCmdId;
  113. uint32_t m_vDrawRanges[ANODE_2D_MAX_DRAW_ANGLES];
  114. uint8_t m_bCurShadowMask;
  115. bool m_bDeviceIsSynced;
  116. bool m_bForceSync;
  117. bool m_bSerialStringValid;
  118. bool m_bVersionStringValid;
  119. char m_tSN[65];
  120. char m_tSV[129];
  121. uint8_t m_nActiveDetectionProfile;
  122. //Shadow
  123. SHADOW_IO_HELPER m_sShadowHelper;
  124. SHADOW m_sShadow;
  125. //GetFile
  126. //GETFILE_IO_HELPER m_sGetFileHelper;
  127. GF_HELPER_STRUCT m_sGetFileTransfers;
  128. /*
  129. FS_IO_HELPER * m_pFSHelper;
  130. bool m_bSupportedFS;
  131. uint8_t m_pFsPackageBuffer[MAX_PATH];
  132. uint8_t m_bCurrentOperationFS;
  133. FS_DATA_EX m_sInFSData;
  134. FS_DATA_EX m_sOutFSData;
  135. */
  136. WORKING_STATE_LRF2D m_eWState;
  137. TARGET_DATA * prepareTargetData( uint16_t AZ, uint16_t RANGE, uint32_t WIDTH, uint8_t LRFID = 0 );
  138. WIDTH_TABLE * prepareWidthTable();
  139. //void saveRawDrawData( uint16_t alngles );
  140. void cleanShadowStructs();
  141. bool PtInPolygons( TEST_POINT& point, uint8_t F );
  142. bool PtInPolygon( SHADOW_POLY& Poly, TEST_POINT& point );
  143. bool rasterizeShadow();
  144. bool saveShadowToDB( void );
  145. bool loadShadowFromDB( void );
  146. bool cleanShadowInDB( void );
  147. //bool downloadFile( CSTR fname );
  148. //COMMAND_SEQUENCE_TYPE m_eCurrentSequence;
  149. //uint8_t m_bSequenceStep;
  150. //bool runSequence( COMMAND_SEQUENCE_TYPE SequenceID );
  151. #ifdef DEBUG
  152. void makeShadowPic( CSTR picname );
  153. #endif
  154. protected:
  155. virtual void connectMode();
  156. virtual void handshakeMode();
  157. virtual void readMode();
  158. virtual void syncMode();
  159. virtual void drawMode();
  160. virtual void fullDrawMode();
  161. virtual void maskMode();
  162. virtual void alarmMode();
  163. virtual void idleMode();
  164. virtual void getfileMode();
  165. virtual void proceedDBCommands();
  166. virtual void cleanupDeviceStructures();
  167. virtual void save_ini();
  168. virtual void save_detection();
  169. virtual void save_masks();
  170. virtual void save_eprom();
  171. virtual void wait_device();
  172. virtual bool validateCommunicationRessource();
  173. virtual bool packetHandler( protocolPackage *Package );
  174. public:
  175. explicit device2DSensor( uint32_t id );
  176. ~device2DSensor();
  177. virtual bool startService();
  178. virtual bool stopService();
  179. virtual bool validate();
  180. virtual void simulateTarget( void );
  181. };
  182. #endif