大铁进路逻辑修改;剧本车次识别增加内容

This commit is contained in:
joylink_zhangsai 2021-04-29 17:31:44 +08:00
parent e966d6360c
commit 7cd4eaac15
7 changed files with 78 additions and 80 deletions

View File

@ -322,10 +322,10 @@ public class CompetitionAndScriptManager {
sb.append("[1一幺妖腰摇要爻]");
break;
case "2":
sb.append("[两梁良亮辆量]");
sb.append("[两梁良亮辆量]");
break;
case "3":
sb.append("[3三]");
sb.append("[3三]");
break;
case "4":
sb.append("[4四]");
@ -337,16 +337,16 @@ public class CompetitionAndScriptManager {
sb.append("[6六]");
break;
case "7":
sb.append("[怪乖拐]");
sb.append("[怪乖拐]");
break;
case "8":
sb.append("[8八]");
break;
case "9":
sb.append("[9九酒]");
sb.append("[9九酒久就]");
break;
case "0":
sb.append("[0洞栋动]");
sb.append("[0洞栋动东冻冬]");
break;
}
}

View File

@ -70,11 +70,11 @@ public class SimulationVoiceHandler {
replacementList.add(new Replacement("(赚钱折法|赚钱折返)", "站前折返"));
replacementList.add(new Replacement("(权限各次)", "全线各次"));
replacementList.add(new Replacement("(庭院)", "停运"));
replacementList.add(new Replacement("(请客|青稞|青客|轻客|轻课|青涩|听课|停课|听,可|听可|顷刻|倾刻)", "清客"));
replacementList.add(new Replacement("(请客|青稞|青客|轻客|轻课|青涩|听课|停课|听,可|听可|顷刻|倾刻|千克)", "清客"));
replacementList.add(new Replacement("(会断|会短|回断)", "回段"));
replacementList.add(new Replacement("(清朝|请朝|请钞)", "请抄"));
replacementList.add(new Replacement("(请超链|请超龄)", "请抄令"));
replacementList.add(new Replacement("(首领处所|手令处所)", "受令处所"));
replacementList.add(new Replacement("(首领处所|手令处所|手链处所)", "受令处所"));
replacementList.add(new Replacement("安全保护", "安全防护"));
replacementList.add(new Replacement("(手摇质|说杨智|受邀至)", "手摇至"));
replacementList.add(new Replacement("(反胃|软位)", "反位"));
@ -88,7 +88,7 @@ public class SimulationVoiceHandler {
replacementList.add(new Replacement("(手机号|首信号|首信好|首信后)", "手信号"));
replacementList.add(new Replacement("(鼓掌|部长)", "故障"));
replacementList.add(new Replacement("(向凤|下方)", "下放"));
replacementList.add(new Replacement("(占线|占先)", "站线"));
replacementList.add(new Replacement("(占线|占先|展现|战线)", "站线"));
replacementList.add(new Replacement("(定为)", "定位"));
replacementList.add(new Replacement("(者搬迁)", "折返线"));
replacementList.add(new Replacement("(进入)", "进路"));

View File

@ -9,6 +9,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
@ -24,8 +25,10 @@ public class CilRouteLogicService {
public void routeLogic(RtSimulation rtSimulation, CilRepository cilRepository) {
List<CilRoute> supervisedRouteList = cilRepository.getSupervisedRouteList();
for (CilRoute cilRoute : supervisedRouteList) {
if (!cilRoute.isGl()) {
this.settingProgress(rtSimulation, cilRoute, cilRepository.getConfig());
if (!cilRoute.isSettingFinished()) {
this.settingProgress(rtSimulation, cilRepository, cilRoute, cilRepository.getConfig());
} else {
monitorRoute(rtSimulation, cilRepository, cilRoute);
}
if (cilRoute.isDelayUnlocking()) {
this.monitorDelayUnlockingRoute(rtSimulation, cilRoute, cilRepository.getConfig());
@ -43,7 +46,7 @@ public class CilRouteLogicService {
if (cilRepository.getSectionById(commonRoute.getPathElement().getStart().getId()).isAxcOccupy()) { //进路首区段占用
cilSignal.initGuideTime();
}
cilSignalLogicService.update2GuideAspect(simulation, cilSignal);
cilSignalLogicService.openGuideSignal(simulation, cilSignal);
}
public void masterUnlock(RtSimulation simulation, boolean right) {
@ -67,7 +70,7 @@ public class CilRouteLogicService {
}
}
if (find)
cilSignalLogicService.update2ForbiddenAspect(simulation, signal.getId());
cilSignalLogicService.openForbiddenAspect(simulation, signal.getId());
}
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(find, "无引导总锁");
}
@ -105,7 +108,7 @@ public class CilRouteLogicService {
//进路锁闭但因为区段占用导致无法开放信号
if (cilRoute.isLock() || cilRoute.isGl()) {
if (cilSignal.isForbidAspect(commonSignal.isShunting())) {
cilSignalLogicService.update2GuideAspect(simulation, cilSignal);
cilSignalLogicService.openGuideSignal(simulation, cilSignal);
if (cilRepository.getSectionById(commonRoute.getPathElement().getStart().getId()).isAxcOccupy()) { //进路首区段占用
cilSignal.initGuideTime();
}
@ -134,7 +137,7 @@ public class CilRouteLogicService {
if (cilRepository.getSectionById(commonRoute.getPathElement().getStart().getId()).isAxcOccupy()) {
cilSignal.initGuideTime();
}
cilSignalLogicService.update2GuideAspect(simulation, cilSignal); //开放引导信号
cilSignalLogicService.openGuideSignal(simulation, cilSignal); //开放引导信号
cilRoute.setGl(true); //引导锁
}
}
@ -149,7 +152,7 @@ public class CilRouteLogicService {
cilRoute.setGl(false);
cilSignal.clearGuideTime();
if (cilSignal.isGuideAspect()) {
cilSignalLogicService.update2ForbiddenAspect(simulation, signalId);
cilSignalLogicService.openForbiddenAspect(simulation, signalId);
}
} else {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilRoute.isDelayUnlocking(), "进路已在延时解锁中");
@ -157,7 +160,7 @@ public class CilRouteLogicService {
"进路未接近锁闭");
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(cilRoute.isTrainIn(), "进路非空闲状态");
//关闭信号
cilSignalLogicService.update2ForbiddenAspect(simulation, signalId);
cilSignalLogicService.openForbiddenAspect(simulation, signalId);
//设置延时解锁
CommonSignal commonSignal = cilRepository.getCommonRepository().getSignalById(signalId);
cilSignal.initDelayTime(commonSignal);
@ -173,7 +176,7 @@ public class CilRouteLogicService {
}
/**
* 检查进路能否开放信号
* 检查联锁状态以判断进路能否开放信号
*/
public boolean canOpenSignal(RtSimulation rtSimulation, String routeId) {
CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
@ -296,7 +299,7 @@ public class CilRouteLogicService {
// 关灯
CommonSignal commonSignal = commonRoute.getStart();
CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId());
cilSignalLogicService.update2ForbiddenAspect(rtSimulation, cilSignal.getId());
cilSignalLogicService.openForbiddenAspect(rtSimulation, cilSignal.getId());
cilSignal.setRouteId(null);
/* 取消进路相关所有设备的锁闭状态 */
// 延续保护解锁
@ -318,7 +321,6 @@ public class CilRouteLogicService {
cancelRouteLockAndCancelRouteUse(cilRepository, commonRoute);
cilRoute.setLock(false);
//信号机可以自动开放
cilRoute.setCanAutoOpen(true);
return true;
}
@ -377,10 +379,13 @@ public class CilRouteLogicService {
}
}
private void settingProgress(RtSimulation rtSimulation, CilRoute cilRoute, CilConfig config) {
private void settingProgress(RtSimulation rtSimulation, CilRepository cilRepository, CilRoute cilRoute, CilConfig config) {
if (LocalDateTime.now().isAfter(cilRoute.getStartSettingTime().plusSeconds(10))) { //进路办理时间超过10秒
cilRepository.removeSupervisedRoute(cilRoute.getId());
return;
}
CommonRepository commonRepository = rtSimulation.getRepository(CommonRepository.NAME, CommonRepository.class);
CommonRoute commonRoute = commonRepository.getRouteById(cilRoute.getId());
CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
List<CommonRoute.MultiRouteAspect> routes = commonRoute.getMultiRouteAspectList();
if (!CollectionUtils.isEmpty(routes)) {
for (int i = routes.size() - 1; i >= 0; i--) {
@ -399,29 +404,35 @@ public class CilRouteLogicService {
}
}
} else {
if (cilRoute.isCanAutoOpen()) {
lockRouteDevices(rtSimulation, cilRepository, cilRoute, commonRoute);
}
lockRouteDevices(rtSimulation, cilRepository, cilRoute, commonRoute);
setLockingStateByInterlockCheck(cilRepository, cilRoute, commonRoute);
CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId());
updateSignalLevel(cilRepository, cilRoute, commonRoute, cilSignal);
try2OpenSignal4Route(rtSimulation, cilRoute, commonRoute, cilSignal, commonRoute.getSignalAspect());
monitorRoute(rtSimulation, commonRepository, cilRepository, cilSignal, commonRoute, cilRoute);
if (cilSignal.getSignalAspect() == commonRoute.getSignalAspect()) //信号机已开启进路指定的信号
cilRoute.finishSetting();
if (cilRoute.isCanAutoOpen()) {
try2OpenSignal4Route(rtSimulation, cilRoute, commonRoute, cilSignal, commonRoute.getSignalAspect());
}
}
}
/**
* 监控进路
*/
private void monitorRoute(RtSimulation rtSimulation, CommonRepository commonRepository, CilRepository cilRepository, CilSignal cilSignal, CommonRoute commonRoute, CilRoute cilRoute) {
private void monitorRoute(RtSimulation simulation, CilRepository cilRepository, CilRoute cilRoute) {
CommonRepository commonRepository = simulation.getRepository(CommonRepository.NAME, CommonRepository.class);
CommonRoute commonRoute = commonRepository.getRouteById(cilRoute.getId());
CilSignal cilSignal = cilRepository.getSignalById(commonRoute.getStart().getId());
setLockingStateByInterlockCheck(cilRepository, cilRoute, commonRoute);
updateSignalLevel(cilRepository, cilRoute, commonRoute, cilSignal);
//列车进入进路检查
cilRoute.setTrainIn(this.isTrainIn(cilRepository, commonRoute));
if (!cilSignal.isGuideAspect()) { //非引导信号
CommonSignal commonSignal = commonRepository.getSignalById(cilSignal.getId());
//信号开放条件检查不通过时关闭信号
if (!cilSignal.isForbidAspect(commonSignal.isShunting())) {
if (!canOpenSignal(rtSimulation, cilRoute.getId())) {
cilSignalLogicService.update2ForbiddenAspect(rtSimulation, cilSignal.getId());
if (!canOpenSignal(simulation, cilRoute.getId())) {
cilSignalLogicService.openForbiddenAspect(simulation, cilSignal.getId());
}
}
}
@ -434,14 +445,8 @@ public class CilRouteLogicService {
//开放信号
// boolean routeCtcMode = cilRoute.getCilServer().isCtcMode();
boolean routeCtcMode = true;
if (cilRoute.isCanAutoOpen()) {
if (cilSignal.getSignalAspect() == commonRoute.getSignalAspect()) { //信号机已开启进路指定的信号
cilRoute.setCanAutoOpen(false);
} else {
if (canOpenSignal(rtSimulation, cilRoute.getId())) {
cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, cilSignal, aspect, routeCtcMode);
}
}
if (canOpenSignal(rtSimulation, cilRoute.getId())) {
cilSignalLogicService.try2OpenSignal(rtSimulation, cilSignal, aspect, routeCtcMode);
}
}
@ -789,7 +794,7 @@ public class CilRouteLogicService {
if (cilSignal.getGuideTime() != 0) { //引导信号的关闭只依赖时间
cilSignal.updateGuideTime();
if (cilSignal.getGuideTime() == 0) {
cilSignalLogicService.update2ForbiddenAspect(rtSimulation, cilSignal.getId());
cilSignalLogicService.openForbiddenAspect(rtSimulation, cilSignal.getId());
}
} else { //列车进入进路不能这么判断
// if (cilRepository.getSectionById(commonRoute.getPathElement().getStart().getId()).isAxcOccupy()) {

View File

@ -22,26 +22,26 @@ public class CilSignalLogicService {
@Autowired
private CilRouteLogicService cilRouteLogicService;
public void update2ForbiddenAspect(RtSimulation simulation, String signalId) {
/**
* 开放禁止信号
*/
public void openForbiddenAspect(RtSimulation simulation, String signalId) {
CommonRepository commonRepository = simulation.getRepository(CommonRepository.NAME, CommonRepository.class);
CilRepository cilRepository = simulation.getRepository(CilRepository.NAME, CilRepository.class);
CommonSignal commonSignal = commonRepository.getSignalById(signalId);
CilSignal cilSignal = cilRepository.getSignalById(signalId);
if (commonSignal.isShunting()) {
UpdateSignalDisplay(simulation, cilSignal, SrSignal.A, false);
srdApiService.changeSignalLight(simulation, cilSignal.getId(), SrSignal.A);
} else {
UpdateSignalDisplay(simulation, cilSignal, SrSignal.H, false);
srdApiService.changeSignalLight(simulation, cilSignal.getId(), SrSignal.H);
}
}
public void update2GuideAspect(RtSimulation simulation, String signalId) {
CilRepository cilRepository = simulation.getRepository(CilRepository.NAME, CilRepository.class);
CilSignal cilSignal = cilRepository.getSignalById(signalId);
UpdateSignalDisplay(simulation, cilSignal, SrSignal.BH, false);
}
public void update2GuideAspect(RtSimulation simulation, CilSignal cilSignal) {
UpdateSignalDisplay(simulation, cilSignal, SrSignal.BH, false);
/**
* 开放引导信号
*/
public void openGuideSignal(RtSimulation simulation, CilSignal cilSignal) {
openSignal(simulation, cilSignal, SrSignal.BH, false);
}
/**
@ -67,6 +67,9 @@ public class CilSignalLogicService {
return false;
}
/**
* 信号重开
*/
public void reopen(RtSimulation rtSimulation, String signalId) {
//检查
CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
@ -81,10 +84,13 @@ public class CilSignalLogicService {
"联锁条件不满足,无法重开");
//执行
cilRouteLogicService.cancelDelayUnlock(cilRepository, cilSignal);//取消延时解锁
UpdateSignalDisplay(rtSimulation, cilSignal, commonRoute.getSignalAspect(), false); //信号机开放
openSignal(rtSimulation, cilSignal, commonRoute.getSignalAspect(), false); //信号机开放
}
public boolean try2UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) {
/**
* 尝试开放信号
*/
public boolean try2OpenSignal(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) {
// TODO: 2021/4/20 因信号机缺少表示虚拟信号机的字段故缺少对虚拟信号机的检查
// boolean logic = !signal.isUta() && ctcMode && !signal.isForceLight();
// if (signal.sufficientLevel(aspect, logic)) {
@ -112,9 +118,8 @@ public class CilSignalLogicService {
}
}
public void UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) {
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(try2UpdateSignalDisplay(rtSimulation, signal, aspect, ctcMode));
public void openSignal(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) {
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(try2OpenSignal(rtSimulation, signal, aspect, ctcMode));
}
public void blockadeSignal(RtSimulation simulation, String signalId) {

View File

@ -2,10 +2,8 @@ package club.joylink.rtss.simulation.rt.CIL.bo;
import lombok.Getter;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -20,7 +18,7 @@ public class CilRoute extends CilDevice {
Map<String, CilSwitchPosition> waitTurnMap = new ConcurrentHashMap<>(); // 进路办理中待转换的道岔
Map<String, CilSwitchPosition> waitOnPositionMap = new ConcurrentHashMap<>(); // 进路办理中待转换到位的道岔
LocalDateTime stageStartTime;
LocalDateTime startSettingTime;
int signalState;// 进路信号状态(当前实际状态)
@Setter
private boolean lock; // 进路是否锁闭进路主体
@ -29,13 +27,14 @@ public class CilRoute extends CilDevice {
@Setter
private boolean fl; // 进路的侧防是否锁闭
@Setter
private boolean canAutoOpen = true; // 是否可以自动开放信号初始应该为true进路办理完毕开放信号之后为false代表不能自动重开信号
private boolean canAutoOpen; // 是否可以自动开放信号初始应该为true进路办理完毕开放信号之后为false代表不能自动重开信号
@Setter
private boolean trainIn; //列车在进路中
@Setter
private boolean delayUnlocking; //延时解锁中
@Setter
boolean gl; //引导锁闭
boolean settingFinished; //进路办理完成
public CilRoute(String id, String name) {
super(id, name);
@ -49,15 +48,16 @@ public class CilRoute extends CilDevice {
flt = false;
waitTurnMap.clear();
waitOnPositionMap.clear();
stageStartTime = null;
startSettingTime = null;
signalState = 0;
lock = false;
ol = false;
fl = false;
canAutoOpen = true;
canAutoOpen = false;
trainIn = false;
delayUnlocking = false;
gl = false;
settingFinished = false;
}
// public boolean isOpenAspect() {
@ -71,7 +71,8 @@ public class CilRoute extends CilDevice {
// }
public void startSetting(LocalDateTime systemTime) {
this.stageStartTime = systemTime;
this.startSettingTime = systemTime;
this.canAutoOpen = true;
// this.stage = STAGE_SETTING;
}
@ -79,6 +80,11 @@ public class CilRoute extends CilDevice {
this.waitTurnMap.put(cilSwitchPosition.getCilSwitch().getId(), cilSwitchPosition);
}
public void finishSetting() {
this.settingFinished = true;
this.canAutoOpen = false;
}
// public boolean isPreparedForCtc() {
// return this.cilServer.isCtcMode() && !this.start.isUta();
// }

View File

@ -90,24 +90,6 @@ public class CilSignal extends CilDevice {
* 信号机有足够的级别以{aspect}显示
*/
public boolean sufficientLevel(int aspect, boolean logic) {
// switch (aspect) {
// case RED:
// return true;
// case GUIDE:
// return level == LEVEL_2 || level == LEVEL_3 || level == LEVEL_4;
// case GREEN:
// case YELLOW:
// if (logic) {
// return level == LEVEL_3 || level == LEVEL_4;
// } else {
// return level == LEVEL_4;
// }
// default:
// throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception(String.format("未知的显示状态[%s]", aspect));
// }
if (aspect == SrSignal.H) {
return true;
}
if (aspect == SrSignal.BH) {
return level == LEVEL_2 || level == LEVEL_3 || level == LEVEL_4;
}

View File

@ -29,7 +29,7 @@ public class SignalFaultListener {
CilSignal cilSignal = cilRepository.getSignalById(deviceFault.getDeviceId());
cilSignal.setFault(fault);
// 室外信号机显示控制
this.cilSignalLogicService.try2UpdateSignalDisplay((RtSimulation) simulation, cilSignal, SrSignal.H, false);
this.cilSignalLogicService.try2OpenSignal((RtSimulation) simulation, cilSignal, SrSignal.H, false);
}
}
}