PIDSClientResultMsg.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #pragma once
  2. #include <iostream>
  3. #include "PIDSDataDefine.h"
  4. #include <map>
  5. using namespace std;
  6. class PIDSClientResultMsg
  7. {
  8. public:
  9. // 列车线路号
  10. int TrainLine;
  11. int Train;
  12. std::map<int, ResultData> data;
  13. public:
  14. PIDSClientResultMsg(){}
  15. ~PIDSClientResultMsg(){}
  16. void Serialization(uint8_t* data)
  17. {
  18. data[0] = PIDS_DATA_HEAD;
  19. data[1] = PIDS_DATA_TYPE;
  20. data[2] = PIDS_SRC_TYPE_MIVA;
  21. //rsvd
  22. data[3] = 0;
  23. data[4] = 0;
  24. data[5] = 0;
  25. data[6] = 0;
  26. //length
  27. data[7] = 0x00;
  28. data[8] = 0x30;
  29. //rsvd
  30. data[9] = 0;
  31. data[10] = 0;
  32. data[11] = 0;
  33. data[12] = 0;
  34. data[13] = 0;
  35. // 填充数据
  36. // Time
  37. //getBCDTime(data + 14);
  38. getTime(data + 14);
  39. data[21] = 0;
  40. data[22] = 0;
  41. //Data
  42. // data[23] = this->data[0].Grade;
  43. // data[24] = this->data[1].Grade;
  44. // data[25] = this->data[2].Grade;
  45. // data[26] = this->data[3].Grade;
  46. // data[27] = this->data[4].Grade;
  47. // data[28] = this->data[5].Grade;
  48. data[23] = this->data[0].Num;
  49. data[24] = this->data[1].Num;
  50. data[25] = this->data[2].Num;
  51. data[26] = this->data[3].Num;
  52. data[27] = this->data[4].Num;
  53. data[28] = this->data[5].Num;
  54. //rsvd
  55. for(int i = 29; i < 45; i++)
  56. {
  57. data[i] = 0;
  58. }
  59. int16_t crc = Crc16::GetCRC16(data, 9, 36);
  60. data[45] = (crc & 0xFF00) >> 8;
  61. data[46] = (crc & 0x00FF);
  62. // 数据尾
  63. data[47] = PIDS_DATA_END;
  64. }
  65. void ObjectToJson(std::string& json)
  66. {
  67. json+="\r\n";
  68. }
  69. };