ncc协议x
This commit is contained in:
parent
46f1de9c75
commit
a4dfde4ffe
@ -0,0 +1,41 @@
|
||||
package club.joylink.xiannccda.protocal.x;
|
||||
|
||||
import club.joylink.xiannccda.ats.message.MessageId;
|
||||
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
|
||||
import club.joylink.xiannccda.ats.message.line3.DriverDistanceReportResponse;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufAllocator;
|
||||
import io.netty.buffer.CompositeByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public class TestDriverDistanceReportResponse {
|
||||
public static void main(String[]args) throws Exception {
|
||||
final ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
|
||||
final ByteBuf body = allocator.buffer(1024);
|
||||
body.writeInt((int) (System.currentTimeMillis() / 1000));
|
||||
body.writeShort(0xff);
|
||||
body.writeShort(MessageId.DRIVER_DISTANCE_REPORT.idValue());
|
||||
body.writeShort(3);//线路号
|
||||
body.writeShort(110);//查询标识号
|
||||
body.writeShort(34);//消息总数
|
||||
body.writeShort(1);//本消息的顺序号
|
||||
body.writeShort(1);//记录条数
|
||||
body.writeBytes(DateTimeUtil.convert(LocalDateTime.now()));//日期
|
||||
final byte[] driverId = new byte[13];
|
||||
TestUtil.fill("司机118",driverId);
|
||||
body.writeBytes(driverId);//司机号
|
||||
body.writeInt(100);
|
||||
final ByteBuf headLen = allocator.buffer(2);
|
||||
headLen.writeShort(body.readableBytes());//消息长度
|
||||
//
|
||||
final CompositeByteBuf composite = allocator.compositeBuffer(2);
|
||||
composite.addComponents(true,headLen,body);
|
||||
//
|
||||
final DriverDistanceReportResponse response = (DriverDistanceReportResponse) MessageId.DRIVER_DISTANCE_REPORT.createResponse();
|
||||
response.decode(composite);
|
||||
System.out.println(JSON.toJSONString(response));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user