新增复合管控器(pCCU) + 惯导数据解析 + 设备控制页增强 + 0824协议文档归档
- 新增 pCCU 复合管控器程序(src/pCCU):FC/PM 双链路(UDP)、协议编解码器 (FcProtocol/PmProtocol/Frame/Message/MessageRegistry)、快照与落库(DbStore)、 内置 WebServer;挂入 src/CMakeLists.txt 与板卡 mission(h100.moos) - 惯导/深度数据:新增 uDevice_insData 消息解析,接入 UpperCommManager, pPowerMangerHost 注册监视,UpmsgTest 覆盖 - pPowerMangerHost 设备控制页增强(web/index.html) - 部署/运维脚本改为 4 个 systemd 服务(moosdb/pPowerManger/pPowerMangerHost/pCCU): deploy/clean-data/fetch-data 同步适配 - 协议文档:归档 0824 控制主机与复合管控器通信协议 xlsx 及关联 docx,移除旧 md - 测试:新增 pccu 单元/集成测试与 disSysTest Python 配电仿真 - 清理:移除未使用的 CCU 状态调试打印 coutMsg;.gitignore 补充编译产物/临时文件忽略
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#include "Frame.h"
|
||||
#include "FieldCodec.h"
|
||||
|
||||
namespace ccu {
|
||||
|
||||
bool Frame::parseId(const std::vector<uint8_t>& buf, uint16_t& outId) {
|
||||
if (buf.size() < FRAME_HEADER_LEN) return false;
|
||||
if (buf[0] != FRAME_START1 || buf[1] != FRAME_START2) return false;
|
||||
outId = FieldCodec::getU16(buf, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Frame::parseHeader(const std::vector<uint8_t>& buf, FrameHeader& h) {
|
||||
if (buf.size() < FRAME_HEADER_LEN) return false;
|
||||
if (buf[0] != FRAME_START1 || buf[1] != FRAME_START2) return false;
|
||||
h.start1 = buf[0];
|
||||
h.start2 = buf[1];
|
||||
h.id = FieldCodec::getU16(buf, 2);
|
||||
h.length = FieldCodec::getU16(buf, 4);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> Frame::build(
|
||||
uint16_t id,
|
||||
const std::vector<uint8_t>& payload,
|
||||
const ChecksumPolicy& checksum) {
|
||||
|
||||
size_t csSize = checksum.size();
|
||||
size_t total = FRAME_HEADER_LEN + payload.size() + csSize;
|
||||
|
||||
std::vector<uint8_t> frame(total, 0);
|
||||
frame[0] = FRAME_START1;
|
||||
frame[1] = FRAME_START2;
|
||||
FieldCodec::putU16(frame, 2, id);
|
||||
FieldCodec::putU16(frame, 4, static_cast<uint16_t>(total)); // 域字节数=整个包长度
|
||||
|
||||
std::copy(payload.begin(), payload.end(), frame.begin() + FRAME_HEADER_LEN);
|
||||
|
||||
if (csSize > 0) {
|
||||
// 校验和:对起始符到校验和之前所有字节求和
|
||||
std::vector<uint8_t> body(frame.begin(), frame.end() - csSize);
|
||||
uint32_t sum = checksum.compute(body);
|
||||
size_t off = frame.size() - csSize;
|
||||
if (csSize == 4) FieldCodec::putU32(frame, off, sum);
|
||||
else FieldCodec::putU16(frame, off, static_cast<uint16_t>(sum));
|
||||
}
|
||||
return frame;
|
||||
}
|
||||
|
||||
} // namespace ccu
|
||||
Reference in New Issue
Block a user