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.

211 lines
4.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __PROTOCOLTGZ_H_INCL__
  2. #define __PROTOCOLTGZ_H_INCL__
  3. #include "../../components/base/basicTransport.h"
  4. #include "../../components/base/basicLogCollection.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. private:
  17. basicLogCollection *m_pLog;
  18. protected:
  19. //U8 m_bDeviceID;
  20. //U8 m_bHostID;
  21. unsigned int preparing;
  22. unsigned int lastSent;
  23. unsigned int lastReceived;
  24. bool m_bRun;
  25. bool m_bErrorReset;
  26. bool m_bVersion2;
  27. U8 m_bPRF;
  28. U8 m_bRatio;
  29. U8 m_bDivider;
  30. uint16_t m_nQFreq;
  31. uint16_t m_nBFreq;
  32. int packetChecker( U8 *Buffer, size_t BufferSize );
  33. protocolPackage *packetExtractor(U8 *Buffer, size_t BufferSize );
  34. basicTransport *m_oDataTransport;
  35. void update( void );
  36. public:
  37. // Constructor
  38. protocolTGZ();
  39. protocolTGZ( basicTransport *canBus );//, U8 MyID = 0, U8 PeerID = 0 );
  40. // Destructor
  41. virtual ~protocolTGZ();
  42. // Copy constructor
  43. // TODO: Uncomment the copy constructor when you need it.
  44. //protocolTGZ(const protocolTGZ& src);
  45. // Assignment operator
  46. // TODO: Uncomment the assignment operator when you need it.
  47. //protocolTGZ& operator=(const protocolTGZ& src);
  48. bool startDeviceStateInquiry( void );
  49. void setRunMode( bool mode ){
  50. m_bRun = mode;
  51. update();
  52. };
  53. void setPrfMode( uint8_t kHz ){
  54. m_bPRF = kHz;
  55. update();
  56. };
  57. void setRatio( uint8_t ratio ){
  58. m_bRatio = ratio;
  59. update();
  60. };
  61. void setDivider( uint8_t divider ){
  62. m_bDivider = divider;
  63. update();
  64. };
  65. void setErrorMode( bool reset ){
  66. m_bErrorReset = reset;
  67. update();
  68. };
  69. uint32_t getLastSend( void ){ return lastSent;};
  70. uint32_t getPreparing( void ){ return preparing;};
  71. uint32_t getLastReceived( void ){ return lastReceived; };
  72. uint8_t getRatio( void ){ return m_bRatio; };
  73. uint8_t getDivider( void ){ return m_bDivider; };
  74. uint8_t getPRF( void ){ return m_bPRF; };
  75. bool getRunFlag( void ){ return m_bRun; };
  76. bool getResetFlag( void ){ return m_bErrorReset; };
  77. uint16_t getQSpeed( void ){ return m_nQFreq; };
  78. uint16_t getBSpeed( void ){ return m_nBFreq; };
  79. void toggleRun( void ){m_bRun=(m_bRun)?false:true; update();};
  80. void toggleErrorReset( void ){m_bErrorReset=(m_bErrorReset)?false:true; update();};
  81. void toggleQSpeed( void ){
  82. m_bVersion2 = true;
  83. if(m_nQFreq==0) {
  84. m_nQFreq = 12000;
  85. }else if(m_nQFreq== 12000) {
  86. m_nQFreq = 26000;
  87. }else if(m_nQFreq==26000) {
  88. m_nQFreq = 40000;
  89. }else if(m_nQFreq==40000) {
  90. m_nQFreq = 12000;
  91. };
  92. update();
  93. };
  94. void toggleBSpeed( void ){
  95. m_bVersion2 = true;
  96. if(m_nBFreq==0) {
  97. m_nBFreq = 2944;
  98. }else if(m_nBFreq== 2944) {
  99. m_nBFreq = 5888;
  100. }else if(m_nBFreq==5888) {
  101. m_nBFreq = 8832;
  102. }else if(m_nQFreq==8832) {
  103. m_nBFreq = 2944;
  104. };
  105. update();
  106. };
  107. void togglePRF( void ){
  108. if(m_bPRF==0) {
  109. m_bPRF = 35;
  110. }else if(m_bPRF== 35) {
  111. m_bPRF = 45;
  112. }else if(m_bPRF==45) {
  113. m_bPRF = 50;
  114. }else if(m_bPRF==50) {
  115. m_bPRF = 35;
  116. };
  117. update();
  118. };
  119. void togleRatio( void ){
  120. if(m_bRatio==0) {
  121. m_bRatio = 64;
  122. } else if(m_bRatio==64) {
  123. m_bRatio = 72;
  124. } else if(m_bRatio==72) {
  125. m_bRatio = 98;
  126. } else if(m_bRatio==98) {
  127. m_bRatio = 128;
  128. } else if(m_bRatio==128) {
  129. m_bRatio = 64;
  130. };
  131. update();
  132. };
  133. void toggleDivider( void ){
  134. if(m_bDivider==0) {
  135. m_bDivider = 1;
  136. } else if(m_bDivider==1) {
  137. m_bDivider = 2;
  138. } else if(m_bDivider==2) {
  139. m_bDivider = 4;
  140. } else if(m_bDivider==4) {
  141. m_bDivider = 1;
  142. };
  143. update();
  144. };
  145. void stopPRF( void ){
  146. m_bPRF = 0;
  147. update();
  148. };
  149. void stopAzimuth( void ){
  150. m_bRatio = 0;
  151. update();
  152. };
  153. void setSpeeds( uint16_t QSpeed, uint16_t BSpeed ){
  154. m_bVersion2 = true;
  155. m_nBFreq = BSpeed;
  156. m_nQFreq = QSpeed;
  157. update();
  158. };
  159. char *generateFileNameForStat( void ){
  160. char *Buffer;
  161. Buffer = (char*)malloc(120);
  162. if(Buffer!=NULL) {
  163. sprintf( Buffer, "stat_%02dkHz_1-%02d_div_%02d.csv", m_bPRF, m_bRatio, m_bDivider );
  164. };
  165. return Buffer;
  166. };
  167. };
  168. // Constructor implementation
  169. inline protocolTGZ::protocolTGZ() : protocolParser(){
  170. m_pLog = basicLogCollection::getInstance();
  171. }
  172. // Destructor implementation
  173. inline protocolTGZ::~protocolTGZ()
  174. {
  175. }
  176. // TODO: Uncomment the copy constructor when you need it.
  177. //inline protocolTGZ::protocolTGZ(const protocolTGZ& src)
  178. //{
  179. // // TODO: copy
  180. //}
  181. // TODO: Uncomment the assignment operator when you need it.
  182. //inline protocolTGZ& protocolTGZ::operator=(const protocolTGZ& rhs)
  183. //{
  184. // if (this == &rhs) {
  185. // return *this;
  186. // }
  187. //
  188. // // TODO: assignment
  189. //
  190. // return *this;
  191. //}
  192. #endif // __PROTOCOLTGZ_H_INCL__