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.

148 lines
5.8 KiB

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 1
  15. #define LGS_DEFAULT_TO_COUNTER 10
  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_NONE 0
  54. #define ARGUS_DS_CREATED 1
  55. #define ARGUS_DS_GET_CONFIG 2
  56. #define ARGUS_DS_VALID 3
  57. #define ARGUS_DS_CONF_MISTMATCH 4
  58. typedef struct S_SHADOW_IO_HELPER{
  59. uint16_t m_nCurrentPolygon;
  60. uint16_t m_nCurrentPoint;
  61. uint16_t m_nCurrentRayLine;
  62. uint16_t m_nCurrentRay;
  63. }SHADOW_IO_HELPER;
  64. typedef struct S_GETFILE_IO_HELPER{
  65. uint32_t fileSize;
  66. uint32_t index;
  67. char destName[33];
  68. char sourceName[33];
  69. uint8_t state;
  70. FILE * fd;
  71. uint8_t data[250];
  72. uint8_t data_size;
  73. }GETFILE_IO_HELPER;
  74. typedef struct S_TEST_POINT{
  75. float x;
  76. float y;
  77. }TEST_POINT;
  78. class device2DSensor: public deviceNodeSensor, public basicThread, public protocolLGS_2D{
  79. private:
  80. //basicLogCollection * m_pLog;
  81. uint8_t m_bPortType;
  82. basicTransport * m_pPort;
  83. uint8_t m_bDeviceWM;
  84. uint32_t m_nSleepTime;
  85. uint16_t m_bTimeOutCounter;
  86. uint8_t m_bInitialFlips;
  87. uint16_t m_nCurrentAngle;
  88. uint8_t m_bDrawType;
  89. uint8_t m_bOpRetryCnt;
  90. uint32_t m_nProcessingCmdId;
  91. uint32_t m_vDrawRanges[ANODE_2D_MAX_DRAW_ANGLES];
  92. bool m_bDeviceIsSynced;
  93. bool m_bSerialStringValid;
  94. bool m_bVersionStringValid;
  95. char m_tSN[65];
  96. char m_tSV[129];
  97. char m_sCurrentFile[MAX_PATH];
  98. uint32_t m_nUploadID;
  99. uint8_t m_nActiveDetectionProfile;
  100. //Shadow
  101. SHADOW_IO_HELPER m_sShadowHelper;
  102. SHADOW m_sShadow;
  103. //GetFile
  104. GETFILE_IO_HELPER m_sGetFileHelper;
  105. TARGET_DATA * prepareTargetData( uint16_t AZ, uint16_t RANGE, uint32_t WIDTH, uint8_t LRFID = 0 );
  106. //void saveRawDrawData( uint16_t alngles );
  107. void cleanupDeviceStructures();
  108. CSTR generateSettingFile();
  109. void cleanShadowStructs();
  110. bool PtInPolygons( TEST_POINT& point, uint8_t F );
  111. bool PtInPolygon( SHADOW_POLY& Poly, TEST_POINT& point );
  112. bool rasterizeShadow();
  113. #ifdef DEBUG_EXTRA
  114. void makeShadowPic( CSTR picname );
  115. #endif
  116. protected:
  117. virtual bool packetHandler( protocolPackage *Package );
  118. virtual void m_fThreadProc( void );
  119. public:
  120. explicit device2DSensor( uint32_t id );
  121. ~device2DSensor();
  122. virtual bool startService();
  123. virtual bool stopService();
  124. virtual bool validate();
  125. virtual void simulateTarget( void );
  126. };
  127. #endif