liusuyi
2024-10-25 75902fb9d5b27a440d14308ccca3c3cff32167bb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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.writeDouble(longitude);         // 写入经度
        out.writeDouble(latitude);          // 写入纬度
        out.writeFloat(height);             // 写入高度
        out.writeFloat(speed);              // 写入速度
    }
}