南昌工学院沙盘项目特殊改动
This commit is contained in:
parent
99ecac0318
commit
5634ab0a39
|
@ -5,7 +5,22 @@ import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
|
|||
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalModel;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.AutoSignal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Cycle;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.DestinationCodeDefinition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.ESP;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.PSD;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.RouteFls;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.RouteOverlap;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.SectionPath;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
|
@ -14,7 +29,28 @@ import club.joylink.rtss.vo.map.CiGenerateResultVO;
|
|||
import club.joylink.rtss.vo.map.MapCiGenerateConfig;
|
||||
import club.joylink.rtss.vo.map.MapRoutingSectionNewVO;
|
||||
import club.joylink.rtss.vo.map.MapVO;
|
||||
import club.joylink.rtss.vo.map.logic.*;
|
||||
import club.joylink.rtss.vo.map.logic.MapAutoReentryVO;
|
||||
import club.joylink.rtss.vo.map.logic.MapAutoSignalNewVO;
|
||||
import club.joylink.rtss.vo.map.logic.MapDestinationCodeDefinitionVO;
|
||||
import club.joylink.rtss.vo.map.logic.MapOverlapVO;
|
||||
import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO;
|
||||
import club.joylink.rtss.vo.map.logic.MapRouteNewVO;
|
||||
import club.joylink.rtss.vo.map.logic.MapRoutingDataVO;
|
||||
import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO;
|
||||
import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Stack;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -23,11 +59,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
|
||||
|
@ -281,7 +312,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
|
|||
List<Signal> signalList = deviceMap.values().stream()
|
||||
.filter(mapElement -> mapElement.getDeviceType().equals(MapElement.DeviceType.SIGNAL))
|
||||
.map(mapElement -> ((Signal) mapElement))
|
||||
.filter(signal -> !signal.getInterlockStation().isDepot())
|
||||
// .filter(signal -> !signal.getInterlockStation().isDepot())
|
||||
.collect(Collectors.toList());
|
||||
// 获取所有道岔
|
||||
List<Switch> switchList = deviceMap.values().stream()
|
||||
|
@ -318,7 +349,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
|
|||
if (Objects.nonNull(autoSignal)) {
|
||||
autoSignalList.add(autoSignal);
|
||||
}
|
||||
} else if (signal.isProtectionSignal()) {
|
||||
} else if (signal.isProtectionSignal() || signal.isShunting2()) {
|
||||
// 防护信号机,生成进路
|
||||
if (config.isLikeHa1()) {
|
||||
generatedRouteList.addAll(this.generateRouteLikeHa1(signal, routeCodeGenerator, overlapMap,
|
||||
|
@ -1450,6 +1481,9 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator {
|
|||
case BW:
|
||||
route.setAspect(SignalAspect.W);
|
||||
break;
|
||||
case YRW:
|
||||
route.setAspect(SignalAspect.W);
|
||||
break;
|
||||
default:
|
||||
throw BusinessExceptionAssertEnum.DATA_ERROR.exception(String.format("信号机[%s]型号[%s]不正确",
|
||||
start.debugStr(), start.getSignalModel()));
|
||||
|
|
|
@ -1,14 +1,26 @@
|
|||
package club.joylink.rtss.services.draftData;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.AutoSignal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Routing;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.vo.map.logic.MapRoutingDataVO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 交路生成
|
||||
*/
|
||||
|
@ -122,7 +134,7 @@ public class RoutingGenerator {
|
|||
if (signal == null) {
|
||||
Section base = section;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Section next = base.getSectionOf(right);
|
||||
Section next = base.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (next == null) { // 可能到尽头了
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1188,8 +1188,8 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
section.setCreateTime(now);
|
||||
SandTableSectionConfigVO configVO = new SandTableSectionConfigVO(mapSectionNewVO.getCode(),
|
||||
mapSectionNewVO.getSrCode());
|
||||
section.setConfig(JsonUtils.writeValueAsString(configVO));
|
||||
ngyFillTime(configVO, mapSectionNewVO);
|
||||
section.setConfig(JsonUtils.writeValueAsString(configVO));
|
||||
list.add(section);
|
||||
}
|
||||
}
|
||||
|
@ -1213,7 +1213,8 @@ public class DeviceServiceImpl implements DeviceService {
|
|||
private void ngyFillTime(SandTableSectionConfigVO configVO, MapSectionNewVO section) {
|
||||
Float headDelayTime = null;
|
||||
Float tailDelayTime = null;
|
||||
if (section.isStandTrack() || section.isReentryTrack() || section.isTransferTrack()) {
|
||||
if (section.isStandTrack() || section.isReentryTrack() || section.isTransferTrack()
|
||||
|| section.isParkingTrack()) {
|
||||
if (section.isStandTrack()) {
|
||||
tailDelayTime = 1f;
|
||||
} else {
|
||||
|
|
|
@ -280,7 +280,13 @@ public class PublishMapDataHandler {
|
|||
MapGraphDataNewVO data = JsonUtils.read(map.getGraphData(), MapGraphDataNewVO.class);
|
||||
for (MapSectionNewVO section : data.getSectionList()) {
|
||||
if (section.getLengthFact() != null && section.getLengthFact() != 0) {
|
||||
section.setLengthFact(section.getLengthFact() * multiple);
|
||||
if (section.isStandTrack() || section.isParkingTrack()) {
|
||||
section.setLengthFact(140f);
|
||||
} else if (section.isSwitchSection()) {
|
||||
section.setLengthFact(30f);
|
||||
} else {
|
||||
section.setLengthFact(1000f);
|
||||
}
|
||||
}
|
||||
}
|
||||
map.setGraphData(JsonUtils.writeValueAsString(data));
|
||||
|
|
|
@ -18,10 +18,24 @@ import club.joylink.rtss.vo.AccountVO;
|
|||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.runplan.RunPlanTripVO;
|
||||
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.*;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingQueryVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingSection;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO;
|
||||
import club.joylink.rtss.vo.client.runplan.user.RunPlanUserConfigVO;
|
||||
import club.joylink.rtss.vo.map.MapVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -29,9 +43,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class RunPlanRoutingService implements IRunPlanRoutingService {
|
||||
|
@ -57,9 +68,11 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
@Transactional
|
||||
@Override
|
||||
public void createUserRouting(RunPlanRoutingVO routingVO) {
|
||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO), "交路数据重复");
|
||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO),
|
||||
"交路数据重复");
|
||||
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
|
||||
map);
|
||||
if (map.getCheckConfig().isCheck()) {
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
|
||||
"地图基础数据校验不通过");
|
||||
|
@ -73,10 +86,12 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
RunPlanRoutingVO routingDataLoop = routingVO.getRoutingDataLoop();
|
||||
try {
|
||||
generateUserRoutingSections(routingDataLoop, deviceMap);
|
||||
}catch (BaseException e){
|
||||
} catch (BaseException e) {
|
||||
return;
|
||||
}
|
||||
if (routingDataExist(routingDataLoop)) {
|
||||
return;
|
||||
}
|
||||
if (routingDataExist(routingDataLoop)) return;
|
||||
Section endSection = (Section) deviceMap.get(routingDataLoop.getEndSectionCode());
|
||||
routingDataLoop.setDestinationCode(endSection.getDestinationCode());
|
||||
runPlanRoutingDAO.insert(routingDataLoop.convert2Entity());
|
||||
|
@ -87,15 +102,20 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
@Override
|
||||
@Transactional
|
||||
public void createDefaultRoutings(List<RunPlanRoutingVO> defaultRoutings) {
|
||||
if (CollectionUtils.isEmpty(defaultRoutings)) return;
|
||||
if (CollectionUtils.isEmpty(defaultRoutings)) {
|
||||
return;
|
||||
}
|
||||
MapVO map = this.iMapService.getMapDetail(defaultRoutings.get(0).getMapId());
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
|
||||
map);
|
||||
// BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), "地图基础数据校验不通过");
|
||||
if (CollectionUtils.isEmpty(buildResult.getErrMsgList())) {
|
||||
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
|
||||
defaultRoutings.forEach(routingVO -> {
|
||||
routingVO.setUserId(null);
|
||||
if (routingDataExist(routingVO)) return;
|
||||
if (routingDataExist(routingVO)) {
|
||||
return;
|
||||
}
|
||||
setRoutingType(routingVO, deviceMap);
|
||||
RunPlanRouting routing = routingVO.convert2Entity();
|
||||
runPlanRoutingDAO.insert(routing);
|
||||
|
@ -107,9 +127,13 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
@Transactional
|
||||
public void syncDefaultRoutingRefData(Long userId, Long mapId) {
|
||||
List<RunPlanRoutingVO> defaultRoutingVOs = getDefaultRoutings(mapId);
|
||||
if (CollectionUtils.isEmpty(defaultRoutingVOs)) return;
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(this.iMapService.getMapDetail(mapId));
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), "地图基础数据校验不通过");
|
||||
if (CollectionUtils.isEmpty(defaultRoutingVOs)) {
|
||||
return;
|
||||
}
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
|
||||
this.iMapService.getMapDetail(mapId));
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
|
||||
"地图基础数据校验不通过");
|
||||
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
|
||||
//根据默认交路生成站间运行等级、停站时间、折返数据
|
||||
Set<RunPlanRunlevelVO> levelList = new HashSet<>(100);
|
||||
|
@ -136,7 +160,8 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
return true;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(routingVO);
|
||||
List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(
|
||||
routingVO);
|
||||
parkingTimeVOS.forEach(p -> {
|
||||
if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack()) {
|
||||
parkingTimeList.add(p);
|
||||
|
@ -152,7 +177,8 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
levelList.forEach(l -> {
|
||||
Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
|
||||
Section endSection = (Section) deviceMap.get(l.getEndSectionCode());
|
||||
if ((startSection.isStandTrack() && endSection.isTransferTrack()) || (endSection.isStandTrack() && startSection.isTransferTrack())) {
|
||||
if ((startSection.isStandTrack() && endSection.isTransferTrack()) || (
|
||||
endSection.isStandTrack() && startSection.isTransferTrack())) {
|
||||
Float distance;
|
||||
try {
|
||||
distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
|
||||
|
@ -177,14 +203,17 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
planConfigService.saveConfig(userId, mapId, userConfig.getConfig());
|
||||
}
|
||||
|
||||
private void setStationReentryTime(Map<String, MapElement> deviceMap, Map<String, RunPlanUserConfigVO.ReentryTime> reentryData, RunPlanRoutingVO routingVO) {
|
||||
private void setStationReentryTime(Map<String, MapElement> deviceMap,
|
||||
Map<String, RunPlanUserConfigVO.ReentryTime> reentryData, RunPlanRoutingVO routingVO) {
|
||||
Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode());
|
||||
if (startSection.isTurnBackTrack()) {
|
||||
reentryData.putIfAbsent(routingVO.getStartStationCode(), new RunPlanUserConfigVO.ReentryTime(120, 210, 45, 45));
|
||||
reentryData.putIfAbsent(routingVO.getStartStationCode(),
|
||||
new RunPlanUserConfigVO.ReentryTime(120, 210, 45, 45));
|
||||
}
|
||||
Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode());
|
||||
if (endSection.isTurnBackTrack()) {
|
||||
reentryData.putIfAbsent(routingVO.getEndStationCode(), new RunPlanUserConfigVO.ReentryTime(120, 210, 45, 45));
|
||||
reentryData.putIfAbsent(routingVO.getEndStationCode(),
|
||||
new RunPlanUserConfigVO.ReentryTime(120, 210, 45, 45));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,7 +226,8 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
@Override
|
||||
public RunPlanRoutingVO generateUserRoutingData(RunPlanRoutingVO routingVO) {
|
||||
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
|
||||
map);
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
|
||||
"地图基础数据校验不通过");
|
||||
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
|
||||
|
@ -206,22 +236,31 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<RunPlanRoutingVO> queryRoutes(Long mapId, RunPlanRoutingQueryVO queryVO, AccountVO user) {
|
||||
public List<RunPlanRoutingVO> queryRoutes(Long mapId, RunPlanRoutingQueryVO queryVO,
|
||||
AccountVO user) {
|
||||
return getUserRoutingBy(user.getId(), mapId).stream()
|
||||
.filter(routing -> Objects.equals(routing.getDestinationCode(), queryVO.getDestinationCode()))
|
||||
.filter(
|
||||
routing -> Objects.equals(routing.getDestinationCode(), queryVO.getDestinationCode()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void generateUserRoutingSections(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
|
||||
private void generateUserRoutingSections(RunPlanRoutingVO routingVO,
|
||||
Map<String, MapElement> deviceMap) {
|
||||
Section startSection = (Section) deviceMap.get(routingVO.getStartSectionCode());
|
||||
Section endSection = (Section) deviceMap.get(routingVO.getEndSectionCode());
|
||||
//中间经停所有站台轨
|
||||
List<Section> passingStandTrack = CalculateService.findPassingStandTrack(startSection, endSection, routingVO.getRight());
|
||||
List<Section> passingStandTrack = CalculateService.findPassingStandTrack(startSection,
|
||||
endSection, routingVO.getRight());
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(passingStandTrack,
|
||||
String.format("没有找到线路方向[%s]的中间经停区段,是否需要更换方向/手动添加/直接保存交路", routingVO.getRight() ? "右向" : "左向"));
|
||||
LinkedList<RunPlanRoutingSection> parkSectionCodeList = passingStandTrack.stream().map(section -> new RunPlanRoutingSection(section.getStation().getCode(), section.getCode())).collect(Collectors.toCollection(LinkedList::new));
|
||||
parkSectionCodeList.addFirst(new RunPlanRoutingSection(routingVO.getStartStationCode(), routingVO.getStartSectionCode()));
|
||||
parkSectionCodeList.addLast(new RunPlanRoutingSection(routingVO.getEndStationCode(), routingVO.getEndSectionCode()));
|
||||
String.format("没有找到线路方向[%s]的中间经停区段,是否需要更换方向/手动添加/直接保存交路",
|
||||
routingVO.getRight() ? "右向" : "左向"));
|
||||
LinkedList<RunPlanRoutingSection> parkSectionCodeList = passingStandTrack.stream().map(
|
||||
section -> new RunPlanRoutingSection(section.getStation().getCode(), section.getCode()))
|
||||
.collect(Collectors.toCollection(LinkedList::new));
|
||||
parkSectionCodeList.addFirst(new RunPlanRoutingSection(routingVO.getStartStationCode(),
|
||||
routingVO.getStartSectionCode()));
|
||||
parkSectionCodeList.addLast(
|
||||
new RunPlanRoutingSection(routingVO.getEndStationCode(), routingVO.getEndSectionCode()));
|
||||
routingVO.setParkSectionCodeList(parkSectionCodeList);
|
||||
}
|
||||
|
||||
|
@ -235,7 +274,8 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
@Override
|
||||
public void updateUserRouting(Long routingId, RunPlanRoutingVO routingVO) {
|
||||
MapVO map = this.iMapService.getMapDetail(routingVO.getMapId());
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(map);
|
||||
SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildMapDeviceData(
|
||||
map);
|
||||
BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(),
|
||||
"地图基础数据校验不通过");
|
||||
Map<String, MapElement> deviceMap = buildResult.getDeviceMap();
|
||||
|
@ -243,11 +283,13 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
RunPlanRouting newRouting = routingVO.convert2Entity();
|
||||
newRouting.setId(routingId);
|
||||
RunPlanRouting routing = getRunPlanRoutingData(routingId);
|
||||
if(Objects.equals(routing.getSectionData(),JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList()))){
|
||||
if (Objects.equals(routing.getSectionData(),
|
||||
JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList()))) {
|
||||
runPlanRoutingDAO.updateByPrimaryKey(newRouting);
|
||||
return;
|
||||
}
|
||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO), "交路数据重复");
|
||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(routingDataExist(routingVO),
|
||||
"交路数据重复");
|
||||
runPlanRoutingDAO.updateByPrimaryKeyWithBLOBs(newRouting);
|
||||
generateUserRunlevels(routingVO, deviceMap);
|
||||
generateUserParktimes(routingVO, deviceMap);
|
||||
|
@ -268,8 +310,10 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
}
|
||||
}
|
||||
|
||||
private void generateUserParktimes(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
|
||||
List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(routingVO);
|
||||
private void generateUserParktimes(RunPlanRoutingVO routingVO,
|
||||
Map<String, MapElement> deviceMap) {
|
||||
List<RunPlanParkingTimeVO> parkingTimeVOS = RunPlanParkingTimeVO.parkingTimeFromRouting(
|
||||
routingVO);
|
||||
parkingTimeVOS.forEach(p -> {
|
||||
if (((Section) deviceMap.get(p.getSectionCode())).isStandTrack()) {
|
||||
planParktimeService.createUserParktime(p);
|
||||
|
@ -277,7 +321,8 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
});
|
||||
}
|
||||
|
||||
private void generateUserRunlevels(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
|
||||
private void generateUserRunlevels(RunPlanRoutingVO routingVO,
|
||||
Map<String, MapElement> deviceMap) {
|
||||
List<RunPlanRunlevelVO> levels = RunPlanRunlevelVO.runLevelsFromRouting(routingVO);
|
||||
levels.forEach(l -> {
|
||||
Section startSection = (Section) deviceMap.get(l.getStartSectionCode());
|
||||
|
@ -286,7 +331,8 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
|| (endSection.isTurnBackTrack() && !endSection.isStandTrack())) {
|
||||
return;
|
||||
}
|
||||
if ((startSection.isStandTrack() && endSection.isTransferTrack()) || (endSection.isStandTrack() && startSection.isTransferTrack())) {
|
||||
if ((startSection.isStandTrack() && endSection.isTransferTrack()) || (
|
||||
endSection.isStandTrack() && startSection.isTransferTrack())) {
|
||||
Float distance;
|
||||
try {
|
||||
distance = CalculateService.calculateDistance(startSection, endSection, l.getRight());
|
||||
|
@ -305,19 +351,22 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
});
|
||||
}
|
||||
|
||||
private void generateUserStationReentryTimes(RunPlanRoutingVO routingVO, Map<String, MapElement> deviceMap) {
|
||||
RunPlanUserConfigVO userConfig = planConfigService.getConfig(routingVO.getUserId(), routingVO.getMapId());
|
||||
private void generateUserStationReentryTimes(RunPlanRoutingVO routingVO,
|
||||
Map<String, MapElement> deviceMap) {
|
||||
RunPlanUserConfigVO userConfig = planConfigService.getConfig(routingVO.getUserId(),
|
||||
routingVO.getMapId());
|
||||
Map<String, RunPlanUserConfigVO.ReentryTime> reentryData;
|
||||
if (Objects.nonNull(userConfig)) {
|
||||
reentryData = userConfig.getConfig().getReentryData();
|
||||
}else{
|
||||
} else {
|
||||
RunPlanUserConfigVO.Config config = new RunPlanUserConfigVO.Config();
|
||||
reentryData = config.getReentryData();
|
||||
userConfig = new RunPlanUserConfigVO( routingVO.getMapId(),routingVO.getUserId(),config);
|
||||
userConfig = new RunPlanUserConfigVO(routingVO.getMapId(), routingVO.getUserId(), config);
|
||||
}
|
||||
//交路是折返轨的一头 设置折返时间
|
||||
setStationReentryTime(deviceMap, reentryData, routingVO);
|
||||
planConfigService.saveConfig(routingVO.getUserId(), routingVO.getMapId(),userConfig.getConfig());
|
||||
planConfigService.saveConfig(routingVO.getUserId(), routingVO.getMapId(),
|
||||
userConfig.getConfig());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -334,7 +383,8 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PageVO<RunPlanRoutingVO> queryPagedUserRouting(Long userId, Long mapId, RunPlanRoutingQueryVO queryVO) {
|
||||
public PageVO<RunPlanRoutingVO> queryPagedUserRouting(Long userId, Long mapId,
|
||||
RunPlanRoutingQueryVO queryVO) {
|
||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
RunPlanRoutingExample example = new RunPlanRoutingExample();
|
||||
example.setOrderByClause("user_id DESC,id");
|
||||
|
@ -358,8 +408,10 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
criteria.andEndSectionCodeEqualTo(queryVO.getEndSectionCode());
|
||||
or.andEndSectionCodeEqualTo(queryVO.getEndSectionCode());
|
||||
}
|
||||
Page<RunPlanRouting> page = (Page<RunPlanRouting>) runPlanRoutingDAO.selectByExampleWithBLOBs(example);
|
||||
List<RunPlanRoutingVO> routingVOList = page.getResult().stream().map(RunPlanRoutingVO::convert2VO).collect(Collectors.toList());
|
||||
Page<RunPlanRouting> page = (Page<RunPlanRouting>) runPlanRoutingDAO.selectByExampleWithBLOBs(
|
||||
example);
|
||||
List<RunPlanRoutingVO> routingVOList = page.getResult().stream()
|
||||
.map(RunPlanRoutingVO::convert2VO).collect(Collectors.toList());
|
||||
return PageVO.convert(page, routingVOList);
|
||||
}
|
||||
|
||||
|
@ -377,16 +429,18 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId);
|
||||
example.or().andMapIdEqualTo(mapId).andUserIdIsNull();
|
||||
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExample(example);
|
||||
return RunPlanRoutingVO.convert2VOList(runPlanRoutings,this.iMapService.getMapDetail(mapId));
|
||||
return RunPlanRoutingVO.convert2VOList(runPlanRoutings, this.iMapService.getMapDetail(mapId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RunPlanRoutingVO> getUserRoutingByType(Long userId, Long mapId, RunPlanRoutingVO.UserRoutingType routingType) {
|
||||
public List<RunPlanRoutingVO> getUserRoutingByType(Long userId, Long mapId,
|
||||
RunPlanRoutingVO.UserRoutingType routingType) {
|
||||
RunPlanRoutingExample example = new RunPlanRoutingExample();
|
||||
example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId).andTypeEqualTo(routingType.name());
|
||||
example.createCriteria().andMapIdEqualTo(mapId).andUserIdEqualTo(userId)
|
||||
.andTypeEqualTo(routingType.name());
|
||||
example.or().andMapIdEqualTo(mapId).andUserIdIsNull().andTypeEqualTo(routingType.name());
|
||||
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
|
||||
return RunPlanRoutingVO.convert2VOList(runPlanRoutings,this.iMapService.getMapDetail(mapId));
|
||||
return RunPlanRoutingVO.convert2VOList(runPlanRoutings, this.iMapService.getMapDetail(mapId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -397,34 +451,46 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
.findFirst()
|
||||
.orElseThrow(() -> BusinessExceptionAssertEnum.DATA_NOT_EXIST.exception());
|
||||
RunPlanRoutingExample example = new RunPlanRoutingExample();
|
||||
example.createCriteria().andMapIdEqualTo(planVO.getMapId()).andUserIdEqualTo(userId).andStartSectionCodeEqualTo(trip.getStartSectionCode()).andEndSectionCodeEqualTo(trip.getEndSectionCode());
|
||||
example.or().andMapIdEqualTo(planVO.getMapId()).andUserIdIsNull().andStartSectionCodeEqualTo(trip.getStartSectionCode()).andEndSectionCodeEqualTo(trip.getEndSectionCode());
|
||||
example.createCriteria().andMapIdEqualTo(planVO.getMapId()).andUserIdEqualTo(userId)
|
||||
.andStartSectionCodeEqualTo(trip.getStartSectionCode())
|
||||
.andEndSectionCodeEqualTo(trip.getEndSectionCode());
|
||||
example.or().andMapIdEqualTo(planVO.getMapId()).andUserIdIsNull()
|
||||
.andStartSectionCodeEqualTo(trip.getStartSectionCode())
|
||||
.andEndSectionCodeEqualTo(trip.getEndSectionCode());
|
||||
List<RunPlanRouting> runPlanRoutings = runPlanRoutingDAO.selectByExampleWithBLOBs(example);
|
||||
if (CollectionUtils.isEmpty(runPlanRoutings)) return null;
|
||||
return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0), this.iMapService.getMapDetail(planVO.getMapId()));
|
||||
if (CollectionUtils.isEmpty(runPlanRoutings)) {
|
||||
return null;
|
||||
}
|
||||
return RunPlanRoutingVO.convert2VO(runPlanRoutings.get(0),
|
||||
this.iMapService.getMapDetail(planVO.getMapId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RunPlanRoutingVO queryUserRoutingById(Long userId, Long mapId, Long routingId) {
|
||||
RunPlanRouting runPlanRouting = getRunPlanRoutingData(routingId);
|
||||
return RunPlanRoutingVO.convert2VO(runPlanRouting,this.iMapService.getMapDetail(mapId));
|
||||
return RunPlanRoutingVO.convert2VO(runPlanRouting, this.iMapService.getMapDetail(mapId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RunPlanRoutingSection> getRoutingSectionDataBy(Long userId, Long routingId) {
|
||||
RunPlanRouting routing = runPlanRoutingDAO.selectByPrimaryKey(routingId);
|
||||
if (Objects.isNull(routing)) return Collections.emptyList();
|
||||
if (Objects.isNull(routing)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return RunPlanRoutingVO.convert2VO(routing).getParkSectionCodeList();
|
||||
}
|
||||
|
||||
|
||||
private boolean routingDataExist(RunPlanRoutingVO routingVO) {
|
||||
return runPlanRoutingDAO.countUserRoutingBySectionData(routingVO.getUserId(), routingVO.getMapId(), JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList())) > 0;
|
||||
return
|
||||
runPlanRoutingDAO.countUserRoutingBySectionData(routingVO.getUserId(), routingVO.getMapId(),
|
||||
JsonUtils.writeValueAsString(routingVO.getParkSectionCodeList())) > 0;
|
||||
}
|
||||
|
||||
private RunPlanRouting getRunPlanRoutingData(Long routingId) {
|
||||
RunPlanRouting routing = runPlanRoutingDAO.selectByPrimaryKey(routingId);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(routing, String.format("交路[%s]不存在", routingId));
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(routing,
|
||||
String.format("交路[%s]不存在", routingId));
|
||||
return routing;
|
||||
}
|
||||
|
||||
|
@ -433,7 +499,8 @@ public class RunPlanRoutingService implements IRunPlanRoutingService {
|
|||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(runPlanDraft);
|
||||
RunPlanVO runPlanVO = new RunPlanVO(runPlanDraft);
|
||||
if (StringUtils.hasText(runPlanDraft.getTrips())) {
|
||||
runPlanVO.setTripList(JsonUtils.read(runPlanDraft.getTrips(), JsonUtils.getCollectionType(List.class, RunPlanTripVO.class)));
|
||||
runPlanVO.setTripList(JsonUtils.read(runPlanDraft.getTrips(),
|
||||
JsonUtils.getCollectionType(List.class, RunPlanTripVO.class)));
|
||||
} else {
|
||||
runPlanVO.setTripList(new ArrayList<>());
|
||||
}
|
||||
|
|
|
@ -9,15 +9,14 @@ import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
|||
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* 地面ATP逻辑循环
|
||||
|
@ -38,15 +37,17 @@ public class AtpSectionService {
|
|||
for (VirtualRealityTrain train : onlineTrainList) {
|
||||
List<Section> atpSectionList = trainAtpSectionMap.get(train.getGroupNumber());
|
||||
List<Section> physicalList = this.convert2PhysicalSectionList(atpSectionList);
|
||||
if (train.isCommunicable() && signal.containsApproachAtpSection(atpSectionList)) { //存在通信车接近,继续
|
||||
if (train.isCommunicable() && signal.containsApproachAtpSection(
|
||||
atpSectionList)) { //存在通信车接近,继续
|
||||
a = 1;
|
||||
} else if (!train.isCommunicable() && signal.containsApproachPhysicalSection(physicalList)) { //存在非通信车接近,结束
|
||||
} else if (!train.isCommunicable() && signal.containsApproachPhysicalSection(
|
||||
physicalList)) { //存在非通信车接近,结束
|
||||
a = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (1 == a) { // 只有通信车接近
|
||||
if(!signal.getSignalModel().getGuideAspect().equals(signal.getAspect())) {
|
||||
if (!signal.getSignalModel().getGuideAspect().equals(signal.getAspect())) {
|
||||
signal.changeToCbtcMode();
|
||||
}
|
||||
} else if (2 == a) { // 有非通信车接近
|
||||
|
@ -88,7 +89,8 @@ public class AtpSectionService {
|
|||
if (train.isCommunicable() || isRailway) { // 通信车占用 或者 大铁配置
|
||||
// 车尾位置追加不确定性距离:(速度*2)m
|
||||
SectionPosition trainTailPosition = CalculateService
|
||||
.calculateNextPositionByStartAndLen(trainHeadPosition, !right, train.getLen() + train.getSpeed() * 2, false);
|
||||
.calculateNextPositionByStartAndLen(trainHeadPosition, !right,
|
||||
train.getLen() + train.getSpeed() * 2, false);
|
||||
atpSectionList = CalculateService.getAtpSections(trainHeadPosition, trainTailPosition,
|
||||
right, switchSingleHandle);
|
||||
List<Section> removes = new ArrayList<>();
|
||||
|
@ -98,7 +100,8 @@ public class AtpSectionService {
|
|||
if (parent != null) {
|
||||
axle = parent;
|
||||
}
|
||||
if (axle.isAxleCounter() && (!axle.isNctOccupied() || Section.AxleFault.FAULT.equals(axle.getFault()))) {
|
||||
if (axle.isAxleCounter() && (!axle.isNctOccupied() || Section.AxleFault.FAULT.equals(
|
||||
axle.getFault()))) {
|
||||
removes.add(atpSection);
|
||||
continue;
|
||||
}
|
||||
|
@ -138,22 +141,23 @@ public class AtpSectionService {
|
|||
*/
|
||||
public void sectionARBCheck(Simulation simulation, Section section, List<Section> sectionList) {
|
||||
//目前ARB故障才会导致ARB判定
|
||||
if (Section.AxleFault.ARB.equals(section.getFault()) && section.getVirtualAxleCounter().isOccupy()) {
|
||||
if (Section.AxleFault.ARB.equals(section.getFault()) && section.getVirtualAxleCounter()
|
||||
.isOccupy()) {
|
||||
if (!sectionList.contains(section)) {
|
||||
section.judgeAsARB();
|
||||
} else {
|
||||
section.setFault(Section.AxleFault.FAULT);
|
||||
}
|
||||
} else if (Section.AxleFault.FAULT.equals(section.getFault()) && section.getVirtualAxleCounter().isOccupy()) {
|
||||
} else if (Section.AxleFault.FAULT.equals(section.getFault()) && section.getVirtualAxleCounter()
|
||||
.isOccupy()) {
|
||||
section.judgeAsNctOccupied(simulation);
|
||||
}
|
||||
if (/*!section.isInvalid() &&*/ section.isNctOccupied()) {
|
||||
if (!sectionList.contains(section)) {
|
||||
section.judgeAsNctOccupied(simulation);
|
||||
}
|
||||
}
|
||||
//ARB故障恢复判断
|
||||
if (Section.AxleFault.ARB.equals(section.getFault()) && !section.getVirtualAxleCounter().isOccupy()) {
|
||||
if (Section.AxleFault.ARB.equals(section.getFault()) && !section.getVirtualAxleCounter()
|
||||
.isOccupy()) {
|
||||
Section.AxleFault.ARB.fix(section);
|
||||
}
|
||||
}
|
||||
|
@ -165,12 +169,14 @@ public class AtpSectionService {
|
|||
* @param trainList
|
||||
* @return
|
||||
*/
|
||||
public List<Section> getTrainExistAxleSectionsUnderDelay(Simulation simulation, List<VirtualRealityTrain> trainList) {
|
||||
public List<Section> getTrainExistAxleSectionsUnderDelay(Simulation simulation,
|
||||
List<VirtualRealityTrain> trainList) {
|
||||
List<Section> list = new ArrayList<>();
|
||||
for (VirtualRealityTrain train : trainList) {
|
||||
//只统计非通信车
|
||||
if (train.isCommunicable())
|
||||
if (train.isCommunicable()) {
|
||||
continue;
|
||||
}
|
||||
boolean right = train.isRight();
|
||||
SectionPosition headPosition = train.getHeadPosition();
|
||||
float offset = 50;
|
||||
|
@ -195,7 +201,8 @@ public class AtpSectionService {
|
|||
return list;
|
||||
}
|
||||
|
||||
public void removeOfflineTrainOccupySections(Simulation simulation, List<VirtualRealityTrain> onlineTrainList) {
|
||||
public void removeOfflineTrainOccupySections(Simulation simulation,
|
||||
List<VirtualRealityTrain> onlineTrainList) {
|
||||
// 移除已经下线的列车占用区段数据
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
Set<String> oldTOSKeyList = repository.queryTrainOccupySectionKeys();
|
||||
|
@ -238,7 +245,8 @@ public class AtpSectionService {
|
|||
do {
|
||||
atpSectionList.add(0, nextSection);
|
||||
nextSection = nextSection.getNextRunningSectionOf(!right);
|
||||
} while (nextSection.getRelSwitch() != null && relSwitchList.contains(nextSection.getRelSwitch()));
|
||||
} while (nextSection.getRelSwitch() != null && relSwitchList.contains(
|
||||
nextSection.getRelSwitch()));
|
||||
// 反位后区段列表
|
||||
nextSection = relSwitch.getA().getNextRunningSectionOf(right);
|
||||
while (nextSection != null && relSwitchList.contains(nextSection.getRelSwitch())) {
|
||||
|
|
|
@ -11,7 +11,14 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
|
|||
import club.joylink.rtss.simulation.cbtc.constant.TrainType;
|
||||
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.DestinationCodeDefinition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Routing;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.SectionRunPath;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
|
||||
|
@ -24,16 +31,20 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
|||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService;
|
||||
import club.joylink.rtss.vo.client.operation.DriveParamVO;
|
||||
import java.time.LocalTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* ATS列车服务
|
||||
*/
|
||||
|
@ -183,12 +194,12 @@ public class AtsTrainService {
|
|||
StationPlan stationPlan = planList.get(i);
|
||||
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(stationPlan.getSection(), phySection);
|
||||
if (!CollectionUtils.isEmpty(routePaths)) {
|
||||
nextPlan = stationPlan;
|
||||
if (routePaths.get(0).isRight() != tripPlan.isRight()) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
nextPlan = stationPlan;
|
||||
// } else {
|
||||
// break;
|
||||
}
|
||||
}
|
||||
if (Objects.isNull(nextPlan)) {
|
||||
|
|
|
@ -5,6 +5,7 @@ import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
|
|||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
||||
import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService;
|
||||
import java.util.Objects;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -22,10 +23,10 @@ public class CiSignalControlService {
|
|||
* @return
|
||||
*/
|
||||
private boolean couldOpenLogicAspect(Signal signal, SignalAspect aspect) {
|
||||
if(signal.getSignalModel().getGuideAspect().equals(aspect)) {
|
||||
if (Objects.equals(signal.getSignalModel().getGuideAspect(), aspect)) {
|
||||
return false;
|
||||
}
|
||||
if (signal.getSignalModel().getDefaultAspect().equals(aspect)) {
|
||||
if (Objects.equals(signal.getSignalModel().getDefaultAspect(), aspect)) {
|
||||
return true;
|
||||
}
|
||||
// else if (aspect.equals(signal.getSignalModel().getGuideAspect()) && signal.isHigherThanGuideLevel()) {
|
||||
|
|
|
@ -3,24 +3,66 @@ package club.joylink.rtss.simulation.cbtc.build;
|
|||
import club.joylink.rtss.constants.BusinessConsts;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SignalModel;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.*;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.AutoSignal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Catenary;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.DirectionRod;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.DisStation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.ESP;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.PSD;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Responder;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Server;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.ZC;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.*;
|
||||
import club.joylink.rtss.vo.map.MapCISwitchVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityGate;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
|
||||
import club.joylink.rtss.vo.map.MapVO;
|
||||
import club.joylink.rtss.vo.map.RealLineConfigVO;
|
||||
import club.joylink.rtss.vo.map.graph.*;
|
||||
import club.joylink.rtss.vo.map.graph.MapDirectionRodVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapESPVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapPSDVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapPowerLineVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapResponderVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapSectionNewVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapSignalNewVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapStationStandNewVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapSwitchVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapTrainModelVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapTrainVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapTurnBackStrategyVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapZcVO;
|
||||
import club.joylink.rtss.vo.map.logic.MapDisStationNewVO;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 地图设备校验/构建器
|
||||
*/
|
||||
|
@ -289,22 +331,22 @@ public class MapDeviceBuilder {
|
|||
.filter(mapElement -> Objects.equals(mapElement.getDeviceType(), MapElement.DeviceType.STATION))
|
||||
.map(mapElement -> ((Station) mapElement))
|
||||
.collect(Collectors.toList());
|
||||
stations.forEach(station -> {
|
||||
if (station.isDepot()) { // 是车辆段/停车场
|
||||
if (CollectionUtils.isEmpty(station.getTransferList())) {
|
||||
errMsgList.add(String.format("车站[%s(%s)]是停车场/车辆段,却没有找到任何转换轨",
|
||||
station.getName(), station.getCode()));
|
||||
}
|
||||
} else if (station.isTurnBack()) {//是折返站
|
||||
if (CollectionUtils.isEmpty(station.getTurnBackList())) {
|
||||
errMsgList.add(String.format("车站[%s(%s)]是折返站,却没有任何折返区段关联",
|
||||
station.getName(), station.getCode()));
|
||||
}
|
||||
// if (CollectionUtils.isEmpty(station.getTbStrategyMap())) {
|
||||
// errMsgList.add(String.format("车站[%s(%s)]是折返站,却没有折返策略"));
|
||||
// stations.forEach(station -> {
|
||||
// if (station.isDepot()) { // 是车辆段/停车场
|
||||
// if (CollectionUtils.isEmpty(station.getTransferList())) {
|
||||
// errMsgList.add(String.format("车站[%s(%s)]是停车场/车辆段,却没有找到任何转换轨",
|
||||
// station.getName(), station.getCode()));
|
||||
// }
|
||||
}
|
||||
});
|
||||
// } else if (station.isTurnBack()) {//是折返站
|
||||
// if (CollectionUtils.isEmpty(station.getTurnBackList())) {
|
||||
// errMsgList.add(String.format("车站[%s(%s)]是折返站,却没有任何折返区段关联",
|
||||
// station.getName(), station.getCode()));
|
||||
// }
|
||||
//// if (CollectionUtils.isEmpty(station.getTbStrategyMap())) {
|
||||
//// errMsgList.add(String.format("车站[%s(%s)]是折返站,却没有折返策略"));
|
||||
//// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1040,6 +1082,10 @@ public class MapDeviceBuilder {
|
|||
if (section.isStandTrack() && !section.isNormalStandTrack()) {
|
||||
errMsgList.add(String.format("区段[%s]不是正常站台的站台轨,却设置了站台轨属性", section.debugStr()));
|
||||
}
|
||||
//为了兼容中航的奇葩沙盘
|
||||
if (section.isTransferTrack() && section.isTurnBackTrack()) {
|
||||
continue;
|
||||
}
|
||||
if (section.isTransferTrack() && (section.getStation() == null || !section.getStation().isDepot())) {
|
||||
errMsgList.add(String.format("区段[%s]所属车站不是车辆段/停车场车站,却设置了转换轨属性", section.debugStr()));
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import club.joylink.rtss.entity.MapDataExample;
|
|||
import club.joylink.rtss.entity.MapDataWithBLOBs;
|
||||
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.ngy.service.NgyTrainServiceImpl;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.service.SrTrainServiceImpl;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.thailand.service.ThailandTrainServiceImpl;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
|
@ -26,6 +27,8 @@ public class SandTableTrainController {
|
|||
private ThailandTrainServiceImpl thailandTrainService;
|
||||
@Autowired
|
||||
private SrTrainServiceImpl srTrainService;
|
||||
@Autowired
|
||||
private NgyTrainServiceImpl ngyTrainService;
|
||||
|
||||
@PutMapping("/{simulationId}/control")
|
||||
public void control(@PathVariable String simulationId, String groupNumber, boolean right,
|
||||
|
@ -38,6 +41,9 @@ public class SandTableTrainController {
|
|||
case ProjectCode.SR_SANDBOX:
|
||||
srTrainService.controlTrain(simulationId, groupNumber, right, speed);
|
||||
break;
|
||||
case ProjectCode.NGY_SAND_TABLE:
|
||||
ngyTrainService.controlTrain(simulationId, groupNumber, right, speed);
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ import io.netty.channel.nio.NioEventLoopGroup;
|
|||
import io.netty.channel.socket.DatagramPacket;
|
||||
import io.netty.channel.socket.nio.NioDatagramChannel;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -60,7 +59,6 @@ public class UDPClient implements ApplicationRunner {
|
|||
public void write(InetSocketAddress addr, byte[] msg) {
|
||||
if (msg != null) {
|
||||
msgQueue.add(new Msg(addr, msg));
|
||||
System.out.println(LocalDateTime.now());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,21 +5,30 @@ import io.netty.buffer.ByteBuf;
|
|||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.SimpleChannelInboundHandler;
|
||||
import io.netty.channel.socket.DatagramPacket;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class UDPMessageHandler extends SimpleChannelInboundHandler<DatagramPacket> {
|
||||
@Autowired
|
||||
private UDPRealDeviceThread udpRealDeviceThread;
|
||||
|
||||
Map<Integer, Long> map = new HashMap<>();
|
||||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, DatagramPacket datagramPacket) {
|
||||
InetSocketAddress sender = datagramPacket.sender();
|
||||
String ip = sender.getHostString();
|
||||
int port = sender.getPort();
|
||||
long time = System.currentTimeMillis();
|
||||
map.putIfAbsent(port, time);
|
||||
log.info("{}::{}",port, time - map.get(port));
|
||||
map.put(port, time);
|
||||
ByteBuf content = datagramPacket.content();
|
||||
udpRealDeviceThread.handleData(ip, port, content);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,30 @@ public class NgySectionServiceImpl implements UDPRealDeviceService {
|
|||
|
||||
@Override
|
||||
public void run(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
|
||||
// // TODO: 2023/7/5 模拟计轴占压数据
|
||||
// List<VirtualRealityTrain> trainList = simulation.getRepository().getOnlineTrainList();
|
||||
// LocalDateTime now = LocalDateTime.now();
|
||||
// for (VirtualRealityTrain train : trainList) {
|
||||
// LocalDateTime time = map.computeIfAbsent(train, K -> now.plusSeconds(7));
|
||||
// Section section = train.getHeadPosition().getSection();
|
||||
// VirtualRealitySectionAxleCounter currentAxle = section.findAxle();
|
||||
// if (!train.isStop() && !now.isBefore(time)) {
|
||||
// Section nextSection = section.getNextRunningSectionOf(train.isRight());
|
||||
// if (nextSection == null) {
|
||||
// continue;
|
||||
// }
|
||||
// VirtualRealitySectionAxleCounter nextAxle = nextSection.findAxle();
|
||||
// if (nextAxle != currentAxle) {
|
||||
// nextAxle.occupied(train.isRight());
|
||||
// currentAxle.setOccupy(false);
|
||||
// }
|
||||
// if (section.isFunctionTrack()) {
|
||||
// map.put(train, time.plusSeconds(7));
|
||||
// } else {
|
||||
// map.put(train, time.plusSeconds(2));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,11 +95,11 @@ public class NgySectionServiceImpl implements UDPRealDeviceService {
|
|||
config.setTimesOfRelease(0);
|
||||
axle.setOccupy(true);
|
||||
} else if (n == 85) {
|
||||
// config.setTimesOfRelease(config.getTimesOfRelease() + 1);
|
||||
// if (config.getTimesOfRelease() > 2) { //连续3次该计轴都是无占用状态,才视为确实无占用
|
||||
config.setTimesOfRelease(config.getTimesOfRelease() + 1);
|
||||
if (config.getTimesOfRelease() > 1) { //连续2次该计轴都是无占用状态,才视为确实无占用
|
||||
config.setTimesOfRelease(0);
|
||||
axle.clear();
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClient;
|
|||
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceService;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSectionConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSectionConfigVO;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableTrainConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
|
||||
import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
|
||||
import club.joylink.rtss.vo.client.project.thailand.ThailandSectionConfigVO;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Objects;
|
||||
|
@ -32,6 +32,7 @@ import java.util.Optional;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
|
@ -99,6 +100,11 @@ public class NgyTrainServiceImpl implements UDPRealDeviceService {
|
|||
udpClient.write(udpLowConfig.getAddr(), data);
|
||||
//清除状态
|
||||
config.updateHeadSection(null);
|
||||
//设置停站时间
|
||||
simulation.getRepository().getStandList().forEach(stand -> {
|
||||
stand.setParkingTime(10);
|
||||
stand.setParkingAlwaysValid(true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -163,10 +169,11 @@ public class NgyTrainServiceImpl implements UDPRealDeviceService {
|
|||
if (previousSection != null && !previousSection.isOccupied()) {
|
||||
delayOfNano = (long) (sectionConfig.getConfigVO().getTailDelayTime() * rate);
|
||||
}
|
||||
} else { //未设置则认为车头占压即刻停车
|
||||
delayOfNano = 0L;
|
||||
} else { //未设置
|
||||
delayOfNano = (long) (0 * rate);
|
||||
}
|
||||
if (delayOfNano != null) {
|
||||
System.out.printf("设置延时%s%d%n", headSection.getName(), delayOfNano);
|
||||
config.setTimeOfArriveStopPoint(now.plusNanos(delayOfNano));
|
||||
}
|
||||
}
|
||||
|
@ -179,11 +186,11 @@ public class NgyTrainServiceImpl implements UDPRealDeviceService {
|
|||
if (stopPosition != null && stopPosition.getSection().equals(headSection)) {
|
||||
train.setHeadPosition(stopPosition);
|
||||
} else {
|
||||
float offset = right ? headSection.getMaxOffset() : 0;
|
||||
float offset = headSection.getEndOffsetByDirection(right);
|
||||
train.setHeadPosition(new SectionPosition(headSection, offset));
|
||||
}
|
||||
}
|
||||
//更新速度。由于沙盘对延时要求很高,机器人驾驶逻辑频率有点低,所以选择不利用机器人驾驶的逻辑
|
||||
|
||||
if (config.getManualGear() != null) {
|
||||
return;
|
||||
}
|
||||
|
@ -193,6 +200,22 @@ public class NgyTrainServiceImpl implements UDPRealDeviceService {
|
|||
return;
|
||||
}
|
||||
}
|
||||
// 列车停站判断调头
|
||||
if (train.isParkingAt()) {
|
||||
TrainInfo trainInfo = simulation.getRepository()
|
||||
.findSupervisedTrainByGroup(train.getGroupNumber());
|
||||
if (trainInfo != null) {
|
||||
if (StringUtils.hasText(trainInfo.getEstimatedArriveStandTrack())) {
|
||||
Section target = simulation.getRepository()
|
||||
.getByCode(trainInfo.getEstimatedArriveStandTrack(), Section.class);
|
||||
if (CalculateService.isTargetSectionOnDirectionExist(headSection, !right, target)
|
||||
&& !Objects.equals(target, headSection)) {
|
||||
atpService.turnDirectionImmediately(train);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//更新速度。由于沙盘对延时要求很高,机器人驾驶逻辑频率有点低,所以选择不利用机器人驾驶的逻辑
|
||||
if (stopPosition != null) {
|
||||
Float distance = CalculateService.calculateDistance(train.getHeadPosition(), stopPosition,
|
||||
right, false);
|
||||
|
@ -206,14 +229,6 @@ public class NgyTrainServiceImpl implements UDPRealDeviceService {
|
|||
train.setSpeed(lowSpeed);
|
||||
return;
|
||||
}
|
||||
if (stopPosition.getSection().isStandTrack()) {
|
||||
Section stopPreviousSection = stopPosition.getSection().getNextRunningSectionOf(!right);
|
||||
if (stopPreviousSection != null && Objects.equals(stopPreviousSection.findAxle(),
|
||||
headSection.findAxle())) { //当前车头在站台轨的前一个计轴区段
|
||||
train.setSpeed(lowSpeed);
|
||||
return;
|
||||
}
|
||||
}
|
||||
train.setSpeed(highSpeed);
|
||||
} else {
|
||||
train.setSpeed(0);
|
||||
|
@ -258,7 +273,7 @@ public class NgyTrainServiceImpl implements UDPRealDeviceService {
|
|||
gear = (int) Math.ceil(speedKmPh / 10);
|
||||
gear = Math.max(1, gear);
|
||||
}
|
||||
if (train.isRight()) { //档位1-5是正向,6-10是反向
|
||||
if (!train.isRight()) { //档位1-5是正向,6-10是反向
|
||||
gear += 5;
|
||||
}
|
||||
}
|
||||
|
@ -276,96 +291,39 @@ public class NgyTrainServiceImpl implements UDPRealDeviceService {
|
|||
/**
|
||||
* 此方法用于调试,调试完成后方法内的数据请保存到项目设备配置
|
||||
*/
|
||||
public void fill(Section section, ThailandSectionConfigVO configVO) {
|
||||
public void fill(Section section, SandTableSectionConfigVO configVO) {
|
||||
Float headDelayTime = null;
|
||||
Float tailDelayTime = null;
|
||||
if (section.isStandTrack()) { //站台轨默认为车尾出清立即停车
|
||||
headDelayTime = 5f;
|
||||
if (section.isFunctionTrack()) {
|
||||
if (section.isStandTrack()) {
|
||||
tailDelayTime = 1f;
|
||||
} else {
|
||||
tailDelayTime = 0f;
|
||||
}
|
||||
} else {
|
||||
headDelayTime = 2f;
|
||||
}
|
||||
switch (section.getCode()) {
|
||||
case "T233": //X302G
|
||||
headDelayTime = 7.3f;
|
||||
case "T68": // 43G
|
||||
tailDelayTime = 1.4f;
|
||||
break;
|
||||
case "T232": //X303G
|
||||
headDelayTime = 6.5f;
|
||||
case "T62": //37G
|
||||
tailDelayTime = 0.8f;
|
||||
break;
|
||||
case "T231": //X304G
|
||||
headDelayTime = 5.5f;
|
||||
case "T35": //9G
|
||||
tailDelayTime = 1.3f;
|
||||
break;
|
||||
case "T178": //4站-3G
|
||||
headDelayTime = 5.2f;
|
||||
case "T33": //5G
|
||||
tailDelayTime = 0.9f;
|
||||
break;
|
||||
case "T177": //4站-IG
|
||||
headDelayTime = 5.4f;
|
||||
case "T5": //8G
|
||||
tailDelayTime = 0.8f;
|
||||
break;
|
||||
case "T175": //4站-IIG
|
||||
headDelayTime = 6.6f;
|
||||
case "T7": //12G
|
||||
tailDelayTime = 0.6f;
|
||||
break;
|
||||
case "T174": //4站-4G
|
||||
headDelayTime = 6.2f;
|
||||
break;
|
||||
case "T176": //4站-6G
|
||||
headDelayTime = 5.9f;
|
||||
break;
|
||||
case "T179": //4站-5G
|
||||
headDelayTime = 6.5f;
|
||||
break;
|
||||
case "T123": //3站-3G
|
||||
headDelayTime = 5.2f;
|
||||
break;
|
||||
case "T122": //3站-IG
|
||||
headDelayTime = 5.3f;
|
||||
break;
|
||||
case "T121": //3站-IIG
|
||||
headDelayTime = 5.9f;
|
||||
break;
|
||||
case "T120": //3站-4G
|
||||
headDelayTime = 5.5f;
|
||||
break;
|
||||
case "T78": //2站-IG
|
||||
headDelayTime = 5.5f;
|
||||
break;
|
||||
case "T77": //2站-IIG
|
||||
headDelayTime = 5.9f;
|
||||
break;
|
||||
case "T76": //2站-4G
|
||||
headDelayTime = 5.7f;
|
||||
break;
|
||||
case "T22": //1站-1G
|
||||
headDelayTime = 5.3f;
|
||||
break;
|
||||
case "T23": //1站-IIG
|
||||
headDelayTime = 5.1f;
|
||||
break;
|
||||
case "T27": //1站-5G
|
||||
headDelayTime = 4.9f;
|
||||
break;
|
||||
case "T26": //1站-3G
|
||||
headDelayTime = 4.8f;
|
||||
break;
|
||||
case "T24": //1站-4G
|
||||
headDelayTime = 5.1f;
|
||||
break;
|
||||
case "T25": //1站-6G
|
||||
headDelayTime = 5.1f;
|
||||
break;
|
||||
case "T145": //QX04
|
||||
headDelayTime = 1.9f;
|
||||
break;
|
||||
case "T146": //QS04
|
||||
headDelayTime = 2.7f;
|
||||
break;
|
||||
case "T104": //QX03
|
||||
tailDelayTime = 0f;
|
||||
break;
|
||||
case "T105": //QS03
|
||||
tailDelayTime = 0f;
|
||||
break;
|
||||
case "T62": //QX02
|
||||
tailDelayTime = 0f;
|
||||
break;
|
||||
case "T63": //QS02
|
||||
tailDelayTime = 0f;
|
||||
case "T45": //24G
|
||||
tailDelayTime = 0.8f;
|
||||
break;
|
||||
}
|
||||
configVO.setHeadDelayTime(headDelayTime);
|
||||
|
@ -382,10 +340,10 @@ public class NgyTrainServiceImpl implements UDPRealDeviceService {
|
|||
atpService.turnDirectionImmediately(train);
|
||||
}
|
||||
train.setRobotTargetPosition(null); //终止机器人司机驾驶
|
||||
//加减速
|
||||
if (train.isEB()) {
|
||||
return;
|
||||
}
|
||||
// //加减速
|
||||
// if (train.isEB()) {
|
||||
// return;
|
||||
// }
|
||||
atpService.changeGear(train, VirtualRealityTrain.Handwheel.MANUAL);
|
||||
int manualGear = speed / 10;
|
||||
config.setManualGear(manualGear);
|
||||
|
|
|
@ -256,7 +256,8 @@ public class SimulationRobotService {
|
|||
SignalAspect throughAspect = robotDriveParam.getThroughSignalAspect();
|
||||
Section section = headPosition.getSection();
|
||||
|
||||
if (throughSignal != null && !Objects.equals(section, throughSignal.getSection())) { //当车头与要越过的信号机不在同一区段
|
||||
if (throughSignal != null && !Objects.equals(section,
|
||||
throughSignal.getSection())) { //当车头与要越过的信号机不在同一区段
|
||||
throughSignal = null;
|
||||
throughAspect = null;
|
||||
robotDriveParam.setThrough(DriveParamVO.NO);
|
||||
|
@ -268,40 +269,35 @@ public class SimulationRobotService {
|
|||
// 车头在正常的站台上
|
||||
if (section.isNormalStandTrack() && !section.equals(train.getParkSection())) { //正常站台轨且未在此处停过车
|
||||
// 如果计划停车区段为空或者计划停车区段中有包含当前区段
|
||||
if (CollectionUtils.isEmpty(plannedParkingSections) || plannedParkingSections.contains(section)) {
|
||||
if (CollectionUtils.isEmpty(plannedParkingSections) || plannedParkingSections.contains(
|
||||
section)) {
|
||||
SectionPosition stopPosition = section.buildStopPointPosition(right);
|
||||
if (targetPosition == null || stopPosition.isAheadOf(targetPosition, right)) {
|
||||
if (targetPosition == null || stopPosition.isAheadOf(targetPosition, !right)) {
|
||||
// 如果头部位置偏移小于停车点位置偏移,目标点为当前停车点
|
||||
if (headPosition.getOffset() < (section.getStopPointByDirection(right) + SimulationConstants.PARK_POINT_MAX_OFFSET)) { //防止意外开过站后无法发车
|
||||
if (headPosition.getOffset() < (section.getStopPointByDirection(right)
|
||||
+ SimulationConstants.PARK_POINT_MAX_OFFSET)) { //防止意外开过站后无法发车
|
||||
targetPosition = stopPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 取禁止信号前停车位置与当前目标停车位置中更近的一个
|
||||
Signal signal = section.getSignalOf(right);
|
||||
if (signal != null && !signal.isShunting()) { // 信号机不为调车信号机
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
SectionPosition signalPosition = signal.getPosition();
|
||||
if (vrSignal != null && (i != 0 || signalPosition.isAheadOf(headPosition, right))) { //有实体信号机且列车未越过信号机
|
||||
if (Objects.equals(vrSignal.getAspect(), signal.getDefaultAspect()) //禁止信号
|
||||
|| Objects.equals(vrSignal.getAspect(), signal.getGuideAspect())) { //引导信号
|
||||
if (!Objects.equals(signal, throughSignal) || !Objects.equals(vrSignal.getAspect(), throughAspect)) {
|
||||
SectionPosition noPassPosition = CalculateService.calculateNextPositionByStartAndLen(signalPosition, !right, 2, true);
|
||||
if (targetPosition == null || noPassPosition.isAheadOf(targetPosition, right)) {
|
||||
targetPosition = noPassPosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
targetPosition = updateTargetPositionOfSignal(headPosition, right,
|
||||
throughSignal, throughAspect, section, i, targetPosition, train.isParkingAt());
|
||||
|
||||
Section tempSection = section.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (tempSection != null && tempSection.isOccupied()) {
|
||||
SectionPosition newTP = CalculateService.calculateNextPositionByStartAndLen(
|
||||
new SectionPosition(section, section.getEndOffsetByDirection(!right)), !right, 2, true);
|
||||
if (targetPosition == null || newTP.isAheadOf(targetPosition, !right)) {
|
||||
targetPosition = newTP;
|
||||
}
|
||||
}
|
||||
if (targetPosition == null) {
|
||||
if (selectedPosition != null && section.equals(selectedPosition.getSection())) { //不会有比选定位置更靠前的停车点了
|
||||
if (selectedPosition != null && section.equals(
|
||||
selectedPosition.getSection())) { //不会有比选定位置更靠前的停车点了
|
||||
targetPosition = selectedPosition;
|
||||
} else {
|
||||
Section tempSection = section.findNextRunningSectionBaseRealSwitch(right);
|
||||
if (tempSection == null) { //到了轨道尽头,目标位置为尽头向内10m
|
||||
targetPosition = new SectionPosition(section, right ? section.getLen() - 10 : 10);
|
||||
} else {
|
||||
|
@ -310,13 +306,13 @@ public class SimulationRobotService {
|
|||
}
|
||||
} else {
|
||||
if (selectedPosition != null) {
|
||||
if (selectedPosition.isAheadOf(targetPosition, right)) {
|
||||
if (selectedPosition.isAheadOf(targetPosition, !right)) {
|
||||
targetPosition = selectedPosition;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (selectedPosition != null && selectedPosition.isAheadOf(targetPosition, right)) {
|
||||
if (selectedPosition != null && selectedPosition.isAheadOf(targetPosition, !right)) {
|
||||
targetPosition = selectedPosition;
|
||||
} else {
|
||||
|
||||
|
@ -329,7 +325,53 @@ public class SimulationRobotService {
|
|||
if (targetPosition == null) { //上方的区段遍历完后,即没有找到目标区段,也没有找到轨道尽头
|
||||
targetPosition = new SectionPosition(section, right ? 0 : section.getMaxOffset());
|
||||
}
|
||||
return Optional.ofNullable(targetPosition);
|
||||
return Optional.of(targetPosition);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取以信号机为依据的目标位置
|
||||
*
|
||||
* @param i 区段的索引
|
||||
* @return 如果计算出的targetPosition比参数中的更近,则返回新的,否则返回原来的
|
||||
*/
|
||||
private SectionPosition updateTargetPositionOfSignal(SectionPosition headPosition, boolean right,
|
||||
Signal throughSignal, SignalAspect throughAspect, Section section, int i,
|
||||
SectionPosition targetPosition, boolean parking) {
|
||||
Signal signal = section.getSignalOf(right);
|
||||
if (signal == null || signal.isShunting()) {
|
||||
return targetPosition;
|
||||
}
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
SectionPosition signalPosition = signal.getPosition();
|
||||
if (vrSignal == null || (i == 0 && headPosition.isAheadOf(signalPosition, right))) {
|
||||
//解释下||后面的条件,如果i!=0,则车头位置一定不可能在信号机前方,即i==0只是为了减少计算,对结果没有影响
|
||||
return targetPosition;
|
||||
}
|
||||
if (targetPosition != null && signalPosition.isAheadOf(targetPosition, right)) {
|
||||
//只要目标位置没有越过信号机,则没必要一定和信号机保持2m距离
|
||||
return targetPosition;
|
||||
}
|
||||
if (!Objects.equals(vrSignal.getAspect(), signal.getDefaultAspect())
|
||||
&& !Objects.equals(vrSignal.getAspect(), signal.getGuideAspect())) { //非禁止/引导信号
|
||||
return targetPosition;
|
||||
}
|
||||
if (Objects.equals(signal, throughSignal)
|
||||
&& Objects.equals(vrSignal.getAspect(), throughAspect)) {
|
||||
return targetPosition;
|
||||
}
|
||||
if (parking && section.equals(headPosition.getSection())) { //避免停站结束后向前移动到信号机前
|
||||
return headPosition;
|
||||
}
|
||||
if (section.isFunctionTrack() || section.isParkingTrack()) { //如果无法越过信号机,则停在停车点而非信号机前
|
||||
return new SectionPosition(section, section.getStopPointByDirection(right));
|
||||
}
|
||||
SectionPosition newPosition = CalculateService.calculateNextPositionByStartAndLen(
|
||||
signalPosition, !right, 2, true);
|
||||
if (targetPosition == null || newPosition.isAheadOf(targetPosition, !right)) {
|
||||
return newPosition;
|
||||
} else {
|
||||
return targetPosition;
|
||||
}
|
||||
}
|
||||
|
||||
private void releaseEB(Simulation simulation, SimulationMember driver,
|
||||
|
|
|
@ -30,6 +30,10 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdPsdConfig;
|
|||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.zjd.ZjdPslConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClientConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSectionConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSignalConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSwitchConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableTrainConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSectionConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSignalConfig;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.udp.sr.config.SrSwitchConfig;
|
||||
|
@ -147,12 +151,43 @@ public class ProjectDeviceVO {
|
|||
case "GXSD": {
|
||||
return gxsdDeviceConfigConvert(voList);
|
||||
}
|
||||
case ProjectCode.NGY_SAND_TABLE: {
|
||||
return sandTableDeviceConfigConvert(voList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> sandTableDeviceConfigConvert(
|
||||
List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
for (ProjectDeviceVO deviceVO : voList) {
|
||||
switch (deviceVO.getType()) {
|
||||
case UDP_LOW:
|
||||
list.add(new UDPLowConfig(deviceVO));
|
||||
break;
|
||||
case UDP_CLIENT:
|
||||
list.add(new UDPClientConfig(deviceVO));
|
||||
break;
|
||||
case SIGNAL:
|
||||
list.add(new SandTableSignalConfig(deviceVO));
|
||||
break;
|
||||
case SECTION:
|
||||
list.add(new SandTableSectionConfig(deviceVO));
|
||||
break;
|
||||
case SWITCH:
|
||||
list.add(new SandTableSwitchConfig(deviceVO));
|
||||
break;
|
||||
case TRAIN:
|
||||
list.add(new SandTableTrainConfig(deviceVO));
|
||||
break;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private static List<RealDeviceConfig> thailandSandboxDeviceConfigConvert(
|
||||
List<ProjectDeviceVO> voList) {
|
||||
List<RealDeviceConfig> list = new ArrayList<>();
|
||||
|
|
Loading…
Reference in New Issue