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.

151 lines
5.9 KiB

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 "../../components/base/basicObject.h"
  7. #include "../../components/base/basicMutex.h"
  8. #include "../../components/base/basicThread.h"
  9. #include "../../components/base/basicLogCollection.h"
  10. #include "../../components/base/basicSettingsProvider.h"
  11. #include "../../alg/lgs/mask.h"
  12. #include "../../data/protocol/protocolLGS2D.h"
  13. #define LGS_DEFAULT_SLEEP_TIME 100
  14. #define LGS_ALERT_SLEEP_TIME 10
  15. #define LGS_DEFAULT_TO_COUNTER 60
  16. #define LGS_INITIAL_FLIPS 8
  17. #define ANODE_WM_2D_BEFORE_START 0
  18. #define ANODE_WM_2D_CREATE_PORT 1
  19. #define ANODE_WM_2D_CONNECT 2
  20. #define ANODE_WM_2D_WAIT_CONNECT 3
  21. #define ANODE_WM_2D_SET_INIT_MODE 4
  22. #define ANODE_WM_2D_GET_SERIAL_NUM 6
  23. #define ANODE_WM_2D_GET_VERSION 8
  24. #define ANODE_WM_2D_GET_DETECTION_PROFILE 10
  25. #define ANODE_WM_2D_GET_MASTER_PARAM 12
  26. #define ANODE_WM_2D_GET_SLAVE_PARAM 14
  27. #define ANODE_WM_2D_GET_MASK_INFO 16
  28. #define ANODE_WM_2D_SET_MASK_INFO 18
  29. #define ANODE_WM_2D_SET_BORDER_MODE 32
  30. #define ANODE_WM_2D_GET_FAST_DRAW 34
  31. #define ANODE_WM_2D_SET_DETECTION_MODE 36
  32. #define ANODE_WM_2D_SET_FILESYSTEM_MODE 38
  33. #define ANODE_WM_2D_FS_TRANSFER_MODE 39
  34. #define ANODE_WM_2D_SET_SHADOW_DONE 40
  35. #define ANODE_WM_2D_GET_SHADOW_POLY_INFO 41
  36. #define ANODE_WM_2D_GET_SHADOW_POLY_POINT 43
  37. #define ANODE_WM_2D_SET_SHADOW_POLY_INFO 45
  38. #define ANODE_WM_2D_SET_SHADOW_POLY_POINT 47
  39. #define ANODE_WM_2D_SET_SHADOW_RAY_LINE 48
  40. #define ANODE_WM_2D_SET_SHADOW_RAY 49
  41. #define ANODE_WM_2D_SET_GETFILE_MODE 50
  42. #define ANODE_WM_2D_SEND_GETFILE_MODE 52
  43. #define ANODE_WM_2D_SET_MASTER_PARAM 58
  44. #define ANODE_WM_2D_SET_SLAVE_PARAM 59
  45. #define ANODE_WM_2D_ISSUE_FULL_RESET 64
  46. #define ANODE_WM_2D_ISSUE_RESET 66
  47. #define ANODE_WM_2D_PING 128
  48. #define ANODE_WM_2D_PONG 129
  49. #define ANODE_WM_2D_SLEEP_AND_RECONNECT 130
  50. #define ANODE_WM_2D_WAIT_DEVICE_REPLAY 254
  51. #define ANODE_WM_2D_WAIT_CHECK_REPLAY 255
  52. #define ANODE_2D_MAX_DRAW_ANGLES 6000
  53. #define ARGUS_DS_DISCONNECTED 0
  54. #define ARGUS_DS_CONNECTING 1
  55. #define ARGUS_DS_GET_INFO 2
  56. #define ARGUS_DS_STUDY 3
  57. #define ARGUS_DS_READY 4
  58. #define ARGUS_DS_ALARMED 5
  59. #define ARGUS_DS_BUSY 6
  60. typedef struct S_SHADOW_IO_HELPER{
  61. uint16_t m_nCurrentPolygon;
  62. uint16_t m_nCurrentPoint;
  63. uint16_t m_nCurrentRayLine;
  64. uint16_t m_nCurrentRay;
  65. }SHADOW_IO_HELPER;
  66. typedef struct S_GETFILE_IO_HELPER{
  67. uint32_t fileSize;
  68. uint32_t index;
  69. char destName[33];
  70. char sourceName[33];
  71. uint8_t state;
  72. FILE * fd;
  73. uint8_t data[250];
  74. uint8_t data_size;
  75. }GETFILE_IO_HELPER;
  76. typedef struct S_TEST_POINT{
  77. float x;
  78. float y;
  79. }TEST_POINT;
  80. class device2DSensor: public deviceNodeSensor, public basicThread, public protocolLGS_2D{
  81. private:
  82. //basicLogCollection * m_pLog;
  83. uint8_t m_bPortType;
  84. basicTransport * m_pPort;
  85. uint8_t m_bDeviceWM;
  86. uint32_t m_nSleepTime;
  87. uint16_t m_bTimeOutCounter;
  88. uint8_t m_bInitialFlips;
  89. uint16_t m_nCurrentAngle;
  90. uint8_t m_bDrawType;
  91. uint8_t m_bOpRetryCnt;
  92. uint32_t m_nProcessingCmdId;
  93. uint32_t m_vDrawRanges[ANODE_2D_MAX_DRAW_ANGLES];
  94. bool m_bDeviceIsSynced;
  95. bool m_bSerialStringValid;
  96. bool m_bVersionStringValid;
  97. char m_tSN[65];
  98. char m_tSV[129];
  99. char m_sCurrentFile[MAX_PATH];
  100. uint32_t m_nUploadID;
  101. uint8_t m_nActiveDetectionProfile;
  102. //Shadow
  103. SHADOW_IO_HELPER m_sShadowHelper;
  104. SHADOW m_sShadow;
  105. //GetFile
  106. GETFILE_IO_HELPER m_sGetFileHelper;
  107. TARGET_DATA * prepareTargetData( uint16_t AZ, uint16_t RANGE, uint32_t WIDTH, uint8_t LRFID = 0 );
  108. //void saveRawDrawData( uint16_t alngles );
  109. void cleanupDeviceStructures();
  110. CSTR generateSettingFile();
  111. void cleanShadowStructs();
  112. bool PtInPolygons( TEST_POINT& point, uint8_t F );
  113. bool PtInPolygon( SHADOW_POLY& Poly, TEST_POINT& point );
  114. bool rasterizeShadow();
  115. void updateDataStatus( uint8_t ds );
  116. #ifdef DEBUG_EXTRA
  117. void makeShadowPic( CSTR picname );
  118. #endif
  119. protected:
  120. virtual bool packetHandler( protocolPackage *Package );
  121. virtual void m_fThreadProc( void );
  122. public:
  123. explicit device2DSensor( uint32_t id );
  124. ~device2DSensor();
  125. virtual bool startService();
  126. virtual bool stopService();
  127. virtual bool validate();
  128. virtual void simulateTarget( void );
  129. };
  130. #endif