ncc协议x

This commit is contained in:
xzb 2023-06-08 17:27:20 +08:00
parent 5c87f6a2bb
commit 2e9a85c962
13 changed files with 37 additions and 34 deletions

View File

@ -78,8 +78,8 @@ public class DispatcherReportResponse extends MessageResponse {
buf.readBytes(logItem);
//
this.reportTime = DateTimeUtil.convert(reportTime);
this.userName = new String(userName, MessageCons.STRING_CHARSET);
this.logItem = new String(logItem, MessageCons.STRING_CHARSET);
this.userName = new String(userName, MessageCons.STRING_CHARSET).trim();
this.logItem = new String(logItem, MessageCons.STRING_CHARSET).trim();
//
return this;
}

View File

@ -77,7 +77,7 @@ public class DriverDistanceReportResponse extends MessageResponse {
this.distance = buf.readInt();
//
this.date=DateTimeUtil.convert(date);
this.driverId=new String(driverId,MessageCons.STRING_CHARSET);
this.driverId=new String(driverId,MessageCons.STRING_CHARSET).trim();
//
return this;
}

View File

@ -90,10 +90,10 @@ public class GroupBakReportResponse extends MessageResponse {
depot = buf.readByte();
buf.readBytes(trackName);
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.status = GroupBakStatusEnum.of(status);
this.depot = GroupBakDepotEnum.of(depot);
this.trackName = new String(trackName, MessageCons.STRING_CHARSET);
this.trackName = new String(trackName, MessageCons.STRING_CHARSET).trim();
return this;
}
}

View File

@ -83,7 +83,7 @@ public class GroupRunningReportResponse extends MessageResponse {
public GroupCell decode(final ByteBuf buf) {
final byte[] groupId = new byte[9];
buf.readBytes(groupId);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
//
this.totalRunning = buf.readInt();
this.monthRepair = buf.readInt();

View File

@ -78,7 +78,7 @@ public class GroupStatusReportResponse extends MessageResponse {
depot = buf.readByte();
buf.readBytes(this.status);
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.depot = GroupPositionEnum.of(depot);
//
return this;

View File

@ -52,6 +52,6 @@ public class InUsedScheduleParameterResponse extends MessageResponse {
case 0x01 -> this.valid = true;
case 0x02 -> this.valid = false;
}
this.inUsedScheduleName = new String(inUsedScheduleName, MessageCons.STRING_CHARSET);
this.inUsedScheduleName = new String(inUsedScheduleName, MessageCons.STRING_CHARSET).trim();
}
}

View File

@ -35,7 +35,7 @@ public class MessageAlarmResponse extends MessageResponse {
final byte[] alarmContent = new byte[alarmLen];
buf.readBytes(alarmContent);
//
this.tagId = new String(tagId, MessageCons.STRING_CHARSET);
this.alarmContent = new String(alarmContent, MessageCons.STRING_CHARSET);
this.tagId = new String(tagId, MessageCons.STRING_CHARSET).trim();
this.alarmContent = new String(alarmContent, MessageCons.STRING_CHARSET).trim();
}
}

View File

@ -100,10 +100,10 @@ public class TrainBlockInfoResponse extends MessageResponse {
buf.readBytes(devName);
blockFlag = buf.readByte();
//
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.trainId = new String(trainId, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.direction = DirectionEnum.of(direction);
switch (blockFlag) {
case 1 -> this.blockFlag = true;

View File

@ -150,12 +150,12 @@ public class TrainIndicationInitResponse extends MessageResponse {
buf.readBytes(this.reserve);
//
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET);
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.trainId = new String(trainId, MessageCons.STRING_CHARSET);
this.globalId = new String(globalId, MessageCons.STRING_CHARSET);
this.driverId = new String(driverId, MessageCons.STRING_CHARSET);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.globalId = new String(globalId, MessageCons.STRING_CHARSET).trim();
this.driverId = new String(driverId, MessageCons.STRING_CHARSET).trim();
this.arriveTime = DateTimeUtil.convert(arriveTime);
this.departTime = DateTimeUtil.convert(departTime);
//

View File

@ -61,8 +61,8 @@ public class TrainIndicationRemoveResponse extends MessageResponse {
buf.readBytes(groupId);
//
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET);
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
}
}

View File

@ -142,12 +142,12 @@ public class TrainIndicationUpdateResponse extends MessageResponse {
buf.readBytes(this.reserve);
//
this.devType = DeviceType.of(devType);
this.devName = new String(devName, MessageCons.STRING_CHARSET);
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.trainId = new String(trainId, MessageCons.STRING_CHARSET);
this.globalId = new String(globalId, MessageCons.STRING_CHARSET);
this.driverId = new String(driverId, MessageCons.STRING_CHARSET);
this.devName = new String(devName, MessageCons.STRING_CHARSET).trim();
this.trainIndex = new String(trainIndex, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.globalId = new String(globalId, MessageCons.STRING_CHARSET).trim();
this.driverId = new String(driverId, MessageCons.STRING_CHARSET).trim();
this.arriveTime = DateTimeUtil.convert(arriveTime);
this.departTime = DateTimeUtil.convert(departTime);
/**

View File

@ -105,12 +105,12 @@ public class TrainRecordResponse extends MessageResponse {
buf.readBytes(recordTime);
buf.readBytes(this.reserve);
//
this.trainId = new String(trainId, MessageCons.STRING_CHARSET);
this.globalId = new String(globalId, MessageCons.STRING_CHARSET);
this.groupId = new String(groupId, MessageCons.STRING_CHARSET);
this.trainId = new String(trainId, MessageCons.STRING_CHARSET).trim();
this.globalId = new String(globalId, MessageCons.STRING_CHARSET).trim();
this.groupId = new String(groupId, MessageCons.STRING_CHARSET).trim();
this.trainType = TrainTypeEnum.of(trainType);
this.direction = DirectionEnum.of(direction);
this.trackName = new String(trackName, MessageCons.STRING_CHARSET);
this.trackName = new String(trackName, MessageCons.STRING_CHARSET).trim();
/**
* 到发点类型(2)<br>
* 0x01H到达<br>

View File

@ -1,6 +1,7 @@
package club.joylink.xiannccda.protocal.x;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.MessageResponse;
import club.joylink.xiannccda.ats.message.line3.DateTimeUtil;
import club.joylink.xiannccda.ats.message.line3.DispatcherReportResponse;
import club.joylink.xiannccda.ats.message.line3.MessageCons;
@ -8,7 +9,9 @@ import com.alibaba.fastjson2.JSON;
import io.netty.buffer.*;
import java.time.LocalDateTime;
/**
* 测试
*/
public class TestDispatcherReportResponse {
public static void main(String[]args) throws Exception {
final ByteBufAllocator allocator = UnpooledByteBufAllocator.DEFAULT;
@ -55,7 +58,7 @@ public class TestDispatcherReportResponse {
composite.addComponents(true,headLen,body);
System.out.println("==>>composite ridx = "+composite.readerIndex()+" widx = "+composite.writerIndex());
//解码
final DispatcherReportResponse response = new DispatcherReportResponse();
final MessageResponse response = MessageId.DISPATCHER_REPORT.createResponse();
response.decode(composite);
//
System.out.println(JSON.toJSONString(response));