新仿真运行流程调整
新仿真逻辑——计算机联锁模块数据构建.
This commit is contained in:
parent
354f676238
commit
98fed5f681
@ -65,8 +65,6 @@ public class SimulationV1Controller {
|
||||
@ApiIgnore @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
|
||||
LoginUserInfoVO loginUserInfoVO) {
|
||||
String simulation = this.groupSimulationService.simulation(mapId, prdType, loginUserInfoVO);
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println(end);
|
||||
return simulation;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class RoutingGenerator {
|
||||
Set<Section> leftDirectionList = new HashSet<>();
|
||||
sectionDirectionSectionsMap.put(this.buildSectionDirectionKey(section, false), leftDirectionList);
|
||||
this.queryAdjoinSections(section, false, leftDirectionList);
|
||||
System.out.println(String.format("区段[%s][右向]邻接区段为[%s],[左向]邻接区段为[%s]",
|
||||
log.debug(String.format("区段[%s][右向]邻接区段为[%s],[左向]邻接区段为[%s]",
|
||||
section.debugStr(),
|
||||
String.join(",",rightDirectionList.stream().map(Section::debugStr).collect(Collectors.toList())),
|
||||
String.join(",", leftDirectionList.stream().map(Section::debugStr).collect(Collectors.toList()))));
|
||||
|
@ -112,7 +112,6 @@ public class LicenseServiceImpl implements LicenseService {
|
||||
FileSystemResource fileSystemResource = new FileSystemResource(License_File_Path);
|
||||
if (!fileSystemResource.exists()) {
|
||||
File parentFile = fileSystemResource.getFile().getParentFile();
|
||||
System.out.println(parentFile.getAbsolutePath());
|
||||
if (!parentFile.exists()) {
|
||||
// 创建目录
|
||||
boolean mkdirs = parentFile.mkdirs();
|
||||
|
@ -63,11 +63,7 @@ public class AsrService {
|
||||
conn.getOutputStream().close();
|
||||
String result = ConnUtil.getResponseString(conn);
|
||||
|
||||
|
||||
params.put("speech", "base64Encode(getFileContent(FILENAME))");
|
||||
System.out.println("url is : " + ASR_URL);
|
||||
System.out.println("params is :" + params.toString());
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
||||
*/
|
||||
private LocalDateTime systemTime;
|
||||
|
||||
private static final int SYSTEM_TIME_RATE = 1;
|
||||
private static final int SYSTEM_TIME_RATE = 20;
|
||||
private final AtomicBoolean mainLogicRunning = new AtomicBoolean(false);
|
||||
/**
|
||||
* 实际运行间隔,单位ns
|
||||
@ -67,7 +67,7 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
||||
private Map<String, String> destinationMap = new HashMap<>();
|
||||
private static final PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("{", "}");
|
||||
private List<SimulationSubscribeMessageService> subscribeMessageServiceList;
|
||||
private SimulationMessagePublisher publisher;
|
||||
private SimulationMessagePublisher messagePublisher;
|
||||
/**
|
||||
* 消息推送线程池
|
||||
*/
|
||||
@ -92,16 +92,21 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
||||
}
|
||||
|
||||
private void runAsSpeed() {
|
||||
if (this.future == null) {
|
||||
ScheduledFuture<?> scheduledFuture = EXECUTOR.scheduleAtFixedRate(()->this.logic(),
|
||||
SYSTEM_TIME_RATE, SYSTEM_TIME_RATE, TimeUnit.MILLISECONDS);
|
||||
this.future = scheduledFuture;
|
||||
if (this.future != null) {
|
||||
if (!this.future.cancel(false)) {
|
||||
log.warn(String.format("仿真[%s]无法取消任务", this.id));
|
||||
}
|
||||
}
|
||||
long period = TimeUnit.MILLISECONDS.toNanos(SYSTEM_TIME_RATE) / this.speed;
|
||||
ScheduledFuture<?> scheduledFuture = EXECUTOR.scheduleAtFixedRate(()->this.logic(),
|
||||
0, period, TimeUnit.NANOSECONDS);
|
||||
this.future = scheduledFuture;
|
||||
this.updateTimeUpdateSpeed(this.speed);
|
||||
}
|
||||
|
||||
private void updateTimeUpdateSpeed(int speed) {
|
||||
this.timeAdd = TimeUnit.MILLISECONDS.toNanos(SYSTEM_TIME_RATE) * speed;
|
||||
// this.timeAdd = TimeUnit.MILLISECONDS.toNanos(SYSTEM_TIME_RATE) * speed;
|
||||
this.timeAdd = TimeUnit.MILLISECONDS.toNanos(SYSTEM_TIME_RATE);
|
||||
}
|
||||
|
||||
private void logic() {
|
||||
@ -112,25 +117,37 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
||||
try {
|
||||
this.mainLogicRunning.set(true);
|
||||
this.systemTime = this.systemTime.plusNanos(timeAdd);
|
||||
for (SimulationScheduledJob scheduledJob : this.scheduledJobMap.values()) {
|
||||
if (scheduledJob.isTimeToRun(this.systemTime)) {
|
||||
scheduledJob.run();
|
||||
scheduledJob.updateNextRunTime(this.systemTime);
|
||||
}
|
||||
}
|
||||
for (SimulationDelayJob delayJob : this.delayJobMap.values()) {
|
||||
if (delayJob.isTimeToRun(systemTime)) {
|
||||
EXECUTOR.execute(delayJob);
|
||||
this.delayJobMap.remove(delayJob.getId());
|
||||
}
|
||||
}
|
||||
for (SimulationScheduledJob scheduledJob : this.scheduledJobMap.values()) {
|
||||
if (scheduledJob.isTimeToRun(this.systemTime)) {
|
||||
// 系统时间更新随着速度增大而增大,可能几倍于有些定时任务的频率,根据计算将执行频率补上
|
||||
// int n = 1;
|
||||
// if (!scheduledJob.isFixed()) {
|
||||
// n = scheduledJob.calculateRunTimes(timeAdd);
|
||||
// }
|
||||
// if (n <= 1) {
|
||||
// scheduledJob.run();
|
||||
// } else {
|
||||
// for (int i = 0; i < n; i++) {
|
||||
// scheduledJob.run();
|
||||
// }
|
||||
// }
|
||||
scheduledJob.run();
|
||||
scheduledJob.updateNextRunTime(this.systemTime);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
this.runError(e);
|
||||
log.error(String.format("仿真[%s]主线程逻辑执行异常,仿真停止运行", this.id), e);
|
||||
} finally {
|
||||
this.mainLogicRunning.set(false);
|
||||
long take = System.nanoTime() - start;
|
||||
log.debug(String.format("仿真[%s]执行时长: %sms", TimeUnit.NANOSECONDS.toMillis(take)));
|
||||
// log.debug(String.format("仿真[%s]执行时长: %sms", this.id, TimeUnit.NANOSECONDS.toMillis(take)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -271,7 +288,9 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
||||
this.speed = speed;
|
||||
int state = this.state.get();
|
||||
this.pause();
|
||||
this.updateTimeUpdateSpeed(this.speed);
|
||||
log.debug(String.format("仿真[%s]更新速度为:[%s]", this.id, speed));
|
||||
// this.updateTimeUpdateSpeed(this.speed);
|
||||
this.runAsSpeed();
|
||||
for (SimulationScheduledJob job : this.scheduledJobMap.values()) {
|
||||
job.updateRunPeriod(speed);
|
||||
}
|
||||
@ -367,8 +386,8 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
||||
return this.simulationUserMap.remove(id);
|
||||
}
|
||||
|
||||
public void setPublisher(SimulationMessagePublisher publisher) {
|
||||
this.publisher = publisher;
|
||||
public void setMessagePublisher(SimulationMessagePublisher messagePublisher) {
|
||||
this.messagePublisher = messagePublisher;
|
||||
}
|
||||
|
||||
public void publishMessage(String destination, Object message) {
|
||||
@ -391,12 +410,12 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
||||
|
||||
public void publishMessageToUser0(String userId, String destination, Object message) {
|
||||
if (userId != null && message != null) {
|
||||
Message_Executor.execute(() -> this.publisher.publishToUser(userId, destination, message));
|
||||
Message_Executor.execute(() -> this.messagePublisher.publishToUser(userId, destination, message));
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPublisherExist() {
|
||||
if (this.publisher == null) {
|
||||
if (this.messagePublisher == null) {
|
||||
throw new UnsupportedOperationException(String.format("仿真[%s]没有消息发布对象:publisher = null.无法发布消息", this.id));
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class SimulationManager {
|
||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(simulationCache.containsKey(simulation.getId()),
|
||||
String.format("已经存在id为[%s]的仿真[%s]", simulation.getId(), simulation.debugStr()));
|
||||
simulationCache.put(simulation.getId(), simulation);
|
||||
simulation.setPublisher(this.defaultMessagePublisher); // 设置默认的消息发布器
|
||||
simulation.setMessagePublisher(this.defaultMessagePublisher); // 设置默认的消息发布器
|
||||
return simulation;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.rtss.simulation;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -42,6 +43,7 @@ final class SimulationScheduledJob implements Runnable {
|
||||
this.updateRunPeriod(1);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
public SimulationScheduledJob(Simulation simulation, String name, SimulationJob job, int rate) {
|
||||
this(simulation, name, job, rate, false);
|
||||
}
|
||||
@ -58,6 +60,10 @@ final class SimulationScheduledJob implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isFixed() {
|
||||
return fixed;
|
||||
}
|
||||
|
||||
public void updateRunPeriod(int speed) {
|
||||
if (this.fixed) {
|
||||
this.runPeriod = TimeUnit.MILLISECONDS.toNanos(this.rate) * speed;
|
||||
@ -72,10 +78,27 @@ final class SimulationScheduledJob implements Runnable {
|
||||
}
|
||||
|
||||
public void updateNextRunTime(LocalDateTime systemTime) {
|
||||
if (this.nextRunTime != null) {
|
||||
// 弥补非整数倍的情况
|
||||
long l = Duration.between(this.nextRunTime, systemTime).toNanos();
|
||||
long l1 = l % this.runPeriod;
|
||||
long add = this.runPeriod - l1;
|
||||
this.nextRunTime = systemTime.plusNanos(add);
|
||||
} else {
|
||||
this.nextRunTime = systemTime.plusNanos(this.runPeriod);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param interval 单位ns
|
||||
* @return
|
||||
*/
|
||||
public int calculateRunTimes(long interval) {
|
||||
return (int) (interval / TimeUnit.MILLISECONDS.toNanos(this.rate));
|
||||
}
|
||||
}
|
||||
|
@ -197,12 +197,10 @@ public class Simulation {
|
||||
|
||||
public synchronized void runAdd() {
|
||||
this.runCount += 1;
|
||||
// System.out.println(String.format("add, result:%s", this.runCount));
|
||||
}
|
||||
|
||||
public synchronized void runOver() {
|
||||
this.runCount -= 1;
|
||||
// System.out.println(String.format("over, result:%s", this.runCount));
|
||||
}
|
||||
|
||||
public boolean isJointSimulation() {
|
||||
|
@ -78,7 +78,6 @@ public class GzbSignalServiceImpl implements RealDeviceService {
|
||||
if (!br0 && !br1 && br2 && !br3 && br4) { // 黄红灯已开
|
||||
return;
|
||||
}
|
||||
System.out.println("控制真实信号机开黄红灯");
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW8(), bw8, false, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW9(), bw9, false, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW10(), bw10, false, channel);
|
||||
@ -87,7 +86,6 @@ public class GzbSignalServiceImpl implements RealDeviceService {
|
||||
if (!br0 && !br1 && !br2 && !br3 && br4) { // 红灯已开
|
||||
return;
|
||||
}
|
||||
System.out.println("控制真实信号机开红灯");
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW8(), bw8, false, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW9(), bw9, false, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW10(), bw10, false, channel);
|
||||
@ -96,7 +94,6 @@ public class GzbSignalServiceImpl implements RealDeviceService {
|
||||
if (br0 && br1 && !br2 && !br3 && br4) { // 绿灯已开
|
||||
return;
|
||||
}
|
||||
System.out.println("控制真实信号机开绿灯");
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW8(), bw8, false, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW9(), bw9, true, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW10(), bw10, true, channel);
|
||||
@ -105,7 +102,6 @@ public class GzbSignalServiceImpl implements RealDeviceService {
|
||||
if (br0 && !br1 && !br2 && !br3 && br4) { // 黄灯已开
|
||||
return;
|
||||
}
|
||||
System.out.println("控制真实信号机开黄灯");
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW8(), bw8, false, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW9(), bw9, true, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW10(), bw10, false, channel);
|
||||
@ -114,7 +110,6 @@ public class GzbSignalServiceImpl implements RealDeviceService {
|
||||
if (!br4) { // 已灭灯
|
||||
return;
|
||||
}
|
||||
System.out.println("控制真实信号机灭灯");
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW8(), bw8, true, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW9(), bw9, false, channel);
|
||||
this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW10(), bw10, false, channel);
|
||||
|
@ -114,21 +114,10 @@ public class PassengerFlowSimulateService {
|
||||
log.debug(String.format("仿真[%s]没有客流数据,不初始化客流", simulation.debugStr()));
|
||||
return;
|
||||
}
|
||||
// MapPassengerFlowWithBLOBs passengerFlowEntity = this.mapPassengerFlowDataService.queryMapPassengerFlowData(mapId);
|
||||
// if (Objects.isNull(passengerFlowEntity)) {
|
||||
// log.debug(String.format("仿真[%s]没有客流数据,不初始化客流", simulation.debugStr()));
|
||||
// return;
|
||||
// }
|
||||
// long start = System.currentTimeMillis();
|
||||
//
|
||||
// PassengerFlowData passengerFlowData = this.mapPassengerFlowDataService.buildPassengerFlowSimulationBo(passengerFlowEntity);
|
||||
// 初始化客流数据
|
||||
Map<String, StandPassengerFlow> standPassengerFlowMap = this.loadStandPassengerFlow(simulation, passengerFlowData);
|
||||
Map<String, TrainPassengerFlow> trainPassengerFlowMap = this.loadTrainPassengerFlow(simulation, passengerFlowData);
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println(String.format("仿真客流初始化共用时:%sms", (end - start)));
|
||||
|
||||
PassengerFlowSimulationData data = new PassengerFlowSimulationData(
|
||||
simulation.getGroup(),
|
||||
passengerFlowData,
|
||||
|
@ -0,0 +1,16 @@
|
||||
package club.joylink.rtss.simulation.event;
|
||||
|
||||
import club.joylink.rtss.simulation.Simulation;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class SimulationErrorEvent extends SimulationEvent {
|
||||
|
||||
private Throwable e;
|
||||
|
||||
public SimulationErrorEvent(Object source, Simulation simulation, Throwable e) {
|
||||
super(source, simulation);
|
||||
this.e = e;
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 侧防
|
||||
*/
|
||||
@Getter
|
||||
public class CilFls {
|
||||
String id;
|
||||
|
||||
@ -16,9 +19,24 @@ public class CilFls {
|
||||
|
||||
List<FlsElement> secondLevelList;
|
||||
|
||||
public CilFls(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static class FlsElement {
|
||||
CilSwitchPosition pp; // 防护道岔
|
||||
CilSignal ps; // 防护信号
|
||||
CilSwitchPosition pae; // 侧防区域元件
|
||||
|
||||
public FlsElement(CilSwitchPosition pp, CilSwitchPosition pae) {
|
||||
this.pp = pp;
|
||||
this.pae = pae;
|
||||
}
|
||||
|
||||
public FlsElement(CilSignal ps, CilSwitchPosition pae) {
|
||||
this.ps = ps;
|
||||
this.pae = pae;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CilOverlap extends CilDevice {
|
||||
|
||||
CilSection releaseSection;
|
||||
List<CilRoutePathElement> pathElementList;
|
||||
int releaseTime;
|
||||
|
||||
public CilOverlap(String id, String name) {
|
||||
super(id, name);
|
||||
}
|
||||
}
|
@ -11,16 +11,36 @@ public class CilRepository extends SimulationRepository {
|
||||
Map<String, CilSection> sectionMap;
|
||||
Map<String, CilSwitch> switchMap;
|
||||
Map<String, CilSignal> signalMap;
|
||||
Map<String, CilStand> standMap;
|
||||
Map<String, CilPsd> psdMap;
|
||||
Map<String, CilEsp> espMap;
|
||||
Map<String, CilRoute> routeMap;
|
||||
Map<String, CilAutoSignal> autoSignalMap;
|
||||
/**
|
||||
* key-id
|
||||
*/
|
||||
Map<String, CilFls> flsMap;
|
||||
Map<String, CilOverlap> overlapMap;
|
||||
Map<String, CilServer> cilServerMap;
|
||||
|
||||
public CilRepository() {
|
||||
super(NAME);
|
||||
this.sectionMap = new HashMap<>();
|
||||
this.switchMap = new HashMap<>();
|
||||
this.signalMap = new HashMap<>();
|
||||
this.standMap = new HashMap<>();
|
||||
this.psdMap = new HashMap<>();
|
||||
this.espMap = new HashMap<>();
|
||||
this.routeMap = new HashMap<>();
|
||||
this.autoSignalMap = new HashMap<>();
|
||||
this.flsMap = new HashMap<>();
|
||||
this.overlapMap = new HashMap<>();
|
||||
this.cilServerMap = new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initState() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,28 +1,259 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.vo.client.map.MapSwitchVO;
|
||||
import club.joylink.rtss.vo.client.map.MapVO;
|
||||
import club.joylink.rtss.vo.client.map.newmap.MapGraphDataNewVO;
|
||||
import club.joylink.rtss.vo.client.map.newmap.MapSectionNewVO;
|
||||
import club.joylink.rtss.vo.client.map.newmap.*;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class CilRepositoryBuilder {
|
||||
|
||||
public static CilRepository buildFrom(MapVO mapVO) {
|
||||
CilRepository cilRepository = new CilRepository();
|
||||
MapGraphDataNewVO graphDataNew = mapVO.getGraphDataNew();
|
||||
MapLogicDataNewVO logicDataNew = mapVO.getLogicDataNew();
|
||||
buildSections(graphDataNew.getSectionList(), cilRepository.sectionMap);
|
||||
buildSwitches(graphDataNew.getSwitchList(), cilRepository.switchMap);
|
||||
buildSignals(graphDataNew.getSignalList(), cilRepository.signalMap);
|
||||
buildStands(graphDataNew.getStationStandList(), cilRepository.standMap);
|
||||
buildPsds(graphDataNew.getPsdList(), cilRepository.psdMap);
|
||||
buildEsps(graphDataNew.getEspList(), cilRepository.espMap);
|
||||
buildFls(logicDataNew.getFlankProtectionList(), cilRepository.flsMap, cilRepository.sectionMap, cilRepository.switchMap, cilRepository.signalMap);
|
||||
buildOverlaps(logicDataNew.getOverlapList(), cilRepository.overlapMap, cilRepository.signalMap, cilRepository.sectionMap, cilRepository.switchMap, cilRepository.flsMap);
|
||||
buildAutoSignals(logicDataNew.getAutoSignalList(), cilRepository.autoSignalMap);
|
||||
buildRoutes(logicDataNew.getRouteList(), cilRepository.routeMap, cilRepository.signalMap, cilRepository.sectionMap, cilRepository.switchMap, cilRepository.flsMap, cilRepository.overlapMap);
|
||||
return cilRepository;
|
||||
}
|
||||
|
||||
private static void buildSections(List<MapSectionNewVO> sectionList, Map<String, CilSection> sectionMap) {
|
||||
for (MapSectionNewVO sectionNewVO : sectionList) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(sectionMap.containsKey(sectionNewVO.getCode()),
|
||||
String.format("存在重复的区段id:[%s]", sectionNewVO.getCode()));
|
||||
String.format("存在id重复的区段:[%s]", sectionNewVO.getCode()));
|
||||
CilSection cilSection = new CilSection(sectionNewVO.getCode(), sectionNewVO.getName());
|
||||
sectionMap.put(cilSection.getId(), cilSection);
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildSwitches(List<MapSwitchVO> switchList, Map<String, CilSwitch> switchMap) {
|
||||
for (MapSwitchVO switchVO : switchList) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(switchMap.containsKey(switchVO.getCode()),
|
||||
String.format("存在id重复的道岔:[%s]", switchVO.getCode()));
|
||||
CilSwitch cilSwitch = new CilSwitch(switchVO.getCode(), switchVO.getName());
|
||||
switchMap.put(cilSwitch.getId(), cilSwitch);
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildSignals(List<MapSignalNewVO> signalList, Map<String, CilSignal> signalMap) {
|
||||
for (MapSignalNewVO signalNewVO : signalList) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(signalMap.containsKey(signalNewVO.getCode()),
|
||||
String.format("存在id重复的信号机:[%s]", signalNewVO.getCode()));
|
||||
CilSignal cilSignal = new CilSignal(signalNewVO.getCode(), signalNewVO.getUniqueName());
|
||||
signalMap.put(cilSignal.getId(), cilSignal);
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildStands(List<MapStationStandNewVO> stationStandList, Map<String, CilStand> standMap) {
|
||||
for (MapStationStandNewVO standNewVO : stationStandList) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(standMap.containsKey(standNewVO.getCode()),
|
||||
String.format("存在id重复的站台:[%s]", standNewVO.getCode()));
|
||||
CilStand cilStand = new CilStand(standNewVO.getCode(), standNewVO.getName());
|
||||
standMap.put(cilStand.getId(), cilStand);
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildPsds(List<MapPSDVO> psdList, Map<String, CilPsd> psdMap) {
|
||||
for (MapPSDVO psdVO : psdList) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(psdMap.containsKey(psdVO.getCode()),
|
||||
String.format("存在id重复的屏蔽门:[%s]", psdVO.getCode()));
|
||||
CilPsd cilPsd = new CilPsd(psdVO.getCode(), psdVO.getName());
|
||||
psdMap.put(cilPsd.getId(), cilPsd);
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildEsps(List<MapESPVO> espList, Map<String, CilEsp> espMap) {
|
||||
for (MapESPVO espVO : espList) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(espMap.containsKey(espVO.getCode()),
|
||||
String.format("存在id重复的紧急停车按钮:[%s]", espVO.getCode()));
|
||||
CilEsp cilEsp = new CilEsp(espVO.getCode(), espVO.getName());
|
||||
espMap.put(cilEsp.getId(), cilEsp);
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildFls(List<MapRouteFlankProtectionNewVO> flankProtectionList,
|
||||
Map<String, CilFls> flsMap, Map<String, CilSection> sectionMap,
|
||||
Map<String, CilSwitch> switchMap, Map<String, CilSignal> signalMap) {
|
||||
if (CollectionUtils.isEmpty(flankProtectionList)) {
|
||||
return;
|
||||
}
|
||||
for (MapRouteFlankProtectionNewVO flankProtectionNewVO : flankProtectionList) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(flsMap.containsKey(flankProtectionNewVO.getCode()),
|
||||
String.format("存在id重复的进路侧防:[%s]", flankProtectionNewVO.getCode()));
|
||||
CilFls cilFls = new CilFls(flankProtectionNewVO.getCode(), flankProtectionNewVO.getName());
|
||||
flsMap.put(cilFls.id, cilFls);
|
||||
MapCISwitchVO source = flankProtectionNewVO.getSource();
|
||||
CilSwitchPosition switchPosition = new CilSwitchPosition(switchMap.get(source.getSwitchCode()), source.isNormal());
|
||||
cilFls.target = switchPosition;
|
||||
List<MapRouteFlankProtectionNewVO.Level> level1List = flankProtectionNewVO.getLevel1List();
|
||||
List<CilFls.FlsElement> firstLevelList = buildFlsElement(level1List, switchMap, signalMap);
|
||||
cilFls.firstLevelList = firstLevelList;
|
||||
List<MapRouteFlankProtectionNewVO.Level> level2List = flankProtectionNewVO.getLevel2List();
|
||||
List<CilFls.FlsElement> secondLevelList = buildFlsElement(level2List, switchMap, signalMap);
|
||||
cilFls.firstLevelList = secondLevelList;
|
||||
}
|
||||
}
|
||||
|
||||
private static List<CilFls.FlsElement> buildFlsElement(List<MapRouteFlankProtectionNewVO.Level> level1List, Map<String, CilSwitch> switchMap, Map<String, CilSignal> signalMap) {
|
||||
List<CilFls.FlsElement> list = new ArrayList<>();
|
||||
for (MapRouteFlankProtectionNewVO.Level level : level1List) {
|
||||
MapCISwitchVO protectSwitch = level.getProtectSwitch();
|
||||
MapCISwitchVO areaSwitch = level.getAreaSwitch();
|
||||
CilFls.FlsElement flsElement;
|
||||
if (protectSwitch != null) {
|
||||
CilSwitchPosition pp = new CilSwitchPosition(switchMap.get(protectSwitch.getSwitchCode()), protectSwitch.isNormal());
|
||||
if (areaSwitch != null) {
|
||||
flsElement = new CilFls.FlsElement(pp,
|
||||
new CilSwitchPosition(switchMap.get(areaSwitch.getSwitchCode()), areaSwitch.isNormal()));
|
||||
} else {
|
||||
flsElement = new CilFls.FlsElement(pp, null);
|
||||
}
|
||||
} else {
|
||||
CilSignal cilSignal = signalMap.get(level.getProtectSignal());
|
||||
if (areaSwitch != null) {
|
||||
flsElement = new CilFls.FlsElement(cilSignal,
|
||||
new CilSwitchPosition(switchMap.get(areaSwitch.getSwitchCode()), areaSwitch.isNormal()));
|
||||
} else {
|
||||
flsElement = new CilFls.FlsElement(cilSignal, null);
|
||||
}
|
||||
}
|
||||
list.add(flsElement);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void buildAutoSignals(List<MapAutoSignalNewVO> autoSignalList, Map<String, CilAutoSignal> autoSignalMap) {
|
||||
if (CollectionUtils.isEmpty(autoSignalList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void buildOverlaps(List<MapOverlapVO> overlapList, Map<String, CilOverlap> overlapMap,
|
||||
Map<String, CilSignal> signalMap, Map<String, CilSection> sectionMap,
|
||||
Map<String, CilSwitch> switchMap, Map<String, CilFls> flsMap) {
|
||||
for (MapOverlapVO overlapVO : overlapList) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(overlapMap.containsKey(overlapVO.getCode()),
|
||||
String.format("存在id重复的延续保护:[%s]", overlapVO.getCode()));
|
||||
CilOverlap cilOverlap = new CilOverlap(overlapVO.getCode(), overlapVO.getName());
|
||||
overlapMap.put(cilOverlap.id, cilOverlap);
|
||||
CilSection cilSection = sectionMap.get(overlapVO.getUnlockSectionCode());
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(cilSection,
|
||||
String.format("不存在id为[%s]的区段", overlapVO.getUnlockSectionCode()));
|
||||
cilOverlap.releaseSection = cilSection;
|
||||
cilOverlap.releaseTime = overlapVO.getUnlockTime();
|
||||
CilSignal cilSignal = signalMap.get(overlapVO.getSignalCode());
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(cilSignal,
|
||||
String.format("不存在id为[%s]的信号机", overlapVO.getSignalCode()));
|
||||
cilOverlap.pathElementList = buildPathElementList(cilSignal, overlapVO.getPathList(), sectionMap, switchMap, flsMap);
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildRoutes(List<MapRouteNewVO> routeList, Map<String, CilRoute> routeMap,
|
||||
Map<String, CilSignal> signalMap, Map<String, CilSection> sectionMap,
|
||||
Map<String, CilSwitch> switchMap, Map<String, CilFls> flsMap,
|
||||
Map<String, CilOverlap> overlapMap) {
|
||||
for (MapRouteNewVO routeNewVO : routeList) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(routeMap.containsKey(routeNewVO.getCode()),
|
||||
String.format("存在id重复的进路:[%s]", routeNewVO.getCode()));
|
||||
CilRoute cilRoute = new CilRoute(routeNewVO.getCode(), routeNewVO.getName());
|
||||
routeMap.put(cilRoute.getId(), cilRoute);
|
||||
CilSignal start = signalMap.get(routeNewVO.getStartSignalCode());
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(start,String.format("不存在id为[%s]的信号机", routeNewVO.getStartSignalCode()));
|
||||
CilSignal end = signalMap.get(routeNewVO.getEndSignalCode());
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(end,String.format("不存在id为[%s]的信号机", routeNewVO.getStartSignalCode()));
|
||||
cilRoute.start = start;
|
||||
cilRoute.end = end;
|
||||
cilRoute.pathElement = buildPathElement(start, routeNewVO.getRouteSectionList(),
|
||||
routeNewVO.getRouteSwitchList(), routeNewVO.getFlsList(), sectionMap, switchMap, flsMap);
|
||||
CilOverlap cilOverlap = overlapMap.get(routeNewVO.getOverlapCode());
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(cilOverlap,
|
||||
String.format("不存在id为[%s]的延续保护进路", routeNewVO.getOverlapCode()));
|
||||
cilRoute.overlap = cilOverlap;
|
||||
cilRoute.arc = routeNewVO.isArc();
|
||||
cilRoute.flt = routeNewVO.isFlt();
|
||||
// 扣车站台
|
||||
List<CilStand> standList = new ArrayList<>();
|
||||
List<String> holdStandList = routeNewVO.getHoldStandList();
|
||||
if (!CollectionUtils.isEmpty(holdStandList)) {
|
||||
for (String standCode : holdStandList) {
|
||||
|
||||
}
|
||||
}
|
||||
cilRoute.standList = standList;
|
||||
// 屏蔽门
|
||||
List<CilPsd> psdList = new ArrayList<>();
|
||||
List<String> psdCodeList = routeNewVO.getPsdList();
|
||||
if (!CollectionUtils.isEmpty(psdCodeList)) {
|
||||
for (String psdCode : psdCodeList) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static List<CilRoutePathElement> buildPathElementList(CilSignal cilSignal, List<MapSectionPathVO> pathList,
|
||||
Map<String, CilSection> sectionMap,
|
||||
Map<String, CilSwitch> switchMap,
|
||||
Map<String, CilFls> flsMap) {
|
||||
Objects.requireNonNull(cilSignal);
|
||||
List<CilRoutePathElement> list = new ArrayList<>();
|
||||
for (MapSectionPathVO pathVO : pathList) {
|
||||
list.add(buildPathElement(cilSignal,
|
||||
pathVO.getSectionList(), pathVO.getSwitchPositionList(), pathVO.getFlsList(),
|
||||
sectionMap, switchMap, flsMap));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static CilRoutePathElement buildPathElement(CilSignal start, List<String> sectionCodeList,
|
||||
List<MapCISwitchVO> ciSwitchList, List<String> flsList,
|
||||
Map<String, CilSection> sectionMap,
|
||||
Map<String, CilSwitch> switchMap,
|
||||
Map<String, CilFls> flsMap) {
|
||||
CilRoutePathElement pathElement = new CilRoutePathElement();
|
||||
List<CilSection> sectionList = new ArrayList<>();
|
||||
for (String code : sectionCodeList) {
|
||||
CilSection cilSection = sectionMap.get(code);
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(cilSection,
|
||||
String.format("不存在id为[%s]的区段", code));
|
||||
sectionList.add(cilSection);
|
||||
}
|
||||
List<CilSwitchPosition> switchPositionList = new ArrayList<>();
|
||||
for (MapCISwitchVO ciSwitchVO : ciSwitchList) {
|
||||
CilSwitch cilSwitch = switchMap.get(ciSwitchVO.getSwitchCode());
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(cilSwitch,
|
||||
String.format("不存在id为[%s]的道岔", ciSwitchVO.getSwitchCode()));
|
||||
switchPositionList.add(new CilSwitchPosition(cilSwitch, ciSwitchVO.isNormal()));
|
||||
}
|
||||
pathElement.start = start;
|
||||
pathElement.right = start.right;
|
||||
pathElement.sectionList = sectionList;
|
||||
pathElement.switchPositionList = switchPositionList;
|
||||
// 侧防
|
||||
List<CilFls> cilFlsList = new ArrayList<>();
|
||||
if (!CollectionUtils.isEmpty(flsList)) {
|
||||
for (String flsId : flsList) {
|
||||
CilFls cilFls = flsMap.get(flsId);
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(cilFls,
|
||||
String.format("不存在id为[%s]的侧防"));
|
||||
cilFlsList.add(cilFls);
|
||||
}
|
||||
}
|
||||
pathElement.flsList = cilFlsList;
|
||||
return pathElement;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,34 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CilRoute extends CilDevice {
|
||||
|
||||
int type; // 进路类型
|
||||
public static final int TYPE_ATP = 1;
|
||||
public static final int TYPE_GROUND = 2;
|
||||
public static final int TYPE_GUIDE = 3;
|
||||
public static final int TYPE_TB = 4;
|
||||
CilSignal start;
|
||||
|
||||
CilSignal end;
|
||||
CilRoutePathElement pathElement;
|
||||
CilOverlap overlap;
|
||||
boolean ars; // ATS自排
|
||||
boolean arc; // 自动追踪/联锁自动触发
|
||||
boolean flt; // 车队/自动进路
|
||||
List<CilPsd> psdList;
|
||||
List<CilEsp> espList;
|
||||
List<CilStand> standList; // 站台扣车
|
||||
List<CilRoute> conflictingRouteList;
|
||||
int signalAspect; // 信号机显示(进路联锁规定)
|
||||
public static final int SA_RED = 1;
|
||||
public static final int SA_GREEN = 2;
|
||||
public static final int SA_YELLOW = 3;
|
||||
public static final int SA_GUIDE = 4;//引导信号,黄红灯显示
|
||||
|
||||
int signalState;// 进路信号状态(当前实际状态)
|
||||
|
||||
|
||||
CilPath path;
|
||||
|
||||
public CilRoute(String id, String name) {
|
||||
super(id, name);
|
||||
|
@ -2,14 +2,15 @@ package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CilPath {
|
||||
public class CilRoutePathElement {
|
||||
|
||||
boolean right;
|
||||
|
||||
CilSignal start;
|
||||
// 区段
|
||||
List<CilSection> sectionList;
|
||||
|
||||
List<CilSection> logicSectionList;
|
||||
|
||||
// 道岔位置
|
||||
List<CilSwitchPosition> switchPositionList;
|
||||
// 侧防
|
||||
List<CilFls> flsList;
|
||||
|
||||
}
|
@ -7,6 +7,8 @@ public class CilSection extends CilDevice {
|
||||
CilSection parent;
|
||||
List<CilSection> logicList;
|
||||
CilSwitch belongSwitch;
|
||||
CilSignal leftSignal;
|
||||
CilSignal rightSignal;
|
||||
|
||||
int axcOccupy;
|
||||
|
||||
|
@ -1,7 +1,13 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CilSignal extends CilDevice {
|
||||
|
||||
boolean right;
|
||||
List<CilSection> approachList;
|
||||
List<CilSection> ctcApproachList;
|
||||
|
||||
int state;
|
||||
int logic;
|
||||
int blockade;
|
||||
|
@ -1,8 +1,19 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class CilSwitchPosition {
|
||||
|
||||
CilSwitch cilSwitch;
|
||||
int position;
|
||||
|
||||
public CilSwitchPosition(CilSwitch cilSwitch, int position) {
|
||||
Objects.requireNonNull(cilSwitch, String.format("道岔不能为null"));
|
||||
this.cilSwitch = cilSwitch;
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
public CilSwitchPosition(CilSwitch cilSwitch, boolean normal) {
|
||||
this(cilSwitch, normal ? CilSwitch.NORMAL : CilSwitch.REVERSE);
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,11 @@ public class SrSignal extends SrDevice {
|
||||
int offset;
|
||||
|
||||
int state = CLOSE;
|
||||
public static final int CLOSE = 1; // 关闭
|
||||
public static final int RED = 2; // 红灯信号(禁止信号)
|
||||
public static final int GREEN = 3; // 绿灯信号(直向通行)
|
||||
public static final int YELLOW = 4; // 黄灯信号(侧向通行)
|
||||
public static final int GUIDE = 5; // 引导信号(正线为黄红)
|
||||
public static final int CLOSE = 0; // 关闭
|
||||
public static final int RED = 1; // 红灯信号(禁止信号)
|
||||
public static final int GREEN = 2; // 绿灯信号(直向通行)
|
||||
public static final int YELLOW = 3; // 黄灯信号(侧向通行)
|
||||
public static final int GUIDE = 4; // 引导信号(正线为黄红)
|
||||
|
||||
AtomicInteger command = new AtomicInteger(NONE);
|
||||
public static final int NONE = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user