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.

325 lines
5.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __PROTOCOLTGZ_H_INCL__
  2. #define __PROTOCOLTGZ_H_INCL__
  3. #include "../../components/base/basicLogCollection.h"
  4. #include "../../components/base/basicTransport.h"
  5. #include "protocol.h"
  6. #define MASTER_TAG 0x80
  7. #define SENSOR_TAG 0x00
  8. #define SEND_TAG MASTER_TAG
  9. #define ACCEPT_TAG SENSOR_TAG
  10. /**
  11. * TODO: Add class description
  12. *
  13. * @author gagua
  14. */
  15. class protocolTGZ : public protocolParser
  16. {
  17. private:
  18. basicLogCollection * m_pLog;
  19. protected:
  20. // U8 m_bDeviceID;
  21. // U8 m_bHostID;
  22. unsigned int preparing;
  23. unsigned int lastSent;
  24. unsigned int lastReceived;
  25. bool m_bRun;
  26. bool m_bErrorReset;
  27. bool m_bVersion2;
  28. U8 m_bPRF;
  29. U8 m_bRatio;
  30. U8 m_bDivider;
  31. uint16_t m_nQFreq;
  32. uint16_t m_nBFreq;
  33. int packetChecker(U8 * Buffer, size_t BufferSize);
  34. protocolPackage * packetExtractor(U8 * Buffer, size_t BufferSize);
  35. basicTransport * m_oDataTransport;
  36. void update(void);
  37. public:
  38. // Constructor
  39. protocolTGZ();
  40. protocolTGZ(basicTransport * canBus); //, U8 MyID = 0, U8 PeerID = 0 );
  41. // Destructor
  42. virtual ~protocolTGZ();
  43. // Copy constructor
  44. // TODO: Uncomment the copy constructor when you need it.
  45. // protocolTGZ(const protocolTGZ& src);
  46. // Assignment operator
  47. // TODO: Uncomment the assignment operator when you need it.
  48. // protocolTGZ& operator=(const protocolTGZ& src);
  49. bool startDeviceStateInquiry(void);
  50. void setRunMode(bool mode)
  51. {
  52. m_bRun = mode;
  53. update();
  54. }
  55. void setPrfMode(uint8_t kHz)
  56. {
  57. m_bPRF = kHz;
  58. update();
  59. }
  60. void setRatio(uint8_t ratio)
  61. {
  62. m_bRatio = ratio;
  63. update();
  64. }
  65. void setDivider(uint8_t divider)
  66. {
  67. m_bDivider = divider;
  68. update();
  69. }
  70. void setErrorMode(bool reset)
  71. {
  72. m_bErrorReset = reset;
  73. update();
  74. }
  75. uint32_t getLastSend(void)
  76. {
  77. return lastSent;
  78. }
  79. uint32_t getPreparing(void)
  80. {
  81. return preparing;
  82. }
  83. uint32_t getLastReceived(void)
  84. {
  85. return lastReceived;
  86. }
  87. uint8_t getRatio(void)
  88. {
  89. return m_bRatio;
  90. }
  91. uint8_t getDivider(void)
  92. {
  93. return m_bDivider;
  94. }
  95. uint8_t getPRF(void)
  96. {
  97. return m_bPRF;
  98. }
  99. bool getRunFlag(void)
  100. {
  101. return m_bRun;
  102. }
  103. bool getResetFlag(void)
  104. {
  105. return m_bErrorReset;
  106. }
  107. uint16_t getQSpeed(void)
  108. {
  109. return m_nQFreq;
  110. }
  111. uint16_t getBSpeed(void)
  112. {
  113. return m_nBFreq;
  114. }
  115. void toggleRun(void)
  116. {
  117. m_bRun = (m_bRun) ? false : true;
  118. update();
  119. }
  120. void toggleErrorReset(void)
  121. {
  122. m_bErrorReset = (m_bErrorReset) ? false : true;
  123. update();
  124. }
  125. void toggleQSpeed(void)
  126. {
  127. m_bVersion2 = true;
  128. if (m_nQFreq == 0)
  129. {
  130. m_nQFreq = 12000;
  131. }
  132. else if (m_nQFreq == 12000)
  133. {
  134. m_nQFreq = 26000;
  135. }
  136. else if (m_nQFreq == 26000)
  137. {
  138. m_nQFreq = 40000;
  139. }
  140. else if (m_nQFreq == 40000)
  141. {
  142. m_nQFreq = 12000;
  143. };
  144. update();
  145. }
  146. void toggleBSpeed(void)
  147. {
  148. m_bVersion2 = true;
  149. if (m_nBFreq == 0)
  150. {
  151. m_nBFreq = 2944;
  152. }
  153. else if (m_nBFreq == 2944)
  154. {
  155. m_nBFreq = 5888;
  156. }
  157. else if (m_nBFreq == 5888)
  158. {
  159. m_nBFreq = 8832;
  160. }
  161. else if (m_nQFreq == 8832)
  162. {
  163. m_nBFreq = 2944;
  164. };
  165. update();
  166. }
  167. void togglePRF(void)
  168. {
  169. if (m_bPRF == 0)
  170. {
  171. m_bPRF = 35;
  172. }
  173. else if (m_bPRF == 35)
  174. {
  175. m_bPRF = 45;
  176. }
  177. else if (m_bPRF == 45)
  178. {
  179. m_bPRF = 50;
  180. }
  181. else if (m_bPRF == 50)
  182. {
  183. m_bPRF = 35;
  184. };
  185. update();
  186. }
  187. void togleRatio(void)
  188. {
  189. if (m_bRatio == 0)
  190. {
  191. m_bRatio = 64;
  192. }
  193. else if (m_bRatio == 64)
  194. {
  195. m_bRatio = 72;
  196. }
  197. else if (m_bRatio == 72)
  198. {
  199. m_bRatio = 98;
  200. }
  201. else if (m_bRatio == 98)
  202. {
  203. m_bRatio = 128;
  204. }
  205. else if (m_bRatio == 128)
  206. {
  207. m_bRatio = 64;
  208. };
  209. update();
  210. }
  211. void toggleDivider(void)
  212. {
  213. if (m_bDivider == 0)
  214. {
  215. m_bDivider = 1;
  216. }
  217. else if (m_bDivider == 1)
  218. {
  219. m_bDivider = 2;
  220. }
  221. else if (m_bDivider == 2)
  222. {
  223. m_bDivider = 4;
  224. }
  225. else if (m_bDivider == 4)
  226. {
  227. m_bDivider = 1;
  228. };
  229. update();
  230. }
  231. void stopPRF(void)
  232. {
  233. m_bPRF = 0;
  234. update();
  235. }
  236. void stopAzimuth(void)
  237. {
  238. m_bRatio = 0;
  239. update();
  240. }
  241. void setSpeeds(uint16_t QSpeed, uint16_t BSpeed)
  242. {
  243. m_bVersion2 = true;
  244. m_nBFreq = BSpeed;
  245. m_nQFreq = QSpeed;
  246. update();
  247. }
  248. char * generateFileNameForStat(void)
  249. {
  250. char * Buffer;
  251. Buffer = (char *) malloc(120);
  252. if (Buffer != NULL)
  253. {
  254. sprintf(Buffer, "stat_%02dkHz_1-%02d_div_%02d.csv", m_bPRF, m_bRatio, m_bDivider);
  255. };
  256. return Buffer;
  257. }
  258. };
  259. // Constructor implementation
  260. inline protocolTGZ::protocolTGZ() :
  261. protocolParser()
  262. {
  263. m_pLog = basicLogCollection::getInstance();
  264. }
  265. // Destructor implementation
  266. inline protocolTGZ::~protocolTGZ() {}
  267. // TODO: Uncomment the copy constructor when you need it.
  268. // inline protocolTGZ::protocolTGZ(const protocolTGZ& src)
  269. //{
  270. // // TODO: copy
  271. //}
  272. // TODO: Uncomment the assignment operator when you need it.
  273. // inline protocolTGZ& protocolTGZ::operator=(const protocolTGZ& rhs)
  274. //{
  275. // if (this == &rhs) {
  276. // return *this;
  277. // }
  278. //
  279. // // TODO: assignment
  280. //
  281. // return *this;
  282. //}
  283. #endif // __PROTOCOLTGZ_H_INCL__