Merge remote-tracking branch 'origin/test' into test-training2

# Conflicts:
#	src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java
This commit is contained in:
joylink_zhangsai 2022-08-24 15:26:18 +08:00
commit 7f870d52ce
24 changed files with 809 additions and 629 deletions

View File

@ -4,25 +4,31 @@ import lombok.Getter;
@Getter
public enum MapPrdTypeEnum {
LOCAL("01", "ATS现地工作站"),
CENTER("02", "ATS行调工作站"),
JOINT("03", "综合演练云平台"),
DRIVER("04", "司机模拟驾驶系统"),
SCHEDULING("05", "派班工作站"),
ISCS("06", "ISCS工作站"),
BIG_SCREEN("07", "大屏工作站"),
RUN_PLAN_MAKE("08", "运行图编制工作站"),
DEPOT_IL("09", "车辆段联锁工作站"),
CTC("10", "CTC工作站")
LOCAL("01", "ATS现地工作站", "车站"),
CENTER("02", "ATS行调工作站", "调度台"),
JOINT("03", "综合演练云平台", null),
DRIVER("04", "司机模拟驾驶系统", null),
SCHEDULING("05", "派班工作站", null),
ISCS("06", "ISCS工作站", null),
BIG_SCREEN("07", "大屏工作站", null),
RUN_PLAN_MAKE("08", "运行图编制工作站", null),
DEPOT_IL("09", "车辆段联锁工作站", null),
// CTC("10", "CTC工作站")
;
private String code;
private String msg;
MapPrdTypeEnum(String code, String msg) {
/**
* 大铁子系统名称
*/
private String railName;
MapPrdTypeEnum(String code, String msg, String railName) {
this.code = code;
this.msg = msg;
this.railName = railName;
}
public static MapPrdTypeEnum getMapPrdTypeEnumByCode(String code) {

View File

@ -60,6 +60,8 @@ public enum Project {
RICHOR_CXJS,
/** 哈盈达-铁路 */
HYD_RAILWAY,
/** 武汉8号线 */
WH
;
public static boolean isDefault(Project project) {

View File

@ -64,20 +64,18 @@ public class MapSystemService implements IMapSystemService {
public void generateSystem(Long mapId) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(iMapService.isExist(mapId),
String.format("id为[%s]的地图不存在", mapId));
MapVO mapDetail = iMapService.getMapDetail(mapId);
for (MapPrdTypeEnum value : MapPrdTypeEnum.values()) {
if (MapPrdTypeEnum.CTC.equals(value)) {
MapVO mapDetail = iMapService.getMapDetail(mapId);
if (!mapDetail.getConfigVO().isRailway()) {
continue;
}
}
generate(mapId, value);
boolean railway = mapDetail.getConfigVO().isRailway();
if (railway && value.getRailName() == null)
continue;
generate(mapId, value, railway);
}
}
private void generate(Long mapId, MapPrdTypeEnum value) {
private void generate(Long mapId, MapPrdTypeEnum value, boolean railway) {
MapSystem system = new MapSystem();
system.setName(value.getMsg());
system.setName(railway ? value.getRailName() : value.getMsg());
system.setMapId(mapId);
system.setPrdType(value.getCode());
system.setStatus(StatusEnum.Valid.getCode());
@ -108,7 +106,12 @@ public class MapSystemService implements IMapSystemService {
String.format("id为[%s]的地图不存在", mapId));
MapPrdTypeEnum prdTypeEnum = MapPrdTypeEnum.getMapPrdTypeEnumByCode(prdType);
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(prdTypeEnum);
generate(mapId, prdTypeEnum);
MapVO mapDetail = iMapService.getMapDetail(mapId);
boolean railway = mapDetail.getConfigVO().isRailway();
if (railway && prdTypeEnum.getRailName() == null) {
return;
}
generate(mapId, prdTypeEnum, railway);
}
private boolean isExist(Long mapId, String prdType, String type) {

View File

@ -405,11 +405,11 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService {
}
} else { //反向信号机
if (destination.equals(last.getSignalOf(!right))) {
sections.remove(i);
// sections.remove(i);
break;
}
}
sections.remove(i);
sections.remove(i); //最后一个区段上没有与终端信号机相同的信号机
}
//添加进路
Route route = new Route(routeCodeGenerator.next(), "D_" + signal.getShowName() + "-" + destination.getShowName());

View File

@ -82,8 +82,8 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
private Map<String, SimulationRepository> repositoryMap = new ConcurrentHashMap<>();
@Setter
private Map<String, M> simulationMemberMap = new ConcurrentHashMap<>();
private Map<String, U> simulationUserMap = new ConcurrentHashMap<>();
private Map<String, M> simulationMemberMap = new ConcurrentSkipListMap<>(); //2022-08-16 为前端展示成员有序
private Map<String, U> simulationUserMap = new ConcurrentSkipListMap<>();
private List<Operation> operationList = new ArrayList<>();
private Map<String, Map<String, SimulationFaultVO>> deviceFaultMap = new ConcurrentHashMap<>();

View File

@ -0,0 +1,29 @@
package club.joylink.rtss.simulation.cbtc.ATS;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.event.SimulationOperationEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@Component
public class AtsListener {
/**
* 计数字段名
*/
public static final String COUNT_PARAM_NAME = "_COUNT";
@EventListener
public void handle(SimulationOperationEvent event) {
if (event.getSuccessful() != null)
return;
String countName = (String) event.getParams().get(COUNT_PARAM_NAME);
if (countName == null)
return;
MapElement device = event.getMember().getDevice();
if (device instanceof Station) {
Station station = (Station) device;
station.count(countName);
}
}
}

View File

@ -467,9 +467,9 @@ public class AtsTrainService {
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
b = vrSignal != null && vrSignal.getModel().getDefaultAspect().equals(vrSignal.getAspect());
}
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且同向信号机为禁止信号");
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且为禁止信号");
param.setThroughSignal(signal);
param.setThroughSignalAspect(signal.getVirtualSignal().getModel().getDefaultAspect());
param.setThroughSignalAspect(signal.getDefaultAspect());
} else if (param.isThroughGuideSignal()) { // 越引导行驶
Signal signal = section.getSignalOf(right);
boolean b = false;
@ -477,9 +477,9 @@ public class AtsTrainService {
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
b = vrSignal != null && vrSignal.getModel().getGuideAspect().equals(vrSignal.getAspect());
}
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且同向信号机为引导信号");
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且为引导信号");
param.setThroughSignal(signal);
param.setThroughSignalAspect(signal.getVirtualSignal().getModel().getDefaultAspect());
param.setThroughSignalAspect(signal.getGuideAspect());
} else if (param.isDriverNextStand()){ // 行驶至前方车站
// 列车车头所在区段
Section headSection = train.getHeadPosition().getSection();

View File

@ -6,7 +6,6 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.map.Route.MultiRouteAspect;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService;
@ -185,8 +184,8 @@ public class CiApiServiceImpl2 implements CiApiService {
public Route.CheckFailMessage settingRoute(Simulation simulation, String routeCode) {
Route route = simulation.getRepository().getByCode(routeCode, Route.class);
//当为一般进路时直接获取信号显示当为组合进路时信号显示获取到办理子进路时
SignalAspect settedAspect=route.isMultiRoute()?null:route.getAspect();
return this.routeService.setRoute(simulation, route,settedAspect);
SignalAspect settedAspect = route.isMultiRoute() ? null : route.getAspect();
return this.routeService.setRoute(simulation, route, settedAspect);
}
@Override
@ -413,8 +412,15 @@ public class CiApiServiceImpl2 implements CiApiService {
} else {
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空");
}
// 判断是否要进行进路判断大铁可以不对进路判断
boolean firstCheck = config.isRailway() ? false : config.isGuideNeedRouteSettingFirst();
if (route == null && signal.getRouteList().stream().anyMatch(Route::isAnySwitchMasterLock)) {
openGuideAspect4GuideMasterLock(simulation, signal);
return;
} else {
}
boolean firstCheck = config.isGuideNeedRouteSettingFirst();
//条件检查
if (firstCheck) {
List<Route> routeList = signal.getRouteList();
@ -454,21 +460,9 @@ public class CiApiServiceImpl2 implements CiApiService {
} else if (!CollectionUtils.isEmpty(signal.getRouteList())) {
List<Route> collect;
if (config.isRailway()) { // 大铁配置引导进路
// collect = getCtcGuideRouteList(repository, signal);
// if (collect == null) {
// return;
// }
collect = signal.getRouteList().stream()
.filter(Route::isTrainRoute)
.filter(route1 -> !route1.hasReverseSwitch())
.filter(route1 -> {
List<SwitchElement> switchList = route1.getSwitchList();
if (!CollectionUtils.isEmpty(switchList)) {
return switchList.stream()
.allMatch(se -> se.isOnPosition() || se.getASwitch().isGuideMasterLock());
}
return true;
}) //大铁直接办理引导进路需道岔在正确位置或道岔引导总锁
.filter(route1 -> route1.isAllSwitchIsOnPos() || route1.isAnySwitchMasterLock())
.collect(Collectors.toList());
BusinessExceptionAssertEnum.OPERATION_FAIL.assertCollectionNotEmpty(collect,
signal.debugStr() + "无符合条件的进路");
@ -498,6 +492,14 @@ public class CiApiServiceImpl2 implements CiApiService {
}
}
/**
* 在引导总锁的状态下开放引导信号
* 引导总锁之后
*/
private void openGuideAspect4GuideMasterLock(Simulation simulation, Signal signal) {
signalService.controlSignalAspect(simulation, signal, signal.getGuideAspect());
}
@Override
public void setEst(Simulation simulation, ESP esp) {

View File

@ -1,238 +1,285 @@
package club.joylink.rtss.simulation.cbtc.CI;
import club.joylink.rtss.simulation.cbtc.CI.device.CiDeviceStatusCollector;
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiSignalControlService;
import club.joylink.rtss.simulation.cbtc.CI.service.assist.StationDirectionService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Objects;
@Slf4j
@Component
public class CiLogic {
@Autowired
private CiDeviceStatusCollector deviceStatusCollector;
@Autowired
private CiRouteService routeService;
@Autowired
private CiSignalControlService signalControlService;
@Autowired
private CiService ciService;
@Autowired
private StationDirectionService stationDirectionService;
public void run(Simulation simulation) {
// 采集真实设备状态
deviceStatusCollector.collect(simulation);
// 信号机监控控制
SimulationDataRepository repository = simulation.getRepository();
for (Signal signal : repository.getSignalList()) {
signalMonitor(simulation, signal);
}
// 联锁监控逻辑
List<Route> routeList = repository.getRouteList();
for (Route route : routeList) {
interlockMonitor(simulation, route);
}
List<RouteOverlap> routeOverlapList = repository.getRouteOverlapList();
for (RouteOverlap routeOverlap : routeOverlapList) {
overlapMonitor(simulation, routeOverlap);
}
// 区间灯点灯逻辑
if (simulation.getRepository().getConfig().isRailway()) {
// 车站
simulation.getRepository().getStationList().stream().forEach(station -> {
// 允许自律状态刷新
station.refreshAllowAutonomyStatus();
// 发辅助按钮倒计时刷新
station.getStationDirectionMap().values().stream()
.forEach(stationDirection -> {
// 判断进路状态是否发生变化
if (stationDirection.monitorRouteChangeStatus()) {
stationDirection.modifyRunStatus();
}
// 如果倒数结束弹起接发辅助按钮,超过50秒时不再自动抬起
if (!stationDirection.isAssistReadyStatus()
&& !stationDirection.assistDurationPass50(simulation.getCorrectSystemTime())
&& stationDirection.getCountDown().decrementAndGet() <= 0) {
stationDirection.setDeliverAssistStatus(false);
stationDirection.setReceiveAssistStatus(false);
stationDirection.getCountDown().set(0);
}
// 联锁数据检查
stationDirectionService.refreshSectionLightStatus(simulation, stationDirection);
});
});
}
}
private void signalMonitor(Simulation simulation, Signal signal) {
signalControlService.controlLightOfSignal(simulation, signal);
//控制通过信号机的显示信号机前第一个区段被占用开红灯第二个区段被占用开黄灯否则开绿灯
if (signal.isPassingSignal()) {
if (simulation.getRepository().getConfig().isRailway()) {
boolean right = signal.isRight();
Section section = signal.getSection();
Section one = section.getNextSection(right);
if (one == null) {
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.G);
return;
}
if (one.isOccupied()) {
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.R);
return;
}
Section two = one.getNextSection(right);
if (two == null) {
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.G);
return;
}
if (two.isOccupied()) {
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.Y);
return;
}
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.G);
}
}
}
/**
* 进路监控
*
* @param simulation
* @param route
*/
public void interlockMonitor(Simulation simulation, Route route) {
MapConfig config = simulation.getRepository().getConfig();
if (route.isCiControl()) { // 进路联锁自动触发
if (!route.isLock() && !route.isSetting() && ciService.isCiRouteTrigger(simulation, route)) {
routeService.setRoute(simulation, route,route.getAspect());
}
} else if (route.isFleetMode()) { // 联锁自动进路
if (ciService.isCiRouteTrigger(simulation, route)) {
signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getSettedAspect());
}
}
if (route.isSetting() || route.isLock() || route.isNormalUnlock()) { // 监控中的进路
if (route.isDelayUnlocking()) {
routeService.delayUnlocking(simulation, route, route.getDelayUnlockDevice());
}
if (route.isSetting()) {
routeService.routeSettingProcess(simulation, route);
}
if (route.isNormalUnlock()) {
routeService.trainUnlockRoute(simulation, route);
}
if (route.isLock()) {
// 进路首区段列车占用进路开始解锁
Section firstLogicSection = route.getFirstLogicSection();
SimulationDataRepository repository = simulation.getRepository();
if (repository.isTrainHeadOccupy(firstLogicSection)) {
trainUnlockStart(simulation, route);
}
}
Signal start = route.getStart();
int guideRemain = start.getGuideRemain();
if (guideRemain != 0) {
guideRemain -= SimulationConstants.CI_LOOP_RATE;
if (guideRemain <= 0) { //计时结束关闭信号
start.setGuideRemain(0);
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
start, start.getDefaultAspect());
} else {
start.setGuideRemain(guideRemain);
}
}
if (route.isLock() && !route.isSetting()) {
ciService.interlockCheck(simulation, route);
if (!config.isRailway()) {
if (route.isOpenMain() && !start.isSupportMainAspect()) {//与联锁显示不同关闭信号
CiLogic.log.info("进路[{}]联锁条件不满足,关闭信号", route.debugStr());
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
start, start.getDefaultAspect());
} else if (start.isDefaultAspect() && !start.isForbidden() && !start.isBlockade() && start.isSupportMainAspect()) {
CiLogic.log.info("进路[{}]联锁条件满足,开放信号", route.debugStr());
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
start, route.getSettedAspect());
}
} else {
if (route.isOpenMain() && !start.isSupportMainAspect()) {//与联锁显示不同关闭信号
CiLogic.log.info("进路[{}]联锁条件不满足,关闭信号", route.debugStr());
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
start, start.getDefaultAspect());
start.setForcePhysical(true); //大铁线路暂时限制自动重开信号
} else if (!start.isForbidden() && !start.isBlockade() && start.isSupportMainAspect()) {
SignalAspect aspect = route.getAspectOfRailway();
if (!Objects.equals(route.getStart().getAspect(), aspect)) {
signalControlService.tryControlSignalAspectAccordingLevel(simulation, start, aspect);
}
}
}
}
// 进路延续保护办理判断
if (route.isSettingOverlap()) {
ciService.checkAndTrySettingOverlap(simulation, route.getOverlap());
}
}
}
public void trainUnlockStart(Simulation simulation, Route route) {
route.startNormalUnlock();
CiLogic.log.info("进路[{}]因列车进入,关闭信号", route.debugStr());
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
route.getStart(), route.getStart().getDefaultAspect());
}
/**
* 延续保护进路监控
*
* @param simulation
* @param overlap
*/
public void overlapMonitor(Simulation simulation, RouteOverlap overlap) {
MapConfig config = simulation.getRepository().getConfig();
if (config.isOverlapSettingByTrigger() && overlap.isTriggerSectionOccupied()) {
ciService.checkAndTrySettingOverlap(simulation, overlap);
}
if (overlap.isSetting()) {
routeService.overlapSettingProcess(simulation, overlap);
}
if (overlap.isForbidden()) {
routeService.checkAndAllowOverlap(simulation, overlap);
}
if (overlap.isLock() && !ciService.interlockCheck(simulation, overlap)) {
overlap.setLock(false);
}
if (overlap.isSectionOverlapLocked()) {
if (simulation.getRepository().isTrainParking(overlap.getSection())) {
CiLogic.log.debug("列车停稳,延续保护[{}}],触发区段[{}}]立即解锁",
overlap.getName(),
overlap.getSection().debugStr());
overlap.releaseImmediately();
return;
}
if (overlap.isReleasing()) {
overlap.releaseProgress();
} else if (!overlap.isReleasing() && simulation.getRepository().isTrainHeadOccupy(overlap.getSection())) {
// 进路首区段列车占用进路开始解锁
overlap.startReleasing();
}
}
}
public void addJobs(Simulation simulation) {
simulation.addJob(SimulationModule.CI.name(), () -> run(simulation), SimulationConstants.CI_LOOP_RATE);
}
}
package club.joylink.rtss.simulation.cbtc.CI;
import club.joylink.rtss.simulation.cbtc.CI.device.CiDeviceStatusCollector;
import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiService;
import club.joylink.rtss.simulation.cbtc.CI.device.CiSignalControlService;
import club.joylink.rtss.simulation.cbtc.CI.service.assist.StationDirectionService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Objects;
@Slf4j
@Component
public class CiLogic {
interface JobName {
String SECTION_STOP_COUNTDOWN = "SECTION_STOP_COUNTDOWN";
}
@Autowired
private CiDeviceStatusCollector deviceStatusCollector;
@Autowired
private CiRouteService routeService;
@Autowired
private CiSignalControlService signalControlService;
@Autowired
private CiService ciService;
@Autowired
private StationDirectionService stationDirectionService;
public void run(Simulation simulation) {
// 采集真实设备状态
deviceStatusCollector.collect(simulation);
// 信号机监控控制
SimulationDataRepository repository = simulation.getRepository();
for (Signal signal : repository.getSignalList()) {
signalMonitor(simulation, signal);
}
// 联锁监控逻辑
List<Route> routeList = repository.getRouteList();
for (Route route : routeList) {
interlockMonitor(simulation, route);
}
List<RouteOverlap> routeOverlapList = repository.getRouteOverlapList();
for (RouteOverlap routeOverlap : routeOverlapList) {
overlapMonitor(simulation, routeOverlap);
}
// 区间灯点灯逻辑
if (simulation.getRepository().getConfig().isRailway()) {
// 车站
simulation.getRepository().getStationList().stream().forEach(station -> {
// 允许自律状态刷新
station.refreshAllowAutonomyStatus();
// 发辅助按钮倒计时刷新
station.getStationDirectionMap().values().stream()
.forEach(stationDirection -> {
// 判断进路状态是否发生变化
if (stationDirection.monitorRouteChangeStatus()) {
stationDirection.modifyRunStatus();
}
// 如果倒数结束弹起接发辅助按钮,超过50秒时不再自动抬起
if (!stationDirection.isAssistReadyStatus()
&& !stationDirection.assistDurationPass50(simulation.getCorrectSystemTime())
&& stationDirection.getCountDown().decrementAndGet() <= 0) {
stationDirection.setDeliverAssistStatus(false);
stationDirection.setReceiveAssistStatus(false);
stationDirection.getCountDown().set(0);
}
// 联锁数据检查
stationDirectionService.refreshSectionLightStatus(simulation, stationDirection);
});
});
}
}
/**
* 区段停稳倒计时
*/
public void sectionStopCountDown(Simulation simulation) {
for (Section section : simulation.getRepository().getHasStopCountDownSections()) {
int stopCountDown = section.getStopCountDown();
if (stopCountDown == 0) {
//股道占用且股道有占用
if (section.isOccupied()) {
if (section.getNextRunningSectionOf(false).isOccupied() || section.getNextRunningSectionOf(true).isOccupied()) {
section.readyStartStopCountDown();
}
}
} else {
if (stopCountDown == -1) {
// 股道占用股道两边没有占用股道没有进路锁闭或该进路正在正常解锁
if (section.isOccupied()) {
if ((!section.getNextRunningSectionOf(false).isOccupied()
&& !section.getNextRunningSectionOf(true).isOccupied())
&& (section.getRoute() == null || section.getRoute().isNormalUnlock())) {
section.startStopCountDown();
}
}
} else {
section.setStopCountDown(stopCountDown - SimulationConstants.CI_LOOP_RATE);
if (stopCountDown <= 0) {
section.setStopCountDown(0);
}
}
}
}
}
private void signalMonitor(Simulation simulation, Signal signal) {
signalControlService.controlLightOfSignal(simulation, signal);
//控制通过信号机的显示信号机前第一个区段被占用开红灯第二个区段被占用开黄灯否则开绿灯
if (simulation.getRepository().getConfig().isRailway()) {
railwaySignalMonitor(simulation, signal);
}
}
private void railwaySignalMonitor(Simulation simulation, Signal signal) {
if (signal.isGuideAspect() && signal.getLockedRoute() == null) { //引导总锁后开放的引导信号
if (signal.getRouteList().stream().noneMatch(Route::isAnySwitchMasterLock)) {
signalControlService.controlSignalAspect(simulation, signal, signal.getDefaultAspect());
}
}
if (signal.isPassingSignal()) {
boolean right = signal.isRight();
Section section = signal.getSection();
Section one = section.getNextSection(right);
if (one == null) {
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.G);
return;
}
if (one.isOccupied()) {
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.R);
return;
}
Section two = one.getNextSection(right);
if (two == null) {
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.G);
return;
}
if (two.isOccupied()) {
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.Y);
return;
}
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.G);
}
}
/**
* 进路监控
*
* @param simulation
* @param route
*/
public void interlockMonitor(Simulation simulation, Route route) {
MapConfig config = simulation.getRepository().getConfig();
if (route.isCiControl()) { // 进路联锁自动触发
if (!route.isLock() && !route.isSetting() && ciService.isCiRouteTrigger(simulation, route)) {
routeService.setRoute(simulation, route, route.getAspect());
}
} else if (route.isFleetMode()) { // 联锁自动进路
if (ciService.isCiRouteTrigger(simulation, route)) {
signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getSettedAspect());
}
}
if (route.isSetting() || route.isLock() || route.isNormalUnlock()) { // 监控中的进路
if (route.isDelayUnlocking()) {
routeService.delayUnlocking(simulation, route, route.getDelayUnlockDevice());
}
if (route.isSetting()) {
routeService.routeSettingProcess(simulation, route);
}
if (route.isNormalUnlock()) {
routeService.trainUnlockRoute(simulation, route);
}
if (route.isLock()) {
// 进路首区段列车占用进路开始解锁
Section firstLogicSection = route.getFirstLogicSection();
SimulationDataRepository repository = simulation.getRepository();
if (repository.isTrainHeadOccupy(firstLogicSection)) {
trainUnlockStart(simulation, route);
}
}
Signal start = route.getStart();
int guideRemain = start.getGuideRemain();
if (guideRemain != 0) {
guideRemain -= SimulationConstants.CI_LOOP_RATE;
if (guideRemain <= 0) { //计时结束关闭信号
start.setGuideRemain(0);
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
start, start.getDefaultAspect());
} else {
start.setGuideRemain(guideRemain);
}
}
if (route.isLock() && !route.isSetting()) {
ciService.interlockCheck(simulation, route);
if (!config.isRailway()) {
if (route.isOpenMain() && !start.isSupportMainAspect()) {//与联锁显示不同关闭信号
CiLogic.log.info("进路[{}]联锁条件不满足,关闭信号", route.debugStr());
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
start, start.getDefaultAspect());
} else if (start.isDefaultAspect() && !start.isForbidden() && !start.isBlockade() && start.isSupportMainAspect()) {
CiLogic.log.info("进路[{}]联锁条件满足,开放信号", route.debugStr());
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
start, route.getSettedAspect());
}
} else {
if (route.isOpenMain() && !start.isSupportMainAspect()) {//与联锁显示不同关闭信号
CiLogic.log.info("进路[{}]联锁条件不满足,关闭信号", route.debugStr());
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
start, start.getDefaultAspect());
start.setForcePhysical(true); //大铁线路暂时限制自动重开信号
} else if (!start.isForbidden() && !start.isBlockade() && start.isSupportMainAspect()) {
SignalAspect aspect = route.getAspectOfRailway();
if (!Objects.equals(route.getStart().getAspect(), aspect)) {
signalControlService.tryControlSignalAspectAccordingLevel(simulation, start, aspect);
}
}
}
}
// 进路延续保护办理判断
if (route.isSettingOverlap()) {
ciService.checkAndTrySettingOverlap(simulation, route.getOverlap());
}
}
}
public void trainUnlockStart(Simulation simulation, Route route) {
route.startNormalUnlock();
CiLogic.log.info("进路[{}]因列车进入,关闭信号", route.debugStr());
signalControlService.tryControlSignalAspectAccordingLevel(simulation,
route.getStart(), route.getStart().getDefaultAspect());
}
/**
* 延续保护进路监控
*
* @param simulation
* @param overlap
*/
public void overlapMonitor(Simulation simulation, RouteOverlap overlap) {
MapConfig config = simulation.getRepository().getConfig();
if (config.isOverlapSettingByTrigger() && overlap.isTriggerSectionOccupied()) {
ciService.checkAndTrySettingOverlap(simulation, overlap);
}
if (overlap.isSetting()) {
routeService.overlapSettingProcess(simulation, overlap);
}
if (overlap.isForbidden()) {
routeService.checkAndAllowOverlap(simulation, overlap);
}
if (overlap.isLock() && !ciService.interlockCheck(simulation, overlap)) {
overlap.setLock(false);
}
if (overlap.isSectionOverlapLocked()) {
if (simulation.getRepository().isTrainParking(overlap.getSection())) {
CiLogic.log.debug("列车停稳,延续保护[{}}],触发区段[{}}]立即解锁",
overlap.getName(),
overlap.getSection().debugStr());
overlap.releaseImmediately();
return;
}
if (overlap.isReleasing()) {
overlap.releaseProgress();
} else if (!overlap.isReleasing() && simulation.getRepository().isTrainHeadOccupy(overlap.getSection())) {
// 进路首区段列车占用进路开始解锁
overlap.startReleasing();
}
}
}
public void addJobs(Simulation simulation) {
simulation.addJob(SimulationModule.CI.name(), () -> run(simulation), SimulationConstants.CI_LOOP_RATE);
simulation.addJob(JobName.SECTION_STOP_COUNTDOWN, () -> sectionStopCountDown(simulation), SimulationConstants.CI_LOOP_RATE);
}
}

