新实训数据结构修改中

This commit is contained in:
joylink_zhangsai 2022-08-15 17:47:02 +08:00
parent 73a1ad2e3d
commit 1e69db5a5e
16 changed files with 228 additions and 144 deletions

View File

@ -48,18 +48,18 @@ public class DraftTraining2 {
*/
private Long runPlanId;
// /**
// * List<OperaVO>的json
// */
// private String operasJson;
/**
* List<OperaVO>的json
*/
private String operaJson;
/**
* List<Step2VO>的json
*/
private String stepsJson;
private String stepJson;
/**
* List<ScoringRule>的json
* List<ScoringRuleVO>的json
*/
private String scoringRuleJson;

View File

@ -313,7 +313,7 @@ public class StationGeneratorNew implements GeneratorNew {
// .filter(station -> station.isTurnBack())
// .collect(Collectors.toList());
// tbStationList.forEach(station -> {
// if (Objects.equals(Operation.Type.Station_Set_Turn_Back_Strategy.name(), operateDefinitionVO.getOperateType())) {
// if (Objects.equals(TrainingOperation.Type.Station_Set_Turn_Back_Strategy.name(), operateDefinitionVO.getOperateType())) {
// station.setControlMode(Station.ControlMode.Center);
// trainingVOList.add(build(config, simulation, station,null, operateDefinitionVO));
// // 仿真重置

View File

@ -11,7 +11,7 @@ public class Training2Service {
public void run(Simulation simulation) {
Training2 training2 = new Training2(null, null); //从仿真里拿到Training2
for (Step2 step : training2.getStepList()) {
for (Step2 step : training2.getSteps()) {
if (!step.isCompletion()) {
if (!step.isTrigger()) {
if (step.getTriggerCondition().getValue(boolean.class)) {

View File

@ -53,10 +53,10 @@ public class Operation {
*/
Switch_Single_Unlock(Operation.CLIENT),
// /** 单锁(联动) */
// Switch_Single_Lock_Chain(Operation.CLIENT
// Switch_Single_Lock_Chain(TrainingOperation.CLIENT
// ),
// /** 单解(联动) */
// Switch_Single_Unlock_Chain(Operation.CLIENT
// Switch_Single_Unlock_Chain(TrainingOperation.CLIENT
// ),
/**
* 初始化封锁
@ -115,10 +115,10 @@ public class Operation {
*/
Switch_Reverse_Position(Operation.CLIENT),
// /** 道岔定操(联动) */
// Switch_Turn_NP_Chain(Operation.CLIENT
// Switch_Turn_NP_Chain(TrainingOperation.CLIENT
// ),
// /** 道岔反操(联动) */
// Switch_Turn_RP_Chain(Operation.CLIENT
// Switch_Turn_RP_Chain(TrainingOperation.CLIENT
// ),
/**
* 确认计轴有效
@ -254,7 +254,7 @@ public class Operation {
*/
Signal_Set_Overlap(Operation.CLIENT),
// /** 取消进路(强制取消进路,无论接近区段是否占用,如果占用延时取消) */
// Signal_Force_Cancel_Route(Operation.CLIENT
// Signal_Force_Cancel_Route(TrainingOperation.CLIENT
// ),
/**
* 人解进路
@ -639,65 +639,65 @@ public class Operation {
// /**
// * 标记ATP切除
// */
// Train_Tag_Atp_Cut(Operation.CLIENT
// Train_Tag_Atp_Cut(TrainingOperation.CLIENT
// ),
// /**
// * 标记ATP恢复
// */
// Train_Tag_Atp_Recover(Operation.CLIENT
// Train_Tag_Atp_Recover(TrainingOperation.CLIENT
// ),
// /**
// * 放行冲突列车
// */
// Train_Allow_Pass(Operation.CLIENT
// Train_Allow_Pass(TrainingOperation.CLIENT
// ),
// /**
// * 列车信息
// */
// Train_Info(Operation.CLIENT
// Train_Info(TrainingOperation.CLIENT
// ),
// /**
// * 人工限速行驶
// */
// Train_Manual_Limit_Drive(Operation.CLIENT
// Train_Manual_Limit_Drive(TrainingOperation.CLIENT
// ),
// /**
// * 按进路闭塞法行车
// */
// Train_Manual_Route_Blocking_Drive(Operation.CLIENT
// Train_Manual_Route_Blocking_Drive(TrainingOperation.CLIENT
// ),
// /**
// * 越信号机红灯
// */
// Train_Pass_Red_Signal(Operation.CLIENT
// Train_Pass_Red_Signal(TrainingOperation.CLIENT
// ),
// /**
// * 引导信号行车
// */
// Train_Drive_By_Guide_Signal(Operation.CLIENT
// Train_Drive_By_Guide_Signal(TrainingOperation.CLIENT
// ),
// /** 添加列车识别号 */
// Train_Identify_Add(Operation.CLIENT
// Train_Identify_Add(TrainingOperation.CLIENT
// ),
// /** 删除列车识别号 */
// Train_Identify_Del(Operation.CLIENT
// Train_Identify_Del(TrainingOperation.CLIENT
// ),
// /** 修改列车识别号 */
// Train_Identify_Modify(Operation.CLIENT
// Train_Identify_Modify(TrainingOperation.CLIENT
// ),
// /** 修改车组号 */
// Train_GroupNo_Modify(Operation.CLIENT
// Train_GroupNo_Modify(TrainingOperation.CLIENT
// ),
// /** 移动列车识别号 */
// Train_Identify_Move(Operation.CLIENT
// Train_Identify_Move(TrainingOperation.CLIENT
// ),
// /** 交换列车识别号 */
// Train_Identify_Exchange(Operation.CLIENT
// Train_Identify_Exchange(TrainingOperation.CLIENT
// ),
// /**
// * 列车惰行
// */
// Train_Idle(Operation.CLIENT
// Train_Idle(TrainingOperation.CLIENT
// ),
/**
* 扣车
@ -710,12 +710,12 @@ public class Operation {
// /**
// * 删除车次号
// */
// Train_Delete_Service_Number(Operation.CLIENT
// Train_Delete_Service_Number(TrainingOperation.CLIENT
// ),
// /**
// * 更改目的地码
// */
// Train_Change_Destination_Code(Operation.CLIENT
// Train_Change_Destination_Code(TrainingOperation.CLIENT
// ),
/**
* 更改车次号
@ -970,17 +970,17 @@ public class Operation {
// /**
// * 到达
// */
// CTC_ARRIVE(Operation.CLIENT
// CTC_ARRIVE(TrainingOperation.CLIENT
// ),
// /**
// * 出发
// */
// CTC_DEPARTURE(Operation.CLIENT
// CTC_DEPARTURE(TrainingOperation.CLIENT
// ),
// /**
// * 通过
// */
// CTC_PASS(Operation.CLIENT
// CTC_PASS(TrainingOperation.CLIENT
// ),
/**

View File

@ -78,7 +78,7 @@ public class SignalOperateHandler {
// * @param simulation
// * @param signalCode
// */
// @OperateHandlerMapping(type = Operation.Type.Signal_Force_Cancel_Route)
// @OperateHandlerMapping(type = TrainingOperation.Type.Signal_Force_Cancel_Route)
// public void forceCancelRoute(Simulation simulation, String signalCode) {
// Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode);
// if (Objects.nonNull(route)) {
@ -185,7 +185,7 @@ public class SignalOperateHandler {
// * @param simulation
// * @param routeCode
// */
// @OperateHandlerMapping(type = Operation.Type.Signal_Route_Guide)
// @OperateHandlerMapping(type = TrainingOperation.Type.Signal_Route_Guide)
// public void settingGuideRoute(Simulation simulation, String routeCode) {
// iciSubsystem.settingGuideRoute(simulation, routeCode);
// }
@ -253,7 +253,7 @@ public class SignalOperateHandler {
// * @param simulation
// * @param signalCode
// */
// @OperateHandlerMapping(type = Operation.Type.Signal_Open_Guide_Check_Switch)
// @OperateHandlerMapping(type = TrainingOperation.Type.Signal_Open_Guide_Check_Switch)
// public void openGuideCheckSwitch(Simulation simulation, String signalCode) {
// this.iciSubsystem.openGuideSignalCheckSwitch(simulation, signalCode);
// }
@ -263,7 +263,7 @@ public class SignalOperateHandler {
// * @param simulation
// * @param signalCode
// */
// @OperateHandlerMapping(type = Operation.Type.Signal_Open_Guide_Check_Route)
// @OperateHandlerMapping(type = TrainingOperation.Type.Signal_Open_Guide_Check_Route)
// public void openGuideCheckRoute(Simulation simulation, String signalCode) {
// this.iciSubsystem.openGuideSignalCheckRoute(simulation, signalCode);
// }

View File

@ -96,7 +96,7 @@ public class SwitchOperateHandler {
}
// /**道岔定操(联动)*/
// @OperateHandlerMapping(type = Operation.Type.Switch_Turn_NP_Chain)
// @OperateHandlerMapping(type = TrainingOperation.Type.Switch_Turn_NP_Chain)
// public void chainTurn2Normal(Simulation simulation, String switchCode) {
// this.turn2Normal(simulation, switchCode);
// SimulationDataRepository repository = simulation.getRepository();
@ -108,7 +108,7 @@ public class SwitchOperateHandler {
// }
// /**道岔反操(联动)*/
// @OperateHandlerMapping(type = Operation.Type.Switch_Turn_RP_Chain)
// @OperateHandlerMapping(type = TrainingOperation.Type.Switch_Turn_RP_Chain)
// public void chainTurn2Reverse(Simulation simulation, String switchCode) {
// this.turn2Reverse(simulation, switchCode);
// SimulationDataRepository repository = simulation.getRepository();
@ -153,7 +153,7 @@ public class SwitchOperateHandler {
}
// /**道岔单锁(联动)*/
// @OperateHandlerMapping(type =Operation.Type.Switch_Single_Lock_Chain)
// @OperateHandlerMapping(type =TrainingOperation.Type.Switch_Single_Lock_Chain)
// public void chainSingleLockSwitch(Simulation simulation, String switchCode) {
// SimulationDataRepository repository = simulation.getRepository();
// Switch aSwitch = repository.getByCode(switchCode, Switch.class);
@ -165,7 +165,7 @@ public class SwitchOperateHandler {
// }
// /**道岔单解(联动)*/
// @OperateHandlerMapping(type =Operation.Type.Switch_Single_Unlock_Chain)
// @OperateHandlerMapping(type =TrainingOperation.Type.Switch_Single_Unlock_Chain)
// public void chainSingleUnlockSwitch(Simulation simulation, String switchCode) {
// SimulationDataRepository repository = simulation.getRepository();
// Switch aSwitch = repository.getByCode(switchCode, Switch.class);

View File

@ -237,7 +237,7 @@ public class TrainOperateHandler {
// /**
// * 删除ID
// */
// @OperateHandlerMapping(type = Operation.Type.Train_Delete_Service_Number)
// @OperateHandlerMapping(type = TrainingOperation.Type.Train_Delete_Service_Number)
// public void deleteServiceNumber(Simulation simulation, String groupNumber) {
// atsTrainService.deleteServiceNumber(simulation, groupNumber);
// }
@ -245,7 +245,7 @@ public class TrainOperateHandler {
// /**
// * 修改目的地码
// */
// @OperateHandlerMapping(type = Operation.Type.Train_Change_Destination_Code)
// @OperateHandlerMapping(type = TrainingOperation.Type.Train_Change_Destination_Code)
// public void changeDestinationCode(Simulation simulation, String groupNumber, String destinationCode) {
// atsTrainService.changeDestinationCode(simulation, groupNumber, destinationCode);
// }

View File

@ -97,7 +97,7 @@ public class AtsStationService {
log.debug("行调请求站控");
targetMembers = simulation.findMemberListByRole(SimulationMember.Type.STATION_SUPERVISOR);
}
transferControl(simulation, fromMember, stationCodes, targetMembers, Operation.Type.CM_Apply_For_Station_Control);*/
transferControl(simulation, fromMember, stationCodes, targetMembers, TrainingOperation.Type.CM_Apply_For_Station_Control);*/
}
@ -121,7 +121,7 @@ public class AtsStationService {
log.debug("行调请求中控");
targetMembers = simulation.findMemberListByRole(SimulationMember.Type.STATION_SUPERVISOR);
}
transferControl(simulation, fromMember, stationCodes, targetMembers, Operation.Type.CM_Apply_For_Center_Control);*/
transferControl(simulation, fromMember, stationCodes, targetMembers, TrainingOperation.Type.CM_Apply_For_Center_Control);*/
}

View File

@ -234,7 +234,7 @@ public class Joylink3DMessageService {
// vrSwitchList.forEach(vrSwitch -> {
// boolean normal;
// if (vrSwitch.isTurning()) {
// normal = vrSwitch.getCommand().equals(VirtualRealitySwitch.Operation.NP);
// normal = vrSwitch.getCommand().equals(VirtualRealitySwitch.TrainingOperation.NP);
// } else if (vrSwitch.isPosN()) {
// normal = true;
// } else {
@ -247,7 +247,7 @@ public class Joylink3DMessageService {
// vrPsdList.forEach(vrPsd -> {
// boolean open;
// if (vrPsd.isTurning()) {
// open = vrPsd.getCommand().equals(VirtualRealityScreenDoor.Operation.K);
// open = vrPsd.getCommand().equals(VirtualRealityScreenDoor.TrainingOperation.K);
// } else if (vrPsd.isClose()) {
// open = false;
// } else {

View File

@ -107,7 +107,7 @@ public class CompetitionAndScriptManager {
}
// //本地测试用
// if (Objects.equals(unfinishedAction.getType(), ScriptActionBO.ActionType.Conversation)
// || Objects.equals(unfinishedAction.getType(), ScriptActionBO.ActionType.Operation)) {
// || Objects.equals(unfinishedAction.getType(), ScriptActionBO.ActionType.TrainingOperation)) {
// scriptExecuteService.executeAction(simulation, unfinishedAction, correctSystemTime);
// }
return;

View File

@ -22,13 +22,21 @@ public class Expression implements Valuable {
*/
Valuable[] valuables;
public Expression(String OperatorName, Valuable... valuables) {
this.operator = Operator.valueOf(OperatorName);
public Expression(String operatorName, Valuable... valuables) {
this(Operator.valueOf(operatorName), valuables);
}
public Expression(Operator operator, Valuable... valuables) {
this.operator = operator;
this.valuables = valuables;
}
@Override
public <T> T getValue(Class<T> cls) {
return calValue(cls);
}
public <T> T calValue(Class<T> cls) {
return operator.handle(cls, valuables);
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.training2;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.vo.client.training2.Step2VO;
import lombok.Getter;
import lombok.Setter;
@ -23,4 +24,12 @@ public class Step2 {
this.id = vo.getId();
this.description = vo.getDescription();
}
public Step2(Step2VO vo, SimulationDataRepository repository) {
this(vo);
Valuable triggerCondition = vo.getTriggerCondition().convert2BO(repository);
Valuable completionCondition = vo.getCompletionCondition().convert2BO(repository);
this.triggerCondition = triggerCondition;
this.completionCondition = completionCondition;
}
}

View File

@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.cbtc.training2;
import club.joylink.rtss.entity.training2.DraftTraining2;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.training2.OperaVO;
import club.joylink.rtss.vo.client.training2.ScoringRuleVO;
import club.joylink.rtss.vo.client.training2.Step2VO;
import lombok.Getter;
@ -33,7 +34,9 @@ public class Training2 {
private Long runPlanId;
private List<Step2> stepList;
private List<TrainingOperation> operations;
private List<Step2> steps;
private List<ScoringRuleVO> scoringRules;
@ -51,15 +54,14 @@ public class Training2 {
public Training2(DraftTraining2 draftTraining2, Simulation simulation) {
labels = JsonUtils.readCollection(draftTraining2.getLabelJson(), List.class, String.class);
List<Step2VO> step2VOS = JsonUtils.readCollection(draftTraining2.getStepsJson(), List.class, Step2VO.class);
stepList = step2VOS.stream().map(vo -> {
Step2 step2 = new Step2(vo);
Valuable triggerCondition = vo.getTriggerCondition().convert2BO(simulation.getRepository());
Valuable completionCondition = vo.getCompletionCondition().convert2BO(simulation.getRepository());
step2.setTriggerCondition(triggerCondition);
step2.setCompletionCondition(completionCondition);
return step2;
}).collect(Collectors.toList());
List<OperaVO> operaVOS = JsonUtils.readCollection(draftTraining2.getOperaJson(), List.class, OperaVO.class);
operations = operaVOS.stream()
.map(vo -> vo.convert2BO(simulation))
.collect(Collectors.toList());
List<Step2VO> step2VOS = JsonUtils.readCollection(draftTraining2.getStepJson(), List.class, Step2VO.class);
steps = step2VOS.stream()
.map(vo -> new Step2(vo, simulation.getRepository()))
.collect(Collectors.toList());
}
public enum Type {

View File

@ -0,0 +1,57 @@
package club.joylink.rtss.simulation.cbtc.training2;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.Getter;
import java.util.Map;
/**
* 实训操作
*/
@Getter
public abstract class TrainingOperation {
private Integer id;
private Type type;
private SimulationMember member;
public enum Type {
/**
* 元操作最小操作单位
*/
META,
/**
* 仿真操作
*/
SIM,
}
public TrainingOperation(Integer id, Type type, SimulationMember member) {
this.id = id;
this.type = type;
this.member = member;
}
@Getter
public static class SimOperation extends TrainingOperation{
private club.joylink.rtss.simulation.cbtc.ATS.operation.Operation.Type operationType;
private Map<String, Object> params;
public SimOperation(Integer id, TrainingOperation.Type type, SimulationMember member,
Operation.Type operationType, Map<String, Object> params) {
super(id, type, member);
this.operationType = operationType;
this.params = params;
}
}
@Getter
public static class MetaOperation extends TrainingOperation{
public MetaOperation(Integer id, Type type, SimulationMember member) {
super(id, type, member);
}
}
}

View File

@ -1,20 +0,0 @@
package club.joylink.rtss.simulation.cbtc.training2;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
public class Value implements Valuable {
private Object v;
public Value(Object v) {
this.v = v;
}
@Override
public <T> T getValue(Class<T> cls) {
try {
return (T) this.v;
} catch (Exception e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e);
}
}
}

View File

@ -1,15 +1,15 @@
package club.joylink.rtss.vo.client.training2;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.training2.Expression;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.map.graph.Point;
import com.fasterxml.jackson.annotation.JsonIgnore;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.training2.TrainingOperation;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
import java.util.Map;
/**
@ -18,83 +18,111 @@ import java.util.Map;
@Getter
@Setter
@NoArgsConstructor
public class OperaVO {
private String id = "1";
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "type")
@JsonSubTypes({
//注意name的值和Operation.Type枚举的name一致
@JsonSubTypes.Type(value = OperaVO.SimOperaVO.class, name = "SIM"),
@JsonSubTypes.Type(value = OperaVO.MetaOperaVO.class, name = "META"),
})
public abstract class OperaVO {
Integer id;
private Type type = Type.META;
TrainingOperation.Type type;
public enum Type {
/**
* 元操作最小操作单位
*/
META,
ATS,
CONVERSATION,
}
@JsonIgnore
private OperaDetail detail;
String memberId;
/**
* 操作的触发条件
*/
private Expression triggerCondition;
ValuableVO triggerCondition;
/**
* 操作的完成判定条件
*/
private Expression completionCondition;
ValuableVO completionCondition;
public String getDetailJson() {
if (detail != null) {
return JsonUtils.writeValueAsString(detail);
}
return null;
}
public abstract TrainingOperation convert2BO(Simulation simulation);
public void setDetailJson(String detailJson) {
if (detailJson != null) {
switch (type) {
case META:
this.detail = JsonUtils.read(detailJson, MetaOperaDetail.class);
break;
case ATS:
this.detail = JsonUtils.read(detailJson, AtsOperaDetail.class);
break;
case CONVERSATION:
this.detail = JsonUtils.read(detailJson, ConversationOperaDetail.class);
break;
}
public static class MetaOperaVO extends OperaVO {
@Override
public TrainingOperation convert2BO(Simulation simulation) {
SimulationMember member = simulation.getSimulationMemberById(memberId);
return new TrainingOperation.MetaOperation(id, type, member);
}
}
public static abstract class OperaDetail {
}
@Getter
@Setter
@NoArgsConstructor
public static class MetaOperaDetail extends OperaDetail{
private String elementCode = "Signal_X1254";
private Point point;
}
@Getter
@Setter
@NoArgsConstructor
public static class AtsOperaDetail extends OperaDetail{
public static class SimOperaVO extends OperaVO{
private Operation.Type operationType;
private Map<String, Object> params;
@Override
public TrainingOperation convert2BO(Simulation simulation) {
SimulationMember member = simulation.getSimulationMemberById(memberId);
return new TrainingOperation.SimOperation(id, type, member, operationType, params);
}
}
@Getter
@Setter
@NoArgsConstructor
public static class ConversationOperaDetail extends OperaDetail{
private String conversationId;
// @JsonIgnore
// private OperaDetail detail;
private List<String> memberIds;
}
// /**
// * 操作的触发条件
// */
// private Expression triggerCondition;
//
// /**
// * 操作的完成判定条件
// */
// private Expression completionCondition;
// /**
// * 勿删用于序列化
// */
// public String getDetailJson() {
// if (detail != null) {
// return JsonUtils.writeValueAsString(detail);
// }
// return null;
// }
//
// /**
// * 勿删用于反序列化
// */
// public void setDetailJson(String detailJson) {
// if (detailJson != null) {
// switch (type) {
// case META:
// this.detail = JsonUtils.read(detailJson, MetaOperaDetail.class);
// break;
// case SIM:
// this.detail = JsonUtils.read(detailJson, SimOperaDetail.class);
// break;
// }
// }
// }
//
// public static abstract class OperaDetail {
// }
//
// /**
// * 数据待定
// */
// @Getter
// @Setter
// @NoArgsConstructor
// public static class MetaOperaDetail extends OperaDetail{
// private String elementCode = "Signal_X1254";
//
// private Point point;
// }
//
// @Getter
// @Setter
// @NoArgsConstructor
// public static class SimOperaDetail extends OperaDetail{
// private TrainingOperation.Type operationType;
//
// private Map<String, Object> params;
// }
}