【NCC world事件操作】

This commit is contained in:
weizhihong 2023-03-02 17:16:40 +08:00
parent 01cd3adc46
commit b8cae4edfa
10 changed files with 529 additions and 83 deletions

@ -1 +1 @@
Subproject commit 2adf468e0be410e0bc530e5ec3882d45fdb1b9b4
Subproject commit 3ff3c0da726665b5bd057c75bd86cd0072c3da31

View File

@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.ncc.simulation;
import club.joylink.ecs.World;
import club.joylink.ecs.WorldManage;
import club.joylink.rtss.simulation.ncc.dto.NccMapDataDto;
import club.joylink.rtss.simulation.ncc.exception.NccExceptionAssertEnum;
import club.joylink.rtss.simulation.ncc.module.proto.StorageProto;
import club.joylink.rtss.simulation.ncc.repository.IRtsNccMapDataRepository;
import club.joylink.rtss.simulation.ncc.simulation.event.NCCCreateEvent;
@ -16,6 +17,7 @@ import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import javax.validation.constraints.NotNull;
import java.util.Optional;
/**
* Ncc world 管理服务类
@ -31,15 +33,20 @@ public class NCCManagerService {
*/
@EventListener
public void createWorld(NCCCreateEvent event) {
// NccMapDataDto nccMapData = rtsNccMapDataRepository.findById(id);
// StorageProto.Storage storage = StorageProto.Storage.parseFrom(nccMapData.getData());
// World world = WorldManage.create(generateWorldId(simId));
// // 将构建信息放入world
// world.getStorage().insertSingleton(storage);
// // 添加系统
// world.getTaskControl().addSystem(new TrainStateSystem());
// world.start();
// world.setSpeed(1);
NccMapDataDto nccMapData = rtsNccMapDataRepository.findById(event.getMapId());
StorageProto.Storage storage = null;
try {
storage = StorageProto.Storage.parseFrom(nccMapData.getData());
World world = WorldManage.create(generateWorldId(event.getSimulationId()));
// 将构建信息放入world
world.getStorage().insertSingleton(storage);
// 添加系统
world.getTaskControl().addSystem(new TrainStateSystem());
world.start();
world.setSpeed(1);
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e);
}
}
/**
@ -47,7 +54,12 @@ public class NCCManagerService {
*/
@EventListener
public void updateWorld(NCCUpdateEvent event) {
Optional<World> worldOptional = WorldManage.get(generateWorldId(event.getSimulationId()));
if (worldOptional.isPresent()) {
event.getStateType().handle(worldOptional.get(), event.getData());
} else {
throw NccExceptionAssertEnum.DataNotExist.exception(String.format("NCC world-[%s]-数据不存在", event.getSimulationId()));
}
}
/**

View File

@ -0,0 +1,52 @@
package club.joylink.rtss.simulation.ncc.simulation;
import club.joylink.ecs.World;
import club.joylink.ecs.api.Entity;
import club.joylink.rtss.simulation.ncc.exception.NccExceptionAssertEnum;
import club.joylink.rtss.simulation.ncc.module.proto.CommandStatusProto;
import club.joylink.rtss.simulation.ncc.module.proto.RunStatusProto;
import club.joylink.rtss.simulation.ncc.module.proto.TrainStateCommandProto;
import club.joylink.rtss.simulation.ncc.module.proto.TrainStateProto;
import club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto;
import com.google.protobuf.InvalidProtocolBufferException;
import java.util.Optional;
/**
* NCC 修改状态Type对应操作方法
*/
public enum NccStateType {
TRAIN_STATE_CHANGE("列车状态变更") {
@Override
public void handle(World world, byte[] data) {
try {
TrainStateCommandProto.TrainStateCommand command = TrainStateCommandProto.TrainStateCommand.parseFrom(data);
Optional<Entity> entity = world.getStorage().queryEntity(command.getCode());
if (entity.isPresent()) {
Optional<TrainStateProto.TrainState.Builder> builder = entity.get().getComponent(TrainStateProto.TrainState.Builder.class);
if (builder.isPresent()) {
builder.get().setCommand(command);
} else {
throw NccExceptionAssertEnum.DataNotExist.exception(String.format("列车【%s】状态组件不存在", command.getCode()));
}
} else {
throw NccExceptionAssertEnum.DataNotExist.exception(String.format("列车【%s】不存在", command.getCode()));
}
} catch (InvalidProtocolBufferException e) {
throw new RuntimeException(e);
}
}
};
private String description;
NccStateType(String description) {
this.description = description;
}
public abstract void handle(World world, byte[] data);
}

