ncc协议x
This commit is contained in:
parent
a6a09fc920
commit
f6f30a083f
@ -146,6 +146,9 @@ public enum MessageId {
|
||||
;
|
||||
|
||||
int val;
|
||||
public int idValue(){
|
||||
return this.val;
|
||||
}
|
||||
/**
|
||||
* 消息对象创建接口
|
||||
*/
|
||||
|
@ -24,6 +24,14 @@ public class DateTimeUtil {
|
||||
buf.writeByte(from.getMinute());
|
||||
buf.writeByte(from.getSecond());
|
||||
}
|
||||
/**
|
||||
* 例如,传送2001年9月21日15时29分30秒,则年、月、日、时、分、秒各单元的值分别为:20、01、9、21、15、29、30
|
||||
*/
|
||||
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秒各单元的值分别为:20、01、9、21、15、29、30
|
||||
*/
|
||||
|
@ -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));
|
||||
|
||||
//
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user