新仿真逻辑——CI联锁系统逻辑开发
This commit is contained in:
parent
7027712908
commit
a3465dc020
@ -1,10 +1,11 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL;
|
||||
|
||||
import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository;
|
||||
import club.joylink.rtss.simulation.rt.CIL.bo.CilRoute;
|
||||
import club.joylink.rtss.simulation.rt.CIL.bo.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class CilRouteLogicService {
|
||||
@ -13,7 +14,7 @@ public class CilRouteLogicService {
|
||||
for (CilRoute cilRoute : supervisedRouteList) {
|
||||
switch (cilRoute.getStage()) {
|
||||
case CilRoute.STAGE_SETTING:
|
||||
this.settingProgress(cilRoute);
|
||||
this.settingProgress(cilRoute, cilRepository.getConfig());
|
||||
break;
|
||||
case CilRoute.STAGE_WATCH:
|
||||
this.watchRoute(cilRoute);
|
||||
@ -22,10 +23,46 @@ public class CilRouteLogicService {
|
||||
}
|
||||
}
|
||||
|
||||
private void settingProgress(CilRoute cilRoute) {
|
||||
private void settingProgress(CilRoute cilRoute, CilConfig config) {
|
||||
if (config.isLockFirst()) {
|
||||
// 预先锁闭进路区段
|
||||
this.lockRouteSections(cilRoute);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void lockRouteSections(CilRoute cilRoute) {
|
||||
CilRoutePathElement pathElement = cilRoute.getPathElement();
|
||||
Set<String> handledSwitchSet = new HashSet<>();
|
||||
List<CilSection> sectionList = pathElement.getSectionList();
|
||||
for (CilSection cilSection : sectionList) {
|
||||
CilSwitch belongSwitch = cilSection.getBelongSwitch();
|
||||
if (belongSwitch != null) {
|
||||
if (!handledSwitchSet.contains(belongSwitch.getId())) {
|
||||
handledSwitchSet.add(belongSwitch.getId());
|
||||
belongSwitch.getA().lockByRoute(cilRoute);
|
||||
if (belongSwitch.isNormalPosition()) {
|
||||
belongSwitch.getB().lockByRoute(cilRoute);
|
||||
} else if (belongSwitch.isReversePosition()) {
|
||||
belongSwitch.getC().lockByRoute(cilRoute);
|
||||
} else {
|
||||
belongSwitch.getB().lockByRoute(cilRoute);
|
||||
belongSwitch.getC().lockByRoute(cilRoute);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
List<CilSection> relateList = cilSection.getRelateList();
|
||||
if (relateList.isEmpty()) {
|
||||
cilSection.lockByRoute(cilRoute);
|
||||
} else {
|
||||
for (CilSection section : relateList) {
|
||||
section.lockByRoute(cilRoute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 进路监控
|
||||
* @param cilRoute
|
||||
|
@ -0,0 +1,9 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class CilConfig {
|
||||
boolean lockFirst;
|
||||
|
||||
}
|
@ -11,6 +11,8 @@ import java.util.Map;
|
||||
public class CilRepository extends SimulationRepository {
|
||||
public static final String NAME = "CIL";
|
||||
|
||||
CilConfig config;
|
||||
|
||||
Map<String, CilSection> sectionMap;
|
||||
Map<String, CilSwitch> switchMap;
|
||||
Map<String, CilSignal> signalMap;
|
||||
@ -47,6 +49,10 @@ public class CilRepository extends SimulationRepository {
|
||||
|
||||
}
|
||||
|
||||
public CilConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public CilSection getSectionById(String id) {
|
||||
CilSection cilSection = this.sectionMap.get(id);
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(cilSection);
|
||||
|
@ -5,11 +5,9 @@ import club.joylink.rtss.vo.client.map.MapSwitchVO;
|
||||
import club.joylink.rtss.vo.client.map.MapVO;
|
||||
import club.joylink.rtss.vo.client.map.newmap.*;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
public class CilRepositoryBuilder {
|
||||
|
||||
@ -29,16 +27,57 @@ public class CilRepositoryBuilder {
|
||||
buildRoutes(logicDataNew.getRouteList(), cilRepository.routeMap, cilRepository);
|
||||
|
||||
buildSectionRelations(graphDataNew.getSectionList(), cilRepository);
|
||||
buildSwitchSectionRelations(graphDataNew.getSwitchList(), cilRepository);
|
||||
return cilRepository;
|
||||
}
|
||||
|
||||
private static void buildSectionRelations(List<MapSectionNewVO> sectionList, CilRepository cilRepository) {
|
||||
Map<String, CilSection> sectionMap = cilRepository.sectionMap;
|
||||
for (MapSectionNewVO sectionNewVO : sectionList) {
|
||||
List<String> relateSectionList = sectionNewVO.getRelateSectionList();
|
||||
if (!CollectionUtils.isEmpty(relateSectionList)) {
|
||||
|
||||
if (sectionNewVO.getType() == "05") {
|
||||
continue;
|
||||
}
|
||||
if (StringUtils.hasText(sectionNewVO.getParentCode())) {
|
||||
CilSection parent = sectionMap.get(sectionNewVO.getParentCode());
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(parent,
|
||||
String.format("区段[%s]parentCode[%s]未找到对应父区段",sectionNewVO.getCode(), sectionNewVO.getParentCode()));
|
||||
CilSection section = sectionMap.get(sectionNewVO.getCode());
|
||||
parent.addRelateSection(section);
|
||||
}
|
||||
}
|
||||
for (MapSectionNewVO sectionNewVO : sectionList) {
|
||||
if (sectionNewVO.getType() == "01") {
|
||||
// 排序逻辑区段
|
||||
CilSection section = sectionMap.get(sectionNewVO.getCode());
|
||||
if (!section.relateList.isEmpty()) {
|
||||
section.relateList.sort(Comparator.comparing(CilSection::getName));
|
||||
ArrayList<CilSection> reverseList = new ArrayList<>(section.relateList);
|
||||
if (sectionNewVO.isLogicSectionNameSort()) {
|
||||
Collections.reverse(reverseList);
|
||||
} else {
|
||||
Collections.reverse(section.relateList);
|
||||
}
|
||||
section.reverseList = reverseList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void buildSwitchSectionRelations(List<MapSwitchVO> switchList, CilRepository cilRepository) {
|
||||
Map<String, CilSwitch> switchMap = cilRepository.switchMap;
|
||||
Map<String, CilSection> sectionMap = cilRepository.sectionMap;
|
||||
for (MapSwitchVO mapSwitchVO : switchList) {
|
||||
CilSwitch cilSwitch = switchMap.get(mapSwitchVO.getCode());
|
||||
CilSection a = sectionMap.get(mapSwitchVO.getSectionACode());
|
||||
CilSection b = sectionMap.get(mapSwitchVO.getSectionBCode());
|
||||
CilSection c = sectionMap.get(mapSwitchVO.getSectionCCode());
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(a,
|
||||
String.format("道岔[%s]关联code为[%s]的a区段不存在",cilSwitch.getId(), mapSwitchVO.getSectionACode()));
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(b,
|
||||
String.format("道岔[%s]关联code为[%s]的a区段不存在",cilSwitch.getId(), mapSwitchVO.getSectionBCode()));
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(c,
|
||||
String.format("道岔[%s]关联code为[%s]的a区段不存在",cilSwitch.getId(), mapSwitchVO.getSectionCCode()));
|
||||
cilSwitch.setSections(a, b, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,10 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class CilRoutePathElement {
|
||||
|
||||
boolean right;
|
||||
|
@ -1,23 +1,44 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
public class CilSection extends CilDevice {
|
||||
|
||||
CilSection parent;
|
||||
List<CilSection> logicList;
|
||||
List<CilSection> relateList = new ArrayList<>();
|
||||
List<CilSection> reverseList = new ArrayList<>();
|
||||
CilSwitch belongSwitch;
|
||||
CilSignal leftSignal;
|
||||
CilSignal rightSignal;
|
||||
|
||||
boolean axcOccupy;
|
||||
|
||||
String routeId; // 锁闭进路的id
|
||||
boolean rl; // 进路锁闭
|
||||
boolean lr; // 进路锁闭方向,true-右向,false-左向
|
||||
|
||||
public CilSection(String id, String name) {
|
||||
super(id, name);
|
||||
}
|
||||
|
||||
public void addRelateSection(CilSection section) {
|
||||
this.relateList.add(section);
|
||||
section.parent = this;
|
||||
}
|
||||
|
||||
public void updateAxcOccupyState(boolean occupy) {
|
||||
this.axcOccupy = occupy;
|
||||
}
|
||||
|
||||
public void lockByRoute(CilRoute cilRoute) {
|
||||
if (!Objects.equals(cilRoute.getId(), this.routeId)) {
|
||||
this.routeId = cilRoute.getId();
|
||||
this.rl = true;
|
||||
this.lr = cilRoute.start.isRight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,14 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class CilSwitch extends CilDevice {
|
||||
|
||||
CilSection a;
|
||||
CilSection b;
|
||||
CilSection c;
|
||||
|
||||
int position;
|
||||
public static final int LOST = 0; // 失表
|
||||
public static final int NORMAL = 1; // 定位
|
||||
@ -21,4 +28,21 @@ public class CilSwitch extends CilDevice {
|
||||
public void updatePosition(int state) {
|
||||
this.position = state;
|
||||
}
|
||||
|
||||
public boolean isNormalPosition() {
|
||||
return NORMAL == this.position;
|
||||
}
|
||||
|
||||
public boolean isReversePosition() {
|
||||
return REVERSE == this.position;
|
||||
}
|
||||
|
||||
public void setSections(CilSection a, CilSection b, CilSection c) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
a.belongSwitch = this;
|
||||
b.belongSwitch = this;
|
||||
c.belongSwitch = this;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL.bo;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
public class CilSwitchPosition {
|
||||
|
||||
CilSwitch cilSwitch;
|
||||
|
@ -35,9 +35,9 @@ public class SrSwitch extends SrDevice {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.c = c;
|
||||
a.setSrSwitch(this);
|
||||
b.setSrSwitch(this);
|
||||
c.setSrSwitch(this);
|
||||
a.srSwitch = this;
|
||||
b.srSwitch = this;
|
||||
c.srSwitch = this;
|
||||
if (this.a.leftTrack == null && this.a.rightTrack == null) {
|
||||
throw new IllegalStateException("道岔a区段两端都没有关联的区段");
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class SrTrack extends SrDevice implements Debug {
|
||||
rightFlank.setLeftTrack(this);
|
||||
}
|
||||
|
||||
public void setSrSwitch(SrSwitch srSwitch) {
|
||||
void setSrSwitch(SrSwitch srSwitch) {
|
||||
this.srSwitch = srSwitch;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user