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.

216 lines
7.6 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
​
​
​
​
​
​
​
​
​
  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. #define LGS_DEFAULT_SLEEP_TIME 100
  16. #define LGS_ALERT_SLEEP_TIME 10
  17. #define LGS_DEFAULT_TO_COUNTER 4
  18. #define LGS_INITIAL_FLIPS 8
  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. #define ANODE_2D_MAX_DRAW_ANGLES 6000
  62. #define ARGUS_DS_DISCONNECTED 0
  63. #define ARGUS_DS_CONNECTING 1
  64. #define ARGUS_DS_GET_INFO 2
  65. #define ARGUS_DS_STUDY 3
  66. #define ARGUS_DS_READY 4
  67. #define ARGUS_DS_ALARMED 5
  68. #define ARGUS_DS_BUSY 6
  69. typedef struct S_SHADOW_IO_HELPER{
  70. uint16_t m_nCurrentPolygon;
  71. uint16_t m_nCurrentPoint;
  72. uint16_t m_nCurrentRayLine;
  73. uint16_t m_nCurrentRay;
  74. }SHADOW_IO_HELPER;
  75. typedef struct S_GETFILE_IO_HELPER{
  76. uint32_t fileSize;
  77. uint8_t index;
  78. char destName[33];
  79. char sourceName[33];
  80. uint8_t state;
  81. uint32_t db_id;
  82. FILE * fd;
  83. uint8_t data[250];
  84. uint8_t data_size;
  85. }GETFILE_IO_HELPER;
  86. typedef std::vector<GETFILE_IO_HELPER *> VECTOR_GF_HELPERS;
  87. typedef enum E_GF_ENDING_MODE{
  88. GF_EM_DO_NOTHING = 0,
  89. GF_EM_ISSUE_RESET = 1,
  90. GF_EM_ISSUE_SAVE_FW = 2,
  91. }GF_ENDING_MODE;
  92. typedef struct S_GF_HELPER_STRUCT{
  93. VECTOR_GF_HELPERS helpers;
  94. uint8_t current;
  95. uint8_t transfer_ending_mode;
  96. }GF_HELPER_STRUCT;
  97. typedef struct S_TEST_POINT{
  98. float x;
  99. float y;
  100. }TEST_POINT;
  101. typedef enum E_COMMAND_SEQUENCE_TYPE{
  102. NO_SEQUENCE = 0,
  103. SET_DEVICE_ID = 1,
  104. SET_DEVCOM_SPEED,
  105. SET_DETECTION_PARAMETERS,
  106. SET_SHADOWS,
  107. SET_HW_PARAMS,
  108. FREEZE_TH,
  109. SAVE_ALL_TO_FLESH
  110. } COMMAND_SEQUENCE_TYPE;
  111. class device2DSensor: public deviceNodeSensor, public protocolLGS_2D{
  112. private:
  113. uint8_t m_bPortType;
  114. basicTransport * m_pPort;
  115. E_MODES m_bActualDeviceWM;
  116. E_MODES m_bRequestedDeviceWM;
  117. uint32_t m_nSleepTime;
  118. uint16_t m_bTimeOutCounter;
  119. uint8_t m_bInitialFlips;
  120. uint16_t m_nCurrentAngle;
  121. uint8_t m_bDrawType;
  122. uint8_t m_bOpRetryCnt;
  123. uint32_t m_nProcessingCmdId;
  124. uint32_t m_vDrawRanges[ANODE_2D_MAX_DRAW_ANGLES];
  125. bool m_bCurMaskOp;
  126. uint8_t m_bCurMaskId;
  127. bool m_bDeviceIsSynced;
  128. bool m_bForceSync;
  129. bool m_bSerialStringValid;
  130. bool m_bVersionStringValid;
  131. char m_tSN[65];
  132. char m_tSV[129];
  133. uint8_t m_nActiveDetectionProfile;
  134. //Shadow
  135. SHADOW_IO_HELPER m_sShadowHelper;
  136. SHADOW m_sShadow;
  137. //GetFile
  138. //GETFILE_IO_HELPER m_sGetFileHelper;
  139. GF_HELPER_STRUCT m_sGetFileTransfers;
  140. /*
  141. FS_IO_HELPER * m_pFSHelper;
  142. bool m_bSupportedFS;
  143. uint8_t m_pFsPackageBuffer[MAX_PATH];
  144. uint8_t m_bCurrentOperationFS;
  145. FS_DATA_EX m_sInFSData;
  146. FS_DATA_EX m_sOutFSData;
  147. */
  148. WORKING_STATE_LRF2D m_eWState;
  149. TARGET_DATA * prepareTargetData( uint16_t AZ, uint16_t RANGE, uint32_t WIDTH, uint8_t LRFID = 0 );
  150. //void saveRawDrawData( uint16_t alngles );
  151. void cleanupDeviceStructures();
  152. void cleanShadowStructs();
  153. bool PtInPolygons( TEST_POINT& point, uint8_t F );
  154. bool PtInPolygon( SHADOW_POLY& Poly, TEST_POINT& point );
  155. bool rasterizeShadow();
  156. void updateDataStatus( uint8_t ds, uint8_t ns = NODE_STATUS_WORK );
  157. //bool downloadFile( CSTR fname );
  158. //COMMAND_SEQUENCE_TYPE m_eCurrentSequence;
  159. //uint8_t m_bSequenceStep;
  160. //bool runSequence( COMMAND_SEQUENCE_TYPE SequenceID );
  161. #ifdef DEBUG_EXTRA
  162. void makeShadowPic( CSTR picname );
  163. #endif
  164. protected:
  165. virtual void connectMode();
  166. virtual void handshakeMode();
  167. virtual void readMode();
  168. virtual void syncMode();
  169. virtual void drawMode();
  170. virtual void maskMode();
  171. virtual void alarmMode();
  172. virtual void idleMode();
  173. virtual void getfileMode();
  174. virtual void proceedDBCommands();
  175. virtual void save_ini();
  176. virtual void save_detection();
  177. virtual void save_masks();
  178. virtual void save_eprom();
  179. virtual bool validateCommunicationRessource();
  180. //virtual bool setCommunicationRessurce();
  181. virtual bool packetHandler( protocolPackage *Package );
  182. //virtual void m_fThreadProc( void );
  183. public:
  184. explicit device2DSensor( uint32_t id );
  185. ~device2DSensor();
  186. virtual bool startService();
  187. virtual bool stopService();
  188. virtual bool validate();
  189. virtual void simulateTarget( void );
  190. };
  191. #endif