删除仿真操作接口阻塞

This commit is contained in:
joylink_zhangsai 2023-11-01 15:00:48 +08:00
parent 67175c5919
commit 3335dea0a6
2 changed files with 275 additions and 272 deletions

View File

@ -1,6 +1,5 @@
package club.joylink.rtss.simulation.cbtc.ATS.operation.handler;
import club.joylink.rtss.exception.BaseException;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
@ -11,99 +10,97 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.status.RouteStatus;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@OperateHandler
public class SignalOperateHandler {
@Autowired
private CiApiService ciApiService;
@Autowired
private CiApiService ciApiService;
@Autowired
private AtsRouteService atsRouteService;
@Autowired
private AtsRouteService atsRouteService;
/**
* 排列进路
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_Route)
public void settingRoute(Simulation simulation, String routeCode) throws InterruptedException {
/**
* 排列进路
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_Route)
public void settingRoute(Simulation simulation, String routeCode) throws InterruptedException {
// Route.CheckFailMessage checkResult = this.ciApiService.routeSettingCheck(simulation, routeCode);
// if (checkResult != null)
// log.info(checkResult.debugStr());
Route.CheckFailMessage checkFailMessage = this.ciApiService.settingRoute(simulation, routeCode);
BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertNull(checkFailMessage, "进路排列失败,被联锁逻辑取消");
Route.CheckFailMessage checkFailMessage = this.ciApiService.settingRoute(simulation, routeCode);
BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertNull(checkFailMessage,
"进路排列失败,被联锁逻辑取消");
//等待进路办理完成
LocalDateTime timeoutTime = simulation.getSystemTime().plusSeconds(20);
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
while (true) {
if (route.getSettedAspect().equals(route.getStart().getAspect()) ||
(route.isGuideSetting() && route.getStart().isGuideAspect())) {
return true;
}
if (simulation.getSystemTime().isAfter(timeoutTime)) {
return false;
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
});
try {
Boolean success = future.get();
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(success);
} catch (BaseException be) {
throw be;
} catch (Exception e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception();
}
}
// //等待进路办理完成
// LocalDateTime timeoutTime = simulation.getSystemTime().plusSeconds(20);
// Route route = simulation.getRepository().getByCode(routeCode, Route.class);
// CompletableFuture<Boolean> future = CompletableFuture.supplyAsync(() -> {
// while (true) {
// if (route.getSettedAspect().equals(route.getStart().getAspect()) ||
// (route.isGuideSetting() && route.getStart().isGuideAspect())) {
// return true;
// }
// if (simulation.getSystemTime().isAfter(timeoutTime)) {
// return false;
// }
// try {
// Thread.sleep(100);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// }
// });
// try {
// Boolean success = future.get();
// BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(success);
// } catch (BaseException be) {
// throw be;
// } catch (Exception e) {
// throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception();
// }
}
/**
* 取消进路
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_Route)
public void cancelRoute(Simulation simulation, String signalCode) {
//是否接近区段占用仍执行取消进路
Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode);
if (route == null) {
return;
}
if (route.isApproachLock()) {
switch (simulation.getRepository().getConfig().getSingleApproachLockCancelRoute()) {
case DELAY:
this.ciApiService.humanCancel(simulation, route.getCode());
break;
case DIRECT:
this.ciApiService.forceUnlockRoute(simulation, route.getCode());
break;
case NOT:
default:
BusinessExceptionAssertEnum.OPERATION_FAIL.fail("无法取消接近锁闭进路");
break;
}
} else {
this.atsRouteService.cancelRoute(simulation, signalCode);
}
/**
* 取消进路
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_Route)
public void cancelRoute(Simulation simulation, String signalCode) {
//是否接近区段占用仍执行取消进路
Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode);
if (route == null) {
return;
}
if (route.isApproachLock()) {
switch (simulation.getRepository().getConfig().getSingleApproachLockCancelRoute()) {
case DELAY:
this.ciApiService.humanCancel(simulation, route.getCode());
break;
case DIRECT:
this.ciApiService.forceUnlockRoute(simulation, route.getCode());
break;
case NOT:
default:
BusinessExceptionAssertEnum.OPERATION_FAIL.fail("无法取消接近锁闭进路");
break;
}
} else {
this.atsRouteService.cancelRoute(simulation, signalCode);
}
}
@OperateHandlerMapping(type = Operation.Type.Signal_Set_Overlap)
public void setOverlap(Simulation simulation, String signalCode, String overlapCode) {
this.atsRouteService.setOverlap(simulation, signalCode, overlapCode);
}
@OperateHandlerMapping(type = Operation.Type.Signal_Set_Overlap)
public void setOverlap(Simulation simulation, String signalCode, String overlapCode) {
this.atsRouteService.setOverlap(simulation, signalCode, overlapCode);
}
// /**
// * 取消进路强制取消进路无论接近区段是否占用如果占用延时取消
// * @param simulation
@ -117,99 +114,103 @@ public class SignalOperateHandler {
// }
// }
/**
* 总人解
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Human_Release_Route)
public void humanCancel(Simulation simulation, String signalCode) {
Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode);
if (Objects.nonNull(route)) {
this.ciApiService.humanCancel(simulation, route.getCode());
}
/**
* 总人解
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Human_Release_Route)
public void humanCancel(Simulation simulation, String signalCode) {
Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode);
if (Objects.nonNull(route)) {
this.ciApiService.humanCancel(simulation, route.getCode());
}
}
/**
* 信号封锁
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Block)
public void block(Simulation simulation, String signalCode) {
this.ciApiService.blockadeSignal(simulation, signalCode);
}
/**
* 信号封锁
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Block)
public void block(Simulation simulation, String signalCode) {
this.ciApiService.blockadeSignal(simulation, signalCode);
}
/**
* 信号解封
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Unblock)
public void unblock(Simulation simulation, String signalCode) {
this.ciApiService.unblockSignal(simulation, signalCode);
}
/**
* 信号解封
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Unblock)
public void unblock(Simulation simulation, String signalCode) {
this.ciApiService.unblockSignal(simulation, signalCode);
}
/**
* 进路收人工控
*
* @param simulation
* @param routeCodeList
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Close_Auto_Setting)
public void setRouteHumanControl(Simulation simulation, String signalCode, List<String> routeCodeList) {
this.atsRouteService.setRouteHumanControl(simulation, signalCode, routeCodeList);
}
/**
* 进路收人工控
*
* @param simulation
* @param routeCodeList
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Close_Auto_Setting)
public void setRouteHumanControl(Simulation simulation, String signalCode,
List<String> routeCodeList) {
this.atsRouteService.setRouteHumanControl(simulation, signalCode, routeCodeList);
}
/**
* 进路交ATS自动控
*
* @param simulation
* @param routeCodeList
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Open_Auto_Setting)
public void setRouteAtsControl(Simulation simulation, String signalCode, List<String> routeCodeList,
List<Boolean> checkConflictList) {
this.atsRouteService.setRouteAtsControl(simulation, signalCode, routeCodeList, checkConflictList);
}
/**
* 进路交ATS自动控
*
* @param simulation
* @param routeCodeList
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Open_Auto_Setting)
public void setRouteAtsControl(Simulation simulation, String signalCode,
List<String> routeCodeList,
List<Boolean> checkConflictList) {
this.atsRouteService.setRouteAtsControl(simulation, signalCode, routeCodeList,
checkConflictList);
}
/**
* 冲突进路办理确认
*
* @param simulation
* @param routeCode
* @param way 处理方式1-按计划执行2-执行冲突进路
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Conflict_Route_Set_Confirm)
public void conflictRouteSetConfirm(Simulation simulation, SimulationMember member, String routeCode, int way) {
this.atsRouteService.conflictRouteSetConfirm(simulation, member, routeCode, way);
}
/**
* 冲突进路办理确认
*
* @param simulation
* @param routeCode
* @param way 处理方式1-按计划执行2-执行冲突进路
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Conflict_Route_Set_Confirm)
public void conflictRouteSetConfirm(Simulation simulation, SimulationMember member,
String routeCode, int way) {
this.atsRouteService.conflictRouteSetConfirm(simulation, member, routeCode, way);
}
/**
* 信号关灯
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Close_Signal)
public void closeSignal(Simulation simulation, String signalCode) {
this.ciApiService.closeSignal(simulation, signalCode);
}
/**
* 信号关灯
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Close_Signal)
public void closeSignal(Simulation simulation, String signalCode) {
this.ciApiService.closeSignal(simulation, signalCode);
}
/**
* 信号重开
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Reopen_Signal)
public void reopenSignal(Simulation simulation, String signalCode) {
this.ciApiService.reopenSignal(simulation, signalCode);
}
/**
* 信号重开
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Reopen_Signal)
public void reopenSignal(Simulation simulation, String signalCode) {
this.ciApiService.reopenSignal(simulation, signalCode);
}
// /**
// * 办理引导进路
@ -221,63 +222,65 @@ public class SignalOperateHandler {
// iciSubsystem.settingGuideRoute(simulation, routeCode);
// }
/**
* 查找进路控制模式/状态
*
* @param simulation
* @param signalCode
* @return
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Find_Routes_Status)
public List<RouteStatus> findRoutesStatus(Simulation simulation, String signalCode) {
return atsRouteService.findRoutesStatus(simulation, signalCode);
}
/**
* 查找进路控制模式/状态
*
* @param simulation
* @param signalCode
* @return
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Find_Routes_Status)
public List<RouteStatus> findRoutesStatus(Simulation simulation, String signalCode) {
return atsRouteService.findRoutesStatus(simulation, signalCode);
}
/**
* 设置联锁自动进路
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_CI_Auto)
public void setCiAuto(Simulation simulation, String signalCode) {
atsRouteService.setCiAuto(simulation, signalCode);
}
/**
* 设置联锁自动进路
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_CI_Auto)
public void setCiAuto(Simulation simulation, String signalCode) {
atsRouteService.setCiAuto(simulation, signalCode);
}
/**
* 取消联锁自动进路
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_CI_Auto)
public void cancelCiAuto(Simulation simulation, String signalCode) {
atsRouteService.cancelCiAuto(simulation, signalCode);
/**
* 取消联锁自动进路
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_CI_Auto)
public void cancelCiAuto(Simulation simulation, String signalCode) {
atsRouteService.cancelCiAuto(simulation, signalCode);
}
}
/**
* 设置联锁自动触发
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_CI_Auto_Trigger)
public void setCiAutoTrigger(Simulation simulation, String signalCode, List<String> routeCodeList) {
atsRouteService.setCiAutoTrigger(simulation, signalCode, routeCodeList);
}
/**
* 设置联锁自动触发
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_CI_Auto_Trigger)
public void setCiAutoTrigger(Simulation simulation, String signalCode,
List<String> routeCodeList) {
atsRouteService.setCiAutoTrigger(simulation, signalCode, routeCodeList);
}
/**
* 取消联锁自动触发
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_CI_Auto_Trigger)
public void cancelCiAutoTrigger(Simulation simulation, String signalCode, List<String> routeCodeList) {
atsRouteService.cancelCiAutoTrigger(simulation, signalCode, routeCodeList);
}
/**
* 取消联锁自动触发
*
* @param simulation
* @param signalCode
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_CI_Auto_Trigger)
public void cancelCiAutoTrigger(Simulation simulation, String signalCode,
List<String> routeCodeList) {
atsRouteService.cancelCiAutoTrigger(simulation, signalCode, routeCodeList);
}
// /**
// * 开启进路引导信号
@ -299,68 +302,68 @@ public class SignalOperateHandler {
// this.iciSubsystem.openGuideSignalCheckRoute(simulation, signalCode);
// }
/**
* 设置自动折返进路
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_Auto_Turn_Back)
public void setAutoTrunBack(Simulation simulation, String cycleCode) {
atsRouteService.setAutoTurnBack(simulation, cycleCode);
}
/**
* 设置自动折返进路
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_Auto_Turn_Back)
public void setAutoTrunBack(Simulation simulation, String cycleCode) {
atsRouteService.setAutoTurnBack(simulation, cycleCode);
}
/**
* 取消自动折返进路
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_Auto_Turn_Back)
public void cancelAutoTurnBack(Simulation simulation, String cycleCode) {
atsRouteService.cancelAutoTurnBack(simulation, cycleCode);
}
/**
* 取消自动折返进路
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_Auto_Turn_Back)
public void cancelAutoTurnBack(Simulation simulation, String cycleCode) {
atsRouteService.cancelAutoTurnBack(simulation, cycleCode);
}
/**
* 总取消
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Total_Cancel)
public void totalCancel(Simulation simulation, String signalCode) {
atsRouteService.totalCancel(simulation, signalCode);
}
/**
* 总取消
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Total_Cancel)
public void totalCancel(Simulation simulation, String signalCode) {
atsRouteService.totalCancel(simulation, signalCode);
}
/**
* 初始化引导
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Initialize_Guide)
public void initializeGuide(Simulation simulation, String signalCode) {
ciApiService.initializeGuide(simulation, signalCode);
}
/**
* 初始化引导
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Initialize_Guide)
public void initializeGuide(Simulation simulation, String signalCode) {
ciApiService.initializeGuide(simulation, signalCode);
}
/**
* 初始化引导
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_Guide_Initialization)
public void cancelGuideInitialization(Simulation simulation, String signalCode) {
ciApiService.cancelGuideInitialization(simulation, signalCode);
}
/**
* 初始化引导
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Cancel_Guide_Initialization)
public void cancelGuideInitialization(Simulation simulation, String signalCode) {
ciApiService.cancelGuideInitialization(simulation, signalCode);
}
/**
* 办理引导
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_Guide)
public void setGuide(Simulation simulation, String signalCode, String routeCode) {
ciApiService.setGuide(simulation, signalCode, routeCode);
}
/**
* 办理引导
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Set_Guide)
public void setGuide(Simulation simulation, String signalCode, String routeCode) {
ciApiService.setGuide(simulation, signalCode, routeCode);
}
/**
* 信号机点灯
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Turn_On)
public void signalTurnOn(Simulation simulation, String signalCode) {
ciApiService.signalTurnOn(simulation, signalCode);
}
/**
* 信号机点灯
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Turn_On)
public void signalTurnOn(Simulation simulation, String signalCode) {
ciApiService.signalTurnOn(simulation, signalCode);
}
/**
* 信号机灭灯
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Turn_Off)
public void signalTurnOff(Simulation simulation, String signalCode) {
ciApiService.signalTurnOff(simulation, signalCode);
}
/**
* 信号机灭灯
*/
@OperateHandlerMapping(type = Operation.Type.Signal_Turn_Off)
public void signalTurnOff(Simulation simulation, String signalCode) {
ciApiService.signalTurnOff(simulation, signalCode);
}
}

View File

@ -278,7 +278,7 @@ public class SwitchOperateHandler {
public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) {
SwitchIndication pos = ciApiService.switchForceTurn(simulation, switchCode);
waitResult(simulation, simulation.getRepository().getByCode(switchCode, Switch.class), pos);
// waitResult(simulation, simulation.getRepository().getByCode(switchCode, Switch.class), pos);
}
/**
@ -288,8 +288,8 @@ public class SwitchOperateHandler {
public void switchSqueezeRecovery(Simulation simulation, String switchCode) {
ciApiService.switchSqueezeRecovery(simulation, switchCode);
waitResult(simulation, simulation.getRepository().getByCode(switchCode, Switch.class),
SwitchIndication.N, SwitchIndication.R);
// waitResult(simulation, simulation.getRepository().getByCode(switchCode, Switch.class),
// SwitchIndication.N, SwitchIndication.R);
}
/**