package com.ard.tianyu.netty.command;// PointFlyCommand.java import io.netty.buffer.ByteBuf; public class PointFlyCommand extends BaseCommand { private double longitude; private double latitude; private float height; private float speed; public PointFlyCommand(double longitude, double latitude, float height, float speed) { this.longitude = longitude; this.latitude = latitude; this.height = height; this.speed = speed; setDataHeader((short) 0x7479); setCmdCode((byte) 0xD1); setDataLength((short) 17); // 数据长度计算 } @Override public void encode(ByteBuf out) { out.writeShort(getDataHeader()); // 写入数据头 out.writeShort(getDataLength()); // 写入数据长度 out.writeByte(getCmdCode()); // 写入命令码 out.writeDouble(longitude); // 写入经度 out.writeDouble(latitude); // 写入纬度 out.writeFloat(height); // 写入高度 out.writeFloat(speed); // 写入速度 } }