应急系统添加速度及调整

This commit is contained in:
tiger_zhou 2022-10-19 13:25:25 +08:00
parent e84b9ad0dc
commit c2dbbbb715
17 changed files with 316 additions and 130 deletions

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.ATS; package club.joylink.rtss.simulation.cbtc.ATS;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection; import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection;
import club.joylink.rtss.simulation.cbtc.CI.data.vo.StationDirectionStatusVO; import club.joylink.rtss.simulation.cbtc.CI.data.vo.StationDirectionStatusVO;
import club.joylink.rtss.simulation.cbtc.CI.status.StationDirectionStatus; import club.joylink.rtss.simulation.cbtc.CI.status.StationDirectionStatus;
@ -100,11 +101,20 @@ public class ATSMessageCollectAndDispatcher {
trainList.forEach(train -> { trainList.forEach(train -> {
TrainStatus trainStatus = repository.findStatusByCode(train.getGroupNumber(), TrainStatus.class); TrainStatus trainStatus = repository.findStatusByCode(train.getGroupNumber(), TrainStatus.class);
if (Objects.isNull(trainStatus)) { if (Objects.isNull(trainStatus)) {
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
trainStatus = new YJDDZHTrainStatus(train);
}else{
trainStatus = new TrainStatus(train); trainStatus = new TrainStatus(train);
}
repository.addDeviceInfo(trainStatus); repository.addDeviceInfo(trainStatus);
totalList.add(trainStatus.convert2VO(train)); totalList.add(trainStatus.convert2VO(train));
} else { } else {
DeviceStatusVO statusVO = new TrainStatusVO(train); DeviceStatusVO statusVO;
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
statusVO = new YJDDZHTrainStatusVO(train);
}else{
statusVO = new TrainStatusVO(train);
}
if (trainStatus.compareAndChange(train, statusVO)) { if (trainStatus.compareAndChange(train, statusVO)) {
totalList.add(statusVO); totalList.add(statusVO);
} }

View File

@ -6,7 +6,6 @@ import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.MapConfig; import club.joylink.rtss.simulation.cbtc.data.map.MapConfig;
import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Section;
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.Station;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
@ -15,7 +14,6 @@ import club.joylink.rtss.vo.ws.TrainPosition;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Function; import java.util.function.Function;
@ -36,6 +34,7 @@ public class NewAtsTrainLoadService {
stands = station.getRdStandList(); stands = station.getRdStandList();
}*/ }*/
VirtualRealityTrain.Door door = train.getDoor1(); VirtualRealityTrain.Door door = train.getDoor1();
train.setSpeed(tp.getSpeed());
if(tp.isRight()){ if(tp.isRight()){
door = train.getDoor2(); door = train.getDoor2();
} }
@ -55,14 +54,16 @@ public class NewAtsTrainLoadService {
door.setClose(tp.isCloseDoor()); door.setClose(tp.isCloseDoor());
train.setSpeed(99F); train.setSpeed(99F);
} }
} }
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
public VirtualRealityTrain loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
Map<String,VirtualRealityTrain> trainMap = repository.getAllVrTrain().stream().collect(Collectors.toMap(VirtualRealityTrain::getGroupNumber,Function.identity())); Map<String,VirtualRealityTrain> trainMap = repository.getAllVrTrain().stream().collect(Collectors.toMap(VirtualRealityTrain::getGroupNumber,Function.identity()));
if(Objects.equals(false,trainMap.containsKey(tp.getGroupNum()))){ if(Objects.equals(false,trainMap.containsKey(tp.getGroupNum()))){
log.error("没有找到对应车组号 param:{}",tp); log.error("没有找到对应车组号 param:{}",tp);
return; return null;
} }
VirtualRealityTrain virtualRealityTrain = repository.queryOnlineTrainBy(tp.getGroupNum()); VirtualRealityTrain virtualRealityTrain = repository.queryOnlineTrainBy(tp.getGroupNum());
@ -77,6 +78,7 @@ public class NewAtsTrainLoadService {
virtualRealityTrain.setRunLevel(RunLevel.IL); virtualRealityTrain.setRunLevel(RunLevel.IL);
trainOnline(simulation, section, tp, virtualRealityTrain); trainOnline(simulation, section, tp, virtualRealityTrain);
} }
return virtualRealityTrain;
} }
@ -95,22 +97,16 @@ public class NewAtsTrainLoadService {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(section.isPhysical(), "列车需加载到物理区段上"); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(section.isPhysical(), "列车需加载到物理区段上");
//重叠检测 //重叠检测
SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin()); SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
// SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
// SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
// boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
// if(willOverlap){
// return;
// }
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
// 列车上线并构建ATS监控列车信息 // 列车上线并构建ATS监控列车信息
manualTrainOnlineAndSupervise(simulation, train, headPosition, right); manualTrainOnlineAndSupervise(simulation, train, headPosition, right,tp);
} }
/** /**
* 人工车上线并监控 * 人工车上线并监控
*/ */
private void manualTrainOnlineAndSupervise(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, boolean right) { private void manualTrainOnlineAndSupervise(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, boolean right,TrainPosition tp) {
train.initManualTrain(headPosition, right); train.initManualTrain(headPosition, right,tp);
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
//设置列车预选模式驾驶模式运行级别 //设置列车预选模式驾驶模式运行级别
if (!headPosition.getSection().anyZcWorking()) { if (!headPosition.getSection().anyZcWorking()) {
@ -130,4 +126,7 @@ public class NewAtsTrainLoadService {
repository.addTrainInfo(trainInfo); repository.addTrainInfo(trainInfo);
} }
} }
} }

