应急系统添加速度及调整
This commit is contained in:
parent
e84b9ad0dc
commit
c2dbbbb715
@ -1,5 +1,6 @@
|
||||
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.vo.StationDirectionStatusVO;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.status.StationDirectionStatus;
|
||||
@ -100,11 +101,20 @@ public class ATSMessageCollectAndDispatcher {
|
||||
trainList.forEach(train -> {
|
||||
TrainStatus trainStatus = repository.findStatusByCode(train.getGroupNumber(), TrainStatus.class);
|
||||
if (Objects.isNull(trainStatus)) {
|
||||
trainStatus = new TrainStatus(train);
|
||||
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
|
||||
trainStatus = new YJDDZHTrainStatus(train);
|
||||
}else{
|
||||
trainStatus = new TrainStatus(train);
|
||||
}
|
||||
repository.addDeviceInfo(trainStatus);
|
||||
totalList.add(trainStatus.convert2VO(train));
|
||||
} 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)) {
|
||||
totalList.add(statusVO);
|
||||
}
|
||||
|
@ -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.map.MapConfig;
|
||||
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.support.SectionPosition;
|
||||
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 org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
@ -36,6 +34,7 @@ public class NewAtsTrainLoadService {
|
||||
stands = station.getRdStandList();
|
||||
}*/
|
||||
VirtualRealityTrain.Door door = train.getDoor1();
|
||||
train.setSpeed(tp.getSpeed());
|
||||
if(tp.isRight()){
|
||||
door = train.getDoor2();
|
||||
}
|
||||
@ -55,14 +54,16 @@ public class NewAtsTrainLoadService {
|
||||
door.setClose(tp.isCloseDoor());
|
||||
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();
|
||||
Map<String,VirtualRealityTrain> trainMap = repository.getAllVrTrain().stream().collect(Collectors.toMap(VirtualRealityTrain::getGroupNumber,Function.identity()));
|
||||
if(Objects.equals(false,trainMap.containsKey(tp.getGroupNum()))){
|
||||
log.error("没有找到对应车组号 param:{}",tp);
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
VirtualRealityTrain virtualRealityTrain = repository.queryOnlineTrainBy(tp.getGroupNum());
|
||||
@ -77,6 +78,7 @@ public class NewAtsTrainLoadService {
|
||||
virtualRealityTrain.setRunLevel(RunLevel.IL);
|
||||
trainOnline(simulation, section, tp, virtualRealityTrain);
|
||||
}
|
||||
return virtualRealityTrain;
|
||||
}
|
||||
|
||||
|
||||
@ -95,22 +97,16 @@ public class NewAtsTrainLoadService {
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(section.isPhysical(), "列车需加载到物理区段上");
|
||||
//重叠检测
|
||||
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监控列车信息
|
||||
manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
|
||||
manualTrainOnlineAndSupervise(simulation, train, headPosition, right,tp);
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工车上线并监控
|
||||
*/
|
||||
private void manualTrainOnlineAndSupervise(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, boolean right) {
|
||||
train.initManualTrain(headPosition, right);
|
||||
private void manualTrainOnlineAndSupervise(Simulation simulation, VirtualRealityTrain train, SectionPosition headPosition, boolean right,TrainPosition tp) {
|
||||
train.initManualTrain(headPosition, right,tp);
|
||||
SimulationDataRepository repository = simulation.getRepository();
|
||||
//设置列车预选模式、驾驶模式、运行级别
|
||||
if (!headPosition.getSection().anyZcWorking()) {
|
||||
@ -130,4 +126,7 @@ public class NewAtsTrainLoadService {
|
||||
repository.addTrainInfo(trainInfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,38 +1,24 @@
|
||||
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.vo.client.SocketMessageVO;
|
||||
import club.joylink.rtss.vo.client.WebSocketMessageType;
|
||||
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import club.joylink.rtss.websocket.StompMessageService;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TrainPositionService {
|
||||
|
||||
|
||||
@Resource
|
||||
private NewAtsTrainLoadService newAtsTrainLoadService;
|
||||
@Resource
|
||||
private SimulationManager simulationManager;
|
||||
@Resource
|
||||
StompMessageService messageService;
|
||||
TrainPositionTimeOverService timeOverService;
|
||||
|
||||
|
||||
/**
|
||||
@ -44,91 +30,10 @@ public class TrainPositionService {
|
||||
public void initTrainOrUpdate(String mapName,String json){
|
||||
TrainPosition tp = JsonUtils.read(json, TrainPosition.class);
|
||||
tp.setReceiveTime(System.currentTimeMillis());
|
||||
// log.info(tp.toString());
|
||||
List<Simulation> simulationList = this.findSimulationList(mapName);
|
||||
if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){
|
||||
log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json);
|
||||
return;
|
||||
}
|
||||
// boolean d = true;
|
||||
SocketMessageVO<TrainPosition> vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
|
||||
this.messageService.send(vo);
|
||||
// SocketMessageVO<TrainPosition> vo = SocketMessageFactory.buildBasic(WebSocketMessageType.YJDDZH_TRAIN_POSITION,tp);
|
||||
// this.messageService.send(vo);
|
||||
this.timeOverService.addTrainAccept(mapName,tp);
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -12,6 +12,7 @@ import club.joylink.rtss.services.publishData.IbpService;
|
||||
import club.joylink.rtss.simulation.SimulationManager;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.ATSLogicLoop;
|
||||
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.CTC.CTCLogicLoop;
|
||||
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.util.CollectionUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@ -143,6 +145,8 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
|
||||
|
||||
@Autowired
|
||||
private PisLogicLoop pisLogicLoop;
|
||||
@Resource
|
||||
TrainPositionTimeOverService timeOverService;
|
||||
|
||||
@Override
|
||||
public Simulation create(SimulationBuildParams params, String group) {
|
||||
@ -199,6 +203,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
|
||||
vrDeviceLogicLoop.addJobsForTrainPosition(simulation);
|
||||
// ciLogic.addJobs(simulation);
|
||||
ciLogic.addJobsForTrainPosition(simulation);
|
||||
timeOverService.run(simulation);
|
||||
return;
|
||||
}
|
||||
if (simulation.getRepository().getConfig().isRailway()) {
|
||||
|
@ -94,6 +94,7 @@ public interface SimulationConstants {
|
||||
|
||||
/** 机器人逻辑循环间隔 */
|
||||
int ROBOT_LOGIC_LOOP_RATE = 200;
|
||||
int YJDDZH_LOGIC_LOOP_RATE = 200;
|
||||
|
||||
/**
|
||||
* ATO列车收到通行信号到列车发动延迟时间
|
||||
|
@ -59,6 +59,7 @@ public enum SimulationModule {
|
||||
CATENARY(SimulationConstants.POWER_SUPPLY_STATUS_UPDATE_RATE),
|
||||
|
||||
ROBOT(SimulationConstants.ROBOT_LOGIC_LOOP_RATE),
|
||||
YJDDZH(SimulationConstants.ROBOT_LOGIC_LOOP_RATE)
|
||||
;
|
||||
|
||||
/** 执行频率-单位ms */
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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.support.SectionPosition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -95,7 +96,7 @@ public class TrainInfo extends MapElement {
|
||||
|
||||
@Setter
|
||||
private Boolean right;
|
||||
|
||||
@Setter
|
||||
private float speed;
|
||||
|
||||
private boolean doorOpen;
|
||||
@ -292,6 +293,12 @@ public class TrainInfo extends MapElement {
|
||||
|
||||
private boolean beAbout2Arrival;
|
||||
|
||||
/**
|
||||
* 公里标
|
||||
*/
|
||||
@Setter
|
||||
private Float locationKM;
|
||||
|
||||
public TrainInfo(String groupNumber) {
|
||||
super(groupNumber, DeviceType.TRAIN);
|
||||
this.groupNumber = groupNumber;
|
||||
@ -313,6 +320,13 @@ public class TrainInfo extends MapElement {
|
||||
info.tripNumber = StringUtils.isEmpty(train.getTripNumber()) ? "" : train.getTripNumber();
|
||||
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) {
|
||||
super(train.getGroupNumber(), DeviceType.TRAIN);
|
||||
@ -404,6 +418,10 @@ public class TrainInfo extends MapElement {
|
||||
this.runLevel = config.getRunMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* ats 数据采集
|
||||
* @param train
|
||||
*/
|
||||
public void tracking(VirtualRealityTrain train) {
|
||||
this.runLevel = train.getRunLevel();
|
||||
SectionPosition headPosition = train.getHeadPosition();
|
||||
@ -419,6 +437,7 @@ public class TrainInfo extends MapElement {
|
||||
}
|
||||
this.right = train.isRight();
|
||||
this.speed = train.getSpeed();
|
||||
this.locationKM = train.getLocationKM();
|
||||
this.doorOpen = !train.isAllDoorCloseAndLock();
|
||||
this.driveMode = train.getDriveMode();
|
||||
this.jump = train.isJump();
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -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.SimulationExceptionType;
|
||||
import club.joylink.rtss.vo.client.operation.DriveParamVO;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -237,6 +238,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
*/
|
||||
private float speed;
|
||||
|
||||
|
||||
/**
|
||||
* 公里标
|
||||
*/
|
||||
private float locationKM;
|
||||
/**
|
||||
* 目标距离
|
||||
*/
|
||||
@ -651,7 +657,13 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
|
||||
this.initPosition(right, headPosition);
|
||||
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() {
|
||||
this.communication = true;
|
||||
this.jump = false;
|
||||
|
@ -18,7 +18,7 @@ public enum SimulationSubscribeTopic {
|
||||
Ctc("/queue/simulation/{id}/ctc"), //大铁CTC
|
||||
Room("/queue/room/{id}"),
|
||||
Wgu3d("/topic/simulation/wgu3d/{id}"),
|
||||
YJDDZH_TRAIN_POSITION("/topic/yjddzh/trainPosition")
|
||||
YJDDZH_TRAIN_POSITION("/topic/yjddzh/trainPosition/simulation/{id}")
|
||||
;
|
||||
|
||||
private String destPattern;
|
||||
|
@ -64,7 +64,7 @@ public class SocketMessageFactory {
|
||||
List<String> topicList = new ArrayList<>();
|
||||
switch (messageType) {
|
||||
case YJDDZH_TRAIN_POSITION:{
|
||||
topicList.add(SimulationSubscribeTopic.YJDDZH_TRAIN_POSITION.getDestPattern());
|
||||
topicList.add(SimulationSubscribeTopic.YJDDZH_TRAIN_POSITION.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case BROADCAST:
|
||||
|
@ -10,6 +10,7 @@ import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@ -55,6 +56,16 @@ public class TrainPosition {
|
||||
*/
|
||||
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(){
|
||||
Section.SectionRoadType type = Section.SectionRoadType.LEFT;
|
||||
|
@ -37,9 +37,7 @@ public class WebSocketController {
|
||||
}
|
||||
|
||||
@MessageMapping("/{mapName}/trainPosition")
|
||||
// @SendTo("/topic/trainPosition")
|
||||
public void mlbs( String json,@DestinationVariable String mapName) {
|
||||
this.trainPositionService.initTrainOrUpdate(mapName,json);
|
||||
// return json;
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ public class StompClientManager {
|
||||
TrainPosition tp = list.get(i);
|
||||
tp.setCloseDoor(false);
|
||||
tp.setStop(false);
|
||||
tp.setSpeed(Float.valueOf(i));
|
||||
// tp.setLocation(tp.getLocation() - 500);
|
||||
String val = JsonUtils.writeValueNullableFieldAsString(tp);
|
||||
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
|
||||
|
@ -7,7 +7,8 @@ modbus-tcp:
|
||||
udp:
|
||||
serverPort: 20002
|
||||
clientPort: 20001
|
||||
|
||||
yjddzh:
|
||||
receiveTimeOver: 60
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
@ -93,11 +94,11 @@ springfox:
|
||||
|
||||
---
|
||||
spring:
|
||||
profiles: dev
|
||||
datasource:
|
||||
url: jdbc:mysql://localhost:3306/joylink?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: root
|
||||
profiles: dev
|
||||
datasource:
|
||||
url: jdbc:mysql://192.168.3.233:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
|
||||
username: root
|
||||
password: joylink0503
|
||||
|
||||
tencent-cloud:
|
||||
allow-send: false
|
||||
|
Loading…
Reference in New Issue
Block a user