【始发计划下发后,自动接车】

This commit is contained in:
weizhihong 2022-07-19 13:28:20 +08:00
parent 2aefb71fed
commit 6440a36356
4 changed files with 148 additions and 2 deletions

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.CTC;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainLoadService;
import club.joylink.rtss.simulation.cbtc.CTC.data.*;
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.*;
import club.joylink.rtss.simulation.cbtc.CTC.service.CTCService;
@ -41,10 +42,15 @@ public class CTCLogicLoop {
@Autowired
private CtcDispatchCommandService ctcDispatchCommandService;
@Autowired
private AtsTrainLoadService atsTrainLoadService;
public void run(Simulation simulation) {
updateRunPlanLog(simulation);
routeSequenceTrigger(simulation);
trackViewUpdate(simulation);
// 加载已签收行车日志
loadSignRunPlanTrain(simulation);
}
public void sendMessage(Simulation simulation) {
@ -300,7 +306,7 @@ public class CTCLogicLoop {
sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_RAILWAY_RUN_PLAN_SEND, simulation.getSimulationUserIds());
}
}
/**
* 运行计划发送变化事件
*/
@ -379,4 +385,30 @@ public class CTCLogicLoop {
stompMessageService.sendToUser(userIds, messageVO);
}
}
/**
* 加载已签收至占线板上的列车
*
* @param simulation 仿真信息
*/
private void loadSignRunPlanTrain(Simulation simulation) {
simulation.getCtcRepository().getAllRunPlanList().stream()
.filter(r -> !r.isLoad() && r.isStartRunPlan() && r.isSign())
.forEach(r -> {
simulation.getCtcRepository().addRunPlanTrain(r);
r.setLoad(true); // 已上线
});
// 列车上线
simulation.getCtcRepository().getRunPlanTrainMap().forEach((k, v) -> {
if (v.getTrackSection().isFree() && !v.getTrainList().isEmpty()) {
CtcTrainQueue.RunPlanTrain train = v.getTrainList().poll();
String tripNumber = train.getTripNumber();
int lastNum = tripNumber.charAt(tripNumber.length() - 1) - 48;
atsTrainLoadService.loadTripNumberTrain(simulation, tripNumber, k, lastNum % 2 == 0);
}
});
}
}

View File

@ -101,6 +101,11 @@ public class CtcRepository {
* 是否需要发送计划消息
*/
private Boolean runPlanSendOut;
/**
* 运行计划列车集合
*/
private final Map<String, CtcTrainQueue> runPlanTrainMap = new ConcurrentHashMap<>();
/******************************************* 以上为车站终端数据:车站为单位 *******************************************/
/**
@ -434,4 +439,23 @@ public class CtcRepository {
trackView.addReceivingLine(routeSequenceLine);
}
}
/**
* 增加列车至轨道队列
*
* @param runPlanLog 运行计划日志
*/
public void addRunPlanTrain(CtcStationRunPlanLog runPlanLog) {
CtcStationRunPlanLog.RunPlanItem departItem = runPlanLog.getDepartRunPlan();
if (departItem.getTrackSection() != null) {
String sectionCode = departItem.getTrackSection().getCode();
CtcTrainQueue trainQueue = this.runPlanTrainMap.get(sectionCode);
if (trainQueue == null) {
trainQueue = new CtcTrainQueue();
trainQueue.setTrackSection(departItem.getTrackSection());
}
trainQueue.addTrain(runPlanLog);
this.runPlanTrainMap.put(sectionCode, trainQueue);
}
}
}

View File

@ -154,6 +154,16 @@ public class CtcStationRunPlanLog {
*/
private int status;
/**
* 是否已加载至轨道
*/
private boolean load;
/**
* 是否签收至占线板
*/
private boolean sign;
public CtcStationRunPlanLog(CtcRunPlanParam paramInfo) {
this.planParam = paramInfo;
this.code = paramInfo.getRunPlanCode();
@ -309,10 +319,11 @@ public class CtcStationRunPlanLog {
}
/**
* 清空变化状态
* 签收后清空变化状态
*/
public void clearChange() {
this.changeType = null;
this.sign = true;
}
/**

View File

@ -0,0 +1,79 @@
package club.joylink.rtss.simulation.cbtc.CTC.data;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.PriorityQueue;
import java.util.Queue;
/**
* Ctc运行计划的列车
*/
@Data
public class CtcTrainQueue {
/**
* 需要加车轨道
*/
private Section trackSection;
/**
* 计划列车队列
*/
private Queue<RunPlanTrain> trainList = new PriorityQueue<>((t1, t2) -> t1.getPlanTime().isBefore(t2.getPlanTime()) ? -1 : 1);
@Data
public static class RunPlanTrain {
private CtcStationRunPlanLog runPlanLog;
private String tripNumber;
private LocalDateTime planTime;
private Section trackSection;
public RunPlanTrain(CtcStationRunPlanLog runPlanLog) {
this.runPlanLog = runPlanLog;
this.tripNumber = runPlanLog.getDepartRunPlan().getTripNumber();
this.planTime = runPlanLog.getDepartRunPlan().getPlanTime();
this.trackSection = runPlanLog.getDepartRunPlan().getTrackSection();
}
}
/**
* 是否已经上线
*
* @return 不存在已上线
*/
public boolean isExistOnline(String tripNumber) {
return trainList.stream().anyMatch(t -> tripNumber.equals(t.getTripNumber()));
}
/**
* 移除已签收未上线的列车
*
* @param tripNumber 车次
* @return 是否移除成功
*/
public boolean removeTrain(String tripNumber) {
if (isExistOnline(tripNumber)) {
RunPlanTrain train = trainList.stream().filter(t -> tripNumber.equals(t.getTripNumber()))
.findFirst().orElseGet(null);
if (train != null) {
this.trainList.remove(train);
return true;
}
}
return false;
}
/**
* 将列车添加至队列
*
* @param runPlanLog 运行计划日志
*/
public void addTrain(CtcStationRunPlanLog runPlanLog) {
RunPlanTrain runPlanTrain = new RunPlanTrain(runPlanLog);
this.trainList.add(runPlanTrain);
}
}