#pragma once #include #include "PIDSDataDefine.h" #include using namespace std; class PIDSClientResultMsg { public: // 列车线路号 int TrainLine; int Train; std::map 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"; } };