【列车状态运行系统】

This commit is contained in:
weizhihong 2023-03-01 10:18:47 +08:00
parent 5eeb1997b9
commit 0d1d726d69
8 changed files with 2718 additions and 41 deletions

@ -1 +1 @@
Subproject commit fd56eae5c7ec52f7885d8148141202f639976ae4
Subproject commit 2adf468e0be410e0bc530e5ec3882d45fdb1b9b4

View File

@ -5,6 +5,7 @@ import club.joylink.ecs.api.WorldSystem;
import club.joylink.ecs.tuple.Tuple1;
import club.joylink.rtss.simulation.ncc.exception.NccExceptionAssertEnum;
import club.joylink.rtss.simulation.ncc.module.proto.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.Objects;
@ -13,17 +14,19 @@ import java.util.Optional;
/**
* 列车行驶位置状态更新
*/
public class TrainStateSystem implements WorldSystem<Tuple1<TrainStateProto.TrainState.Builder>, Tuple1<StorageProto.Storage>> {
@Slf4j
public class TrainStateSystem implements WorldSystem<Tuple1<TrainStateProto.TrainState.Builder>, Tuple1<StorageProto.Storage.Builder>> {
@Override
public void update(WorldQuery<Tuple1<TrainStateProto.TrainState.Builder>> query, Tuple1<StorageProto.Storage> storageTuple1) {
public void update(WorldQuery<Tuple1<TrainStateProto.TrainState.Builder>> query, Tuple1<StorageProto.Storage.Builder> storageTuple1) {
// 所有资源
StorageProto.Storage storage = storageTuple1.val1().get();
StorageProto.Storage storage = storageTuple1.val1().get().build();
// 查找需要更新的车状态信息
query.forEach(tuple -> {
TrainStateProto.TrainState.Builder trainState = tuple.val1().get();
TrainStateCommandProto.TrainStateCommand command = trainState.getCommand();
if (command != null) {
TrainStateCommandProto.TrainStateCommand.Builder command = trainState.getCommandBuilder();
if (command != null && Objects.equals(command.getStatus(), CommandStatusProto.CommandStatus.UNDO)) {
command.setStatus(CommandStatusProto.CommandStatus.DOING);
// 更新车次信息
if (StringUtils.isNoneBlank(command.getTripNumber())) {
trainState.setTripNumber(command.getTripNumber());
@ -35,6 +38,18 @@ public class TrainStateSystem implements WorldSystem<Tuple1<TrainStateProto.Trai
.findFirst();
if (stationOptional.isPresent()) {
trainState.setStartStation(stationOptional.get());
log.info("列车进入车站:" + trainState.getStartStation().getName());
} else {
throw NccExceptionAssertEnum.DataNotExist.exception();
}
}
// 更新终点站
if (StringUtils.isNoneBlank(command.getTerminusCode())) {
Optional<StationProto.Station> stationOptional = storage.getStationsList().stream()
.filter(station -> Objects.equals(station.getCode(), command.getTerminusCode()))
.findFirst();
if (stationOptional.isPresent()) {
trainState.setTerminus(stationOptional.get());
} else {
throw NccExceptionAssertEnum.DataNotExist.exception();
}
@ -49,9 +64,21 @@ public class TrainStateSystem implements WorldSystem<Tuple1<TrainStateProto.Trai
if (command.getDirection() != 0) {
trainState.setDirection(command.getDirection());
}
// 行驶线路
if (StringUtils.isNoneBlank(command.getLineCode())) {
Optional<LineProto.Line> lineOptional = storage.getLinesList().stream()
.filter(line -> Objects.equals(line.getCode(), command.getLineCode()) )
.findFirst();
if (lineOptional.isPresent()) {
trainState.setLine(lineOptional.get());
} else {
throw NccExceptionAssertEnum.DataNotExist.exception();
}
}
// 更新位置 方向一致的路段
Optional<RoadSectionProto.RoadSection> roadSectionOptional = storage.getRoadSectionsList().stream()
.filter(rs -> Objects.equals(trainState.getStartStation().getCode(), rs.getStartStationId()))
.filter(rs -> Objects.equals(trainState.getLine().getCode(), rs.getLineId())
&& Objects.equals(trainState.getStartStation().getCode(), rs.getStartStationId()))
.filter(rs -> (rs.getMaxDistance() - rs.getMinDistance()) * trainState.getDirection() > 0)
.findFirst();
if (roadSectionOptional.isPresent()) {
@ -60,9 +87,11 @@ public class TrainStateSystem implements WorldSystem<Tuple1<TrainStateProto.Trai
double totalDistance = Math.abs(roadSection.getMaxDistance() - roadSection.getMinDistance());
double distanceRatio = command.getDistance() / totalDistance;
trainState.setDistanceRatio(distanceRatio);
log.info("列车行驶至车站:" + trainState.getStartStation().getName() + "距离 " + trainState.getDistance() + ",行驶比例:" + distanceRatio);
}
// 清除命令
trainState.clearCommand();
// 完成标识
command.setStatus(CommandStatusProto.CommandStatus.DONE);
}
});
}

View File

@ -0,0 +1,121 @@
import club.joylink.ecs.CoreStage;
import club.joylink.ecs.World;
import club.joylink.ecs.WorldManage;
import club.joylink.ecs.api.Entity;
import club.joylink.rtss.simulation.ncc.module.proto.*;
import club.joylink.rtss.simulation.ncc.sys.TrainStateSystem;
import lombok.extern.slf4j.Slf4j;
import java.util.Optional;
@Slf4j
public class TrainStateSystemTest {
private static final String stationIdFormat = "station-%s";
private static final String stationNameFormat = "车站-%s";
private static final String lineIdFormat = "line-%s";
private static final String lineNameFormat = "%s号线";
private static final String roadSectionIdFormat = "road_section_%s_%s";
private static final String trainIdFormat = "train_%s";
public static void main(String[] args) throws InterruptedException {
String worldId = "train-world-1";
World world = WorldManage.create(worldId);
// 总资源信息
StorageProto.Storage.Builder storage = StorageProto.Storage.newBuilder();
// 车站列表
for (int j = 1; j <= 10; j++) {
StationProto.Station.Builder stationBuilder = StationProto.Station.newBuilder();
stationBuilder.setCode(String.format(stationIdFormat, j));
stationBuilder.setName(String.format(stationNameFormat, j));
stationBuilder.setTransfer(j == 5);
world.getStorage().createEntity(stationBuilder.getCode(), stationBuilder);
storage.addStations(stationBuilder);
}
// 线路列表
for (int j = 1; j <= 2; j++) {
LineProto.Line.Builder lineBuilder = LineProto.Line.newBuilder();
lineBuilder.setCode(String.format(lineIdFormat, j));
lineBuilder.setName(String.format(lineNameFormat, j));
world.getStorage().createEntity(lineBuilder.getCode(), lineBuilder);
storage.addLines(lineBuilder);
}
// 路段列表建立
int[][] roadSectionArr = new int[][]{
{1,3}, {3,5}, {5,7}, {7,9},
{2,4}, {4,5}, {5,6}, {6,8}, {8,10}
};
for (int[] relArr : roadSectionArr) {
// 正向行驶路段
RoadSectionProto.RoadSection.Builder roadSectionBuilder = getRoadSection(relArr[0], relArr[1]);
world.getStorage().createEntity(roadSectionBuilder.getCode(), roadSectionBuilder);
storage.addRoadSections(roadSectionBuilder);
// 反向行驶路段
RoadSectionProto.RoadSection.Builder reverseRoadSectionBuilder = getRoadSection(relArr[1], relArr[0]);
world.getStorage().createEntity(reverseRoadSectionBuilder.getCode(), reverseRoadSectionBuilder);
storage.addRoadSections(reverseRoadSectionBuilder);
}
// 列车列表
TrainProto.Train.Builder trainBuilder = TrainProto.Train.newBuilder();
trainBuilder.setCode(String.format(trainIdFormat, 1));
trainBuilder.setLen(300);
world.getStorage().createEntity(trainBuilder.getCode(), trainBuilder, TrainStateProto.TrainState.newBuilder());
storage.addTrain(trainBuilder);
// 将构建信息放入world
world.getStorage().insertSingleton(storage);
// 添加系统
world.getTaskControl().addSystem(new TrainStateSystem());
world.start();
world.setSpeed(100);
for (int j = 0, i = 1; j < 9; j++) {
Thread.sleep(1000);
log.debug("列车开始运行" + j);
world.getTaskControl().addStageBefore(CoreStage.Update, MyStage.Start);
Optional<Entity> entity = world.getStorage().queryEntity(String.format(trainIdFormat, 1));
TrainStateProto.TrainState.Builder builder = entity.get().getComponent(TrainStateProto.TrainState.Builder.class).get();
TrainStateCommandProto.TrainStateCommand.Builder stateCommand = TrainStateCommandProto.TrainStateCommand.newBuilder();
if (j == 0) {
stateCommand.setTripNumber("1024");
stateCommand.setStationCode(String.format(stationIdFormat, 1));
stateCommand.setRunStatus(RunStatusProto.RunStatus.Run);
stateCommand.setDirection(1);
stateCommand.setLineCode(String.format(lineIdFormat, 1));
stateCommand.setTerminusCode(String.format(stationIdFormat, 9));
} else {
if (j % 2 == 0) {
i = i + 2;
stateCommand.setStationCode(String.format(stationIdFormat, i));
stateCommand.setDistance(0);
} else {
stateCommand.setDistance(5);
}
}
stateCommand.setStatus(CommandStatusProto.CommandStatus.UNDO);
builder.setCommand(stateCommand);
}
Thread.sleep(3000);
WorldManage.destroy(worldId);
}
private static RoadSectionProto.RoadSection.Builder getRoadSection(int startId, int endId){
RoadSectionProto.RoadSection.Builder roadSectionBuilder = RoadSectionProto.RoadSection.newBuilder();
roadSectionBuilder.setCode(String.format(roadSectionIdFormat, startId, endId));
roadSectionBuilder.setStartStationId(String.format(stationIdFormat, startId));
roadSectionBuilder.setEndStationId(String.format(stationIdFormat, endId));
if (startId % 2 == 0 && endId % 2 == 0) {
roadSectionBuilder.setLineId(String.format(lineIdFormat, 2));
} else {
roadSectionBuilder.setLineId(String.format(lineIdFormat, 1));
}
roadSectionBuilder.setMinDistance(startId * 10);
roadSectionBuilder.setMaxDistance(endId * 10);
return roadSectionBuilder;
}
enum MyStage {
Start,
End
}
}

View File

@ -0,0 +1,179 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: command_status.proto
package club.joylink.rtss.simulation.ncc.module.proto;
public final class CommandStatusProto {
private CommandStatusProto() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
/**
* Protobuf enum {@code proto.CommandStatus}
*/
public enum CommandStatus
implements com.google.protobuf.ProtocolMessageEnum {
/**
* <pre>
* 未执行
* </pre>
*
* <code>UNDO = 0;</code>
*/
UNDO(0),
/**
* <pre>
* 正操作
* </pre>
*
* <code>DOING = 1;</code>
*/
DOING(1),
/**
* <pre>
* 已执行
* </pre>
*
* <code>DONE = 2;</code>
*/
DONE(2),
UNRECOGNIZED(-1),
;
/**
* <pre>
* 未执行
* </pre>
*
* <code>UNDO = 0;</code>
*/
public static final int UNDO_VALUE = 0;
/**
* <pre>
* 正操作
* </pre>
*
* <code>DOING = 1;</code>
*/
public static final int DOING_VALUE = 1;
/**
* <pre>
* 已执行
* </pre>
*
* <code>DONE = 2;</code>
*/
public static final int DONE_VALUE = 2;
public final int getNumber() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalArgumentException(
"Can't get the number of an unknown enum value.");
}
return value;
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
* @deprecated Use {@link #forNumber(int)} instead.
*/
@java.lang.Deprecated
public static CommandStatus valueOf(int value) {
return forNumber(value);
}
/**
* @param value The numeric wire value of the corresponding enum entry.
* @return The enum associated with the given numeric wire value.
*/
public static CommandStatus forNumber(int value) {
switch (value) {
case 0: return UNDO;
case 1: return DOING;
case 2: return DONE;
default: return null;
}
}
public static com.google.protobuf.Internal.EnumLiteMap<CommandStatus>
internalGetValueMap() {
return internalValueMap;
}
private static final com.google.protobuf.Internal.EnumLiteMap<
CommandStatus> internalValueMap =
new com.google.protobuf.Internal.EnumLiteMap<CommandStatus>() {
public CommandStatus findValueByNumber(int number) {
return CommandStatus.forNumber(number);
}
};
public final com.google.protobuf.Descriptors.EnumValueDescriptor
getValueDescriptor() {
if (this == UNRECOGNIZED) {
throw new java.lang.IllegalStateException(
"Can't get the descriptor of an unrecognized enum value.");
}
return getDescriptor().getValues().get(ordinal());
}
public final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptorForType() {
return getDescriptor();
}
public static final com.google.protobuf.Descriptors.EnumDescriptor
getDescriptor() {
return club.joylink.rtss.simulation.ncc.module.proto.CommandStatusProto.getDescriptor().getEnumTypes().get(0);
}
private static final CommandStatus[] VALUES = values();
public static CommandStatus valueOf(
com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
if (desc.getType() != getDescriptor()) {
throw new java.lang.IllegalArgumentException(
"EnumValueDescriptor is not for this type.");
}
if (desc.getIndex() == -1) {
return UNRECOGNIZED;
}
return VALUES[desc.getIndex()];
}
private final int value;
private CommandStatus(int value) {
this.value = value;
}
// @@protoc_insertion_point(enum_scope:proto.CommandStatus)
}
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\024command_status.proto\022\005proto*.\n\rCommand" +
"Status\022\010\n\004UNDO\020\000\022\t\n\005DOING\020\001\022\010\n\004DONE\020\002BC\n" +
"-club.joylink.rtss.simulation.ncc.module" +
".protoB\022CommandStatusProtob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
});
}
// @@protoc_insertion_point(outer_class_scope)
}

View File

@ -1555,20 +1555,17 @@ public final class RoadSectionProto {
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\022road_section.proto\022\005proto\032\020model/line." +
"proto\032\023model/station.proto\"\221\001\n\013RoadSecti" +
"on\022\014\n\004code\030\001 \001(\t\022\014\n\004name\030\002 \001(\t\022\026\n\016startS" +
"tationId\030\003 \001(\t\022\024\n\014endStationId\030\004 \001(\t\022\023\n\013" +
"minDistance\030\005 \001(\001\022\023\n\013maxDistance\030\006 \001(\001\022\016" +
"\n\006lineId\030\007 \001(\tBA\n-club.joylink.rtss.simu" +
"lation.ncc.module.protoB\020RoadSectionProt" +
"ob\006proto3"
"\n\022road_section.proto\022\005proto\"\221\001\n\013RoadSect" +
"ion\022\014\n\004code\030\001 \001(\t\022\014\n\004name\030\002 \001(\t\022\026\n\016start" +
"StationId\030\003 \001(\t\022\024\n\014endStationId\030\004 \001(\t\022\023\n" +
"\013minDistance\030\005 \001(\001\022\023\n\013maxDistance\030\006 \001(\001\022" +
"\016\n\006lineId\030\007 \001(\tBA\n-club.joylink.rtss.sim" +
"ulation.ncc.module.protoB\020RoadSectionPro" +
"tob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
club.joylink.rtss.simulation.ncc.module.proto.LineProto.getDescriptor(),
club.joylink.rtss.simulation.ncc.module.proto.StationProto.getDescriptor(),
});
internal_static_proto_RoadSection_descriptor =
getDescriptor().getMessageTypes().get(0);
@ -1576,8 +1573,6 @@ public final class RoadSectionProto {
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_proto_RoadSection_descriptor,
new java.lang.String[] { "Code", "Name", "StartStationId", "EndStationId", "MinDistance", "MaxDistance", "LineId", });
club.joylink.rtss.simulation.ncc.module.proto.LineProto.getDescriptor();
club.joylink.rtss.simulation.ncc.module.proto.StationProto.getDescriptor();
}
// @@protoc_insertion_point(outer_class_scope)