View File

@ -1,38 +1,24 @@
package club.joylink.rtss.simulation.cbtc.ATS.service; package club.joylink.rtss.simulation.cbtc.ATS.service;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.SocketMessageVO; import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.WebSocketMessageType; import club.joylink.rtss.vo.client.WebSocketMessageType;
import club.joylink.rtss.vo.client.factory.SocketMessageFactory; import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
import club.joylink.rtss.vo.ws.TrainPosition; import club.joylink.rtss.vo.ws.TrainPosition;
import club.joylink.rtss.websocket.StompMessageService; import club.joylink.rtss.websocket.StompMessageService;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class TrainPositionService { public class TrainPositionService {
@Resource @Resource
private NewAtsTrainLoadService newAtsTrainLoadService; TrainPositionTimeOverService timeOverService;
@Resource
private SimulationManager simulationManager;
@Resource
StompMessageService messageService;
/** /**
@ -44,91 +30,10 @@ public class TrainPositionService {
public void initTrainOrUpdate(String mapName,String json){ public void initTrainOrUpdate(String mapName,String json){
TrainPosition tp = JsonUtils.read(json, TrainPosition.class); TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
tp.setReceiveTime(System.currentTimeMillis()); tp.setReceiveTime(System.currentTimeMillis());
// log.info(tp.toString()); // SocketMessageVO<TrainPosition> vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
List<Simulation> simulationList = this.findSimulationList(mapName); // this.messageService.send(vo);
if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){ this.timeOverService.addTrainAccept(mapName,tp);
log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json);
return;
}
// boolean d = true;
SocketMessageVO<TrainPosition> vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
this.messageService.send(vo);
for (Simulation sim : simulationList) {
List<Section> sectionList = findDirectionAllSection(sim,tp.getRoadType());
Section section = this.findSecion(sectionList,tp);
// if(d){
// tp.setSectionCode(section.getCode());
// log.info(tp.toString());
// d = false;
// }
if(Objects.isNull(section)){
log.error("未找到对应的区段 param:{}",json);
return;
}
log.info(tp.toString());
this.newAtsTrainLoadService.loadTripNumberTrain(sim,tp,section);
}
} }
/**
* 根据传入的参数 定位对应的所在的区段
* @param sectionList
* @param tp
* @return
*/
private Section findSecion(List<Section> sectionList,TrainPosition tp){
// int i = 0;
// Section findSection;
for (Section section : sectionList) {
if(tp.isRight()){
if(tp.getLocation() <= section.getKmMax()){
return section;
}
}else{
if(tp.getLocation() <= section.getKmMax() && tp.getLocation() >= section.getKmMin()){
return section;
}
}
// i++;
}
return null;
}
/**
* 根据车辆方向获取对应的区段并升序排序
* @param sim
* @param roadType
* @return
*/
private synchronized List<Section> findDirectionAllSection(Simulation sim,Section.SectionRoadType roadType){
String key = sim.getId() + "-" + roadType.name();
List<Section> list = simulationManager.getSectionDir(key);
if(Objects.equals(true,CollectionUtils.isEmpty(list))){
list = sim.getRepository().getSectionList();
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
simulationManager.putSectionDirCache(key,list);
}
return list;
}
/**
* 获取对应线路的仿真并且地图类型为 MapPrdTypeEnum.YJDDZH
* @param mapName
* @return
*/
private List<Simulation> findSimulationList(String mapName){
return this.simulationManager.getSimulationList().stream().filter(d->{
if(d instanceof Simulation){
Simulation sim = (Simulation) d;
SimulationBuildParams params = sim.getBuildParams();
return Objects.equals(mapName,params.getMap().getName()) && params.getProdType() == MapPrdTypeEnum.YJDDZH;
}
return false;
}).map(d->(Simulation) d).collect(Collectors.toList());
}
} }

