ncc协议x

This commit is contained in:
xzb 2023-06-07 17:07:20 +08:00
parent e71876efd7
commit 10446891eb
3 changed files with 95 additions and 2 deletions

View File

@ -110,7 +110,7 @@ public enum MessageId {
/**
* 断点续传开始
*/
Resume_Begin_ACK(0x0025, null),
Resume_Begin_ACK(0x0025, ()->new ResumeBeginAckResponse()),
/**
* 断点续传结束
*/
@ -130,7 +130,7 @@ public enum MessageId {
/**
* 断点续传数据消息
*/
Resume_DATA(0x0030, null),
Resume_DATA(0x0030, ()->new ResumeDataResponse()),
/**
* 实时报警事件消息
*/
@ -161,6 +161,15 @@ public enum MessageId {
this.omc = omc;
}
public MessageData create() {
return null != this.omc ? this.omc.create() : null;
}
public MessageResponse createResponse() {
final MessageData messageData = create();
if(null==messageData) return null;
return messageData instanceof MessageResponse ? (MessageResponse) messageData : null;
}
public static MessageId of(int val) {
for (MessageId messageId : MessageId.values()) {
if (messageId.val == val) {

View File

@ -0,0 +1,30 @@
package club.joylink.xiannccda.ats.message.line3;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
/**
* 2.9.3.2 断点续传开始消息
*/
public class ResumeBeginAckResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 开始时间(7)
*/
private byte[] beginTime = new byte[7];
/**
* 结束时间(7)
*/
private byte[] endTime = new byte[7];
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
buf.readBytes(this.beginTime);
buf.readBytes(this.endTime);
}
}

View File

@ -0,0 +1,54 @@
package club.joylink.xiannccda.ats.message.line3;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.MessageResponse;
import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
/**
* 2.9.3.3 断点续传数据消息
*/
public class ResumeDataResponse extends MessageResponse {
/**
* 线路号(2)
*/
private Short lineId;
/**
* 消息总数(2)
*/
private Short totalMessage;
/**
* 本消息的顺序号(2)
*/
private Short messageSequence;
/**
* 消息message_data的数量(2)
*/
private Short msgCnt;
/**
* 补传的消息消息格式内容和本接口协议定义的消息格式一致时间戳保持与实时发送时的一致
*/
private List<MessageResponse> messageData;
@Override
public void decode2(ByteBuf buf) throws Exception {
this.lineId = buf.readShort();
this.totalMessage = buf.readShort();
this.messageSequence = buf.readShort();
this.msgCnt = buf.readShort();
this.messageData = new ArrayList<>(this.msgCnt);
//
for(int i=0;i<this.msgCnt;i++){
final int _readIndex = buf.readerIndex();
buf.skipBytes(8);
final MessageId messageId = MessageId.of(buf.readShort());
buf.readerIndex(_readIndex);
final MessageResponse messageResponse = messageId.createResponse();
messageResponse.decode(buf);
this.messageData.add(messageResponse);
}
}
}