public class ProtocolData { private static final String PROTOCOL_HEADER = "10Hz"; //输出10HZ private static final String PROTOCOL_SEPARATOR = ","; //英文“,”分隔 private static final String PROTOCOL_NEWLINE = "\r\n"; //\r\n结束 private int frameNumber; //帧序号 private byte systemState; //系统状态 private byte northProgress; //寻北进度 private float headingAngle; //航向角 private float pitchAngle; //俯仰角 private float rollAngle; //横滚角 private float realTimeData; //数据更新 public ProtocolData(int frameNumber, byte systemState, byte northProgress, float headingAngle, float pitchAngle, float rollAngle, float realTimeData) { this.frameNumber = frameNumber; this.systemState = systemState; this.northProgress = northProgress; this.headingAngle = headingAngle; this.pitchAngle = pitchAngle; this.rollAngle = rollAngle; this.realTimeData = realTimeData; } public String toString() { StringBuilder builder = new StringBuilder(); builder.append(PROTOCOL_HEADER); builder.append(frameNumber).append(PROTOCOL_SEPARATOR); builder.append(systemState).append(PROTOCOL_SEPARATOR); builder.append(northProgress).append(PROTOCOL_SEPARATOR); builder.append(headingAngle).append(PROTOCOL_SEPARATOR); builder.append(pitchAngle).append(PROTOCOL_SEPARATOR); builder.append(rollAngle).append(PROTOCOL_SEPARATOR); builder.append(realTimeData).append(PROTOCOL_NEWLINE); return builder.toString(); }
时间: 2024-04-06 15:31:36 浏览: 106
ctor_int_error_category_string.rar_class A
这段代码看起来是一个 Java 类,名为 ProtocolData。它有一些常量,包括协议头、分隔符和换行符。它还有一些实例变量,包括帧序号、系统状态、寻北进度、航向角、俯仰角、横滚角和实时数据。它有一个构造函数,用于初始化这些实例变量。它还有一个 toString 方法,用于将实例变量格式化成一个字符串,以便发送到其他设备。
阅读全文