新版仿真,添加创建仿真和获取仿真信息接口(构建数据的逻辑先去掉了,因为大铁线路数据不完整);仿真消息发送功能实现中

This commit is contained in:
joylink_zhangsai 2021-04-22 10:51:38 +08:00
parent e7db868c99
commit c23da105a0
34 changed files with 1082 additions and 449 deletions

View File

@ -0,0 +1,6 @@
ALTER TABLE `map_system`
ADD COLUMN `new_api` tinyint(1) NOT NULL DEFAULT 0 AFTER `status`;
ALTER TABLE `map_system`
DROP COLUMN `prd_id`;

View File

@ -0,0 +1,36 @@
package club.joylink.rtss.controller.simulation.rt;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO;
import club.joylink.rtss.simulation.rt.RtSimulationService;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.map.MapVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/rtSimulation")
public class RtSimulationController {
@Autowired
private RtSimulationService rtSimulationService;
@PostMapping
public String create(Long mapId, String prdType, @RequestAttribute LoginUserInfoVO loginInfo) {
MapPrdTypeEnum prdTypeEnum = MapPrdTypeEnum.getMapPrdTypeEnumByCode(prdType);
return rtSimulationService.create(loginInfo.getUserVO(), mapId, prdTypeEnum).getId();
}
@ApiOperation(value = "根据仿真group获取仿真基础信息")
@GetMapping("/{id}")
public SimulationVO getSimulationBasicInfo(@PathVariable String id) {
return rtSimulationService.getBasicInfo(id);
}
@ApiOperation(value = "根据仿真group获取仿真地图数据")
@GetMapping("/{id}/mapData")
public MapVO getSimulationMapData(@PathVariable String id) {
return rtSimulationService.getMapData(id);
}
}

View File

@ -38,8 +38,8 @@ public interface MapSystemDAO extends MyBatisBaseDao<MapSystem, Long, MapSystemE
" <foreach collection=\"list\" item=\"entity\" separator=\",\"> " +
" (#{entity.id,jdbcType=BIGINT}, #{entity.name,jdbcType=VARCHAR}, #{entity.type,jdbcType=VARCHAR}," +
" #{entity.mapId,jdbcType=BIGINT}, #{entity.prdType,jdbcType=VARCHAR}," +
" #{entity.customized,jdbcType=VARCHAR}, #{entity.status,jdbcType=VARCHAR})"+
" #{entity.customized,jdbcType=VARCHAR}, #{entity.status,jdbcType=VARCHAR}, #{entity.newApi,jdbcType=TINYINT})"+
" </foreach>" +
"</script>")
int batchInsertWithId(@Param("list") List<MapSystem> mapSystemList);
}
}

View File

