package com.osnav.application.Data; 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 enum systemState{ POSITION_1((byte)0x01), POSITION_2((byte)0x02), POSITION_3((byte)0x03), POSITION_4((byte)0x04), MIDDLE_PROCESS((byte)0x05), MAVIGATION_STAT((byte)0x06); private byte value; systemState(byte value){ this.value=value; } public byte getValue(){ return value; } } public enum realTimeData{ BATTERY_VOLTIGE((byte)0x00), PRESSURE_ALTITUDE((byte)0x01), PRODUCT_VERSION_NUMBER((byte)0x02), SOFTWARE_VERSIONING((byte)0x03); private byte value; realTimeData(byte value){ this.value=value; } public byte getValue(){ return value; } } 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 21:28:54 浏览: 81
详解npm脚本和package.json
这段代码是一个 Java 类,名为 ProtocolData,其中定义了一个协议数据的结构。它包含了一些常量,例如协议头 PROTOCOL_HEADER,协议分隔符 PROTOCOL_SEPARATOR,协议换行符 PROTOCOL_NEWLINE;以及一些数据字段,例如帧序号 frameNumber,系统状态 systemState,寻北进度 northProgress,航向角 headingAngle,俯仰角 pitchAngle,横滚角 rollAngle,实时数据 realTimeData。此外,它还定义了两个枚举类型 systemState 和 realTimeData,分别表示系统状态和实时数据的类型。最后,它还重写了 toString 方法,将数据转换成字符串。
阅读全文