View File

@ -0,0 +1,18 @@
package club.joylink.rtss.simulation.ncc.simulation.event;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
/**
* NCC公共事件
*/
@Getter
public abstract class NCCCommEvent extends ApplicationEvent {
private String simulationId;
public NCCCommEvent(Object source, String simulationId) {
super(source);
this.simulationId = simulationId;
}
}

View File

@ -1,14 +1,17 @@
package club.joylink.rtss.simulation.ncc.simulation.event;
import org.springframework.context.ApplicationEvent;
import lombok.Getter;
/**
* 创建事件
*/
public class NCCCreateEvent extends ApplicationEvent {
@Getter
public class NCCCreateEvent extends NCCCommEvent {
public NCCCreateEvent(Object source) {
super(source);
private Long mapId;
public NCCCreateEvent(Object source, String simulationId, Long mapId) {
super(source, simulationId);
this.mapId = mapId;
}
}

View File

@ -1,13 +1,14 @@
package club.joylink.rtss.simulation.ncc.simulation.event;
import org.springframework.context.ApplicationEvent;
import lombok.Getter;
/**
* NCC销毁时间
*/
public class NCCDestroyEvent extends ApplicationEvent {
@Getter
public class NCCDestroyEvent extends NCCCommEvent {
public NCCDestroyEvent(Object source) {
super(source);
public NCCDestroyEvent(Object source, String simulationId) {
super(source, simulationId);
}
}

View File

@ -1,13 +1,14 @@
package club.joylink.rtss.simulation.ncc.simulation.event;
import org.springframework.context.ApplicationEvent;
import lombok.Getter;
/**
* NCC重置事件
*/
public class NCCResetEvent extends ApplicationEvent {
@Getter
public class NCCResetEvent extends NCCCommEvent {
public NCCResetEvent(Object source) {
super(source);
public NCCResetEvent(Object source, String simulationId) {
super(source, simulationId);
}
}

View File

@ -1,13 +1,27 @@
package club.joylink.rtss.simulation.ncc.simulation.event;
import org.springframework.context.ApplicationEvent;
import club.joylink.rtss.simulation.ncc.simulation.NccStateType;
import lombok.Getter;
/**
* 更新事件
*/
public class NCCUpdateEvent extends ApplicationEvent {
@Getter
public class NCCUpdateEvent extends NCCCommEvent {
public NCCUpdateEvent(Object source) {
super(source);
/**
* 更新状态类型
*/
private NccStateType stateType;
/**
* 状态参数
*/
private byte[] data;
public NCCUpdateEvent(Object source, String simulationId, NccStateType stateType, byte[] data) {
super(source, simulationId);
this.stateType = stateType;
this.data = data;
}
}

View File

@ -169,6 +169,28 @@ public final class TrainStateCommandProto {
* @return The status.
*/
club.joylink.rtss.simulation.ncc.module.proto.CommandStatusProto.CommandStatus getStatus();
/**
* <pre>
**
* 列车编号
* </pre>
*
* <code>string code = 10;</code>
* @return The code.
*/
java.lang.String getCode();
/**
* <pre>
**
* 列车编号
* </pre>
*
* <code>string code = 10;</code>
* @return The bytes for code.
*/
com.google.protobuf.ByteString
getCodeBytes();
}
/**
* <pre>
@ -194,6 +216,7 @@ public final class TrainStateCommandProto {
lineCode_ = "";
terminusCode_ = "";
status_ = 0;
code_ = "";
}
@java.lang.Override
@ -272,6 +295,12 @@ public final class TrainStateCommandProto {
status_ = rawValue;
break;
}
case 82: {
java.lang.String s = input.readStringRequireUtf8();
code_ = s;
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
@ -586,6 +615,54 @@ public final class TrainStateCommandProto {
return result == null ? club.joylink.rtss.simulation.ncc.module.proto.CommandStatusProto.CommandStatus.UNRECOGNIZED : result;
}
public static final int CODE_FIELD_NUMBER = 10;
private volatile java.lang.Object code_;
/**
* <pre>
**
* 列车编号
* </pre>
*
* <code>string code = 10;</code>
* @return The code.
*/
@java.lang.Override
public java.lang.String getCode() {
java.lang.Object ref = code_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
code_ = s;
return s;
}
}
/**
* <pre>
**
* 列车编号
* </pre>
*
* <code>string code = 10;</code>
* @return The bytes for code.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getCodeBytes() {
java.lang.Object ref = code_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
code_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
private byte memoizedIsInitialized = -1;
@java.lang.Override
public final boolean isInitialized() {
@ -624,6 +701,9 @@ public final class TrainStateCommandProto {
if (status_ != club.joylink.rtss.simulation.ncc.module.proto.CommandStatusProto.CommandStatus.UNDO.getNumber()) {
output.writeEnum(9, status_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(code_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 10, code_);
}
unknownFields.writeTo(output);
}
@ -661,6 +741,9 @@ public final class TrainStateCommandProto {
size += com.google.protobuf.CodedOutputStream
.computeEnumSize(9, status_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(code_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, code_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
@ -691,6 +774,8 @@ public final class TrainStateCommandProto {
if (!getTerminusCode()
.equals(other.getTerminusCode())) return false;
if (status_ != other.status_) return false;
if (!getCode()
.equals(other.getCode())) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@ -719,6 +804,8 @@ public final class TrainStateCommandProto {
hash = (53 * hash) + getTerminusCode().hashCode();
hash = (37 * hash) + STATUS_FIELD_NUMBER;
hash = (53 * hash) + status_;
hash = (37 * hash) + CODE_FIELD_NUMBER;
hash = (53 * hash) + getCode().hashCode();
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
@ -873,6 +960,8 @@ public final class TrainStateCommandProto {
status_ = 0;
code_ = "";
return this;
}
@ -907,6 +996,7 @@ public final class TrainStateCommandProto {
result.lineCode_ = lineCode_;
result.terminusCode_ = terminusCode_;
result.status_ = status_;
result.code_ = code_;
onBuilt();
return result;
}
@ -983,6 +1073,10 @@ public final class TrainStateCommandProto {
if (other.status_ != 0) {
setStatusValue(other.getStatusValue());
}
if (!other.getCode().isEmpty()) {
code_ = other.code_;
onChanged();
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
@ -1665,6 +1759,107 @@ public final class TrainStateCommandProto {
onChanged();
return this;
}
private java.lang.Object code_ = "";
/**
* <pre>
**
* 列车编号
* </pre>
*
* <code>string code = 10;</code>
* @return The code.
*/
public java.lang.String getCode() {
java.lang.Object ref = code_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
code_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
**
* 列车编号
* </pre>
*
* <code>string code = 10;</code>
* @return The bytes for code.
*/
public com.google.protobuf.ByteString
getCodeBytes() {
java.lang.Object ref = code_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
code_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
**
* 列车编号
* </pre>
*
* <code>string code = 10;</code>
* @param value The code to set.
* @return This builder for chaining.
*/
public Builder setCode(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
code_ = value;
onChanged();
return this;
}
/**
* <pre>
**
* 列车编号
* </pre>
*
* <code>string code = 10;</code>
* @return This builder for chaining.
*/
public Builder clearCode() {
code_ = getDefaultInstance().getCode();
onChanged();
return this;
}
/**
* <pre>
**
* 列车编号
* </pre>
*
* <code>string code = 10;</code>
* @param value The bytes for code to set.
* @return This builder for chaining.
*/
public Builder setCodeBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
code_ = value;
onChanged();
return this;
}
@java.lang.Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
@ -1733,15 +1928,15 @@ public final class TrainStateCommandProto {
static {
java.lang.String[] descriptorData = {
"\n\031train_state_command.proto\022\005proto\032\020run_" +
"status.proto\032\024command_status.proto\"\324\001\n\021T" +
"status.proto\032\024command_status.proto\"\342\001\n\021T" +
"rainStateCommand\022\022\n\ntripNumber\030\001 \001(\t\022\023\n\013" +
"stationCode\030\002 \001(\t\022\020\n\010distance\030\003 \001(\001\022#\n\tr" +
"unStatus\030\004 \001(\0162\020.proto.RunStatus\022\021\n\tdire" +
"ction\030\006 \001(\005\022\020\n\010lineCode\030\007 \001(\t\022\024\n\014terminu" +
"sCode\030\010 \001(\t\022$\n\006status\030\t \001(\0162\024.proto.Comm" +
"andStatusBG\n-club.joylink.rtss.simulatio" +
"n.ncc.module.protoB\026TrainStateCommandPro" +
"tob\006proto3"
"andStatus\022\014\n\004code\030\n \001(\tBG\n-club.joylink." +
"rtss.simulation.ncc.module.protoB\026TrainS" +
"tateCommandProtob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
@ -1754,7 +1949,7 @@ public final class TrainStateCommandProto {
internal_static_proto_TrainStateCommand_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_proto_TrainStateCommand_descriptor,
new java.lang.String[] { "TripNumber", "StationCode", "Distance", "RunStatus", "Direction", "LineCode", "TerminusCode", "Status", });
new java.lang.String[] { "TripNumber", "StationCode", "Distance", "RunStatus", "Direction", "LineCode", "TerminusCode", "Status", "Code", });
club.joylink.rtss.simulation.ncc.module.proto.RunStatusProto.getDescriptor();
club.joylink.rtss.simulation.ncc.module.proto.CommandStatusProto.getDescriptor();
}

View File

@ -18,13 +18,25 @@ public final class TrainStateDtoProto {
// @@protoc_insertion_point(interface_extends:proto.TrainStateDto)
com.google.protobuf.MessageOrBuilder {
/**
* <code>string code = 1;</code>
* @return The code.
*/
java.lang.String getCode();
/**
* <code>string code = 1;</code>
* @return The bytes for code.
*/
com.google.protobuf.ByteString
getCodeBytes();
/**
* <pre>
**
* 车次信息
* </pre>
*
* <code>string tripNumber = 1;</code>
* <code>string tripNumber = 2;</code>
* @return The tripNumber.
*/
java.lang.String getTripNumber();
@ -34,7 +46,7 @@ public final class TrainStateDtoProto {
* 车次信息
* </pre>
*
* <code>string tripNumber = 1;</code>
* <code>string tripNumber = 2;</code>
* @return The bytes for tripNumber.
*/
com.google.protobuf.ByteString
@ -46,7 +58,7 @@ public final class TrainStateDtoProto {
* 运行方向
* </pre>
*
* <code>int32 direction = 2;</code>
* <code>int32 direction = 3;</code>
* @return The direction.
*/
int getDirection();
@ -57,7 +69,7 @@ public final class TrainStateDtoProto {
* 距离占比
* </pre>
*
* <code>double distanceRatio = 3;</code>
* <code>double distanceRatio = 4;</code>
* @return The distanceRatio.
*/
double getDistanceRatio();
@ -68,7 +80,7 @@ public final class TrainStateDtoProto {
* 所在轨道
* </pre>
*
* <code>string roadSection = 4;</code>
* <code>string roadSection = 5;</code>
* @return The roadSection.
*/
java.lang.String getRoadSection();
@ -78,7 +90,7 @@ public final class TrainStateDtoProto {
* 所在轨道
* </pre>
*
* <code>string roadSection = 4;</code>
* <code>string roadSection = 5;</code>
* @return The bytes for roadSection.
*/
com.google.protobuf.ByteString
@ -102,6 +114,7 @@ public final class TrainStateDtoProto {
super(builder);
}
private TrainStateDto() {
code_ = "";
tripNumber_ = "";
roadSection_ = "";
}
@ -139,20 +152,26 @@ public final class TrainStateDtoProto {
case 10: {
java.lang.String s = input.readStringRequireUtf8();
code_ = s;
break;
}
case 18: {
java.lang.String s = input.readStringRequireUtf8();
tripNumber_ = s;
break;
}
case 16: {
case 24: {
direction_ = input.readInt32();
break;
}
case 25: {
case 33: {
distanceRatio_ = input.readDouble();
break;
}
case 34: {
case 42: {
java.lang.String s = input.readStringRequireUtf8();
roadSection_ = s;
@ -190,7 +209,45 @@ public final class TrainStateDtoProto {
club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto.TrainStateDto.class, club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto.TrainStateDto.Builder.class);
}
public static final int TRIPNUMBER_FIELD_NUMBER = 1;
public static final int CODE_FIELD_NUMBER = 1;
private volatile java.lang.Object code_;
/**
* <code>string code = 1;</code>
* @return The code.
*/
@java.lang.Override
public java.lang.String getCode() {
java.lang.Object ref = code_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
code_ = s;
return s;
}
}
/**
* <code>string code = 1;</code>
* @return The bytes for code.
*/
@java.lang.Override
public com.google.protobuf.ByteString
getCodeBytes() {
java.lang.Object ref = code_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
code_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int TRIPNUMBER_FIELD_NUMBER = 2;
private volatile java.lang.Object tripNumber_;
/**
* <pre>
@ -198,7 +255,7 @@ public final class TrainStateDtoProto {
* 车次信息
* </pre>
*
* <code>string tripNumber = 1;</code>
* <code>string tripNumber = 2;</code>
* @return The tripNumber.
*/
@java.lang.Override
@ -220,7 +277,7 @@ public final class TrainStateDtoProto {
* 车次信息
* </pre>
*
* <code>string tripNumber = 1;</code>
* <code>string tripNumber = 2;</code>
* @return The bytes for tripNumber.
*/
@java.lang.Override
@ -238,7 +295,7 @@ public final class TrainStateDtoProto {
}
}
public static final int DIRECTION_FIELD_NUMBER = 2;
public static final int DIRECTION_FIELD_NUMBER = 3;
private int direction_;
/**
* <pre>
@ -246,7 +303,7 @@ public final class TrainStateDtoProto {
* 运行方向
* </pre>
*
* <code>int32 direction = 2;</code>
* <code>int32 direction = 3;</code>
* @return The direction.
*/
@java.lang.Override
@ -254,7 +311,7 @@ public final class TrainStateDtoProto {
return direction_;
}
public static final int DISTANCERATIO_FIELD_NUMBER = 3;
public static final int DISTANCERATIO_FIELD_NUMBER = 4;
private double distanceRatio_;
/**
* <pre>
@ -262,7 +319,7 @@ public final class TrainStateDtoProto {
* 距离占比
* </pre>
*
* <code>double distanceRatio = 3;</code>
* <code>double distanceRatio = 4;</code>
* @return The distanceRatio.
*/
@java.lang.Override
@ -270,7 +327,7 @@ public final class TrainStateDtoProto {
return distanceRatio_;
}
public static final int ROADSECTION_FIELD_NUMBER = 4;
public static final int ROADSECTION_FIELD_NUMBER = 5;
private volatile java.lang.Object roadSection_;
/**
* <pre>
@ -278,7 +335,7 @@ public final class TrainStateDtoProto {
* 所在轨道
* </pre>
*
* <code>string roadSection = 4;</code>
* <code>string roadSection = 5;</code>
* @return The roadSection.
*/
@java.lang.Override
@ -300,7 +357,7 @@ public final class TrainStateDtoProto {
* 所在轨道
* </pre>
*
* <code>string roadSection = 4;</code>
* <code>string roadSection = 5;</code>
* @return The bytes for roadSection.
*/
@java.lang.Override
@ -332,17 +389,20 @@ public final class TrainStateDtoProto {
@java.lang.Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(code_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, code_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(tripNumber_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, tripNumber_);
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, tripNumber_);
}
if (direction_ != 0) {
output.writeInt32(2, direction_);
output.writeInt32(3, direction_);
}
if (java.lang.Double.doubleToRawLongBits(distanceRatio_) != 0) {
output.writeDouble(3, distanceRatio_);
output.writeDouble(4, distanceRatio_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(roadSection_)) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 4, roadSection_);
com.google.protobuf.GeneratedMessageV3.writeString(output, 5, roadSection_);
}
unknownFields.writeTo(output);
}
@ -353,19 +413,22 @@ public final class TrainStateDtoProto {
if (size != -1) return size;
size = 0;
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(code_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, code_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(tripNumber_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, tripNumber_);
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, tripNumber_);
}
if (direction_ != 0) {
size += com.google.protobuf.CodedOutputStream
.computeInt32Size(2, direction_);
.computeInt32Size(3, direction_);
}
if (java.lang.Double.doubleToRawLongBits(distanceRatio_) != 0) {
size += com.google.protobuf.CodedOutputStream
.computeDoubleSize(3, distanceRatio_);
.computeDoubleSize(4, distanceRatio_);
}
if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(roadSection_)) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, roadSection_);
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, roadSection_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
@ -382,6 +445,8 @@ public final class TrainStateDtoProto {
}
club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto.TrainStateDto other = (club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto.TrainStateDto) obj;
if (!getCode()
.equals(other.getCode())) return false;
if (!getTripNumber()
.equals(other.getTripNumber())) return false;
if (getDirection()
@ -402,6 +467,8 @@ public final class TrainStateDtoProto {
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + CODE_FIELD_NUMBER;
hash = (53 * hash) + getCode().hashCode();
hash = (37 * hash) + TRIPNUMBER_FIELD_NUMBER;
hash = (53 * hash) + getTripNumber().hashCode();
hash = (37 * hash) + DIRECTION_FIELD_NUMBER;
@ -549,6 +616,8 @@ public final class TrainStateDtoProto {
@java.lang.Override
public Builder clear() {
super.clear();
code_ = "";
tripNumber_ = "";
direction_ = 0;
@ -583,6 +652,7 @@ public final class TrainStateDtoProto {
@java.lang.Override
public club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto.TrainStateDto buildPartial() {
club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto.TrainStateDto result = new club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto.TrainStateDto(this);
result.code_ = code_;
result.tripNumber_ = tripNumber_;
result.direction_ = direction_;
result.distanceRatio_ = distanceRatio_;
@ -635,6 +705,10 @@ public final class TrainStateDtoProto {
public Builder mergeFrom(club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto.TrainStateDto other) {
if (other == club.joylink.rtss.simulation.ncc.module.proto.dto.TrainStateDtoProto.TrainStateDto.getDefaultInstance()) return this;
if (!other.getCode().isEmpty()) {
code_ = other.code_;
onChanged();
}
if (!other.getTripNumber().isEmpty()) {
tripNumber_ = other.tripNumber_;
onChanged();
@ -678,6 +752,82 @@ public final class TrainStateDtoProto {
return this;
}
private java.lang.Object code_ = "";
/**
* <code>string code = 1;</code>
* @return The code.
*/
public java.lang.String getCode() {
java.lang.Object ref = code_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
code_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <code>string code = 1;</code>
* @return The bytes for code.
*/
public com.google.protobuf.ByteString
getCodeBytes() {
java.lang.Object ref = code_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
code_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <code>string code = 1;</code>
* @param value The code to set.
* @return This builder for chaining.
*/
public Builder setCode(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
code_ = value;
onChanged();
return this;
}
/**
* <code>string code = 1;</code>
* @return This builder for chaining.
*/
public Builder clearCode() {
code_ = getDefaultInstance().getCode();
onChanged();
return this;
}
/**
* <code>string code = 1;</code>
* @param value The bytes for code to set.
* @return This builder for chaining.
*/
public Builder setCodeBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
code_ = value;
onChanged();
return this;
}
private java.lang.Object tripNumber_ = "";
/**
* <pre>
@ -685,7 +835,7 @@ public final class TrainStateDtoProto {
* 车次信息
* </pre>
*
* <code>string tripNumber = 1;</code>
* <code>string tripNumber = 2;</code>
* @return The tripNumber.
*/
public java.lang.String getTripNumber() {
@ -706,7 +856,7 @@ public final class TrainStateDtoProto {
* 车次信息
* </pre>
*
* <code>string tripNumber = 1;</code>
* <code>string tripNumber = 2;</code>
* @return The bytes for tripNumber.
*/
public com.google.protobuf.ByteString
@ -728,7 +878,7 @@ public final class TrainStateDtoProto {
* 车次信息
* </pre>
*
* <code>string tripNumber = 1;</code>
* <code>string tripNumber = 2;</code>
* @param value The tripNumber to set.
* @return This builder for chaining.
*/
@ -748,7 +898,7 @@ public final class TrainStateDtoProto {
* 车次信息
* </pre>
*
* <code>string tripNumber = 1;</code>
* <code>string tripNumber = 2;</code>
* @return This builder for chaining.
*/
public Builder clearTripNumber() {
@ -763,7 +913,7 @@ public final class TrainStateDtoProto {
* 车次信息
* </pre>
*
* <code>string tripNumber = 1;</code>
* <code>string tripNumber = 2;</code>
* @param value The bytes for tripNumber to set.
* @return This builder for chaining.
*/
@ -786,7 +936,7 @@ public final class TrainStateDtoProto {
* 运行方向
* </pre>
*
* <code>int32 direction = 2;</code>
* <code>int32 direction = 3;</code>
* @return The direction.
*/
@java.lang.Override
@ -799,7 +949,7 @@ public final class TrainStateDtoProto {
* 运行方向
* </pre>
*
* <code>int32 direction = 2;</code>
* <code>int32 direction = 3;</code>
* @param value The direction to set.
* @return This builder for chaining.
*/
@ -815,7 +965,7 @@ public final class TrainStateDtoProto {
* 运行方向
* </pre>
*
* <code>int32 direction = 2;</code>
* <code>int32 direction = 3;</code>
* @return This builder for chaining.
*/
public Builder clearDirection() {
@ -832,7 +982,7 @@ public final class TrainStateDtoProto {
* 距离占比
* </pre>
*
* <code>double distanceRatio = 3;</code>
* <code>double distanceRatio = 4;</code>
* @return The distanceRatio.
*/
@java.lang.Override
@ -845,7 +995,7 @@ public final class TrainStateDtoProto {
* 距离占比
* </pre>
*
* <code>double distanceRatio = 3;</code>
* <code>double distanceRatio = 4;</code>
* @param value The distanceRatio to set.
* @return This builder for chaining.
*/
@ -861,7 +1011,7 @@ public final class TrainStateDtoProto {
* 距离占比
* </pre>
*
* <code>double distanceRatio = 3;</code>
* <code>double distanceRatio = 4;</code>
* @return This builder for chaining.
*/
public Builder clearDistanceRatio() {
@ -878,7 +1028,7 @@ public final class TrainStateDtoProto {
* 所在轨道
* </pre>
*
* <code>string roadSection = 4;</code>
* <code>string roadSection = 5;</code>
* @return The roadSection.
*/
public java.lang.String getRoadSection() {
@ -899,7 +1049,7 @@ public final class TrainStateDtoProto {
* 所在轨道
* </pre>
*
* <code>string roadSection = 4;</code>
* <code>string roadSection = 5;</code>
* @return The bytes for roadSection.
*/
public com.google.protobuf.ByteString
@ -921,7 +1071,7 @@ public final class TrainStateDtoProto {
* 所在轨道
* </pre>
*
* <code>string roadSection = 4;</code>
* <code>string roadSection = 5;</code>
* @param value The roadSection to set.
* @return This builder for chaining.
*/
@ -941,7 +1091,7 @@ public final class TrainStateDtoProto {
* 所在轨道
* </pre>
*
* <code>string roadSection = 4;</code>
* <code>string roadSection = 5;</code>
* @return This builder for chaining.
*/
public Builder clearRoadSection() {
@ -956,7 +1106,7 @@ public final class TrainStateDtoProto {
* 所在轨道
* </pre>
*
* <code>string roadSection = 4;</code>
* <code>string roadSection = 5;</code>
* @param value The bytes for roadSection to set.
* @return This builder for chaining.
*/
@ -1038,12 +1188,12 @@ public final class TrainStateDtoProto {
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\025train_state_dto.proto\022\005proto\"b\n\rTrainS" +
"tateDto\022\022\n\ntripNumber\030\001 \001(\t\022\021\n\tdirection" +
"\030\002 \001(\005\022\025\n\rdistanceRatio\030\003 \001(\001\022\023\n\013roadSec" +
"tion\030\004 \001(\tBG\n1club.joylink.rtss.simulati" +
"on.ncc.module.proto.dtoB\022TrainStateDtoPr" +
"otob\006proto3"
"\n\025train_state_dto.proto\022\005proto\"p\n\rTrainS" +
"tateDto\022\014\n\004code\030\001 \001(\t\022\022\n\ntripNumber\030\002 \001(" +
"\t\022\021\n\tdirection\030\003 \001(\005\022\025\n\rdistanceRatio\030\004 " +
"\001(\001\022\023\n\013roadSection\030\005 \001(\tBG\n1club.joylink" +
".rtss.simulation.ncc.module.proto.dtoB\022T" +
"rainStateDtoProtob\006proto3"
};
descriptor = com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
@ -1054,7 +1204,7 @@ public final class TrainStateDtoProto {
internal_static_proto_TrainStateDto_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_proto_TrainStateDto_descriptor,
new java.lang.String[] { "TripNumber", "Direction", "DistanceRatio", "RoadSection", });
new java.lang.String[] { "Code", "TripNumber", "Direction", "DistanceRatio", "RoadSection", });
}
// @@protoc_insertion_point(outer_class_scope)