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.

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