@ -3,8 +3,8 @@ package club.joylink.rtss.entity;
import java.io.Serializable;
/**
* map_system
* @author
*
*/
public class MapSystem implements Serializable {
private Long id;
@ -39,6 +39,8 @@ public class MapSystem implements Serializable {
*/
private String status;
private Boolean newApi;
private static final long serialVersionUID = 1L;
public Long getId() {
@ -97,6 +99,14 @@ public class MapSystem implements Serializable {
this.status = status;
}
public Boolean getNewApi() {
return newApi;
}
public void setNewApi(Boolean newApi) {
this.newApi = newApi;
}
@Override
public boolean equals(Object that) {
if (this == that) {
@ -115,7 +125,8 @@ public class MapSystem implements Serializable {
&& (this.getMapId() == null ? other.getMapId() == null : this.getMapId().equals(other.getMapId()))
&& (this.getPrdType() == null ? other.getPrdType() == null : this.getPrdType().equals(other.getPrdType()))
&& (this.getCustomized() == null ? other.getCustomized() == null : this.getCustomized().equals(other.getCustomized()))
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()));
&& (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
&& (this.getNewApi() == null ? other.getNewApi() == null : this.getNewApi().equals(other.getNewApi()));
}
@Override
@ -129,6 +140,7 @@ public class MapSystem implements Serializable {
result = prime * result + ((getPrdType() == null) ? 0 : getPrdType().hashCode());
result = prime * result + ((getCustomized() == null) ? 0 : getCustomized().hashCode());
result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
result = prime * result + ((getNewApi() == null) ? 0 : getNewApi().hashCode());
return result;
}
@ -145,8 +157,9 @@ public class MapSystem implements Serializable {
sb.append(", prdType=").append(prdType);
sb.append(", customized=").append(customized);
sb.append(", status=").append(status);
sb.append(", newApi=").append(newApi);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
}

View File

@ -593,6 +593,66 @@ public class MapSystemExample {
addCriterion("`status` not between", value1, value2, "status");
return (Criteria) this;
}
public Criteria andNewApiIsNull() {
addCriterion("new_api is null");
return (Criteria) this;
}
public Criteria andNewApiIsNotNull() {
addCriterion("new_api is not null");
return (Criteria) this;
}
public Criteria andNewApiEqualTo(Boolean value) {
addCriterion("new_api =", value, "newApi");
return (Criteria) this;
}
public Criteria andNewApiNotEqualTo(Boolean value) {
addCriterion("new_api <>", value, "newApi");
return (Criteria) this;
}
public Criteria andNewApiGreaterThan(Boolean value) {
addCriterion("new_api >", value, "newApi");
return (Criteria) this;
}
public Criteria andNewApiGreaterThanOrEqualTo(Boolean value) {
addCriterion("new_api >=", value, "newApi");
return (Criteria) this;
}
public Criteria andNewApiLessThan(Boolean value) {
addCriterion("new_api <", value, "newApi");
return (Criteria) this;
}
public Criteria andNewApiLessThanOrEqualTo(Boolean value) {
addCriterion("new_api <=", value, "newApi");
return (Criteria) this;
}
public Criteria andNewApiIn(List<Boolean> values) {
addCriterion("new_api in", values, "newApi");
return (Criteria) this;
}
public Criteria andNewApiNotIn(List<Boolean> values) {
addCriterion("new_api not in", values, "newApi");
return (Criteria) this;
}
public Criteria andNewApiBetween(Boolean value1, Boolean value2) {
addCriterion("new_api between", value1, value2, "newApi");
return (Criteria) this;
}
public Criteria andNewApiNotBetween(Boolean value1, Boolean value2) {
addCriterion("new_api not between", value1, value2, "newApi");
return (Criteria) this;
}
}
/**
@ -689,4 +749,4 @@ public class MapSystemExample {
this(condition, value, secondValue, null);
}
}
}
}

View File

@ -45,7 +45,7 @@ public class SimulationManager {
return (T) simulationCache.get(id);
}
public <T extends Simulation> T getById(String id, T t) {
public <T extends Simulation> T getById(String id, Class<T> t) {
Simulation simulation = simulationCache.get(id);
BusinessExceptionAssertEnum.DATA_NOT_EXIST
.assertNotNull(simulation, String.format("id为[%s]的仿真不存在", id));

View File

@ -0,0 +1,26 @@
package club.joylink.rtss.simulation.rt.ATS;
import club.joylink.rtss.simulation.rt.ATS.bo.AtsRepository;
import club.joylink.rtss.simulation.rt.ATS.bo.AtsSwitch;
import club.joylink.rtss.simulation.rt.CIL.bo.CilDevice;
import club.joylink.rtss.simulation.rt.CIL.bo.CilSwitch;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.repo.CommonSwitch;
import org.springframework.stereotype.Component;
@Component
public class AtsApiService {
public void handle(RtSimulation rtSimulation, CilSwitch cilSwitch) {
AtsRepository atsRepository = rtSimulation.getRepository(AtsRepository.NAME, AtsRepository.class);
AtsSwitch atsSwitch = atsRepository.getSwitchById(cilSwitch.getId());
if (atsSwitch.getPosition() != cilSwitch.getPosition()) {
atsSwitch.setPosition(cilSwitch.getPosition());
atsRepository.ready2Send(atsSwitch.getId());
}
}
public void handle(CilDevice cilDevice) {
}
}

View File

@ -1,5 +1,12 @@
package club.joylink.rtss.simulation.rt.ATS;
import club.joylink.rtss.simulation.rt.ATS.bo.AtsRepository;
import club.joylink.rtss.simulation.rt.ATS.bo.AtsRepositoryBuilder;
import club.joylink.rtss.simulation.rt.CIL.bo.CilDevice;
import club.joylink.rtss.simulation.rt.RtSimulation;
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.MapLogicDataNewVO;
import org.springframework.stereotype.Component;
/**
@ -7,4 +14,8 @@ import org.springframework.stereotype.Component;
*/
@Component
public class AtsLogicService {
public void buildRepository(RtSimulation rtSimulation, MapVO mapVO) {
AtsRepository atsRepository = AtsRepositoryBuilder.buildFrom(mapVO);
rtSimulation.addRepository(atsRepository);
}
}

View File

@ -1,9 +1,12 @@
package club.joylink.rtss.simulation.rt.ATS.bo;
import club.joylink.rtss.simulation.rt.RtSimulationSubscribeTopic;
import lombok.Getter;
import java.util.List;
@Getter
public class AtsDevice {
public abstract class AtsDevice {
String id;
String name;
@ -11,4 +14,6 @@ public class AtsDevice {
this.id = id;
this.name = name;
}
// public abstract void buildMessage(List<Object> message, RtSimulationSubscribeTopic topic);
}

View File

@ -1,11 +1,33 @@
package club.joylink.rtss.simulation.rt.ATS.bo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.SimulationRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AtsRepository extends SimulationRepository {
public static final String NAME = "ATS";
AtsRunPlan runPlan;
// TODO: 2021/4/22 如果设备id有重复那不同类的设备的消息需要分开存
Map<String, List<Object>> messageMap = new HashMap<>();
Map<String, List<Object>> sendMessageMap = new HashMap<>();
Map<String, AtsRoute> routeMap = new HashMap<>();
Map<String, AtsRunPlan> runPlanMap = new HashMap<>();
Map<String, AtsSection> sectionMap = new HashMap<>();
Map<String, AtsSignal> signalMap = new HashMap<>();
Map<String, AtsStand> standMap = new HashMap<>();
Map<String, Station> stationMap = new HashMap<>();
Map<String, AtsStationPlan> stationPlanMap = new HashMap<>();
Map<String, AtsSwitch> switchMap = new HashMap<>();
Map<String, AtsTrain> trainMap = new HashMap<>();
Map<String, AtsTripPlan> tripPlanMap = new HashMap<>();
Map<String, AtsUnitPath> unitPathMap = new HashMap<>();
public AtsRepository() {
super(NAME);
@ -19,4 +41,14 @@ public class AtsRepository extends SimulationRepository {
public AtsRunPlan getRunPlan() {
return runPlan;
}
public AtsSwitch getSwitchById(String id) {
AtsSwitch atsSwitch = switchMap.get(id);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(atsSwitch);
return atsSwitch;
}
public void ready2Send(String id) {
sendMessageMap.putIfAbsent(id, messageMap.get(id));
}
}

View File

@ -0,0 +1,56 @@
package club.joylink.rtss.simulation.rt.ATS.bo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository;
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 java.util.List;
import java.util.Map;
public class AtsRepositoryBuilder {
public static AtsRepository buildFrom(MapVO mapVO) {
AtsRepository atsRepository = new AtsRepository();
MapGraphDataNewVO graphDataNew = mapVO.getGraphDataNew();
MapLogicDataNewVO logicDataNew = mapVO.getLogicDataNew();
buildRoutes(logicDataNew.getRouteList(), atsRepository.routeMap);
buildSections(graphDataNew.getSectionList(), atsRepository.sectionMap);
buildSignals(graphDataNew.getSignalList(), atsRepository.signalMap);
buildSwitches(graphDataNew.getSwitchList(), atsRepository.switchMap, atsRepository.messageMap);
return atsRepository;
}
private static void buildSwitches(List<MapSwitchVO> switchList, Map<String, AtsSwitch> switchMap, Map<String, List<Object>> messageMap) {
for (MapSwitchVO switchVO : switchList) {
AtsSwitch atsSwitch = new AtsSwitch(switchVO.getCode(), switchVO.getName());
switchMap.put(atsSwitch.getId(), atsSwitch);
}
}
private static void buildSignals(List<MapSignalNewVO> signalList, Map<String, AtsSignal> signalMap) {
for (MapSignalNewVO signalVO : signalList) {
AtsSignal atsSignal = new AtsSignal(signalVO.getCode(), signalVO.getName());
signalMap.put(atsSignal.getId(), atsSignal);
}
}
private static void buildSections(List<MapSectionNewVO> sectionList, Map<String, AtsSection> sectionMap) {
for (MapSectionNewVO sectionVO : sectionList) {
AtsSection atsSection = new AtsSection(sectionVO.getCode(), sectionVO.getName());
sectionMap.put(atsSection.getId(), atsSection);
}
}
private static void buildRoutes(List<MapRouteNewVO> routeList, Map<String, AtsRoute> routeMap) {
for (MapRouteNewVO routeVO : routeList) {
BusinessExceptionAssertEnum.DATA_ERROR.assertNotTrue(routeMap.containsKey(routeVO.getCode()),
String.format("进路id重复[%s]", routeVO.getId()));
AtsRoute atsRoute = new AtsRoute(routeVO.getCode(), routeVO.getName());
routeMap.put(atsRoute.getId(), atsRoute);
}
}
}

View File

@ -1,7 +1,48 @@
package club.joylink.rtss.simulation.rt.ATS.bo;
import club.joylink.rtss.simulation.rt.RtSimulationSubscribeTopic;
import lombok.Getter;
import lombok.NonNull;
import java.util.List;
import java.util.Objects;
@Getter
public class AtsRoute extends AtsDevice {
boolean ars;
boolean arc;
boolean flt;
public void setArs(boolean ars) {
if (!Objects.equals(this.ars, ars)) {
}
this.ars = ars;
}
public void setArc(boolean arc) {
this.arc = arc;
}
public void setFlt(boolean flt) {
this.flt = flt;
}
public AtsRoute(String id, String name) {
super(id, name);
}
// @Override
public void buildMessage(@NonNull List<Object> message, RtSimulationSubscribeTopic topic) {
switch (topic) {
case ATS:
message.add(ars);
message.add(arc);
message.add(flt);
break;
}
}
}

View File

@ -1,6 +1,16 @@
package club.joylink.rtss.simulation.rt.ATS.bo;
public class AtsSection extends AtsDevice {
boolean axcOccupy;
String routeId;
boolean rl;
boolean lr;
boolean ol;
public AtsSection(String id, String name) {
super(id, name);
}

View File

@ -1,6 +1,16 @@
package club.joylink.rtss.simulation.rt.ATS.bo;
public class AtsSignal extends AtsDevice {
int signalAspect;
boolean logic;
boolean forceLight;
boolean bl;
boolean rbl;
public AtsSignal(String id, String name) {
super(id, name);
}

View File

@ -1,7 +1,16 @@
package club.joylink.rtss.simulation.rt.ATS.bo;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class AtsSwitch extends AtsDevice {
int position;
public AtsSwitch(String id, String name) {
super(id, name);
}
}

View File

@ -4,7 +4,7 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.rt.CIL.bo.*;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.SRD.SrdApiService;
import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal;
import club.joylink.rtss.simulation.rt.repo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@ -46,155 +46,252 @@ public class CilRouteLogicService {
* @return 是否办理
*/
public boolean setRoute(RtSimulation rtSimulation, CilRoute cilRoute) {
CommonRepository commonRepository = null; // TODO: 2021/4/19
CommonRoute commonRoute = commonRepository.getRouteById(cilRoute.getId());
CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
// 检查
// 延续保护选择
this.selectRouteOverlap(cilRoute);
this.selectRouteOverlap(cilRepository, commonRoute, cilRoute);
// 其他初始化
// 道岔征用
CilRoutePathElement pathElement = cilRoute.getPathElement();
List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
cilSwitchPosition.routeUse();
TrackWay pathElement = commonRoute.getPathElement();
List<SwitchPosition> switchPositionList = pathElement.getSpList();
for (SwitchPosition switchPosition : switchPositionList) {
this.routeUse(cilRepository, switchPosition);
}
List<CilFls> flsList = pathElement.getFlsList();
for (CilFls cilFls : flsList) {
List<CilFls.FlsElement> firstLevelList = cilFls.getFirstLevelList();
for (CilFls.FlsElement flsElement : firstLevelList) {
CilSwitchPosition pp = flsElement.getPp();
List<CommonFls> flsList = pathElement.getFlsList();
for (CommonFls commonFls : flsList) {
List<CommonFls.FlsElement> firstLevelList = commonFls.getFirstLevelList();
for (CommonFls.FlsElement flsElement : firstLevelList) {
SwitchPosition pp = flsElement.getPp();
if (pp != null) {
pp.routeUse();
this.routeUse(cilRepository, pp);
}
CilSwitchPosition pae = flsElement.getPae();
SwitchPosition pae = flsElement.getPae();
if (pae != null) {
pae.routeUse();
this.routeUse(cilRepository, pae);
}
}
}
// 开始办理
cilRoute.startSetting(rtSimulation.getSystemTime());
CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
cilRepository.addSupervisedRoute(cilRoute);
return true;
// // 检查
// // 延续保护选择
// this.selectRouteOverlap(cilRoute);
// // 其他初始化
// // 道岔征用
// CilRoutePathElement pathElement = cilRoute.getPathElement();
// List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
// for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
// cilSwitchPosition.routeUse();
// }
// List<CilFls> flsList = pathElement.getFlsList();
// for (CilFls cilFls : flsList) {
// List<CilFls.FlsElement> firstLevelList = cilFls.getFirstLevelList();
// for (CilFls.FlsElement flsElement : firstLevelList) {
// CilSwitchPosition pp = flsElement.getPp();
// if (pp != null) {
// pp.routeUse();
// }
// CilSwitchPosition pae = flsElement.getPae();
// if (pae != null) {
// pae.routeUse();
// }
// }
// }
// // 开始办理
// cilRoute.startSetting(rtSimulation.getSystemTime());
// CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
// cilRepository.addSupervisedRoute(cilRoute);
// return true;
}
private void selectRouteOverlap(CilRoute cilRoute) {
CilOverlap overlap = cilRoute.getOverlap();
if (overlap != null) {
List<CilRoutePathElement> pathElementList = overlap.getPathElementList();
private void routeUse(CilRepository cilRepository, SwitchPosition switchPosition) {
CilSwitch cilSwitch = cilRepository.getSwitchById(switchPosition.getCommonSwitch().getId());
cilSwitch.routeUse(switchPosition.getPosition());
}
private void selectRouteOverlap(CilRepository cilRepository, CommonRoute commonRoute, CilRoute cilRoute) {
CommonOverlap commonOverlap = commonRoute.getOverlap();
CilOverlap cilOverlap = cilRoute.getOverlap();
if (commonOverlap != null) {
List<TrackWay> pathElementList = commonOverlap.getPathElementList();
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(pathElementList);
if (pathElementList.size() == 1) {
overlap.updateSelectedPath(pathElementList.get(0));
cilOverlap.updateSelectedPath(pathElementList.get(0));
} else { // 多于一个筛选(暂时选择逻辑为所有道岔在指定位置,若无取直向)
CilRoutePathElement straight = null;
CilRoutePathElement selected = null;
for (CilRoutePathElement cilRoutePathElement : pathElementList) {
TrackWay straight = null;
TrackWay selected = null;
for (TrackWay trackWay : pathElementList) {
boolean select = true;
boolean line = true; // 是否直向
List<CilSwitchPosition> switchPositionList = cilRoutePathElement.getSwitchPositionList();
for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
if (!cilSwitchPosition.isNormalPosition()) {
List<SwitchPosition> switchPositionList = trackWay.getSpList();
for (SwitchPosition switchPosition : switchPositionList) {
if (!switchPosition.isNormal()) {
line = false;
}
if (!cilSwitchPosition.isOnPosition()) {
CilSwitch cilSwitch = cilRepository.getSwitchById(switchPosition.getCommonSwitch().getId());
if (cilSwitch.getPosition() != switchPosition.getPosition()) {
select = false;
break;
}
}
if (line) {
straight = cilRoutePathElement;
straight = trackWay;
}
if (select) {
selected = cilRoutePathElement;
selected = trackWay;
break;
}
}
if (selected != null) {
overlap.updateSelectedPath(selected);
cilOverlap.updateSelectedPath(selected);
} else {
overlap.updateSelectedPath(straight);
cilOverlap.updateSelectedPath(straight);
}
}
}
// CilOverlap commonOverlap = cilRoute.getOverlap();
// if (commonOverlap != null) {
// List<CilRoutePathElement> pathElementList = commonOverlap.getPathElementList();
// BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionNotEmpty(pathElementList);
// if (pathElementList.size() == 1) {
// commonOverlap.updateSelectedPath(pathElementList.get(0));
// } else { // 多于一个筛选(暂时选择逻辑为所有道岔在指定位置,若无取直向)
// CilRoutePathElement straight = null;
// CilRoutePathElement selected = null;
// for (CilRoutePathElement cilRoutePathElement : pathElementList) {
// boolean select = true;
// boolean line = true; // 是否直向
// List<CilSwitchPosition> switchPositionList = cilRoutePathElement.getSwitchPositionList();
// for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
// if (!cilSwitchPosition.isNormalPosition()) {
// line = false;
// }
// if (!cilSwitchPosition.isOnPosition()) {
// select = false;
// break;
// }
// }
// if (line) {
// straight = cilRoutePathElement;
// }
// if (select) {
// selected = cilRoutePathElement;
// break;
// }
// }
// if (selected != null) {
// commonOverlap.updateSelectedPath(selected);
// } else {
// commonOverlap.updateSelectedPath(straight);
// }
// }
// }
}
private void settingProgress(RtSimulation rtSimulation, CilRoute cilRoute, CilConfig config) {
CommonRepository commonRepository = null; // TODO: 2021/4/19
CommonRoute commonRoute = commonRepository.getRouteById(cilRoute.getId());
CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
if (config.isLockFirst()) {
this.lockFirst(cilRoute);
this.lockFirst(cilRepository, commonRoute, cilRoute);
}
CilRoutePathElement pathElement = cilRoute.getPathElement();
// 进路内的设备转动锁闭级修改信号机级别
CilSignal startSignal = cilRoute.getStart();
TrackWay pathElement = commonRoute.getPathElement();
CommonSignal commonSignal = commonRoute.getStart();
CilSignal cilSignal = cilRepository.getSignalById(commonSignal.getId());
// 进路内的设备转动锁闭
if (!cilRoute.isLock()) {
cilSwitchLogicService.tryTurn(rtSimulation, pathElement.getSwitchPositionList()); // 转动道岔
boolean allLock = try2RouteLockSwitches(cilRoute, pathElement.getSwitchPositionList()); // 锁闭道岔
cilSwitchLogicService.tryTurn(rtSimulation, pathElement.getSpList()); // 转动道岔
boolean allLock = try2RouteLockSwitches(cilRepository, cilRoute, pathElement.getSpList()); // 锁闭道岔
if (allLock) {
if (!config.isLockFirst()) {
routeLockSections(cilRoute, pathElement.getSectionList());
routeLockSections(cilRepository, commonRoute, pathElement.getSectionList());
}
cilRoute.setLock(true);
startSignal.updateLevel(CilSignal.LEVEL_2);
}
}
// 侧防设备转动锁闭并修改信号机级别
// 侧防设备转动锁闭
if (!cilRoute.isFl()) {
List<CilFls> flsList = pathElement.getFlsList();
List<CommonFls> flsList = pathElement.getFlsList();
if (!CollectionUtils.isEmpty(flsList)) {
boolean allSwitchLocked = true;
for (CilFls cilFls : flsList) {
List<CilFls.FlsElement> firstLevelList = cilFls.getFirstLevelList();
for (CilFls.FlsElement flsElement : firstLevelList) {
for (CommonFls commonFls : flsList) {
List<CommonFls.FlsElement> firstLevelList = commonFls.getFirstLevelList();
for (CommonFls.FlsElement commonFlsElement : firstLevelList) {
//侧防道岔转动
cilSwitchLogicService.tryTurn(rtSimulation, flsElement.getPp().getCilSwitch(), flsElement.getPp().getPosition());
cilSwitchLogicService.tryTurn(rtSimulation, flsElement.getPae().getCilSwitch(), flsElement.getPae().getPosition());
cilSwitchLogicService.tryTurn(rtSimulation, cilRepository, commonFlsElement.getPp().getCommonSwitch(), commonFlsElement.getPp().getPosition());
cilSwitchLogicService.tryTurn(rtSimulation, cilRepository, commonFlsElement.getPae().getCommonSwitch(), commonFlsElement.getPae().getPosition());
//侧防设备锁闭
flsElement.lock();
if (!flsElement.getPp().getCilSwitch().isFl() || flsElement.getPae().getCilSwitch().isFl()) {
// this.lock(cilRepository, commonFlsElement);
boolean allLock = commonFlsElement.lock(cilRepository);
if (!allLock) {
allSwitchLocked = false;
}
}
}
if (allSwitchLocked) { //进路侧防锁闭信号机级别改为ATP级
cilRoute.setFl(true);
startSignal.updateLevel(CilSignal.LEVEL_3);
}
}
}
// 延续保护设备转动锁闭并修改信号机级别
// 延续保护设备转动锁闭
if (!cilRoute.isOl()) {
CilOverlap overlap = cilRoute.getOverlap();
if (overlap != null) {
CilRoutePathElement selectedPath = overlap.getSelectedPath();
TrackWay selectedPath = overlap.getSelectedPath();
if (selectedPath != null) {
cilSwitchLogicService.tryTurn(rtSimulation, selectedPath.getSwitchPositionList());
boolean allSwitchesLocked = try2OverlapLockSwitches(overlap, pathElement.getSwitchPositionList()); // 锁闭道岔
cilSwitchLogicService.tryTurn(rtSimulation, selectedPath.getSpList());
boolean allSwitchesLocked = try2OverlapLockSwitches(cilRepository, overlap, pathElement.getSpList()); // 锁闭道岔
if (allSwitchesLocked) {
if (!config.isLockFirst()) {
overlapLockSections(overlap, overlap.getSelectedPath().getSectionList());
overlapLockSections(cilRepository, overlap, overlap.getSelectedPath().getSectionList());
}
startSignal.updateLevel(CilSignal.LEVEL_4);
}
}
}
}
//尝试开放信号
//判断信号级别并尝试开放信号
if (cilRoute.isLock()) {
if (cilRoute.isFl()) {
if (cilRoute.isOl()) {
cilSignal.updateLevel(CilSignal.LEVEL_4);
} else {
cilSignal.updateLevel(CilSignal.LEVEL_3);
}
} else {
cilSignal.updateLevel(CilSignal.LEVEL_2);
}
}
boolean routeCtcMode = cilRoute.getCilServer().isCtcMode();
if (cilRoute.isCanAutoOpen()) {
if (startSignal.getSignalAspect() == cilRoute.getSignalAspect()) { //信号机已开启进路指定的信号
if (cilSignal.getSignalAspect() == commonRoute.getSignalAspect()) { //信号机已开启进路指定的信号
cilRoute.setCanAutoOpen(false);
} else {
cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, startSignal, cilRoute.getSignalAspect());
cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, cilSignal, commonRoute.getSignalAspect(), routeCtcMode);
}
}
//持续监视
if (!startSignal.isForbidAspect()) {
if (!cilSignal.isForbidAspect()) {
if (!cilRoute.isLock()) { //进路主体未锁闭
cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, startSignal, CilSignal.LEVEL_1);
cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, cilSignal, CilSignal.LEVEL_1, routeCtcMode);
} else if (!CollectionUtils.isEmpty(pathElement.getFlsList()) || !cilRoute.isFl()) { //有侧防但是侧防未锁闭
if (startSignal.getSignalAspect() != CilSignal.LEVEL_2) { //信号机不是引导信号
cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, startSignal, CilSignal.LEVEL_1);
if (cilSignal.getSignalAspect() != CilSignal.LEVEL_2) { //信号机不是引导信号
cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, cilSignal, CilSignal.LEVEL_1, routeCtcMode);
}
}
if (cilRoute.getOverlap() != null && cilRoute.isOl()) { //信号机延续保护没有锁闭
cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, startSignal, CilSignal.LEVEL_1);
if (cilRoute.getOverlap() != null && !cilRoute.isOl()) { //进路延续保护没有锁闭
if (cilSignal.getSignalAspect() != CilSignal.LEVEL_1 && !cilSignal.isLogic()) { //信号机是物理点灯且不是引导信号
cilSignalLogicService.try2UpdateSignalDisplay(rtSimulation, cilSignal, CilSignal.LEVEL_1, routeCtcMode);
}
}
}
@ -217,10 +314,25 @@ public class CilRouteLogicService {
// this.controlSignalAspectByLevel(rtSimulation, cilRoute, level);
}
private boolean try2OverlapLockSwitches(CilOverlap overlap, List<CilSwitchPosition> switchPositionList) {
// private void lock(CilRepository cilRepository, CommonFls.FlsElement commonFlsElement) {
// if (this.pp != null) {
// CilSwitch cilSwitch = cilRepository.getSwitchById(pp.getCommonSwitch().getId());
// if (pp.getPosition() == cilSwitch.getPosition()) {
// cilSwitch.flankLock();
// }
// }
// if (this.pae != null) {
// CilSwitch cilSwitch = cilRepository.getSwitchById(pae.getCommonSwitch().getId());
// if (pae.getPosition() == cilSwitch.getPosition()) {
// cilSwitch.flankLock();
// }
// }
// }
private boolean try2OverlapLockSwitches(CilRepository cilRepository, CilOverlap overlap, List<SwitchPosition> switchPositionList) {
boolean flag = true;
for (CilSwitchPosition switchPosition : switchPositionList) {
CilSwitch cilSwitch = switchPosition.getCilSwitch();
for (SwitchPosition switchPosition : switchPositionList) {
CilSwitch cilSwitch = cilRepository.getSwitchById(switchPosition.getCommonSwitch().getId());
if (cilSwitch.getPosition() == switchPosition.getPosition()) {
cilSwitch.lockByOverlap(overlap);
} else {
@ -235,14 +347,16 @@ public class CilRouteLogicService {
*
* @return 全部锁闭时为true
*/
private boolean try2RouteLockSwitches(CilRoute route, List<CilSwitchPosition> switchPositionList) {
private boolean try2RouteLockSwitches(CilRepository cilRepository, CilRoute route, List<SwitchPosition> switchPositionList) {
boolean flag = true;
for (CilSwitchPosition switchPosition : switchPositionList) {
CilSwitch cilSwitch = switchPosition.getCilSwitch();
if (cilSwitch.getPosition() != switchPosition.getPosition()) {
flag = false;
} else {
cilSwitch.lockByRoute(route);
if (!CollectionUtils.isEmpty(switchPositionList)) {
for (SwitchPosition switchPosition : switchPositionList) {
CilSwitch cilSwitch = cilRepository.getSwitchById(switchPosition.getCommonSwitch().getId());
if (cilSwitch.getPosition() != switchPosition.getPosition()) {
flag = false;
} else {
cilSwitch.lockByRoute(route);
}
}
}
return flag;
@ -251,35 +365,37 @@ public class CilRouteLogicService {
/**
* 预先锁闭锁闭进路内和延续保护的区段
*/
private void lockFirst(CilRoute cilRoute) {
private void lockFirst(CilRepository cilRepository, CommonRoute commonRoute, CilRoute cilRoute) {
// 进路内区段锁闭
CilRoutePathElement pathElement = cilRoute.getPathElement();
TrackWay pathElement = commonRoute.getPathElement();
if (pathElement != null) {
routeLockSections(cilRoute, pathElement.getSectionList());
routeLockSections(cilRepository, commonRoute, pathElement.getSectionList());
}
// 延续保护区段锁闭
CilOverlap overlap = cilRoute.getOverlap();
if (overlap != null) {
CilRoutePathElement selectedPath = overlap.getSelectedPath();
TrackWay selectedPath = overlap.getSelectedPath();
if (selectedPath != null) {
overlapLockSections(overlap, selectedPath.getSectionList());
overlapLockSections(cilRepository, overlap, selectedPath.getSectionList());
}
}
}
private void routeLockSections(CilRoute cilRoute, List<CilSection> sections) {
private void routeLockSections(CilRepository cilRepository, CommonRoute commonRoute, List<CommonSection> sections) {
if (!CollectionUtils.isEmpty(sections)) {
for (CilSection cilSection : sections) {
CilSwitch belongSwitch = cilSection.getBelongSwitch();
for (CommonSection commonSection : sections) {
CommonSwitch belongSwitch = commonSection.getBelongSwitch();
if (belongSwitch != null) {
continue;
}
List<CilSection> relateList = cilSection.getRelateList();
List<CommonSection> relateList = commonSection.getRelateList();
if (relateList.isEmpty()) {
cilSection.lockByRoute(cilRoute);
CilSection cilSection = cilRepository.getSectionById(commonSection.getId());
cilSection.lockByRoute(commonRoute);
} else {
for (CilSection section : relateList) {
section.lockByRoute(cilRoute);
for (CommonSection section : relateList) {
CilSection cilSection = cilRepository.getSectionById(section.getId());
cilSection.lockByRoute(commonRoute);
}
}
}
@ -294,132 +410,132 @@ public class CilRouteLogicService {
return switchPositions.stream().allMatch(sp -> sp.getCilSwitch().getPosition() == sp.getPosition());
}
private boolean checkSwitchOnPosition(CilRoute cilRoute) {
boolean onPosition = true;
// 检查进路内道岔
CilRoutePathElement pathElement = cilRoute.getPathElement();
List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
if (!cilSwitchPosition.isOnPosition()) {
onPosition = false;
break;
}
}
if (!cilRoute.isPreparedForCtc()) {
// 如果是为非CTC车准备的进路还需检查延续保护
CilOverlap overlap = cilRoute.getOverlap();
CilRoutePathElement selectedPath = overlap.getSelectedPath();
List<CilSwitchPosition> overlapSwitchPositionList = selectedPath.getSwitchPositionList();
for (CilSwitchPosition cilSwitchPosition : overlapSwitchPositionList) {
if (!cilSwitchPosition.isOnPosition()) {
onPosition = false;
break;
}
}
}
return onPosition;
}
// private boolean checkSwitchOnPosition(CilRoute cilRoute) {
// boolean onPosition = true;
// // 检查进路内道岔
// CilRoutePathElement pathElement = cilRoute.getPathElement();
// List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
// for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
// if (!cilSwitchPosition.isOnPosition()) {
// onPosition = false;
// break;
// }
// }
// if (!cilRoute.isPreparedForCtc()) {
// // 如果是为非CTC车准备的进路还需检查延续保护
// CilOverlap overlap = cilRoute.getOverlap();
// CilRoutePathElement selectedPath = overlap.getSelectedPath();
// List<CilSwitchPosition> overlapSwitchPositionList = selectedPath.getSwitchPositionList();
// for (CilSwitchPosition cilSwitchPosition : overlapSwitchPositionList) {
// if (!cilSwitchPosition.isOnPosition()) {
// onPosition = false;
// break;
// }
// }
// }
// return onPosition;
// }
private void controlSignalAspectByLevel(RtSimulation rtSimulation, CilRoute cilRoute, int level) {
CilSignal start = cilRoute.getStart();
start.updateLevel(level);
Integer aspect = null;
switch (level) {
case CilSignal.LEVEL_1:
case CilSignal.LEVEL_2: {
if (!cilRoute.isPreparedForCtc() || start.isForceLight()) {
if (start.getSignalAspect() != CilSignal.RED) {
aspect = SrSignal.RED;
}
} else {
if (!start.isLogic()) {
aspect = SrSignal.OFF;
} else {
start.setAspect(CilSignal.RED);
}
}
break;
}
case CilSignal.LEVEL_3: {
if (cilRoute.isPreparedForCtc()) {
if (start.isForceLight()) {
if (start.getSignalAspect() != cilRoute.getSignalAspect()) {
aspect = cilRoute.getSignalAspect();
}
} else {
if (!start.isLogic()) {
aspect = SrSignal.OFF;
} else {
start.setAspect(cilRoute.getSignalAspect());
}
}
}
break;
}
case CilSignal.LEVEL_4: {
if (!cilRoute.isPreparedForCtc() || start.isForceLight()) {
if (start.getSignalAspect() != cilRoute.getSignalAspect()) {
aspect = cilRoute.getSignalAspect();
}
} else {
if (!start.isLogic()) {
aspect = SrSignal.OFF;
} else {
start.setAspect(cilRoute.getSignalAspect());
}
}
break;
}
}
if (aspect != null) {
this.srdApiService.changeSignalLight(rtSimulation, start.getId(), aspect);
}
}
// private void controlSignalAspectByLevel(RtSimulation rtSimulation, CilRoute cilRoute, int level) {
// CilSignal start = cilRoute.getStart();
// start.updateLevel(level);
// Integer aspect = null;
// switch (level) {
// case CilSignal.LEVEL_1:
// case CilSignal.LEVEL_2: {
// if (!cilRoute.isPreparedForCtc() || start.isForceLight()) {
// if (start.getSignalAspect() != CilSignal.RED) {
// aspect = SrSignal.RED;
// }
// } else {
// if (!start.isLogic()) {
// aspect = SrSignal.OFF;
// } else {
// start.setAspect(CilSignal.RED);
// }
// }
// break;
// }
// case CilSignal.LEVEL_3: {
// if (cilRoute.isPreparedForCtc()) {
// if (start.isForceLight()) {
// if (start.getSignalAspect() != cilRoute.getSignalAspect()) {
// aspect = cilRoute.getSignalAspect();
// }
// } else {
// if (!start.isLogic()) {
// aspect = SrSignal.OFF;
// } else {
// start.setAspect(cilRoute.getSignalAspect());
// }
// }
// }
// break;
// }
// case CilSignal.LEVEL_4: {
// if (!cilRoute.isPreparedForCtc() || start.isForceLight()) {
// if (start.getSignalAspect() != cilRoute.getSignalAspect()) {
// aspect = cilRoute.getSignalAspect();
// }
// } else {
// if (!start.isLogic()) {
// aspect = SrSignal.OFF;
// } else {
// start.setAspect(cilRoute.getSignalAspect());
// }
// }
// break;
// }
// }
// if (aspect != null) {
// this.srdApiService.changeSignalLight(rtSimulation, start.getId(), aspect);
// }
// }
private int levelCheck(CilRoute cilRoute) {
int level = CilSignal.LEVEL_1;
// 进路内道岔检查
CilRoutePathElement pathElement = cilRoute.getPathElement();
List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
if (!cilSwitchPosition.isOnPosition() || !cilSwitchPosition.getCilSwitch().isRl()) {
return level;
}
}
// 进路区段检查
List<CilSection> sectionList = pathElement.getSectionList();
for (CilSection section : sectionList) {
if (!section.isRl()) {
return level;
}
}
// 进路内道岔到位达到引导级别
level = CilSignal.LEVEL_2;
// 进路侧防检查
List<CilFls> flsList = pathElement.getFlsList();
for (CilFls cilFls : flsList) {
List<CilFls.FlsElement> firstLevelList = cilFls.getFirstLevelList();
for (CilFls.FlsElement flsElement : firstLevelList) {
CilSwitchPosition pp = flsElement.getPp();
if (pp != null && !pp.isOnPosition()) {
return level;
}
CilSwitchPosition pae = flsElement.getPae();
if (pae != null && !pae.isOnPosition()) {
return level;
}
CilSignal ps = flsElement.getPs();
if (ps != null && !ps.isForbidAspect()) {
return level;
}
}
}
// 进路侧防满足达到移动闭塞信号级别
level = CilSignal.LEVEL_3;
// 进路空闲情况延续保护检查
return level;
}
// private int levelCheck(CilRoute cilRoute) {
// int level = CilSignal.LEVEL_1;
// // 进路内道岔检查
// CilRoutePathElement pathElement = cilRoute.getPathElement();
// List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
// for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
// if (!cilSwitchPosition.isOnPosition() || !cilSwitchPosition.getCilSwitch().isRl()) {
// return level;
// }
// }
// // 进路区段检查
// List<CilSection> sectionList = pathElement.getSectionList();
// for (CilSection section : sectionList) {
// if (!section.isRl()) {
// return level;
// }
// }
// // 进路内道岔到位达到引导级别
// level = CilSignal.LEVEL_2;
// // 进路侧防检查
// List<CilFls> flsList = pathElement.getFlsList();
// for (CilFls cilFls : flsList) {
// List<CilFls.FlsElement> firstLevelList = cilFls.getFirstLevelList();
// for (CilFls.FlsElement flsElement : firstLevelList) {
// CilSwitchPosition pp = flsElement.getPp();
// if (pp != null && !pp.isOnPosition()) {
// return level;
// }
// CilSwitchPosition pae = flsElement.getPae();
// if (pae != null && !pae.isOnPosition()) {
// return level;
// }
// CilSignal ps = flsElement.getPs();
// if (ps != null && !ps.isForbidAspect()) {
// return level;
// }
// }
// }
// // 进路侧防满足达到移动闭塞信号级别
// level = CilSignal.LEVEL_3;
// // 进路空闲情况延续保护检查
//
// return level;
// }
/**
* 进路征用并转换道岔
@ -428,32 +544,32 @@ public class CilRouteLogicService {
* @param cilRoute
* @return 是否所有道岔已经转换到位
*/
private void turnSwitch(RtSimulation rtSimulation, CilRoute cilRoute) {
// 进路内道岔
CilRoutePathElement pathElement = cilRoute.getPathElement();
List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
boolean onPosition = true;
for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
this.turnSwitch(rtSimulation, cilSwitchPosition);
}
// 进路侧防道岔
List<CilFls> flsList = pathElement.getFlsList();
for (CilFls cilFls : flsList) {
List<CilFls.FlsElement> firstLevelList = cilFls.getFirstLevelList();
for (CilFls.FlsElement flsElement : firstLevelList) {
CilSwitchPosition pp = flsElement.getPp();
if (pp != null) {
this.turnSwitch(rtSimulation, pp);
}
CilSwitchPosition pae = flsElement.getPae();
if (pae != null) {
this.turnSwitch(rtSimulation, pae);
}
}
}
// 延续保护道岔
// 延续保护侧防道岔
}
// private void turnSwitch(RtSimulation rtSimulation, CilRoute cilRoute) {
// // 进路内道岔
// CilRoutePathElement pathElement = cilRoute.getPathElement();
// List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
// boolean onPosition = true;
// for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
// this.turnSwitch(rtSimulation, cilSwitchPosition);
// }
// // 进路侧防道岔
// List<CilFls> flsList = pathElement.getFlsList();
// for (CilFls cilFls : flsList) {
// List<CilFls.FlsElement> firstLevelList = cilFls.getFirstLevelList();
// for (CilFls.FlsElement flsElement : firstLevelList) {
// CilSwitchPosition pp = flsElement.getPp();
// if (pp != null) {
// this.turnSwitch(rtSimulation, pp);
// }
// CilSwitchPosition pae = flsElement.getPae();
// if (pae != null) {
// this.turnSwitch(rtSimulation, pae);
// }
// }
// }
// // 延续保护道岔
// // 延续保护侧防道岔
// }
/**
* @param rtSimulation
@ -471,84 +587,84 @@ public class CilRouteLogicService {
return true;
}
private void lockRouteDevices(CilRoute cilRoute) {
CilRoutePathElement pathElement = cilRoute.getPathElement();
this.routeLockPathDevices(cilRoute, pathElement);
// 延续保护锁闭
CilOverlap overlap = cilRoute.getOverlap();
if (overlap != null) {
CilRoutePathElement selectedPath = overlap.getSelectedPath();
if (selectedPath != null) {
this.overlapLockPathDevices(overlap, selectedPath);
}
}
}
// private void lockRouteDevices(CilRoute cilRoute) {
// CilRoutePathElement pathElement = cilRoute.getPathElement();
// this.routeLockPathDevices(cilRoute, pathElement);
// // 延续保护锁闭
// CilOverlap overlap = cilRoute.getOverlap();
// if (overlap != null) {
// CilRoutePathElement selectedPath = overlap.getSelectedPath();
// if (selectedPath != null) {
// this.overlapLockPathDevices(overlap, selectedPath);
// }
// }
// }
private void routeLockPathDevices(CilRoute cilRoute, CilRoutePathElement pathElement) {
// 进路内道岔锁闭
List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
CilSwitch cilSwitch = cilSwitchPosition.getCilSwitch();
cilSwitch.getA().lockByRoute(cilRoute);
if (cilSwitchPosition.isOnPosition()) {
cilSwitch.lockByRoute(cilRoute);
if (cilSwitch.isNormalPosition()) {
cilSwitch.getB().lockByRoute(cilRoute);
} else {
cilSwitch.getC().lockByRoute(cilRoute);
}
} else {
cilSwitch.getB().lockByRoute(cilRoute);
cilSwitch.getC().lockByRoute(cilRoute);
}
}
// 进路侧防道岔锁闭
List<CilFls> flsList = pathElement.getFlsList();
for (CilFls cilFls : flsList) {
List<CilFls.FlsElement> firstLevelList = cilFls.getFirstLevelList();
for (CilFls.FlsElement flsElement : firstLevelList) {
flsElement.lock();
}
}
// 进路内区段锁闭
routeLockSections(cilRoute, pathElement.getSectionList());
}
// private void routeLockPathDevices(CilRoute cilRoute, CilRoutePathElement pathElement) {
// // 进路内道岔锁闭
// List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
// for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
// CilSwitch cilSwitch = cilSwitchPosition.getCilSwitch();
// cilSwitch.getA().lockByRoute(cilRoute);
// if (cilSwitchPosition.isOnPosition()) {
// cilSwitch.lockByRoute(cilRoute);
// if (cilSwitch.isNormalPosition()) {
// cilSwitch.getB().lockByRoute(cilRoute);
// } else {
// cilSwitch.getC().lockByRoute(cilRoute);
// }
// } else {
// cilSwitch.getB().lockByRoute(cilRoute);
// cilSwitch.getC().lockByRoute(cilRoute);
// }
// }
// // 进路侧防道岔锁闭
// List<CilFls> flsList = pathElement.getFlsList();
// for (CilFls cilFls : flsList) {
// List<CilFls.FlsElement> firstLevelList = cilFls.getFirstLevelList();
// for (CilFls.FlsElement flsElement : firstLevelList) {
// flsElement.lock();
// }
// }
// // 进路内区段锁闭
// routeLockSections(cilRoute, pathElement.getSectionList());
// }
private void overlapLockPathDevices(CilOverlap overlap, CilRoutePathElement pathElement) {
// 进路内道岔锁闭
List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
CilSwitch cilSwitch = cilSwitchPosition.getCilSwitch();
cilSwitch.getA().lockByOverlap(overlap);
if (cilSwitchPosition.isOnPosition()) {
cilSwitch.lockByOverlap(overlap);
if (cilSwitch.isNormalPosition()) {
cilSwitch.getB().lockByOverlap(overlap);
} else {
cilSwitch.getC().lockByOverlap(overlap);
}
} else {
cilSwitch.getB().lockByOverlap(overlap);
cilSwitch.getC().lockByOverlap(overlap);
}
}
// 进路内区段锁闭
List<CilSection> sectionList = pathElement.getSectionList();
overlapLockSections(overlap, sectionList);
}
// private void overlapLockPathDevices(CilOverlap overlap, CilRoutePathElement pathElement) {
// // 进路内道岔锁闭
// List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
// for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
// CilSwitch cilSwitch = cilSwitchPosition.getCilSwitch();
// cilSwitch.getA().lockByOverlap(overlap);
// if (cilSwitchPosition.isOnPosition()) {
// cilSwitch.lockByOverlap(overlap);
// if (cilSwitch.isNormalPosition()) {
// cilSwitch.getB().lockByOverlap(overlap);
// } else {
// cilSwitch.getC().lockByOverlap(overlap);
// }
// } else {
// cilSwitch.getB().lockByOverlap(overlap);
// cilSwitch.getC().lockByOverlap(overlap);
// }
// }
// // 进路内区段锁闭
// List<CilSection> sectionList = pathElement.getSectionList();
// overlapLockSections(overlap, sectionList);
// }
private void overlapLockSections(CilOverlap overlap, List<CilSection> sectionList) {
for (CilSection cilSection : sectionList) {
CilSwitch belongSwitch = cilSection.getBelongSwitch();
private void overlapLockSections(CilRepository cilRepository, CilOverlap overlap, List<CommonSection> sectionList) {
for (CommonSection commonSection : sectionList) {
CommonSwitch belongSwitch = commonSection.getBelongSwitch();
if (belongSwitch != null) {
continue;
}
List<CilSection> relateList = cilSection.getRelateList();
List<CommonSection> relateList = commonSection.getRelateList();
if (relateList.isEmpty()) {
cilSection.lockByOverlap(overlap);
cilRepository.getSectionById(commonSection.getId()).lockByOverlap(overlap);
} else {
for (CilSection section : relateList) {
section.lockByOverlap(overlap);
for (CommonSection section : relateList) {
cilRepository.getSectionById(section.getId()).lockByOverlap(overlap);
}
}
}
@ -560,8 +676,8 @@ public class CilRouteLogicService {
* @param cilRoute
*/
private void watchRoute(CilRoute cilRoute) {
if (cilRoute.isOpenAspect()) {
}
// if (cilRoute.isOpenAspect()) {
//
// }
}
}

View File

@ -7,6 +7,7 @@ import club.joylink.rtss.simulation.rt.CIL.bo.CilSignal;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.SRD.SrdApiService;
import club.joylink.rtss.simulation.rt.SRD.bo.SrSignal;
import club.joylink.rtss.simulation.rt.repo.CommonRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -19,16 +20,18 @@ public class CilSignalLogicService {
private SrdApiService srdApiService;
public void reopen(RtSimulation rtSimulation, String signalId) {
CilRepository repository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
CilSignal signal = repository.getSignalById(signalId);
BusinessExceptionAssertEnum.OPERATION_REPEAT.assertEquals(CilSignal.RED, signal.getSignalAspect(), "信号已开,无需重开");
Optional<CilRoute> routeOptional = repository.getSupervisedRouteList().stream().filter(route -> signal.equals(route.getStart())).limit(1).findAny();
if (routeOptional.isEmpty()) {
throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无已排列进路,无法重开");
} else {
CilRoute route = routeOptional.get();
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue();
}
// CommonRepository commonRepository = null; // TODO: 2021/4/20
// CilRepository cilRepository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
// CilSignal signal = cilRepository.getSignalById(signalId);
// BusinessExceptionAssertEnum.OPERATION_REPEAT.assertEquals(CilSignal.RED, signal.getSignalAspect(), "信号已开,无需重开");
//
// Optional<CilRoute> routeOptional = cilRepository.getSupervisedRouteList().stream().filter(route -> signal.equals(route.getStart())).limit(1).findAny();
// if (routeOptional.isEmpty()) {
// throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无已排列进路,无法重开");
// } else {
// CilRoute route = routeOptional.get();
//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue();
// }
}
/**
@ -43,16 +46,14 @@ public class CilSignalLogicService {
}
}
public void try2UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect) {
if (signal.sufficientLevel(aspect)) {
if (signal.isUta()) {
srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect);
public void try2UpdateSignalDisplay(RtSimulation rtSimulation, CilSignal signal, int aspect, boolean ctcMode) {
// TODO: 2021/4/20 因信号机缺少表示虚拟信号机的字段故缺少对虚拟信号机的检查
boolean logic = !signal.isUta() && ctcMode && !signal.isForceLight();
if (signal.sufficientLevel(aspect, logic)) {
if (logic) {
signal.setAspect(aspect);
} else {
if (signal.isForceLight()) {
srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect);
} else {
signal.setAspect(aspect);
}
srdApiService.changeSignalLight(rtSimulation, signal.getId(), aspect);
}
}
}

View File

@ -1,12 +1,13 @@
package club.joylink.rtss.simulation.rt.CIL;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.SimulationRepository;
import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository;
import club.joylink.rtss.simulation.rt.CIL.bo.CilSwitch;
import club.joylink.rtss.simulation.rt.CIL.bo.CilSwitchPosition;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.SRD.SrdApiService;
import club.joylink.rtss.simulation.rt.repo.CommonSwitch;
import club.joylink.rtss.simulation.rt.repo.SwitchPosition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@ -32,25 +33,21 @@ public class CilSwitchLogicService {
srdApiService.turnSwitch(rtSimulation, switchId, position);
}
public void tryTurn(RtSimulation rtSimulation, String switchId, int position) {
CilRepository repository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
CilSwitch aSwitch = repository.getSwitchById(switchId);
tryTurn(rtSimulation, aSwitch, position);
}
public void tryTurn(RtSimulation rtSimulation, CilSwitch cilSwitch, int position) {
public void tryTurn(RtSimulation rtSimulation, CilRepository cilRepository, CommonSwitch commonSwitch, int position) {
CilSwitch cilSwitch = cilRepository.getSwitchById(commonSwitch.getId());
if (cilSwitch.getPosition() == position) {
return;
}
if (!cilSwitch.isLocked() && !cilSwitch.isOccupy()) {
srdApiService.turnSwitch(rtSimulation, cilSwitch.getId(), position);
srdApiService.turnSwitch(rtSimulation, commonSwitch.getId(), position);
}
}
public void tryTurn(RtSimulation rtSimulation, List<CilSwitchPosition> switchPositions) {
public void tryTurn(RtSimulation rtSimulation, List<SwitchPosition> switchPositions) {
if (!CollectionUtils.isEmpty(switchPositions)) {
for (CilSwitchPosition switchPosition : switchPositions) {
tryTurn(rtSimulation, switchPosition.getCilSwitch(), switchPosition.getPosition());
CilRepository repository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
for (SwitchPosition switchPosition : switchPositions) {
tryTurn(rtSimulation, repository, switchPosition.getCommonSwitch(), switchPosition.getPosition());
}
}
}

View File

@ -40,9 +40,6 @@ public class CilFls {
this.pae = pae;
}
/**
* 是否全部锁闭
*/
public void lock() {
if (this.pp != null && this.pp.isOnPosition()) {
this.pp.getCilSwitch().flankLock();

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.rt.CIL.bo;
import club.joylink.rtss.simulation.rt.repo.TrackWay;
import lombok.Getter;
import java.util.List;
@ -13,13 +14,18 @@ public class CilOverlap extends CilDevice {
List<CilRoutePathElement> pathElementList;
int releaseTime; // 延续保护解锁时间
CilRoutePathElement selectedPath; // 选择出所需办理的路径
// CilRoutePathElement selectedPath; // 选择出所需办理的路径
TrackWay selectedPath;
public CilOverlap(String id, String name) {
super(id, name);
}
public void updateSelectedPath(CilRoutePathElement cilRoutePathElement) {
this.selectedPath = cilRoutePathElement;
// public void updateSelectedPath(CilRoutePathElement cilRoutePathElement) {
// this.selectedPath = cilRoutePathElement;
// }
public void updateSelectedPath(TrackWay path) {
this.selectedPath = path;
}
}

View File

@ -222,23 +222,23 @@ public class CilRepositoryBuilder {
String.format("存在id重复的进路:[%s]", routeNewVO.getCode()));
CilRoute cilRoute = new CilRoute(routeNewVO.getCode(), routeNewVO.getName());
routeMap.put(cilRoute.getId(), cilRoute);
if (routeNewVO.isTurnBack()) {
cilRoute.type = CilRoute.TYPE_TB;
} else if (routeNewVO.isGuide()) {
cilRoute.type = CilRoute.TYPE_GUIDE;
} else if (routeNewVO.isAtp()) {
cilRoute.type = CilRoute.TYPE_ATP;
} else {
cilRoute.type = cilRoute.TYPE_GROUND;
}
// if (routeNewVO.isTurnBack()) {
// cilRoute.type = CilRoute.TYPE_TB;
// } else if (routeNewVO.isGuide()) {
// cilRoute.type = CilRoute.TYPE_GUIDE;
// } else if (routeNewVO.isAtp()) {
// cilRoute.type = CilRoute.TYPE_ATP;
// } else {
// cilRoute.type = cilRoute.TYPE_GROUND;
// }
CilSignal start = cilRepository.signalMap.get(routeNewVO.getStartSignalCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(start,String.format("不存在id为[%s]的信号机", routeNewVO.getStartSignalCode()));
CilSignal end = cilRepository.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(), cilRepository.sectionMap, cilRepository.switchMap, cilRepository.flsMap);
// cilRoute.start = start;
// cilRoute.end = end;
// cilRoute.pathElement = buildPathElement(start, routeNewVO.getRouteSectionList(),
// routeNewVO.getRouteSwitchList(), routeNewVO.getFlsList(), cilRepository.sectionMap, cilRepository.switchMap, cilRepository.flsMap);
CilOverlap cilOverlap = cilRepository.overlapMap.get(routeNewVO.getOverlapCode());
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(cilOverlap,
String.format("不存在id为[%s]的延续保护进路", routeNewVO.getOverlapCode()));
@ -256,7 +256,7 @@ public class CilRepositoryBuilder {
standList.add(cilStand);
}
}
cilRoute.standList = standList;
// cilRoute.standList = standList;
// 屏蔽门
List<CilPsd> psdList = new ArrayList<>();
List<String> psdCodeList = routeNewVO.getPsdList();
@ -268,7 +268,7 @@ public class CilRepositoryBuilder {
psdList.add(cilPsd);
}
}
cilRoute.psdList = psdList;
// cilRoute.psdList = psdList;
// 紧急停车/关闭按钮
List<CilEsp> espList = new ArrayList<>();
List<String> espCodeList = routeNewVO.getEspList();
@ -280,9 +280,9 @@ public class CilRepositoryBuilder {
espList.add(cilEsp);
}
}
cilRoute.espList = espList;
cilRoute.signalAspect = routeNewVO.isGreenOpen() ? CilRoute.SA_GREEN : CilRoute.SA_YELLOW;
cilRoute.conflictingList = routeNewVO.getConflictRouteList();
// cilRoute.espList = espList;
// cilRoute.signalAspect = routeNewVO.isGreenOpen() ? CilRoute.SA_GREEN : CilRoute.SA_YELLOW;
// cilRoute.conflictingList = routeNewVO.getConflictRouteList();
}
}

View File

@ -13,38 +13,38 @@ import java.util.concurrent.ConcurrentHashMap;
public class CilRoute extends CilDevice {
CilServer cilServer;
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;
// 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<String> conflictingList;
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; //引导信号黄红灯显示
// List<CilPsd> psdList;
// List<CilEsp> espList;
// List<CilStand> standList; // 站台扣车
// List<String> conflictingList;
// 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; //引导信号黄红灯显示
Map<String, CilSwitchPosition> waitTurnMap = new ConcurrentHashMap<>(); // 进路办理中待转换的道岔
Map<String, CilSwitchPosition> waitOnPositionMap = new ConcurrentHashMap<>(); // 进路办理中待转换到位的道岔
LocalDateTime stageStartTime;
int stage; // 进路当前所处逻辑阶段
public static final int STAGE_NONE = 0; //
public static final int STAGE_SETTING = 1; // 建立阶段
public static final int STAGE_WATCH = 2; // 信号正常开放后监视
public static final int STAGE_UL = 3; // 正常解锁
public static final int STAGE_DUL = 4; // 延时解锁
public static final int STAGE_FUL = 5; // 故障解锁
// int stage; // 进路当前所处逻辑阶段
// public static final int STAGE_NONE = 0; //
// public static final int STAGE_SETTING = 1; // 建立阶段
// public static final int STAGE_WATCH = 2; // 信号正常开放后监视
// public static final int STAGE_UL = 3; // 正常解锁
// public static final int STAGE_DUL = 4; // 延时解锁
// public static final int STAGE_FUL = 5; // 故障解锁
int signalState;// 进路信号状态(当前实际状态)
@Setter
private boolean lock; // 进路是否锁闭进路主体
@ -63,40 +63,26 @@ public class CilRoute extends CilDevice {
super(id, name);
}
public boolean isOpenAspect() {
return this.start.getSignalAspect() == CilSignal.GREEN
||
this.start.getSignalAspect() == CilSignal.YELLOW;
}
// public boolean isOpenAspect() {
// return this.start.getSignalAspect() == CilSignal.GREEN
// ||
// this.start.getSignalAspect() == CilSignal.YELLOW;
// }
public boolean isGuideAspect() {
return this.start.getSignalAspect() == CilSignal.GUIDE;
}
// public boolean isGuideAspect() {
// return this.start.getSignalAspect() == CilSignal.GUIDE;
// }
public void startSetting(LocalDateTime systemTime) {
this.stageStartTime = systemTime;
this.stage = STAGE_SETTING;
// this.stage = STAGE_SETTING;
}
public void addWaitTurnSwitch(CilSwitchPosition cilSwitchPosition) {
this.waitTurnMap.put(cilSwitchPosition.getCilSwitch().getId(), cilSwitchPosition);
}
public boolean isPreparedForCtc() {
return this.cilServer.isCtcMode() && !this.start.isUta();
}
/**
* 是否达到ATP级
*/
public boolean isATPLevel() {
return this.lock && (!CollectionUtils.isEmpty(this.pathElement.getFlsList()) || this.fl);
}
/**
* 是否达到主信号级
*/
public boolean isMainLevel() {
return isATPLevel() && (this.overlap == null || this.ol);
}
// public boolean isPreparedForCtc() {
// return this.cilServer.isCtcMode() && !this.start.isUta();
// }
}

View File

@ -1,6 +1,8 @@
package club.joylink.rtss.simulation.rt.CIL.bo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.rt.repo.CommonRoute;
import club.joylink.rtss.simulation.rt.repo.CommonSection;
import lombok.Getter;
import java.util.ArrayList;
@ -34,11 +36,11 @@ public class CilSection extends CilDevice {
this.axcOccupy = occupy;
}
public void lockByRoute(CilRoute cilRoute) {
if (!Objects.equals(cilRoute.getId(), this.routeId)) {
this.routeId = cilRoute.getId();
public void lockByRoute(CommonRoute commonRoute) {
if (!Objects.equals(commonRoute.getId(), this.routeId)) {
this.routeId = commonRoute.getId();
this.rl = true;
this.lr = cilRoute.start.isRight();
this.lr = commonRoute.getStart().isRight();
}
}

View File

@ -61,7 +61,7 @@ public class CilSignal extends CilDevice {
/**
* 信号机有足够的级别以{aspect}显示
*/
public boolean sufficientLevel(int aspect) {
public boolean sufficientLevel(int aspect, boolean logic) {
switch (aspect) {
case RED:
return true;
@ -69,7 +69,11 @@ public class CilSignal extends CilDevice {
return level == LEVEL_2 || level == LEVEL_3 || level == LEVEL_4;
case GREEN:
case YELLOW:
return level == LEVEL_3 || level == LEVEL_4;
if (logic) {
return level == LEVEL_3 || level == LEVEL_4;
} else {
return level == LEVEL_4;
}
default:
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("未知的显示状态");
}

View File

@ -1,6 +1,8 @@
package club.joylink.rtss.simulation.rt;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.simulation.Simulation;
import club.joylink.rtss.vo.client.map.MapVO;
import lombok.Getter;
import java.time.LocalDateTime;
@ -9,6 +11,10 @@ import java.time.LocalDateTime;
public class RtSimulation extends Simulation<RtSimulationUser, RtSimulationMember> {
public static final int TIME_OFFSET_HOUR = 2;
MapVO mapVO;
MapPrdTypeEnum prdType;
public RtSimulation(String id) {
super(id);
}

View File

@ -1,7 +1,11 @@
package club.joylink.rtss.simulation.rt;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.services.MapService;
import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO;
import club.joylink.rtss.simulation.rt.ATS.AtsLogicService;
import club.joylink.rtss.simulation.rt.CIL.CilLogicService;
import club.joylink.rtss.simulation.rt.CIL.CilLogicService;
import club.joylink.rtss.simulation.rt.SRD.SrdLogicService;
import club.joylink.rtss.simulation.rt.repo.CommonRepoService;
@ -24,11 +28,14 @@ public class RtSimulationService {
private CilLogicService cilLogicService;
@Autowired
private SrdLogicService srdLogicService;
@Autowired
private AtsLogicService atsLogicService;
public RtSimulation create(UserVO userVO, Long mapId) {
public RtSimulation create(UserVO userVO, Long mapId, MapPrdTypeEnum prdTypeEnum) {
Objects.requireNonNull(mapId);
MapVO mapVO = this.mapService.getMapDetail(mapId);
RtSimulation rtSimulation = new RtSimulation(SimulationIdGenerator.buildId());
rtSimulation.mapVO = mapVO;
this.loadData(rtSimulation, mapVO);
this.srdLogicService.addJobs(rtSimulation);
this.simulationManager.save(rtSimulation);
@ -37,12 +44,24 @@ public class RtSimulationService {
/**
* 加载相关数据
* @param rtSimulation
* @param mapVO
*/
private void loadData(RtSimulation rtSimulation, MapVO mapVO) {
this.commonRepoService.buildRepository(rtSimulation, mapVO);
this.cilLogicService.buildRepository(rtSimulation, mapVO);
this.srdLogicService.buildRepository(rtSimulation, mapVO);
// this.commonRepoService.buildRepository(rtSimulation, mapVO);
// this.cilLogicService.buildRepository(rtSimulation, mapVO);
// this.srdLogicService.buildRepository(rtSimulation, mapVO);
// this.atsLogicService.buildRepository(rtSimulation, mapVO);
}
public SimulationVO getBasicInfo(String id) {
RtSimulation rtSimulation = simulationManager.getById(id, RtSimulation.class);
SimulationVO.SimulationVOBuilder builder = SimulationVO.builder();
builder.map(rtSimulation.mapVO.buildBasicInfo());
builder.prodType(rtSimulation.prdType != null ? rtSimulation.prdType.getCode() : null);
return builder.build();
}
public MapVO getMapData(String id) {
RtSimulation rtSimulation = simulationManager.getById(id, RtSimulation.class);
return rtSimulation.getMapVO();
}
}

View File

@ -0,0 +1,30 @@
package club.joylink.rtss.simulation.rt;
import club.joylink.rtss.simulation.SimulationSubscribeMessageService;
import org.springframework.stereotype.Component;
@Component
public class RtSimulationSubscribeMessageService implements SimulationSubscribeMessageService {
@Override
public boolean acceptedSubscribePath(String destination) {
return RtSimulationSubscribeTopic.hasMatched(destination);
}
@Override
public Object buildMessageOfSubscribe(String destination) {
RtSimulationSubscribeTopic topic = RtSimulationSubscribeTopic.match(destination);
return null;
}
public void addJobs(RtSimulation rtSimulation) {
for (RtSimulationSubscribeTopic topic : RtSimulationSubscribeTopic.values()) {
rtSimulation.addJob("MESSAGE-" + topic.name(), () -> buildMessages(rtSimulation, topic), topic.getRate());
}
}
public Object buildMessages(RtSimulation rtSimulation, RtSimulationSubscribeTopic topic) {
return null;
}
}

View File

@ -0,0 +1,88 @@
package club.joylink.rtss.simulation.rt;
import club.joylink.rtss.simulation.rt.SRD.SrdLogicService;
import lombok.Getter;
import org.springframework.util.PropertyPlaceholderHelper;
import org.springframework.util.StringUtils;
import java.util.Objects;
import java.util.Properties;
@Getter
public enum RtSimulationSubscribeTopic {
ATS("/ats", SrdLogicService.DEVICE_RUN_RATE),
// SandBox("/queue/simulation/jl3d/{id}, ", SrdLogicService.DEVICE_RUN_RATE),
// Drive("/queue/simulation/drive/{id}", SrdLogicService.TRAIN_RUN_RATE),
// PassengerFlow("/queue/simulation/passenger/{id}", SrdLogicService.DEVICE_RUN_RATE),
// WeChatMini("/topic/simulation/assistant/{id}", SrdLogicService.DEVICE_RUN_RATE),
;
private String destPattern;
private int rate;
public static final String PATH_SEPARATOR = "/";
private static final PropertyPlaceholderHelper placeholderHelper = new PropertyPlaceholderHelper("{", "}");
RtSimulationSubscribeTopic(String destPattern, int rate) {
this.destPattern = destPattern;
this.rate = rate;
}
public static boolean hasMatched(String destination) {
for (RtSimulationSubscribeTopic value : RtSimulationSubscribeTopic.values()) {
if (value.isMatch(destination)) {
return true;
}
}
return false;
}
public static RtSimulationSubscribeTopic match(String destination) {
for (RtSimulationSubscribeTopic value : RtSimulationSubscribeTopic.values()) {
if (value.isMatch(destination)) {
return value;
}
}
return null;
}
public boolean isMatch(String destination) {
String[] patterns = StringUtils.tokenizeToStringArray(this.destPattern, PATH_SEPARATOR);
String[] dests = StringUtils.tokenizeToStringArray(destination, PATH_SEPARATOR);
if (patterns.length == dests.length) {
for (int i = 0; i < patterns.length; i++) {
String p = patterns[i];
if (p.startsWith("{")) {
continue;
}
if (!Objects.equals(p, dests[i])) {
return false;
}
}
return true;
}
return false;
}
public String getId(String destination) {
String[] patterns = StringUtils.tokenizeToStringArray(this.destPattern, PATH_SEPARATOR);
String[] dests = StringUtils.tokenizeToStringArray(destination, PATH_SEPARATOR);
if (patterns.length == dests.length) {
for (int i = 0; i < patterns.length; i++) {
String p = patterns[i];
if (p.startsWith("{")) {
return dests[i];
} else {
continue;
}
}
}
throw new IllegalArgumentException(String.format("无效的仿真订阅路径:[%s]", destination));
}
public String buildDestination(String simulationId) {
Properties properties = new Properties();
properties.put("id", simulationId);
String dest = placeholderHelper.replacePlaceholders(this.destPattern, properties);
return dest;
}
}

View File

@ -11,9 +11,12 @@ import club.joylink.rtss.vo.client.map.newmap.MapSectionNewVO;
import club.joylink.rtss.vo.client.map.newmap.MapSignalNewVO;
import org.springframework.util.StringUtils;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.stream.Collectors;
public class SrdRepositoryBuilder {
@ -24,7 +27,7 @@ public class SrdRepositoryBuilder {
buildTurnout(graphDataNew.getSwitchList(), srdRepository.switchMap);
buildSignal(graphDataNew.getSignalList(), srdRepository.signalMap);
buildSrPsd(graphDataNew.getPsdList(), srdRepository.psdMap);
buildTrain(graphDataNew.getTrainList(), srdRepository.trainMap);
buildTrain(graphDataNew.getTrainModelList(), graphDataNew.getTrainList(), srdRepository.trainMap);
// 关系构建
buildRelationOfTrackAndAxc(graphDataNew.getSectionList(), srdRepository.trackMap, srdRepository.axcMap);
buildRelationOfTurnoutAndTrack(graphDataNew.getSwitchList(), srdRepository.switchMap, srdRepository.trackMap);
@ -145,10 +148,12 @@ public class SrdRepositoryBuilder {
}
}
private static void buildTrain(List<MapTrainVO> trainList, Map<String, SrTrain> trainMap) {
private static void buildTrain(List<MapTrainModelVO> trainModelList, List<MapTrainVO> trainList, Map<String, SrTrain> trainMap) {
Map<String, MapTrainModelVO> modelMap = trainModelList.stream().collect(Collectors.toMap(MapTrainModelVO::getCode, Function.identity()));
for (MapTrainVO trainVO : trainList) {
MapTrainModelVO trainModel = trainVO.getTrainModel();
SrTrain srTrain = new SrTrain(trainVO.getGroupNumber(), (int) (trainModel.getLength() * 1000));
// MapTrainModelVO trainModel = trainVO.getTrainModel();
MapTrainModelVO model = modelMap.get(trainVO.getModelCode());
SrTrain srTrain = new SrTrain(trainVO.getGroupNumber(), (int) (model.getLength() * 1000));
trainMap.put(srTrain.getId(), srTrain);
}
}

View File

@ -1,9 +1,12 @@
package club.joylink.rtss.simulation.rt.repo;
import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository;
import club.joylink.rtss.simulation.rt.CIL.bo.CilSwitch;
import lombok.Getter;
import java.util.List;
@Getter
public class CommonFls extends CommonDevice {
SwitchPosition target;
@ -30,5 +33,29 @@ public class CommonFls extends CommonDevice {
this.pae = pae;
}
/**
*
* @return 是否全部锁闭
*/
public boolean lock(CilRepository cilRepository) {
boolean flag = true;
if (this.pp != null) {
CilSwitch cilSwitch = cilRepository.getSwitchById(pp.getCommonSwitch().getId());
if (pp.getPosition() == cilSwitch.getPosition()) {
cilSwitch.flankLock();
} else {
flag = false;
}
}
if (this.pae != null) {
CilSwitch cilSwitch = cilRepository.getSwitchById(pae.getCommonSwitch().getId());
if (pae.getPosition() == cilSwitch.getPosition()) {
cilSwitch.flankLock();
} else {
flag = false;
}
}
return flag;
}
}
}

View File

@ -48,4 +48,11 @@ public class CommonRepository extends SimulationRepository {
public void initState() {
}
public CommonRoute getRouteById(String id) {
CommonRoute commonRoute = this.routeMap.get(id);
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(commonRoute,
String.format("不存在id为[%s]的进路", id));
return commonRoute;
}
}

View File

@ -127,6 +127,15 @@ public class MapVO {
this.version = map.getVersion();
}
public MapVO buildBasicInfo() {
MapVO mapVO = new MapVO();
mapVO.setId(this.id);
mapVO.setName(this.name);
mapVO.setLineCode(this.lineCode);
mapVO.setVersion(this.version);
return mapVO;
}
public static MapVO fromDraftMapEntity(DraftMapWithBLOBs draftMap) {
MapVO mapVO = new MapVO();
mapVO.setId(draftMap.getId());

View File

@ -29,6 +29,8 @@ public class MapSystemDetailVO {
@ApiModelProperty(value = "产品类型")
private String prdType;
private Boolean newApi;
private String name;
private String remarks;
@ -55,6 +57,7 @@ public class MapSystemDetailVO {
id = system.getId();
mapId = system.getMapId();
prdType = system.getPrdType();
newApi = system.getNewApi();
name = system.getName();
status = system.getStatus();
}

View File

@ -9,6 +9,7 @@
<result column="prd_type" jdbcType="VARCHAR" property="prdType" />
<result column="customized" jdbcType="VARCHAR" property="customized" />
<result column="status" jdbcType="VARCHAR" property="status" />
<result column="new_api" jdbcType="TINYINT" property="newApi" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
@ -69,7 +70,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, `type`, map_id, prd_type, customized, `status`
id, `name`, `type`, map_id, prd_type, customized, `status`, new_api
</sql>
<select id="selectByExample" parameterType="club.joylink.rtss.entity.MapSystemExample" resultMap="BaseResultMap">
select
@ -94,7 +95,7 @@
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
select
<include refid="Base_Column_List" />
from map_system
where id = #{id,jdbcType=BIGINT}
@ -110,12 +111,12 @@
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.MapSystem" useGeneratedKeys="true">
insert into map_system (`name`, `type`, map_id,
prd_type, customized, `status`
)
values (#{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{mapId,jdbcType=BIGINT},
#{prdType,jdbcType=VARCHAR}, #{customized,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}
)
insert into map_system (`name`, `type`, map_id,
prd_type, customized, `status`,
new_api)
values (#{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{mapId,jdbcType=BIGINT},
#{prdType,jdbcType=VARCHAR}, #{customized,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR},
#{newApi,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.MapSystem" useGeneratedKeys="true">
insert into map_system
@ -138,6 +139,9 @@
<if test="status != null">
`status`,
</if>
<if test="newApi != null">
new_api,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null">
@ -158,6 +162,9 @@
<if test="status != null">
#{status,jdbcType=VARCHAR},
</if>
<if test="newApi != null">
#{newApi,jdbcType=TINYINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="club.joylink.rtss.entity.MapSystemExample" resultType="java.lang.Long">
@ -190,6 +197,9 @@
<if test="record.status != null">
`status` = #{record.status,jdbcType=VARCHAR},
</if>
<if test="record.newApi != null">
new_api = #{record.newApi,jdbcType=TINYINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
@ -203,7 +213,8 @@
map_id = #{record.mapId,jdbcType=BIGINT},
prd_type = #{record.prdType,jdbcType=VARCHAR},
customized = #{record.customized,jdbcType=VARCHAR},
`status` = #{record.status,jdbcType=VARCHAR}
`status` = #{record.status,jdbcType=VARCHAR},
new_api = #{record.newApi,jdbcType=TINYINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -229,6 +240,9 @@
<if test="status != null">
`status` = #{status,jdbcType=VARCHAR},
</if>
<if test="newApi != null">
new_api = #{newApi,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
@ -239,7 +253,8 @@
map_id = #{mapId,jdbcType=BIGINT},
prd_type = #{prdType,jdbcType=VARCHAR},
customized = #{customized,jdbcType=VARCHAR},
`status` = #{status,jdbcType=VARCHAR}
`status` = #{status,jdbcType=VARCHAR},
new_api = #{newApi,jdbcType=TINYINT}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
</mapper>