123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #pragma once
- #include <iostream>
- #include "PIDSDataDefine.h"
- #include <map>
- using namespace std;
- class PIDSClientResultMsg
- {
- public:
- // 列车线路号
- int TrainLine;
- int Train;
- std::map<int, ResultData> data;
- public:
- PIDSClientResultMsg(){}
- ~PIDSClientResultMsg(){}
- void Serialization(uint8_t* data)
- {
- data[0] = PIDS_DATA_HEAD;
- data[1] = PIDS_DATA_TYPE;
- data[2] = PIDS_SRC_TYPE_MIVA;
-
- //rsvd
- data[3] = 0;
- data[4] = 0;
- data[5] = 0;
- data[6] = 0;
- //length
- data[7] = 0x00;
- data[8] = 0x30;
- //rsvd
- data[9] = 0;
- data[10] = 0;
- data[11] = 0;
- data[12] = 0;
- data[13] = 0;
- // 填充数据
- // Time
- //getBCDTime(data + 14);
- getTime(data + 14);
- data[21] = 0;
- data[22] = 0;
- //Data
- // data[23] = this->data[0].Grade;
- // data[24] = this->data[1].Grade;
- // data[25] = this->data[2].Grade;
- // data[26] = this->data[3].Grade;
- // data[27] = this->data[4].Grade;
- // data[28] = this->data[5].Grade;
- data[23] = this->data[0].Num;
- data[24] = this->data[1].Num;
- data[25] = this->data[2].Num;
- data[26] = this->data[3].Num;
- data[27] = this->data[4].Num;
- data[28] = this->data[5].Num;
- //rsvd
- for(int i = 29; i < 45; i++)
- {
- data[i] = 0;
- }
- int16_t crc = Crc16::GetCRC16(data, 9, 36);
- data[45] = (crc & 0xFF00) >> 8;
- data[46] = (crc & 0x00FF);
-
- // 数据尾
- data[47] = PIDS_DATA_END;
- }
- void ObjectToJson(std::string& json)
- {
-
- json+="\r\n";
- }
- };
|