View File

@ -0,0 +1,131 @@
package club.joylink.rtss.simulation.cbtc.ATS.service;
import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.status.TrainStatus;
import club.joylink.rtss.vo.ws.TrainPosition;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Service
@Slf4j
public class TrainPositionTimeOverService {
@Resource
private SimulationManager simulationManager;
@Resource
NewAtsTrainLoadService newAtsTrainLoadService;
@Value("${yjddzh.receiveTimeOver:60}")
private Integer receiveTimeOver;
private static final Map<String, TrainPosition> TRAIN_POSITION_MAP = new ConcurrentHashMap<>();
private static final Map<String,List<String>> TRAIN_SIMULATION_EXIST_MAP = new ConcurrentHashMap<>();
private static synchronized boolean checkExist(String key,Simulation simulation){
List<String> list = TRAIN_SIMULATION_EXIST_MAP.get(key);
if(CollectionUtils.isEmpty(list)){
list = new ArrayList<>();
list.add(simulation.getId());
TRAIN_SIMULATION_EXIST_MAP.put(key,list);
return true;
}else if(list.contains(simulation.getId())){
return false;
}else{
list.add(simulation.getId());
return true;
}
}
public void addTrainAccept(String mapName ,TrainPosition train){
String key = String.format("%s,%s",mapName,train.getGroupNum());
TRAIN_POSITION_MAP.put(key,train);
TRAIN_SIMULATION_EXIST_MAP.remove(key);
}
/**
* 根据车辆方向获取对应的区段并升序排序
* @param sim
* @param roadType
* @return
*/
private synchronized List<Section> findDirectionAllSection(Simulation sim, Section.SectionRoadType roadType){
String key = sim.getId() + "-" + roadType.name();
List<Section> list = simulationManager.getSectionDir(key);
if(Objects.equals(true, CollectionUtils.isEmpty(list))){
list = sim.getRepository().getSectionList();
list = list.stream().filter(d->d.getRoadType() == roadType && Objects.nonNull(d.getKmMin()))
.sorted(Comparator.comparing(Section::getKmMin)).collect(Collectors.toList());
simulationManager.putSectionDirCache(key,list);
}
return list;
}
/**
* 根据传入的参数 定位对应的所在的区段
* @param sectionList
* @param tp
* @return
*/
private Section findSecion(List<Section> sectionList,TrainPosition tp){
for (Section section : sectionList) {
if(tp.isRight()){
if(tp.getLocation() <= section.getKmMax()){
return section;
}
}else{
if(tp.getLocation() <= section.getKmMax() && tp.getLocation() >= section.getKmMin()){
return section;
}
}
}
return null;
}
private void trainInitOrUpdate(Simulation simulation){
String mapName = simulation.getBuildParams().getMap().getName();
for (Map.Entry<String,TrainPosition> entry: TRAIN_POSITION_MAP.entrySet()) {
String key = entry.getKey();
TrainPosition tp = entry.getValue();
if(!StringUtils.startsWithIgnoreCase(key,mapName)){
continue;
}
if(tp.receiveTimeOver(this.receiveTimeOver)){
if(checkExist(key,simulation)){
SimulationDataRepository repository = simulation.getRepository();
TrainStatus ts = new TrainStatus(tp.getGroupNum());
ts.setGroupNumber(tp.getGroupNum());
repository.addDeviceInfo(ts);
repository.deleteSuperviseTrain(tp.getGroupNum());
repository.deleteOnlineTrain(tp.getGroupNum());
}
continue;
}
List<Section> sectionList = findDirectionAllSection(simulation,tp.getRoadType());
Section section = this.findSecion(sectionList,tp);
if(Objects.isNull(section)){
log.error("未找到对应的区段 param:{}",tp);
continue;
}
log.info(tp.toString());
this.newAtsTrainLoadService.loadTripNumberTrain(simulation,tp,section);
}
}
public void run(Simulation simulation){
simulation.addJob(SimulationModule.YJDDZH.name(), () -> trainInitOrUpdate(simulation), SimulationConstants.YJDDZH_LOGIC_LOOP_RATE);
}
}

