gps_collect.cpp 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. #include "gps_collect.h"
  2. // General constants.
  3. #define NOUTPUT_PACKET_LENGTH (72) //!< NCom packet length.
  4. #define NCOM_SYNC (0xE7) //!< NCom sync byte.
  5. #define PKT_PERIOD (0.01) //!< 10ms updates.
  6. #define TIME2SEC (1e-3) //!< Units of 1 ms.
  7. #define FINETIME2SEC (4e-6) //!< Units of 4 us.
  8. #define TIMECYCLE (60000) //!< Units of TIME2SEC (i.e. 60 seconds).
  9. #define WEEK2CYCLES (10080) //!< Time cycles in a week.
  10. #define ACC2MPS2 (1e-4) //!< Units of 0.1 mm/s^2.
  11. #define RATE2RPS (1e-5) //!< Units of 0.01 mrad/s.
  12. #define VEL2MPS (1e-4) //!< Units of 0.1 mm/s.
  13. #define ANG2RAD (1e-6) //!< Units of 0.001 mrad.
  14. #define INNFACTOR (0.1) //!< Resolution of 0.1.
  15. #define POSA2M (1e-3) //!< Units of 1 mm.
  16. #define VELA2MPS (1e-3) //!< Units of 1 mm/s.
  17. #define ANGA2RAD (1e-5) //!< Units of 0.01 mrad.
  18. #define GB2RPS (5e-6) //!< Units of 0.005 mrad/s.
  19. #define AB2MPS2 (1e-4) //!< Units of 0.1 mm/s^2.
  20. #define GSFACTOR (1e-6) //!< Units of 1 ppm.
  21. #define ASFACTOR (1e-6) //!< Units of 1 ppm.
  22. #define GBA2RPS (1e-6) //!< Units of 0.001 mrad/s.
  23. #define ABA2MPS2 (1e-5) //!< Units of 0.01 mm/s^2.
  24. #define GSAFACTOR (1e-6) //!< Units of 1 ppm.
  25. #define ASAFACTOR (1e-6) //!< Units of 1 ppm.
  26. #define GPSPOS2M (1e-3) //!< Units of 1 mm.
  27. #define GPSATT2RAD (1e-4) //!< Units of 0.1 mrad.
  28. #define GPSPOSA2M (1e-4) //!< Units of 0.1 mm.
  29. #define GPSATTA2RAD (1e-5) //!< Units of 0.01 mrad.
  30. #define INNFACTOR (0.1) //!< Resolution of 0.1.
  31. #define DIFFAGE2SEC (1e-2) //!< Units of 0.01 s.
  32. #define REFPOS2M (0.0012) //!< Units of 1.2 mm.
  33. #define REFANG2RAD (1e-4) //!< Units of 0.1 mrad.
  34. #define OUTPOS2M (1e-3) //!< Units of 1 mm.
  35. #define ZVPOS2M (1e-3) //!< Units of 1 mm.
  36. #define ZVPOSA2M (1e-4) //!< Units of 0.1 mm.
  37. #define NSPOS2M (1e-3) //!< Units of 1 mm.
  38. #define NSPOSA2M (1e-4) //!< Units of 0.1 mm.
  39. #define ALIGN2RAD (1e-4) //!< Units of 0.1 mrad.
  40. #define ALIGNA2RAD (1e-5) //!< Units of 0.01 mrad.
  41. #define SZVDELAY2S (1.0) //!< Units of 1.0 s.
  42. #define SZVPERIOD2S (0.1) //!< Units of 0.1 s.
  43. #define TOPSPEED2MPS (0.5) //!< Units of 0.5 m/s.
  44. #define NSDELAY2S (0.1) //!< Units of 0.1 s.
  45. #define NSPERIOD2S (0.02) //!< Units of 0.02 s.
  46. #define NSACCEL2MPS2 (0.04) //!< Units of 0.04 m/s^2.
  47. #define NSSPEED2MPS (0.1) //!< Units of 0.1 m/s.
  48. #define NSRADIUS2M (0.5) //!< Units of 0.5 m.
  49. #define INITSPEED2MPS (0.1) //!< Units of 0.1 m/s.
  50. #define HLDELAY2S (1.0) //!< Units of 1.0 s.
  51. #define HLPERIOD2S (0.1) //!< Units of 0.1 s.
  52. #define STATDELAY2S (1.0) //!< Units of 1.0 s.
  53. #define STATSPEED2MPS (0.01) //!< Units of 1.0 cm/s.
  54. #define WSPOS2M (1e-3) //!< Units of 1 mm.
  55. #define WSPOSA2M (1e-4) //!< Units of 0.1 mm.
  56. #define WSSF2PPM (0.1) //!< Units of 0.1 pulse per metre (ppm).
  57. #define WSSFA2PC (0.002) //!< Units of 0.002% of scale factor.
  58. #define WSDELAY2S (0.1) //!< Units of 0.1 s.
  59. #define WSNOISE2CNT (0.1) //!< Units of 0.1 count for wheel speed noise.
  60. #define UNDUL2M (0.005) //!< Units of 5 mm.
  61. #define DOPFACTOR (0.1) //!< Resolution of 0.1.
  62. #define OMNISTAR_MIN_FREQ (1.52e9) //!< (Hz) i.e. 1520.0 MHz.
  63. #define OMNIFREQ2HZ (1000.0) //!< Resolution of 1 kHz.
  64. #define SNR2DB (0.2) //!< Resolution of 0.2 dB.
  65. #define LTIME2SEC (1.0) //!< Resolution of 1.0 s.
  66. #define TEMPK_OFFSET (203.15) //!< Temperature offset in degrees K.
  67. #define ABSZERO_TEMPC (-273.15) //!< Absolute zero (i.e. 0 deg K) in deg C.
  68. // For more accurate and complete local coordinates
  69. #define FINEANG2RAD (1.74532925199433e-9) //!< Units of 0.1 udeg.
  70. #define ALT2M (1e-3) //!< Units of 1 mm.
  71. // For GPS supply voltage
  72. #define SUPPLYV2V (0.1) //!< Units of 0.1 V.
  73. // Mathematical constant definitions
  74. #ifndef M_PI
  75. #define M_PI (3.1415926535897932384626433832795) //!< Pi.
  76. #endif
  77. #define DEG2RAD (M_PI/180.0) //!< Convert degrees to radians.
  78. #define RAD2DEG (180.0/M_PI) //!< Convert radians to degrees.
  79. #define POS_INT_24 (8388607) //!< Maximum value of a two's complement 24 bit integer.
  80. #define NEG_INT_24 (-8388607) //!< Minimum value of a two's complement 24 bit integer.
  81. #define INV_INT_24 (-8388608) //!< Represents an invalid two's complement 24 bit integer.
  82. #define NCOM_COUNT_TOO_OLD (150) //!< Cycle counter for data too old.
  83. #define NCOM_STDCNT_MAX (0xFF) //!< Definition for the RTBNS accuracy counter.
  84. #define MIN_HORZ_SPEED (0.07) //!< 0.07 m/s hold distance.
  85. #define MIN_VERT_SPEED (0.07) //!< 0.07 m/s hold distance.
  86. #define SPEED_HOLD_FACTOR (2.0) //!< Hold distance when speed within 2 sigma of 0.
  87. #define MINUTES_IN_WEEK (10080) //!< Number of minutes in a week.
  88. // OmniStar status definitions
  89. #define NCOM_OMNI_STATUS_UNKNOWN (0xFF)
  90. #define NCOM_OMNI_STATUS_VBSEXPIRED (0x01)
  91. #define NCOM_OMNI_STATUS_VBSREGION (0x02)
  92. #define NCOM_OMNI_STATUS_VBSNOBASE (0x04)
  93. #define NCOM_OMNI_STATUS_HPEXPIRED (0x08)
  94. #define NCOM_OMNI_STATUS_HPREGION (0x10)
  95. #define NCOM_OMNI_STATUS_HPNOBASE (0x20)
  96. #define NCOM_OMNI_STATUS_HPNOCONVERGE (0x40)
  97. #define NCOM_OMNI_STATUS_HPKEYINVALID (0x80)
  98. // GPS hardware status definitions
  99. #define NCOM_GPS_ANT_STATUS_BITMASK (0x03)
  100. #define NCOM_GPS_ANT_STATUS_DONTKNOW (0x03)
  101. #define NCOM_GPS_ANT_STATUS_BITSHIFT (0)
  102. #define NCOM_GPS_ANT_POWER_BITMASK (0x0C)
  103. #define NCOM_GPS_ANT_POWER_DONTKNOW (0x0C)
  104. #define NCOM_GPS_ANT_POWER_BITSHIFT (2)
  105. // GPS feature set 1 definitions
  106. #define NCOM_GPS_FEATURE_PSRDIFF (0x01)
  107. #define NCOM_GPS_FEATURE_SBAS (0x02)
  108. #define NCOM_GPS_FEATURE_OMNIVBS (0x08)
  109. #define NCOM_GPS_FEATURE_OMNIHP (0x10)
  110. #define NCOM_GPS_FEATURE_L1DIFF (0x20)
  111. #define NCOM_GPS_FEATURE_L1L2DIFF (0x40)
  112. // GPS feature set 2 definitions
  113. #define NCOM_GPS_FEATURE_GLONASS (0x01)
  114. #define NCOM_GPS_FEATURE_GALILEO (0x02)
  115. #define NCOM_GPS_FEATURE_RAWRNG (0x04)
  116. #define NCOM_GPS_FEATURE_RAWDOP (0x08)
  117. #define NCOM_GPS_FEATURE_RAWL1 (0x10)
  118. #define NCOM_GPS_FEATURE_RAWL2 (0x20)
  119. #define NCOM_GPS_FEATURE_RAWL5 (0x40)
  120. // GPS feature valid definition
  121. #define NCOM_GPS_FEATURE_VALID (0x80)
  122. // The start of GPS time in a time_t style. In this version it is a constant, but this constant assumes that
  123. // the local machine uses 00:00:00 01/01/1970 as its Epoch time. If your machine is different then you need to
  124. // convert 00:00:00 06/01/1980 in to the local machine's time_t time.
  125. #define GPS_TIME_START_TIME_T (315964800)
  126. // Second order filter class
  127. #define INPUT_JITTER_TOLERANCE (0.01) // i.e. 1%
  128. /*index*/
  129. #define PI_SYNC 0
  130. #define PI_TIME 1
  131. #define PI_ACCEL_X 3
  132. #define PI_ACCEL_Y 6
  133. #define PI_ACCEL_Z 9
  134. #define PI_ANG_RATE_X 12
  135. #define PI_ANG_RATE_Y 15
  136. #define PI_ANG_RATE_Z 18
  137. #define PI_INS_NAV_MODE 21
  138. #define PI_CHECKSUM_1 22
  139. #define PI_POS_LAT 23
  140. #define PI_POS_LON 31
  141. #define PI_POS_ALT 39
  142. #define PI_VEL_N 43
  143. #define PI_VEL_E 46
  144. #define PI_VEL_D 49
  145. #define PI_ORIEN_H 52
  146. #define PI_ORIEN_P 55
  147. #define PI_ORIEN_R 58
  148. #define PI_CHECKSUM_2 61
  149. #define PI_CHANNEL_INDEX 62
  150. #define PI_CHANNEL_STATUS 63
  151. #define PI_SAT_NUM 67
  152. #define PI_RTK_STATUS 68
  153. #define PI_CHECKSUM_3 71
  154. /*RTK IMU status check*/
  155. #define RTK_IMU_OK 0
  156. #define IMU_STATUS_ERR 1
  157. #define RTK_STATUS_ERR 2
  158. #define UNKNOWN 0xFF
  159. struct GPS_INS
  160. {
  161. int valid = 0xff;
  162. int index = 0; //gps点序号
  163. double gps_lat = 0;//纬度
  164. double gps_lng = 0;//经度
  165. double gps_x = 0;
  166. double gps_y = 0;
  167. double gps_z = 0;
  168. double ins_roll_angle = 0; //横滚角 一般定义载体的右、前、上三个方向构成右手系,绕向前的轴旋转就是横滚角,绕向右的轴旋转就是俯仰角,绕向上的轴旋转就是航向角
  169. double ins_pitch_angle = 0; //俯仰角
  170. double ins_heading_angle = 0; //航向角
  171. int ins_status = 0; //惯导状态 4
  172. int rtk_status = 0; //rtk状态 6 -5 -3
  173. int gps_satelites_num = 0;
  174. //-----加速度--------------
  175. double accel_x = 0;
  176. double accel_y = 0;
  177. double accel_z = 0;
  178. //-------角速度------------
  179. double ang_rate_x = 0;
  180. double ang_rate_y = 0;
  181. double ang_rate_z = 0;
  182. //-----------方向速度--------------
  183. double vel_N = 0;
  184. double vel_E = 0;
  185. double vel_D = 0;
  186. int speed_mode = 0;
  187. int mode2 = 0;
  188. double speed = 0; //速度 若导航点则为导航预设速度 若为当前点则为当前车速
  189. };
  190. typedef boost::shared_ptr<GPS_INS> GPSData;
  191. class CarStatus : public boost::noncopyable {
  192. public:
  193. float speed; //车速
  194. std::int16_t wheel_angle; //方向盘转角
  195. std::uint8_t braking_pressure; //刹车压力
  196. GPSData location; //当前车辆位置
  197. CarStatus() {
  198. speed = 0;
  199. braking_pressure = 0;
  200. wheel_angle = 0;
  201. location = boost::shared_ptr<GPS_INS>(new GPS_INS);
  202. }
  203. ~CarStatus() {
  204. }
  205. };
  206. typedef boost::serialization::singleton<CarStatus> CarStatusSingleton;
  207. #define ServiceCarStatus CarStatusSingleton::get_mutable_instance()
  208. static double cast_8_byte_to_double(const uint8_t *b);
  209. static int32_t cast_3_byte_to_int32(const uint8_t *b);
  210. GPSSensor::GPSSensor() {
  211. }
  212. GPSSensor::~GPSSensor() {
  213. }
  214. void GPSSensor::start()
  215. {
  216. thread_sensor_run_ = new boost::thread(boost::bind(&GPSSensor::processSensor, this));
  217. }
  218. void GPSSensor::stop()
  219. {
  220. thread_sensor_run_->interrupt();
  221. thread_sensor_run_->join();
  222. }
  223. void GPSSensor::obs_modechange(int rec)
  224. {
  225. _mtx.lock();
  226. obs_modes = rec;
  227. _mtx.unlock();
  228. }
  229. void GPSSensor::speed_modechange(int rec)
  230. {
  231. _mtx.lock();
  232. speed_modes = rec;
  233. _mtx.unlock();
  234. }
  235. void GPSSensor::lane_num_modechange(int rec)
  236. {
  237. _mtx.lock();
  238. lane_num = rec;
  239. _mtx.unlock();
  240. }
  241. void GPSSensor::lane_status_modechange(int rec)
  242. {
  243. _mtx.lock();
  244. lane_status = rec;
  245. _mtx.unlock();
  246. }
  247. void GPSSensor::start_or_end(bool rec)
  248. {
  249. _mtx2.lock();
  250. writegps = rec;
  251. _mtx2.unlock();
  252. }
  253. void GPSSensor::collect_modechange(bool rec)
  254. {
  255. _mtx3.lock();
  256. is_forbidden = rec;
  257. _mtx3.unlock();
  258. }
  259. void GPSSensor::jianju_change(double rec)
  260. {
  261. _mtx4.lock();
  262. jianju = rec;
  263. _mtx4.unlock();
  264. }
  265. bool GPSSensor::isRunning() const
  266. {
  267. return (thread_sensor_run_ != NULL && !thread_sensor_run_->timed_join(boost::posix_time::milliseconds(10)));
  268. }
  269. void GPSSensor::processSensor()
  270. {
  271. //todo GPS/惯导 设备接口 对接
  272. /*Initialize udp server, listen on port 3000.*/
  273. /*int sockfd;
  274. struct sockaddr_in addr;
  275. socklen_t addrlen;
  276. sockfd = socket(AF_INET, SOCK_DGRAM, 0);
  277. if (sockfd < 0)
  278. {
  279. printf("socket failed\n");
  280. exit(EXIT_FAILURE);
  281. }
  282. addrlen = sizeof(struct sockaddr_in);
  283. bzero(&addr, addrlen);
  284. addr.sin_family = AF_INET;
  285. addr.sin_addr.s_addr = htonl(INADDR_ANY);
  286. addr.sin_port = htons(3000);
  287. if (bind(sockfd, (struct sockaddr*)(&addr), addrlen) < 0)
  288. {
  289. printf("bind fail\n");
  290. exit(EXIT_FAILURE);
  291. }*/
  292. QUdpSocket *udpsocket;//summer
  293. udpsocket = new QUdpSocket();
  294. udpsocket->bind(QHostAddress::Any, 3000);
  295. /* udpsocket->bind(3000);
  296. if(!udpsocket->waitForConnected())
  297. {
  298. printf("bind fail\n");
  299. exit(EXIT_FAILURE);
  300. }
  301. */
  302. unsigned char recvBuf[100] = { 0 };
  303. GPSData data(new GPS_INS);
  304. int x;
  305. ServiceCarStatus.location->gps_x = 0;
  306. ServiceCarStatus.location->gps_y = 0;
  307. std::string sk;
  308. std::stringstream ss;
  309. while (true)
  310. {
  311. ss.clear();
  312. ss.str("");
  313. sk.clear();
  314. gps_index = 0;
  315. testcount = 0;
  316. _mtx2.lock();
  317. while (writegps == false)
  318. {
  319. _mtx2.unlock();
  320. if(should_exit == true)
  321. {
  322. udpsocket->close();
  323. ready_exit++;
  324. return;
  325. }
  326. //boost::this_thread::sleep(boost::posix_time::milliseconds(10));
  327. #ifdef linux
  328. usleep(10000);
  329. #endif
  330. #ifdef WIN32
  331. boost::this_thread::sleep(boost::posix_time::milliseconds(10));
  332. // Sleep(10);
  333. #endif
  334. _mtx2.lock();
  335. }
  336. std::ofstream fout;
  337. fout.setf(std::ios::fixed, std::ios::floatfield); // 设定为 fixed 模式,以小数点表示浮点数
  338. fout.precision(12); // 设置精度 2
  339. time_t now;
  340. struct tm *timenow;
  341. time(&now);
  342. timenow = localtime(&now);
  343. ss << "/home/adc/" << timenow->tm_year+1900 << "-" << timenow->tm_mon+1 << "-" << timenow->tm_mday << "-" << timenow->tm_hour << "h-" << timenow->tm_min << "m-" << timenow->tm_sec << "s.txt";
  344. sk = ss.str();
  345. fout.open(sk);
  346. while (writegps) {
  347. _mtx2.unlock();
  348. if(should_exit == true)
  349. {
  350. udpsocket->close();
  351. fout.close();
  352. ready_exit++;
  353. return;
  354. }
  355. char *buf = new char[100];
  356. memset(buf,0,100);
  357. int rec = 0;
  358. if(udpsocket->waitForReadyRead())
  359. rec = udpsocket->read(buf,100);
  360. convertStrToUnChar(buf,recvBuf);
  361. //int rec = recvfrom(sockfd, recvBuf, 100, 0, (struct sockaddr *)(&addr), &addrlen);
  362. if (rec != NOUTPUT_PACKET_LENGTH) {
  363. std::cout << "ERR: rec must be 72 bytes\n" << std::endl;
  364. continue;
  365. }
  366. if (recvBuf[PI_SYNC] != NCOM_SYNC) {
  367. std::cout << "ERR: head always be 0xE7\n" << std::endl;
  368. continue;
  369. }
  370. data->gps_lat = cast_8_byte_to_double(recvBuf + PI_POS_LAT) * RAD2DEG;
  371. data->gps_lng = cast_8_byte_to_double(recvBuf + PI_POS_LON) * RAD2DEG;
  372. x = cast_3_byte_to_int32(recvBuf + PI_ORIEN_H);
  373. if (x != INV_INT_24) data->ins_heading_angle = x * (ANG2RAD * RAD2DEG);
  374. if (data->ins_heading_angle < 0.0)
  375. {
  376. data->ins_heading_angle += 360.0;
  377. }
  378. if (abs(data->gps_lng - 117.0) < 5)
  379. {
  380. ServiceCarStatus.location->gps_lat = data->gps_lat;
  381. ServiceCarStatus.location->gps_lng = data->gps_lng;
  382. ServiceCarStatus.location->ins_heading_angle = data->ins_heading_angle;
  383. if (testcount < 1000)
  384. {
  385. testcount++;
  386. }
  387. else
  388. {
  389. double x = (ServiceCarStatus.location->gps_x - data->gps_x)*(ServiceCarStatus.location->gps_x - data->gps_x) + (ServiceCarStatus.location->gps_y - data->gps_y)*(ServiceCarStatus.location->gps_y - data->gps_y);
  390. if (x > (jianju*jianju))
  391. {
  392. if (is_forbidden == false)
  393. {
  394. _mtx.try_lock();
  395. fout << gps_index << "\t" << data->gps_lng << "\t" << data->gps_lat << "\t" << ServiceCarStatus.location->speed_mode << "\t" << ServiceCarStatus.location->mode2 << "\t" << data->ins_heading_angle << "\t" << obs_modes << "\t" << speed_modes << "\t" << lane_num << "\t" << lane_status << std::endl;
  396. _mtx.unlock();
  397. }
  398. else
  399. {
  400. _mtx.try_lock();
  401. fout << gps_index << "\t" << data->gps_lng << "\t" << data->gps_lat << "\t" << ServiceCarStatus.location->speed_mode << "\t" << ServiceCarStatus.location->mode2 << "\t" << data->ins_heading_angle << std::endl;
  402. _mtx.unlock();
  403. }
  404. gps_index++;
  405. ServiceCarStatus.location->gps_x = data->gps_x;
  406. ServiceCarStatus.location->gps_y = data->gps_y;
  407. }
  408. }
  409. }
  410. _mtx2.lock();
  411. }
  412. _mtx2.unlock();
  413. fout.close(); //关闭文件
  414. }
  415. udpsocket->close();
  416. }
  417. void GPSSensor::wait_exit()
  418. {
  419. while(true)
  420. {
  421. should_exit = true;
  422. #ifdef linux
  423. usleep(5000);
  424. #endif
  425. #ifdef WIN32
  426. boost::this_thread::sleep(boost::posix_time::milliseconds(5));
  427. // Sleep(5);
  428. #endif
  429. if(ready_exit == 1)
  430. {
  431. return;
  432. }
  433. }
  434. }
  435. static double cast_8_byte_to_double(const uint8_t *b)
  436. {
  437. union { double x; uint8_t c[8]; } u;
  438. u.c[0] = b[0];
  439. u.c[1] = b[1];
  440. u.c[2] = b[2];
  441. u.c[3] = b[3];
  442. u.c[4] = b[4];
  443. u.c[5] = b[5];
  444. u.c[6] = b[6];
  445. u.c[7] = b[7];
  446. return u.x;
  447. }
  448. static int32_t cast_3_byte_to_int32(const uint8_t *b)
  449. {
  450. union { int32_t x; uint8_t c[4]; } u;
  451. u.c[1] = b[0];
  452. u.c[2] = b[1];
  453. u.c[3] = b[2];
  454. return u.x >> 8;
  455. }
  456. GPS_Collect::GPS_Collect(QWidget *parent):
  457. QWidget(parent)
  458. {
  459. //gps_collector_close = new boost::signals2::signal<void()>();
  460. this->setObjectName(QStringLiteral("GPS_Collector"));
  461. this->resize(800, 700);
  462. frame = new QFrame(this);
  463. frame->setObjectName(QStringLiteral("frame"));
  464. frame->setGeometry(QRect(440, 390, 120, 80));
  465. frame->setFrameShape(QFrame::StyledPanel);
  466. frame->setFrameShadow(QFrame::Raised);
  467. label = new QLabel(this);
  468. label->setObjectName(QStringLiteral("label"));
  469. label->setGeometry(QRect(20, 20, 90, 35));
  470. comboBox = new QComboBox(this);
  471. comboBox->setObjectName(QStringLiteral("comboBox"));
  472. comboBox->setGeometry(QRect(120, 60, 100, 35));
  473. QFont font;
  474. font.setPointSize(16);
  475. comboBox->setFont(font);
  476. label_2 = new QLabel(this);
  477. label_2->setObjectName(QStringLiteral("label_2"));
  478. label_2->setGeometry(QRect(20, 60, 90, 35));
  479. lineEdit = new QLineEdit(this);
  480. lineEdit->setObjectName(QStringLiteral("lineEdit"));
  481. lineEdit->setGeometry(QRect(120, 20, 100, 35));
  482. lineEdit->setFont(font);
  483. lineEdit->setAlignment(Qt::AlignCenter);
  484. label_3 = new QLabel(this);
  485. label_3->setObjectName(QStringLiteral("label_3"));
  486. label_3->setGeometry(QRect(270, 20, 30, 16));
  487. label_4 = new QLabel(this);
  488. label_4->setObjectName(QStringLiteral("label_4"));
  489. label_4->setGeometry(QRect(270, 40, 30, 16));
  490. label_5 = new QLabel(this);
  491. label_5->setObjectName(QStringLiteral("label_5"));
  492. label_5->setGeometry(QRect(270, 60, 60, 16));
  493. label_6 = new QLabel(this);
  494. label_6->setObjectName(QStringLiteral("label_6"));
  495. label_6->setGeometry(QRect(440, 20, 80, 16));
  496. label_7 = new QLabel(this);
  497. label_7->setObjectName(QStringLiteral("label_7"));
  498. label_7->setGeometry(QRect(440, 80, 80, 16));
  499. label_8 = new QLabel(this);
  500. label_8->setObjectName(QStringLiteral("label_8"));
  501. label_8->setGeometry(QRect(440, 40, 80, 16));
  502. label_9 = new QLabel(this);
  503. label_9->setObjectName(QStringLiteral("label_9"));
  504. label_9->setGeometry(QRect(440, 60, 80, 16));
  505. lineEdit_2 = new QLineEdit(this);
  506. lineEdit_2->setObjectName(QStringLiteral("lineEdit_2"));
  507. lineEdit_2->setGeometry(QRect(310, 20, 120, 20));
  508. lineEdit_3 = new QLineEdit(this);
  509. lineEdit_3->setObjectName(QStringLiteral("lineEdit_3"));
  510. lineEdit_3->setGeometry(QRect(310, 40, 120, 20));
  511. lineEdit_4 = new QLineEdit(this);
  512. lineEdit_4->setObjectName(QStringLiteral("lineEdit_4"));
  513. lineEdit_4->setGeometry(QRect(340, 60, 90, 20));
  514. lineEdit_5 = new QLineEdit(this);
  515. lineEdit_5->setObjectName(QStringLiteral("lineEdit_5"));
  516. lineEdit_5->setGeometry(QRect(520, 20, 90, 20));
  517. lineEdit_6 = new QLineEdit(this);
  518. lineEdit_6->setObjectName(QStringLiteral("lineEdit_6"));
  519. lineEdit_6->setGeometry(QRect(520, 40, 90, 20));
  520. lineEdit_7 = new QLineEdit(this);
  521. lineEdit_7->setObjectName(QStringLiteral("lineEdit_7"));
  522. lineEdit_7->setGeometry(QRect(520, 60, 90, 20));
  523. lineEdit_8 = new QLineEdit(this);
  524. lineEdit_8->setObjectName(QStringLiteral("lineEdit_8"));
  525. lineEdit_8->setGeometry(QRect(520, 80, 90, 20));
  526. this->setWindowTitle(QApplication::translate("GPS_Collector", "GPS_Collector", nullptr));
  527. label->setText(QApplication::translate("GPS_Collector", "\351\207\207\351\233\206\347\202\271\351\227\264\350\267\235(m)", nullptr));
  528. label_2->setText(QApplication::translate("GPS_Collector", "\347\246\201\347\224\250\351\231\204\345\212\240\345\261\236\346\200\247", nullptr));
  529. label_3->setText(QApplication::translate("GPS_Collector", "\347\273\217\345\272\246", nullptr));
  530. label_4->setText(QApplication::translate("GPS_Collector", "\347\272\254\345\272\246", nullptr));
  531. label_5->setText(QApplication::translate("GPS_Collector", "\345\267\262\351\207\207\351\233\206\347\202\271\346\225\260", nullptr));
  532. label_6->setText(QApplication::translate("GPS_Collector", "\351\201\277\351\232\234\346\250\241\345\274\217", nullptr));
  533. label_7->setText(QApplication::translate("GPS_Collector", "\346\211\200\345\234\250\350\275\246\351\201\223", nullptr));
  534. label_8->setText(QApplication::translate("GPS_Collector", "\351\200\237\345\272\246\346\216\247\345\210\266\346\250\241\345\274\217", nullptr));
  535. label_9->setText(QApplication::translate("GPS_Collector", "\350\275\246\351\201\223\346\200\273\346\225\260", nullptr));
  536. pushButtonstart = new QPushButton(this);
  537. pushButtonstart->setObjectName(QStringLiteral("pushButtonstart"));
  538. pushButtonstart->setGeometry(QRect(630, 11, 158, 50));
  539. pushButtonstart->setText("start");
  540. connect(pushButtonstart, SIGNAL(clicked()), this, SLOT(ClickButton_start()));
  541. pushButtonend = new QPushButton(this);
  542. pushButtonend->setObjectName(QStringLiteral("pushButtonend"));
  543. pushButtonend->setGeometry(QRect(630, 70, 158, 50));
  544. pushButtonend->setText("end");
  545. connect(pushButtonend, SIGNAL(clicked()), this, SLOT(ClickButton_end()));
  546. pushButton0 = new QPushButton(this);
  547. pushButton0->setObjectName(QStringLiteral("pushButton0"));
  548. pushButton0->setGeometry(QRect(20, 130, 192, 93));
  549. pushButton0->setText(QStringLiteral("停障"));
  550. connect(pushButton0, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_0()));
  551. pushButton1 = new QPushButton(this);
  552. pushButton1->setObjectName(QStringLiteral("pushButton1"));
  553. pushButton1->setGeometry(QRect(20, 223, 192, 93));
  554. pushButton1->setText(QStringLiteral("避障"));
  555. connect(pushButton1, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_1()));
  556. pushButton2 = new QPushButton(this);
  557. pushButton2->setObjectName(QStringLiteral("pushButton2"));
  558. pushButton2->setGeometry(QRect(20, 316, 192, 93));
  559. pushButton2->setText(QStringLiteral("不停不避"));
  560. connect(pushButton2, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_2()));
  561. pushButton33 = new QPushButton(this);
  562. pushButton33->setObjectName(QStringLiteral("pushButton33"));
  563. pushButton33->setGeometry(QRect(20, 409, 192, 93));
  564. pushButton33->setText(QStringLiteral("保留"));
  565. connect(pushButton33, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_33()));
  566. pushButton34 = new QPushButton(this);
  567. pushButton34->setObjectName(QStringLiteral("pushButton34"));
  568. pushButton34->setGeometry(QRect(20, 502, 192, 93));
  569. pushButton34->setText(QStringLiteral("保留"));
  570. connect(pushButton34, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_34()));
  571. pushButton3 = new QPushButton(this);
  572. pushButton3->setObjectName(QStringLiteral("pushButton3"));
  573. pushButton3->setGeometry(QRect(212, 130, 96, 46));
  574. pushButton3->setText(QStringLiteral("常速行驶"));
  575. connect(pushButton3, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_3()));
  576. pushButton4 = new QPushButton(this);
  577. pushButton4->setObjectName(QStringLiteral("pushButton4"));
  578. pushButton4->setGeometry(QRect(308, 130, 96, 46));
  579. pushButton4->setText(QStringLiteral("入口"));
  580. connect(pushButton4, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_4()));
  581. pushButton5 = new QPushButton(this);
  582. pushButton5->setObjectName(QStringLiteral("pushButton5"));
  583. pushButton5->setGeometry(QRect(212, 176, 96, 47));
  584. pushButton5->setText(QStringLiteral("事故区"));
  585. connect(pushButton5, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_5()));
  586. pushButton6 = new QPushButton(this);
  587. pushButton6->setObjectName(QStringLiteral("pushButton6"));
  588. pushButton6->setGeometry(QRect(308, 176, 96, 47));
  589. pushButton6->setText(QStringLiteral("驻车点"));
  590. connect(pushButton6, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_6()));
  591. pushButton7 = new QPushButton(this);
  592. pushButton7->setObjectName(QStringLiteral("pushButton7"));
  593. pushButton7->setGeometry(QRect(212, 223, 96, 46));
  594. pushButton7->setText(QStringLiteral("隧道"));
  595. connect(pushButton7, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_7()));
  596. pushButton18 = new QPushButton(this);
  597. pushButton18->setObjectName(QStringLiteral("pushButton18"));
  598. pushButton18->setGeometry(QRect(308, 223, 96, 46));
  599. pushButton18->setText(QStringLiteral("低速"));
  600. connect(pushButton18, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_18()));
  601. pushButton19 = new QPushButton(this);
  602. pushButton19->setObjectName(QStringLiteral("pushButton19"));
  603. pushButton19->setGeometry(QRect(212, 269, 96, 47));
  604. pushButton19->setText(QStringLiteral("红绿灯"));
  605. connect(pushButton19, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_19()));
  606. pushButton20 = new QPushButton(this);
  607. pushButton20->setObjectName(QStringLiteral("pushButton20"));
  608. pushButton20->setGeometry(QRect(308, 269, 96, 47));
  609. pushButton20->setText(QStringLiteral("行人"));
  610. connect(pushButton20, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_20()));
  611. pushButton21 = new QPushButton(this);
  612. pushButton21->setObjectName(QStringLiteral("pushButton21"));
  613. pushButton21->setGeometry(QRect(212, 316, 96, 46));
  614. pushButton21->setText(QStringLiteral("雾区"));
  615. connect(pushButton21, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_21()));
  616. pushButton22 = new QPushButton(this);
  617. pushButton22->setObjectName(QStringLiteral("pushButton22"));
  618. pushButton22->setGeometry(QRect(308, 316, 96, 46));
  619. pushButton22->setText(QStringLiteral("变道停车"));
  620. connect(pushButton22, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_22()));
  621. pushButton23 = new QPushButton(this);
  622. pushButton23->setObjectName(QStringLiteral("pushButton23"));
  623. pushButton23->setGeometry(QRect(212, 362, 96, 47));
  624. pushButton23->setText(QStringLiteral("等人停车"));
  625. connect(pushButton23, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_23()));
  626. pushButton24 = new QPushButton(this);
  627. pushButton24->setObjectName(QStringLiteral("pushButton24"));
  628. pushButton24->setGeometry(QRect(308, 362, 96, 47));
  629. pushButton24->setText(QStringLiteral("疯狂加速"));
  630. connect(pushButton24, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_24()));
  631. pushButton25 = new QPushButton(this);
  632. pushButton25->setObjectName(QStringLiteral("pushButton25"));
  633. pushButton25->setGeometry(QRect(212, 409, 96, 46));
  634. pushButton25->setText(QStringLiteral("跟随"));
  635. connect(pushButton25, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_25()));
  636. pushButton26 = new QPushButton(this);
  637. pushButton26->setObjectName(QStringLiteral("pushButton26"));
  638. pushButton26->setGeometry(QRect(308, 409, 96, 46));
  639. pushButton26->setText(QStringLiteral("保留"));
  640. connect(pushButton26, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_26()));
  641. pushButton27 = new QPushButton(this);
  642. pushButton27->setObjectName(QStringLiteral("pushButton27"));
  643. pushButton27->setGeometry(QRect(212, 455, 96, 47));
  644. pushButton27->setText(QStringLiteral("保留"));
  645. connect(pushButton27, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_27()));
  646. pushButton28 = new QPushButton(this);
  647. pushButton28->setObjectName(QStringLiteral("pushButton28"));
  648. pushButton28->setGeometry(QRect(308, 455, 96, 47));
  649. pushButton28->setText(QStringLiteral("保留"));
  650. connect(pushButton28, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_28()));
  651. pushButton29 = new QPushButton(this);
  652. pushButton29->setObjectName(QStringLiteral("pushButton29"));
  653. pushButton29->setGeometry(QRect(212, 502, 96, 46));
  654. pushButton29->setText(QStringLiteral("保留"));
  655. connect(pushButton29, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_29()));
  656. pushButton30 = new QPushButton(this);
  657. pushButton30->setObjectName(QStringLiteral("pushButton30"));
  658. pushButton30->setGeometry(QRect(308, 502, 96, 46));
  659. pushButton30->setText(QStringLiteral("保留"));
  660. connect(pushButton30, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_30()));
  661. pushButton31 = new QPushButton(this);
  662. pushButton31->setObjectName(QStringLiteral("pushButton31"));
  663. pushButton31->setGeometry(QRect(212, 548, 96, 47));
  664. pushButton31->setText(QStringLiteral("保留"));
  665. connect(pushButton31, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_31()));
  666. pushButton32 = new QPushButton(this);
  667. pushButton32->setObjectName(QStringLiteral("pushButton32"));
  668. pushButton32->setGeometry(QRect(308, 548, 96, 47));
  669. pushButton32->setText(QStringLiteral("保留"));
  670. connect(pushButton32, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_32()));
  671. pushButton8 = new QPushButton(this);
  672. pushButton8->setObjectName(QStringLiteral("pushButton8"));
  673. pushButton8->setGeometry(QRect(404, 130, 192, 93));
  674. pushButton8->setText(QStringLiteral("单车道"));
  675. connect(pushButton8, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_8()));
  676. pushButton9 = new QPushButton(this);
  677. pushButton9->setObjectName(QStringLiteral("pushButton9"));
  678. pushButton9->setGeometry(QRect(404, 223, 192, 93));
  679. pushButton9->setText(QStringLiteral("双车道"));
  680. connect(pushButton9, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_9()));
  681. pushButton10 = new QPushButton(this);
  682. pushButton10->setObjectName(QStringLiteral("pushButton10"));
  683. pushButton10->setGeometry(QRect(404, 316, 192, 93));
  684. pushButton10->setText(QStringLiteral("三车道"));
  685. connect(pushButton10, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_10()));
  686. pushButton11 = new QPushButton(this);
  687. pushButton11->setObjectName(QStringLiteral("pushButton11"));
  688. pushButton11->setGeometry(QRect(404, 409, 192, 93));
  689. pushButton11->setText(QStringLiteral("四车道"));
  690. connect(pushButton11, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_11()));
  691. pushButton12 = new QPushButton(this);
  692. pushButton12->setObjectName(QStringLiteral("pushButton12"));
  693. pushButton12->setGeometry(QRect(404, 502, 192, 93));
  694. pushButton12->setText(QStringLiteral("五车道"));
  695. connect(pushButton12, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_12()));
  696. pushButton13 = new QPushButton(this);
  697. pushButton13->setObjectName(QStringLiteral("pushButton13"));
  698. pushButton13->setGeometry(QRect(596, 130, 192, 93));
  699. pushButton13->setText(QStringLiteral("在车道0"));
  700. connect(pushButton13, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_13()));
  701. pushButton14 = new QPushButton(this);
  702. pushButton14->setObjectName(QStringLiteral("pushButton0"));
  703. pushButton14->setGeometry(QRect(596, 223, 192, 93));
  704. pushButton14->setText(QStringLiteral("在车道1"));
  705. connect(pushButton14, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_14()));
  706. pushButton15 = new QPushButton(this);
  707. pushButton15->setObjectName(QStringLiteral("pushButton0"));
  708. pushButton15->setGeometry(QRect(596, 316, 192, 93));
  709. pushButton15->setText(QStringLiteral("在车道2"));
  710. connect(pushButton15, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_15()));
  711. pushButton16 = new QPushButton(this);
  712. pushButton16->setObjectName(QStringLiteral("pushButton0"));
  713. pushButton16->setGeometry(QRect(596, 409, 192, 93));
  714. pushButton16->setText(QStringLiteral("在车道3"));
  715. connect(pushButton16, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_16()));
  716. pushButton17 = new QPushButton(this);
  717. pushButton17->setObjectName(QStringLiteral("pushButton0"));
  718. pushButton17->setGeometry(QRect(596, 502, 192, 93));
  719. pushButton17->setText(QStringLiteral("在车道4"));
  720. connect(pushButton17, SIGNAL(clicked()), this, SLOT(ClickButton_nomall_17()));
  721. lineEdit->setText(QStringLiteral("0.1"));
  722. connect(lineEdit, SIGNAL(textEdited(const QString &)), this, SLOT(savestabuyEditinfo(const QString &)));
  723. comboBox->addItem(QStringLiteral(" 禁用"));
  724. comboBox->addItem(QStringLiteral(" 不禁用"));
  725. connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(mycombox(const QString &)));
  726. timer = new QTimer(this);
  727. connect(timer, SIGNAL(timeout()), this, SLOT(timeoutslot1()));
  728. connect(timer, SIGNAL(timeout()), this, SLOT(timeoutslot2()));
  729. timer->start(20);
  730. sensor_gps = new GPSSensor();
  731. sensor_gps->start();
  732. }
  733. GPS_Collect::~GPS_Collect()
  734. {
  735. }
  736. //刷新
  737. void GPS_Collect::paintEvent(QPaintEvent *)
  738. {
  739. }
  740. void GPS_Collect::savestabuyEditinfo(const QString &txt)
  741. {
  742. jianju = txt.toDouble();
  743. if (jianju > 0.01)
  744. {
  745. sensor_gps->jianju_change(jianju);
  746. }
  747. }
  748. void GPS_Collect::mycombox(const QString &txt)
  749. {
  750. if (txt == QStringLiteral(" 禁用"))
  751. {
  752. is_forbidden = true;
  753. }
  754. else
  755. {
  756. is_forbidden = false;
  757. }
  758. sensor_gps->collect_modechange(is_forbidden);
  759. }
  760. void GPS_Collect::timeoutslot1()
  761. {
  762. //update();
  763. }
  764. void GPS_Collect::timeoutslot2()
  765. {
  766. lineEdit_2->setText(QString::number(ServiceCarStatus.location->gps_lng));
  767. lineEdit_3->setText(QString::number(ServiceCarStatus.location->gps_lat));
  768. lineEdit_4->setText(QString::number(sensor_gps->gps_index));
  769. lineEdit_5->setText(QString::number(obs_modes));
  770. lineEdit_6->setText(QString::number(speed_modes));
  771. lineEdit_7->setText(QString::number(lane_num));
  772. lineEdit_8->setText(QString::number(lane_status));
  773. }
  774. void GPS_Collect::ClickButton_start()
  775. {
  776. starts = true;
  777. sensor_gps->start_or_end(starts);
  778. }
  779. void GPS_Collect::ClickButton_end()
  780. {
  781. starts = false;
  782. sensor_gps->start_or_end(starts);
  783. }
  784. /////////////////////////////////////////////////////
  785. void GPS_Collect::ClickButton_nomall_0()
  786. {
  787. obs_modes = 0;
  788. sensor_gps->obs_modechange(obs_modes);
  789. }
  790. void GPS_Collect::ClickButton_nomall_1()
  791. {
  792. obs_modes = 1;
  793. sensor_gps->obs_modechange(obs_modes);
  794. }
  795. void GPS_Collect::ClickButton_nomall_2()
  796. {
  797. obs_modes = 2;
  798. sensor_gps->obs_modechange(obs_modes);
  799. }
  800. ////////////////////////////////////////////////////////
  801. void GPS_Collect::ClickButton_nomall_3()
  802. {
  803. speed_modes = 0;
  804. sensor_gps->speed_modechange(speed_modes);
  805. }
  806. void GPS_Collect::ClickButton_nomall_4()
  807. {
  808. speed_modes = 1;
  809. sensor_gps->speed_modechange(speed_modes);
  810. }
  811. void GPS_Collect::ClickButton_nomall_5()
  812. {
  813. speed_modes = 2;
  814. sensor_gps->speed_modechange(speed_modes);
  815. }
  816. void GPS_Collect::ClickButton_nomall_6()
  817. {
  818. speed_modes = 3;
  819. sensor_gps->speed_modechange(speed_modes);
  820. }
  821. void GPS_Collect::ClickButton_nomall_7()
  822. {
  823. speed_modes = 4;
  824. sensor_gps->speed_modechange(speed_modes);
  825. }
  826. /////////////////////////////////////////////////////////
  827. void GPS_Collect::ClickButton_nomall_8()
  828. {
  829. lane_num = 1;
  830. sensor_gps->lane_num_modechange(lane_num);
  831. }
  832. void GPS_Collect::ClickButton_nomall_9()
  833. {
  834. lane_num = 2;
  835. sensor_gps->lane_num_modechange(lane_num);
  836. }
  837. void GPS_Collect::ClickButton_nomall_10()
  838. {
  839. lane_num = 3;
  840. sensor_gps->lane_num_modechange(lane_num);
  841. }
  842. void GPS_Collect::ClickButton_nomall_11()
  843. {
  844. lane_num = 4;
  845. sensor_gps->lane_num_modechange(lane_num);
  846. }
  847. void GPS_Collect::ClickButton_nomall_12()
  848. {
  849. lane_num = 5;
  850. sensor_gps->lane_num_modechange(lane_num);
  851. }
  852. //////////////////////////////////////////////////////////
  853. void GPS_Collect::ClickButton_nomall_13()
  854. {
  855. lane_status = 0;
  856. sensor_gps->lane_status_modechange(lane_status);
  857. }
  858. void GPS_Collect::ClickButton_nomall_14()
  859. {
  860. lane_status = 1;
  861. sensor_gps->lane_status_modechange(lane_status);
  862. }
  863. void GPS_Collect::ClickButton_nomall_15()
  864. {
  865. lane_status = 2;
  866. sensor_gps->lane_status_modechange(lane_status);
  867. }
  868. void GPS_Collect::ClickButton_nomall_16()
  869. {
  870. lane_status = 3;
  871. sensor_gps->lane_status_modechange(lane_status);
  872. }
  873. void GPS_Collect::ClickButton_nomall_17()
  874. {
  875. lane_status = 4;
  876. sensor_gps->lane_status_modechange(lane_status);
  877. }
  878. /////////////////////////////////////////////////////////
  879. void GPS_Collect::ClickButton_nomall_18()
  880. {
  881. speed_modes = 5;
  882. sensor_gps->speed_modechange(speed_modes);
  883. }
  884. void GPS_Collect::ClickButton_nomall_19()
  885. {
  886. speed_modes = 6;
  887. sensor_gps->speed_modechange(speed_modes);
  888. }
  889. void GPS_Collect::ClickButton_nomall_20()
  890. {
  891. speed_modes = 7;
  892. sensor_gps->speed_modechange(speed_modes);
  893. }
  894. void GPS_Collect::ClickButton_nomall_21()
  895. {
  896. speed_modes = 8;
  897. sensor_gps->speed_modechange(speed_modes);
  898. }
  899. void GPS_Collect::ClickButton_nomall_22()
  900. {
  901. speed_modes = 9;
  902. sensor_gps->speed_modechange(speed_modes);
  903. }
  904. void GPS_Collect::ClickButton_nomall_23()
  905. {
  906. speed_modes = 10;
  907. sensor_gps->speed_modechange(speed_modes);
  908. }
  909. void GPS_Collect::ClickButton_nomall_24()
  910. {
  911. speed_modes = 11;
  912. sensor_gps->speed_modechange(speed_modes);
  913. }
  914. void GPS_Collect::ClickButton_nomall_25()
  915. {
  916. speed_modes = 12;
  917. sensor_gps->speed_modechange(speed_modes);
  918. }
  919. void GPS_Collect::ClickButton_nomall_26()
  920. {
  921. speed_modes = 13;
  922. sensor_gps->speed_modechange(speed_modes);
  923. }
  924. void GPS_Collect::ClickButton_nomall_27()
  925. {
  926. speed_modes = 14;
  927. sensor_gps->speed_modechange(speed_modes);
  928. }
  929. void GPS_Collect::ClickButton_nomall_28()
  930. {
  931. speed_modes = 15;
  932. sensor_gps->speed_modechange(speed_modes);
  933. }
  934. void GPS_Collect::ClickButton_nomall_29()
  935. {
  936. speed_modes = 16;
  937. sensor_gps->speed_modechange(speed_modes);
  938. }
  939. void GPS_Collect::ClickButton_nomall_30()
  940. {
  941. speed_modes = 17;
  942. sensor_gps->speed_modechange(speed_modes);
  943. }
  944. void GPS_Collect::ClickButton_nomall_31()
  945. {
  946. speed_modes = 18;
  947. sensor_gps->speed_modechange(speed_modes);
  948. }
  949. void GPS_Collect::ClickButton_nomall_32()
  950. {
  951. speed_modes = 19;
  952. sensor_gps->speed_modechange(speed_modes);
  953. }
  954. void GPS_Collect::ClickButton_nomall_33()
  955. {
  956. obs_modes = 3;
  957. sensor_gps->obs_modechange(obs_modes);
  958. }
  959. void GPS_Collect::ClickButton_nomall_34()
  960. {
  961. obs_modes = 4;
  962. sensor_gps->obs_modechange(obs_modes);
  963. }
  964. void GPS_Collect::closeEvent(QCloseEvent *event)
  965. {
  966. if(should_close == false)
  967. {
  968. QMessageBox::StandardButton button;
  969. button=QMessageBox::question(this,tr("退出程序"),QString(tr("确认退出程序")),QMessageBox::Yes|QMessageBox::No);
  970. if(button==QMessageBox::No)
  971. {
  972. event->ignore(); // 忽略退出信号,程序继续进行
  973. }
  974. else if(button==QMessageBox::Yes)
  975. {
  976. sensor_gps->wait_exit();
  977. event->accept(); // 接受退出信号,程序退出
  978. gps_collector_close();
  979. }
  980. }
  981. else
  982. {
  983. event->accept(); // 接受退出信号,程序退出
  984. }
  985. }
  986. void GPSSensor::convertStrToUnChar(char* str, unsigned char* UnChar)
  987. {
  988. int i = strlen(str), j = 0, counter = 0;
  989. char c[2];
  990. unsigned int bytes[2];
  991. for (j = 0; j < i; j += 2)
  992. {
  993. if(0 == j % 2)
  994. {
  995. c[0] = str[j];
  996. c[1] = str[j + 1];
  997. sscanf(c, "%02x" , &bytes[0]);
  998. UnChar[counter] = bytes[0];
  999. counter++;
  1000. }
  1001. }
  1002. }