ncc协议x

This commit is contained in:
xzb 2023-06-08 11:03:37 +08:00
parent a6a09fc920
commit f6f30a083f
3 changed files with 49 additions and 0 deletions

View File

@ -146,6 +146,9 @@ public enum MessageId {
;
int val;
public int idValue(){
return this.val;
}
/**
* 消息对象创建接口
*/

View File

@ -24,6 +24,14 @@ public class DateTimeUtil {
buf.writeByte(from.getMinute());
buf.writeByte(from.getSecond());
}
/**
* 例如传送2001年9月21日15时29分30秒则年秒各单元的值分别为2001921152930
*/
public static byte[]convert(final LocalDateTime from){
final byte[] to = new byte[7];
convert(from,to);
return to;
}
/**
* 例如传送2001年9月21日15时29分30秒则01年2月3日4时5分6秒各单元的值分别为2001921152930
*/

View File

@ -0,0 +1,38 @@
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.DispatcherReportResponse;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.Unpooled;
import io.netty.buffer.UnpooledByteBufAllocator;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.Arrays;
public class TestDispatcherReportResponse {
public static void main(String[]args){
final DispatcherReportResponse response = new DispatcherReportResponse();
final ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
final ByteBuf body = allocator.buffer(1024);
body.writeInt((int) (System.currentTimeMillis() / 1000));
body.writeShort(0xff);
body.writeShort(MessageId.DISPATCHER_REPORT.idValue());
body.writeShort(3);
body.writeShort(110);
body.writeShort(2);
body.writeShort(1);
body.writeShort(2);//Count
body.readBytes(DateTimeUtil.convert(LocalDateTime.now()));
//
final byte[]userName = new byte[32];
Arrays.fill(userName, (byte) '\0');
final ByteBuf userNameBuf = Unpooled.wrappedBuffer(userName);
userNameBuf.readBytes("调度员1".getBytes(StandardCharsets.UTF_8));
//
}
}