View File

@ -12,6 +12,7 @@ import club.joylink.rtss.services.publishData.IbpService;
import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.SimulationManager;
import club.joylink.rtss.simulation.cbtc.ATS.ATSLogicLoop; import club.joylink.rtss.simulation.cbtc.ATS.ATSLogicLoop;
import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher; import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher;
import club.joylink.rtss.simulation.cbtc.ATS.service.TrainPositionTimeOverService;
import club.joylink.rtss.simulation.cbtc.CI.CiLogic; import club.joylink.rtss.simulation.cbtc.CI.CiLogic;
import club.joylink.rtss.simulation.cbtc.CTC.CTCLogicLoop; import club.joylink.rtss.simulation.cbtc.CTC.CTCLogicLoop;
import club.joylink.rtss.simulation.cbtc.ISCS.IscsLogicLoop; import club.joylink.rtss.simulation.cbtc.ISCS.IscsLogicLoop;
@ -49,6 +50,7 @@ import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -143,6 +145,8 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
@Autowired @Autowired
private PisLogicLoop pisLogicLoop; private PisLogicLoop pisLogicLoop;
@Resource
TrainPositionTimeOverService timeOverService;
@Override @Override
public Simulation create(SimulationBuildParams params, String group) { public Simulation create(SimulationBuildParams params, String group) {
@ -199,6 +203,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
vrDeviceLogicLoop.addJobsForTrainPosition(simulation); vrDeviceLogicLoop.addJobsForTrainPosition(simulation);
// ciLogic.addJobs(simulation); // ciLogic.addJobs(simulation);
ciLogic.addJobsForTrainPosition(simulation); ciLogic.addJobsForTrainPosition(simulation);
timeOverService.run(simulation);
return; return;
} }
if (simulation.getRepository().getConfig().isRailway()) { if (simulation.getRepository().getConfig().isRailway()) {

View File

@ -94,6 +94,7 @@ public interface SimulationConstants {
/** 机器人逻辑循环间隔 */ /** 机器人逻辑循环间隔 */
int ROBOT_LOGIC_LOOP_RATE = 200; int ROBOT_LOGIC_LOOP_RATE = 200;
int YJDDZH_LOGIC_LOOP_RATE = 200;
/** /**
* ATO列车收到通行信号到列车发动延迟时间 * ATO列车收到通行信号到列车发动延迟时间

View File

@ -59,6 +59,7 @@ public enum SimulationModule {
CATENARY(SimulationConstants.POWER_SUPPLY_STATUS_UPDATE_RATE), CATENARY(SimulationConstants.POWER_SUPPLY_STATUS_UPDATE_RATE),
ROBOT(SimulationConstants.ROBOT_LOGIC_LOOP_RATE), ROBOT(SimulationConstants.ROBOT_LOGIC_LOOP_RATE),
YJDDZH(SimulationConstants.ROBOT_LOGIC_LOOP_RATE)
; ;
/** 执行频率-单位ms */ /** 执行频率-单位ms */

View File

@ -0,0 +1,49 @@
package club.joylink.rtss.simulation.cbtc.data.status;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import club.joylink.rtss.simulation.cbtc.data.vo.YJDDZHTrainStatusVO;
import lombok.Getter;
import lombok.Setter;
import java.util.Objects;
/**
* 应急列车状态
*/
@Getter
@Setter
public class YJDDZHTrainStatus extends TrainStatus {
/**
* 公里标
*/
private Float locationKM;
public YJDDZHTrainStatus(TrainInfo train) {
super(train);
this.setSpeed(train.getSpeed());
this.locationKM = train.getLocationKM();
}
@Override
public DeviceStatusVO convert2VO(MapElement device) {
return new YJDDZHTrainStatusVO(this);
}
@Override
public boolean compareAndChange(MapElement device, DeviceStatusVO statusVO) {
TrainInfo train = (TrainInfo) device;
YJDDZHTrainStatusVO status = (YJDDZHTrainStatusVO)statusVO;
boolean change = super.compareAndChange(device, statusVO);
if (!Objects.equals(this.locationKM, train.getLocationKM())) {
this.locationKM = train.getLocationKM();
status.setLocationKM(this.locationKM);
change = true;
}
status.setSpeed(train.getSpeed());
return change;
}
}

View File

@ -11,6 +11,7 @@ import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
import club.joylink.rtss.simulation.cbtc.data.storage.vo.StorageTrainInfo; import club.joylink.rtss.simulation.cbtc.data.storage.vo.StorageTrainInfo;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.vo.ws.TrainPosition;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -95,7 +96,7 @@ public class TrainInfo extends MapElement {
@Setter @Setter
private Boolean right; private Boolean right;
@Setter
private float speed; private float speed;
private boolean doorOpen; private boolean doorOpen;
@ -292,6 +293,12 @@ public class TrainInfo extends MapElement {
private boolean beAbout2Arrival; private boolean beAbout2Arrival;
/**
* 公里标
*/
@Setter
private Float locationKM;
public TrainInfo(String groupNumber) { public TrainInfo(String groupNumber) {
super(groupNumber, DeviceType.TRAIN); super(groupNumber, DeviceType.TRAIN);
this.groupNumber = groupNumber; this.groupNumber = groupNumber;
@ -313,6 +320,13 @@ public class TrainInfo extends MapElement {
info.tripNumber = StringUtils.isEmpty(train.getTripNumber()) ? "" : train.getTripNumber(); info.tripNumber = StringUtils.isEmpty(train.getTripNumber()) ? "" : train.getTripNumber();
return info; return info;
} }
// public static TrainInfo constructManualTrain(VirtualRealityTrain train, TrainPosition tp) {
// TrainInfo info = constructManualTrain(train);
// info.setLocationKM(tp.getLocation());
// info.setRight(tp.isRight());
// info.setSpeed(tp.getSpeed());
// return info;
// }
private TrainInfo(VirtualRealityTrain train) { private TrainInfo(VirtualRealityTrain train) {
super(train.getGroupNumber(), DeviceType.TRAIN); super(train.getGroupNumber(), DeviceType.TRAIN);
@ -404,6 +418,10 @@ public class TrainInfo extends MapElement {
this.runLevel = config.getRunMode(); this.runLevel = config.getRunMode();
} }
/**
* ats 数据采集
* @param train
*/
public void tracking(VirtualRealityTrain train) { public void tracking(VirtualRealityTrain train) {
this.runLevel = train.getRunLevel(); this.runLevel = train.getRunLevel();
SectionPosition headPosition = train.getHeadPosition(); SectionPosition headPosition = train.getHeadPosition();
@ -419,6 +437,7 @@ public class TrainInfo extends MapElement {
} }
this.right = train.isRight(); this.right = train.isRight();
this.speed = train.getSpeed(); this.speed = train.getSpeed();
this.locationKM = train.getLocationKM();
this.doorOpen = !train.isAllDoorCloseAndLock(); this.doorOpen = !train.isAllDoorCloseAndLock();
this.driveMode = train.getDriveMode(); this.driveMode = train.getDriveMode();
this.jump = train.isJump(); this.jump = train.isJump();

View File

@ -0,0 +1,43 @@
package club.joylink.rtss.simulation.cbtc.data.vo;
import club.joylink.rtss.simulation.cbtc.constant.DriveMode;
import club.joylink.rtss.simulation.cbtc.constant.PlanRoutingType;
import club.joylink.rtss.simulation.cbtc.constant.RunLevel;
import club.joylink.rtss.simulation.cbtc.constant.TrainType;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.status.TrainStatus;
import club.joylink.rtss.simulation.cbtc.data.status.YJDDZHTrainStatus;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* 列车状态
*/
@Getter
@Setter
@NoArgsConstructor
public class YJDDZHTrainStatusVO extends TrainStatusVO {
/**
* 公里标
*/
private Float locationKM;
public YJDDZHTrainStatusVO(TrainInfo train){
super(train);
}
public YJDDZHTrainStatusVO(TrainStatus train) {
super(train);
if(train instanceof YJDDZHTrainStatus){
YJDDZHTrainStatus yjddzhTrainStatus = (YJDDZHTrainStatus)train;
this.locationKM = yjddzhTrainStatus.getLocationKM();
}
}
}

View File

@ -14,6 +14,7 @@ import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.vo.client.operation.DriveParamVO; import club.joylink.rtss.vo.client.operation.DriveParamVO;
import club.joylink.rtss.vo.ws.TrainPosition;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -237,6 +238,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
*/ */
private float speed; private float speed;
/**
* 公里标
*/
private float locationKM;
/** /**
* 目标距离 * 目标距离
*/ */
@ -651,7 +657,13 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
this.initPosition(right, headPosition); this.initPosition(right, headPosition);
init(); init();
} }
public void initManualTrain(SectionPosition headPosition, boolean right, TrainPosition tp) {
this.initPosition(right, headPosition);
init();
this.speed = tp.getSpeed();
this.locationKM = tp.getLocation();
this.right = tp.isRight();
}
private void init() { private void init() {
this.communication = true; this.communication = true;
this.jump = false; this.jump = false;

View File

@ -18,7 +18,7 @@ public enum SimulationSubscribeTopic {
Ctc("/queue/simulation/{id}/ctc"), //大铁CTC Ctc("/queue/simulation/{id}/ctc"), //大铁CTC
Room("/queue/room/{id}"), Room("/queue/room/{id}"),
Wgu3d("/topic/simulation/wgu3d/{id}"), Wgu3d("/topic/simulation/wgu3d/{id}"),
YJDDZH_TRAIN_POSITION("/topic/yjddzh/trainPosition") YJDDZH_TRAIN_POSITION("/topic/yjddzh/trainPosition/simulation/{id}")
; ;
private String destPattern; private String destPattern;

View File

@ -64,7 +64,7 @@ public class SocketMessageFactory {
List<String> topicList = new ArrayList<>(); List<String> topicList = new ArrayList<>();
switch (messageType) { switch (messageType) {
case YJDDZH_TRAIN_POSITION:{ case YJDDZH_TRAIN_POSITION:{
topicList.add(SimulationSubscribeTopic.YJDDZH_TRAIN_POSITION.getDestPattern()); topicList.add(SimulationSubscribeTopic.YJDDZH_TRAIN_POSITION.buildDestination(group));
break; break;
} }
case BROADCAST: case BROADCAST:

View File

@ -10,6 +10,7 @@ import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
@ -55,6 +56,16 @@ public class TrainPosition {
*/ */
private boolean stop; private boolean stop;
/**
* 列车速度
*/
private Float speed;
private boolean del = false;
public boolean receiveTimeOver(int second){
return (System.currentTimeMillis() - this.receiveTime) > TimeUnit.SECONDS.toMillis(second);
}
public Section.SectionRoadType getRoadType(){ public Section.SectionRoadType getRoadType(){
Section.SectionRoadType type = Section.SectionRoadType.LEFT; Section.SectionRoadType type = Section.SectionRoadType.LEFT;

View File

@ -37,9 +37,7 @@ public class WebSocketController {
} }
@MessageMapping("/{mapName}/trainPosition") @MessageMapping("/{mapName}/trainPosition")
// @SendTo("/topic/trainPosition")
public void mlbs( String json,@DestinationVariable String mapName) { public void mlbs( String json,@DestinationVariable String mapName) {
this.trainPositionService.initTrainOrUpdate(mapName,json); this.trainPositionService.initTrainOrUpdate(mapName,json);
// return json;
} }
} }

View File

@ -53,6 +53,7 @@ public class StompClientManager {
TrainPosition tp = list.get(i); TrainPosition tp = list.get(i);
tp.setCloseDoor(false); tp.setCloseDoor(false);
tp.setStop(false); tp.setStop(false);
tp.setSpeed(Float.valueOf(i));
// tp.setLocation(tp.getLocation() - 500); // tp.setLocation(tp.getLocation() - 500);
String val = JsonUtils.writeValueNullableFieldAsString(tp); String val = JsonUtils.writeValueNullableFieldAsString(tp);
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime()); Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());

View File

@ -7,7 +7,8 @@ modbus-tcp:
udp: udp:
serverPort: 20002 serverPort: 20002
clientPort: 20001 clientPort: 20001
yjddzh:
receiveTimeOver: 60
spring: spring:
profiles: profiles:
active: dev active: dev
@ -95,9 +96,9 @@ springfox:
spring: spring:
profiles: dev profiles: dev
datasource: datasource:
url: jdbc:mysql://localhost:3306/joylink?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true url: jdbc:mysql://192.168.3.233:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
username: root username: root
password: root password: joylink0503
tencent-cloud: tencent-cloud:
allow-send: false allow-send: false