View File

@ -1116,6 +1116,7 @@ public class MapDeviceBuilder {
section.setVirtualAxleCounter(axleCounter);
deviceMap.put(axleCounter.getCode(), axleCounter);
}
section.setHasStopCountDown(sectionVO.isHasStopCD());
}
}

View File

@ -1248,4 +1248,10 @@ public class SimulationDataRepository {
}
return stream.collect(Collectors.toList());
}
public List<Section> getHasStopCountDownSections() {
return getListByType(MapElement.DeviceType.SECTION, Section.class).stream()
.filter(Section::isHasStopCountDown)
.collect(Collectors.toList());
}
}

View File

@ -182,7 +182,7 @@ public class Route extends MapNamedElement {
/**
* 该进路办理成功后要开放的信号
* <p>
* 注意每次开始触发办理进路时设置
* 注意每次开始触发办理进路时设置
*/
private SignalAspect settedAspect;
/**
@ -259,11 +259,15 @@ public class Route extends MapNamedElement {
this.settedAspect=null;
}
/**
* 是否是组合进路
* 是否是组合进路
*/
public boolean isMultiRoute() {
return null!=this.multiRouteAspects&&!this.multiRouteAspects.isEmpty();
}
/**
* 所有道岔都在正确位置
*/
public boolean isAllSwitchIsOnPos() {
if (!CollectionUtils.isEmpty(switchList)) {
return switchList.stream().allMatch(SwitchElement::isOnPosition);
@ -271,6 +275,16 @@ public class Route extends MapNamedElement {
return true;
}
/**
* 进路道岔中有任意一个处于引导总锁状态
*/
public boolean isAnySwitchMasterLock() {
if (!CollectionUtils.isEmpty(switchList)) {
return switchList.stream().map(SwitchElement::getASwitch).anyMatch(Switch::isGuideMasterLock);
}
return false;
}
/**
* 进路是否开放(进路是否锁闭并开放指定信号灯)
*

View File

@ -164,6 +164,11 @@ public class Section extends DelayUnlockDevice {
*/
private Set<ZC> zcs = new HashSet<>();
/**
* 有停稳计时
*/
private boolean hasStopCountDown;
// ------------------状态属性---------------------
/**
@ -261,6 +266,14 @@ public class Section extends DelayUnlockDevice {
*/
private List<ShuntingType> shuntingTypeList;
/**
* 停稳倒计时
* 0 表示初始状态
* -1 表示准备开始计时
* 非负数表示当前计时
*/
private int stopCountDown;
@Override
public void reset() {
super.reset();
@ -282,12 +295,29 @@ public class Section extends DelayUnlockDevice {
this.closed = false;
this.badShunt = false;
this.shuntingTypeList = new ArrayList<>();
this.stopCountDown = 0;
}
/**
* 开始停稳倒计时
*/
public void startStopCountDown() {
stopCountDown = 40 * 1000;
}
/**
* 准备开始停稳倒计时
*/
public void readyStartStopCountDown() {
stopCountDown = -1;
}
public int getStopCountDownInSeconds() {
return stopCountDown / 1000;
}
/**
* 区段是否被列车占用
*
* @return
*/
public boolean isOccupied() {
return this.nctOccupied || this.ctOccupied || this.isLogicOccupied();

View File

@ -197,8 +197,12 @@ public class Station extends MayOutOfOrderDevice {
*/
private boolean allowAutonomy;
@Override
/**
* 操作计数器
*/
private Map<String, Integer> counter;
@Override
public void reset() {
super.reset();
if (vrIbp != null) {
@ -223,6 +227,7 @@ public class Station extends MayOutOfOrderDevice {
preResetValidDuration = new AtomicInteger(0);
sGuideMasterLock = false;
xGuideMasterLock = false;
counter = null;
}
public List<Stand> getStandOf(boolean right) {
@ -459,6 +464,13 @@ public class Station extends MayOutOfOrderDevice {
return Fault.ATS_ROUTE_TRIGGER_FAULT.equals(getFault());
}
public void count(String countName) {
if (this.counter == null) {
this.counter = new HashMap<>();
}
this.counter.merge(countName, 1, Integer::sum);
}
public enum ControlMode {
/**
* 交出未被接收

View File

@ -126,6 +126,8 @@ public class SectionStatus extends DeviceStatus {
*/
private boolean badShunt;
private Integer stopCountDown;
public SectionStatus(Section section) {
super(section.getCode(), section.getDeviceType());
this.blockade = section.isBlockade();
@ -147,6 +149,7 @@ public class SectionStatus extends DeviceStatus {
this.fault = section.getFault() == null ? null : section.getFault().toString();
this.shuntingTypeList = section.getShuntingTypeList();
this.badShunt = section.isBadShunt();
this.stopCountDown = section.getStopCountDownInSeconds();
}
@Override
@ -250,6 +253,13 @@ public class SectionStatus extends DeviceStatus {
this.badShunt = section.isBadShunt();
status.setBadShunt(this.badShunt);
}
int stopCountDownInSeconds = section.getStopCountDownInSeconds();
if (!Objects.equals(this.stopCountDown, stopCountDownInSeconds)) {
change = true;
this.stopCountDown = stopCountDownInSeconds;
}
status.setStopCountDown(stopCountDown == 0 ? null : stopCountDown);
return change;
}

View File

@ -11,6 +11,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import java.time.LocalTime;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
@ -90,6 +92,11 @@ public class StationStatus extends DeviceStatus {
*/
private boolean allowAutonomy;
/**
* 计数器
*/
private Map<String, Integer> counter;
public StationStatus(Station station) {
super(station.getCode(), station.getDeviceType());
controlMode = station.getControlMode();
@ -107,6 +114,9 @@ public class StationStatus extends DeviceStatus {
sGuideMasterLock = station.isSGuideMasterLock();
xGuideMasterLock = station.isXGuideMasterLock();
allowAutonomy = station.isAllowAutonomy();
if (station.getCounter() != null) {
counter = new HashMap<>(station.getCounter());
}
}
@Override
@ -190,6 +200,15 @@ public class StationStatus extends DeviceStatus {
allowAutonomy = station.isAllowAutonomy();
status.setAllowAutonomy(allowAutonomy);
}
if (!Objects.equals(counter, station.getCounter())) {
change = true;
if (counter == null) {
counter = new HashMap<>(station.getCounter());
} else {
counter.putAll(station.getCounter());
}
status.setCounter(counter);
}
return change;
}

View File

@ -106,6 +106,11 @@ public class StorageSection extends StorageDelayUnlockDevice {
*/
private Boolean badShunt;
/**
* 停稳倒计时
*/
private Integer stopCountDown;
public StorageSection(Section section) {
super(section);
}
@ -176,6 +181,10 @@ public class StorageSection extends StorageDelayUnlockDevice {
this.shuntingTypeList = section.getShuntingTypeList();
this.badShunt = section.isBadShunt();
}
if (section.getStopCountDown() != 0) {
change = true;
this.stopCountDown = section.getStopCountDown();
}
return change;
}
@ -197,5 +206,6 @@ public class StorageSection extends StorageDelayUnlockDevice {
section.setSpeedLimitBeforeFault(speedLimitBeforeFault);
section.setShuntingTypeList(shuntingTypeList != null ? shuntingTypeList : new ArrayList<>());
section.setBadShunt(badShunt != null ? badShunt : false);
section.setStopCountDown(stopCountDown == null ? 0 : stopCountDown);
}
}

View File

@ -13,6 +13,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalTime;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
@ -65,6 +66,8 @@ public class StorageStation extends StorageStatusDevice {
private Integer preResetValidDuration;
private Map<String, Integer> counter;
public StorageStation(Station station) {
super(station);
}
@ -111,6 +114,7 @@ public class StorageStation extends StorageStatusDevice {
if (station.getPreResetValidDuration() != null && station.getPreResetValidDuration().get() != 0) {
this.setPreResetValidDuration(station.getPreResetValidDuration().get());
}
this.counter = station.getCounter();
return true;
}
@ -133,5 +137,6 @@ public class StorageStation extends StorageStatusDevice {
station.setEmergencyController(emergencyController != null ? emergencyController : false);
station.setControlApplicant(controlApplicant != null ? simulation.getSimulationMemberById(controlApplicant) : null);
station.setPreResetValidDuration(new AtomicInteger(Objects.requireNonNullElse(preResetValidDuration, 0)));
station.setCounter(counter);
}
}

View File

@ -99,6 +99,9 @@ public class SectionStatusVO extends DeviceStatusVO {
private Boolean badShunt;
@JsonInclude
private Integer stopCountDown;
public SectionStatusVO(Section section) {
super(section.getCode(), section.getDeviceType());
}

View File

@ -10,6 +10,7 @@ import lombok.Getter;
import lombok.Setter;
import java.time.LocalTime;
import java.util.Map;
/**
* 车站状态
@ -87,6 +88,8 @@ public class StationStatusVO extends DeviceStatusVO {
private Boolean allowAutonomy;
private Map<String, Integer> counter;
public StationStatusVO(Station station) {
super(station.getCode(), station.getDeviceType());
}

View File

@ -106,11 +106,11 @@ public class MemberManager {
this.playRole(simulation, userId, ddList.get(0).getId());
break;
}
case CTC: {
List<SimulationMember> list = simulation.querySimulationMembersOfRole(SimulationMember.Type.RAIL_CTC);
this.playRole(simulation, userId, list.get(0).getId());
break;
}
// case CTC: {
// List<SimulationMember> list = simulation.querySimulationMembersOfRole(SimulationMember.Type.RAIL_CTC);
// this.playRole(simulation, userId, list.get(0).getId());
// break;
// }
}
}
}

View File

@ -46,6 +46,11 @@ public class MapIndicatorLightVO {
*/
private boolean right;
/**
* 计数器类型
*/
private String counterType;
// public enum Type{
// AtsControl,
// CenterCommunication,

View File

@ -48,6 +48,16 @@ public class MapSectionNewVO {
*/
private Point namePosition;
/**
* 有停稳计时
*/
private boolean hasStopCD;
/**
* 停车倒计时显示坐标
*/
private Point stopCDPosition;
/**
* 是否显示计轴器false-不显示true-显示
*/