View File

@ -173,6 +173,66 @@ public final class TrainStateProto {
* <code>.proto.RoadSection roadSection = 8;</code>
*/
club.joylink.rtss.simulation.ncc.module.proto.RoadSectionProto.RoadSectionOrBuilder getRoadSectionOrBuilder();
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
* @return Whether the line field is set.
*/
boolean hasLine();
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
* @return The line.
*/
club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line getLine();
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
*/
club.joylink.rtss.simulation.ncc.module.proto.LineProto.LineOrBuilder getLineOrBuilder();
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
* @return Whether the terminus field is set.
*/
boolean hasTerminus();
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
* @return The terminus.
*/
club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station getTerminus();
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
*/
club.joylink.rtss.simulation.ncc.module.proto.StationProto.StationOrBuilder getTerminusOrBuilder();
}
/**
* Protobuf type {@code proto.TrainState}
@ -287,6 +347,32 @@ public final class TrainStateProto {
break;
}
case 74: {
club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.Builder subBuilder = null;
if (line_ != null) {
subBuilder = line_.toBuilder();
}
line_ = input.readMessage(club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.parser(), extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(line_);
line_ = subBuilder.buildPartial();
}
break;
}
case 82: {
club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.Builder subBuilder = null;
if (terminus_ != null) {
subBuilder = terminus_.toBuilder();
}
terminus_ = input.readMessage(club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.parser(), extensionRegistry);
if (subBuilder != null) {
subBuilder.mergeFrom(terminus_);
terminus_ = subBuilder.buildPartial();
}
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
@ -557,6 +643,88 @@ public final class TrainStateProto {
return getRoadSection();
}
public static final int LINE_FIELD_NUMBER = 9;
private club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line line_;
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
* @return Whether the line field is set.
*/
@java.lang.Override
public boolean hasLine() {
return line_ != null;
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
* @return The line.
*/
@java.lang.Override
public club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line getLine() {
return line_ == null ? club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.getDefaultInstance() : line_;
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
*/
@java.lang.Override
public club.joylink.rtss.simulation.ncc.module.proto.LineProto.LineOrBuilder getLineOrBuilder() {
return getLine();
}
public static final int TERMINUS_FIELD_NUMBER = 10;
private club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station terminus_;
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
* @return Whether the terminus field is set.
*/
@java.lang.Override
public boolean hasTerminus() {
return terminus_ != null;
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
* @return The terminus.
*/
@java.lang.Override
public club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station getTerminus() {
return terminus_ == null ? club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.getDefaultInstance() : terminus_;
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
*/
@java.lang.Override
public club.joylink.rtss.simulation.ncc.module.proto.StationProto.StationOrBuilder getTerminusOrBuilder() {
return getTerminus();
}
private byte memoizedIsInitialized = -1;
@java.lang.Override
public final boolean isInitialized() {
@ -595,6 +763,12 @@ public final class TrainStateProto {
if (roadSection_ != null) {
output.writeMessage(8, getRoadSection());
}
if (line_ != null) {
output.writeMessage(9, getLine());
}
if (terminus_ != null) {
output.writeMessage(10, getTerminus());
}
unknownFields.writeTo(output);
}
@ -635,6 +809,14 @@ public final class TrainStateProto {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(8, getRoadSection());
}
if (line_ != null) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(9, getLine());
}
if (terminus_ != null) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(10, getTerminus());
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
@ -676,6 +858,16 @@ public final class TrainStateProto {
if (!getRoadSection()
.equals(other.getRoadSection())) return false;
}
if (hasLine() != other.hasLine()) return false;
if (hasLine()) {
if (!getLine()
.equals(other.getLine())) return false;
}
if (hasTerminus() != other.hasTerminus()) return false;
if (hasTerminus()) {
if (!getTerminus()
.equals(other.getTerminus())) return false;
}
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@ -711,6 +903,14 @@ public final class TrainStateProto {
hash = (37 * hash) + ROADSECTION_FIELD_NUMBER;
hash = (53 * hash) + getRoadSection().hashCode();
}
if (hasLine()) {
hash = (37 * hash) + LINE_FIELD_NUMBER;
hash = (53 * hash) + getLine().hashCode();
}
if (hasTerminus()) {
hash = (37 * hash) + TERMINUS_FIELD_NUMBER;
hash = (53 * hash) + getTerminus().hashCode();
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
@ -872,6 +1072,18 @@ public final class TrainStateProto {
roadSection_ = null;
roadSectionBuilder_ = null;
}
if (lineBuilder_ == null) {
line_ = null;
} else {
line_ = null;
lineBuilder_ = null;
}
if (terminusBuilder_ == null) {
terminus_ = null;
} else {
terminus_ = null;
terminusBuilder_ = null;
}
return this;
}
@ -918,6 +1130,16 @@ public final class TrainStateProto {
} else {
result.roadSection_ = roadSectionBuilder_.build();
}
if (lineBuilder_ == null) {
result.line_ = line_;
} else {
result.line_ = lineBuilder_.build();
}
if (terminusBuilder_ == null) {
result.terminus_ = terminus_;
} else {
result.terminus_ = terminusBuilder_.build();
}
onBuilt();
return result;
}
@ -991,6 +1213,12 @@ public final class TrainStateProto {
if (other.hasRoadSection()) {
mergeRoadSection(other.getRoadSection());
}
if (other.hasLine()) {
mergeLine(other.getLine());
}
if (other.hasTerminus()) {
mergeTerminus(other.getTerminus());
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
@ -1804,6 +2032,334 @@ public final class TrainStateProto {
}
return roadSectionBuilder_;
}
private club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line line_;
private com.google.protobuf.SingleFieldBuilderV3<
club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line, club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.Builder, club.joylink.rtss.simulation.ncc.module.proto.LineProto.LineOrBuilder> lineBuilder_;
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
* @return Whether the line field is set.
*/
public boolean hasLine() {
return lineBuilder_ != null || line_ != null;
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
* @return The line.
*/
public club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line getLine() {
if (lineBuilder_ == null) {
return line_ == null ? club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.getDefaultInstance() : line_;
} else {
return lineBuilder_.getMessage();
}
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
*/
public Builder setLine(club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line value) {
if (lineBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
line_ = value;
onChanged();
} else {
lineBuilder_.setMessage(value);
}
return this;
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
*/
public Builder setLine(
club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.Builder builderForValue) {
if (lineBuilder_ == null) {
line_ = builderForValue.build();
onChanged();
} else {
lineBuilder_.setMessage(builderForValue.build());
}
return this;
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
*/
public Builder mergeLine(club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line value) {
if (lineBuilder_ == null) {
if (line_ != null) {
line_ =
club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.newBuilder(line_).mergeFrom(value).buildPartial();
} else {
line_ = value;
}
onChanged();
} else {
lineBuilder_.mergeFrom(value);
}
return this;
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
*/
public Builder clearLine() {
if (lineBuilder_ == null) {
line_ = null;
onChanged();
} else {
line_ = null;
lineBuilder_ = null;
}
return this;
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
*/
public club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.Builder getLineBuilder() {
onChanged();
return getLineFieldBuilder().getBuilder();
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
*/
public club.joylink.rtss.simulation.ncc.module.proto.LineProto.LineOrBuilder getLineOrBuilder() {
if (lineBuilder_ != null) {
return lineBuilder_.getMessageOrBuilder();
} else {
return line_ == null ?
club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.getDefaultInstance() : line_;
}
}
/**
* <pre>
**
* 行驶线路
* </pre>
*
* <code>.proto.Line line = 9;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line, club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.Builder, club.joylink.rtss.simulation.ncc.module.proto.LineProto.LineOrBuilder>
getLineFieldBuilder() {
if (lineBuilder_ == null) {
lineBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line, club.joylink.rtss.simulation.ncc.module.proto.LineProto.Line.Builder, club.joylink.rtss.simulation.ncc.module.proto.LineProto.LineOrBuilder>(
getLine(),
getParentForChildren(),
isClean());
line_ = null;
}
return lineBuilder_;
}
private club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station terminus_;
private com.google.protobuf.SingleFieldBuilderV3<
club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station, club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.Builder, club.joylink.rtss.simulation.ncc.module.proto.StationProto.StationOrBuilder> terminusBuilder_;
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
* @return Whether the terminus field is set.
*/
public boolean hasTerminus() {
return terminusBuilder_ != null || terminus_ != null;
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
* @return The terminus.
*/
public club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station getTerminus() {
if (terminusBuilder_ == null) {
return terminus_ == null ? club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.getDefaultInstance() : terminus_;
} else {
return terminusBuilder_.getMessage();
}
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
*/
public Builder setTerminus(club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station value) {
if (terminusBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
terminus_ = value;
onChanged();
} else {
terminusBuilder_.setMessage(value);
}
return this;
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
*/
public Builder setTerminus(
club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.Builder builderForValue) {
if (terminusBuilder_ == null) {
terminus_ = builderForValue.build();
onChanged();
} else {
terminusBuilder_.setMessage(builderForValue.build());
}
return this;
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
*/
public Builder mergeTerminus(club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station value) {
if (terminusBuilder_ == null) {
if (terminus_ != null) {
terminus_ =
club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.newBuilder(terminus_).mergeFrom(value).buildPartial();
} else {
terminus_ = value;
}
onChanged();
} else {
terminusBuilder_.mergeFrom(value);
}
return this;
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
*/
public Builder clearTerminus() {
if (terminusBuilder_ == null) {
terminus_ = null;
onChanged();
} else {
terminus_ = null;
terminusBuilder_ = null;
}
return this;
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
*/
public club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.Builder getTerminusBuilder() {
onChanged();
return getTerminusFieldBuilder().getBuilder();
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
*/
public club.joylink.rtss.simulation.ncc.module.proto.StationProto.StationOrBuilder getTerminusOrBuilder() {
if (terminusBuilder_ != null) {
return terminusBuilder_.getMessageOrBuilder();
} else {
return terminus_ == null ?
club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.getDefaultInstance() : terminus_;
}
}
/**
* <pre>
**
* 终点站
* </pre>
*
* <code>.proto.Station terminus = 10;</code>
*/
private com.google.protobuf.SingleFieldBuilderV3<
club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station, club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.Builder, club.joylink.rtss.simulation.ncc.module.proto.StationProto.StationOrBuilder>
getTerminusFieldBuilder() {
if (terminusBuilder_ == null) {
terminusBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station, club.joylink.rtss.simulation.ncc.module.proto.StationProto.Station.Builder, club.joylink.rtss.simulation.ncc.module.proto.StationProto.StationOrBuilder>(
getTerminus(),
getParentForChildren(),
isClean());
terminus_ = null;
}
return terminusBuilder_;
}
@java.lang.Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
@ -1871,22 +2427,25 @@ public final class TrainStateProto {
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\021train_state.proto\022\005proto\032\023model/statio" +
"n.proto\032\030model/road_section.proto\032\037state" +
"/train_state_command.proto\032\020run_status.p" +
"roto\"\373\001\n\nTrainState\022\022\n\ntripNumber\030\001 \001(\t\022" +
"$\n\014startStation\030\002 \001(\0132\016.proto.Station\022\020\n" +
"\010distance\030\003 \001(\001\022#\n\trunStatus\030\004 \001(\0162\020.pro" +
"to.RunStatus\022\021\n\tdirection\030\005 \001(\005\022)\n\007comma" +
"nd\030\006 \001(\0132\030.proto.TrainStateCommand\022\025\n\rdi" +
"stanceRatio\030\007 \001(\001\022\'\n\013roadSection\030\010 \001(\0132\022" +
".proto.RoadSectionB@\n-club.joylink.rtss." +
"simulation.ncc.module.protoB\017TrainStateP" +
"rotob\006proto3"
"\n\021train_state.proto\022\005proto\032\020model/Line.p" +
"roto\032\023model/station.proto\032\030model/road_se" +
"ction.proto\032\037state/train_state_command.p" +
"roto\032\020run_status.proto\"\270\002\n\nTrainState\022\022\n" +
"\ntripNumber\030\001 \001(\t\022$\n\014startStation\030\002 \001(\0132" +
"\016.proto.Station\022\020\n\010distance\030\003 \001(\001\022#\n\trun" +
"Status\030\004 \001(\0162\020.proto.RunStatus\022\021\n\tdirect" +
"ion\030\005 \001(\005\022)\n\007command\030\006 \001(\0132\030.proto.Train" +
"StateCommand\022\025\n\rdistanceRatio\030\007 \001(\001\022\'\n\013r" +
"oadSection\030\010 \001(\0132\022.proto.RoadSection\022\031\n\004" +
"line\030\t \001(\0132\013.proto.Line\022 \n\010terminus\030\n \001(" +
"\0132\016.proto.StationB@\n-club.joylink.rtss.s" +
"imulation.ncc.module.protoB\017TrainStatePr" +
"otob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
club.joylink.rtss.simulation.ncc.module.proto.LineProto.getDescriptor(),
club.joylink.rtss.simulation.ncc.module.proto.StationProto.getDescriptor(),
club.joylink.rtss.simulation.ncc.module.proto.RoadSectionProto.getDescriptor(),
club.joylink.rtss.simulation.ncc.module.proto.TrainStateCommandProto.getDescriptor(),
@ -1897,7 +2456,8 @@ public final class TrainStateProto {
internal_static_proto_TrainState_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_proto_TrainState_descriptor,
new java.lang.String[] { "TripNumber", "StartStation", "Distance", "RunStatus", "Direction", "Command", "DistanceRatio", "RoadSection", });
new java.lang.String[] { "TripNumber", "StartStation", "Distance", "RunStatus", "Direction", "Command", "DistanceRatio", "RoadSection", "Line", "Terminus", });
club.joylink.rtss.simulation.ncc.module.proto.LineProto.getDescriptor();
club.joylink.rtss.simulation.ncc.module.proto.StationProto.getDescriptor();
club.joylink.rtss.simulation.ncc.module.proto.RoadSectionProto.getDescriptor();
club.joylink.rtss.simulation.ncc.module.proto.TrainStateCommandProto.getDescriptor();