Merge branch 'test-zhouyin' into test

This commit is contained in:
tiger_zhou 2022-09-09 13:33:49 +08:00
commit 88c0ac23b0
5 changed files with 56 additions and 9 deletions

View File

@ -51,7 +51,8 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@Component @Component
public class NewAtsTrainLoadService { public class NewAtsTrainLoadService {
@Autowired
private VRTrainRunningService vrTrainRunningService;
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) { public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
@ -91,9 +92,12 @@ public class NewAtsTrainLoadService {
//重叠检测 //重叠检测
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 headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
// SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false); SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
// boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition); boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠"); if(willOverlap){
return;
}
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
// 列车上线并构建ATS监控列车信息 // 列车上线并构建ATS监控列车信息
manualTrainOnlineAndSupervise(simulation, train, headPosition, right); manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
} }

View File

@ -37,16 +37,21 @@ 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()); // log.info(tp.toString());
List<Simulation> simulationList = this.findSimulationList(mapName); List<Simulation> simulationList = this.findSimulationList(mapName);
if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){ if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){
log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json); log.error("未找到对应的类型的仿真,无法渲染列车位置 param:{}",json);
return; return;
} }
boolean d = true;
for (Simulation sim : simulationList) { for (Simulation sim : simulationList) {
List<Section> sectionList = findDirectionAllSection(sim,tp.getRoadType()); List<Section> sectionList = findDirectionAllSection(sim,tp.getRoadType());
Section section = this.findSecion(sectionList,tp); Section section = this.findSecion(sectionList,tp);
if(d){
tp.setSectionCode(section.getCode());
log.info(tp.toString());
d = false;
}
if(Objects.isNull(section)){ if(Objects.isNull(section)){
log.error("未找到对应的区段 param:{}",json); log.error("未找到对应的区段 param:{}",json);
return; return;

View File

@ -182,7 +182,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
private void addJobs(Simulation simulation) { private void addJobs(Simulation simulation) {
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){ if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
//非武汉大屏车辆定位 //非武汉大屏车辆定位
atsLogicLoop.addJobs(simulation); // atsLogicLoop.addJobs(simulation);
atsMessageCollectAndDispatcher.addJobs(simulation); atsMessageCollectAndDispatcher.addJobs(simulation);
vrDeviceLogicLoop.addJobs(simulation); vrDeviceLogicLoop.addJobs(simulation);
ciLogic.addJobs(simulation); ciLogic.addJobs(simulation);

View File

@ -17,6 +17,7 @@ public class TrainPosition {
private int direction; private int direction;
private float location; private float location;
private Long receiveTime; private Long receiveTime;
private String sectionCode;
public Section.SectionRoadType getRoadType(){ public Section.SectionRoadType getRoadType(){
Section.SectionRoadType type = Section.SectionRoadType.LEFT; Section.SectionRoadType type = Section.SectionRoadType.LEFT;
if(this.direction == 1){ if(this.direction == 1){

View File

@ -1,6 +1,10 @@
package club.joylink.rtss.websocket.client; package club.joylink.rtss.websocket.client;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.util.test.LogTest;
import club.joylink.rtss.vo.ws.TrainPosition;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.stomp.StompSession; import org.springframework.messaging.simp.stomp.StompSession;
@ -9,7 +13,12 @@ import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.messaging.WebSocketStompClient; import org.springframework.web.socket.messaging.WebSocketStompClient;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -26,10 +35,38 @@ public class StompClientManager {
ListenableFuture<StompSession> future = stompClient ListenableFuture<StompSession> future = stompClient
.connect("ws://127.0.0.1:9000/joylink-tbi-websocket",handler, "null"); .connect("ws://127.0.0.1:9000/joylink-tbi-websocket",handler, "null");
StompSession stompSession = future.get(); StompSession stompSession = future.get();
LogTest lt = new LogTest();
List<TrainPosition> list = lt.readFile("d:\\spring.log2");
// runToLeft(stompSession,"001");
// runToRight(stompSession,"002");
list = lt.query(list,"004", Section.SectionRoadType.RIGHT);
send(stompSession,list);
}
runToLeft(stompSession,"001"); public static void send(StompSession stompSession,List<TrainPosition> list){
runToRight(stompSession,"002"); //4855,566575121127,138150155162183
//128
for (int i = 183; i < list.size(); i++) {
TrainPosition tp = list.get(i);
String val = JsonUtils.writeValueNullableFieldAsString(tp);
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
ZoneId zone = ZoneId.systemDefault();
String d = LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
System.out.println(d + " ->" + i +" ->" + val);
stompSession.send("/app/武汉8号线/trainPosition",val.getBytes(StandardCharsets.UTF_8));
if(i > 0){
TrainPosition old = list.get(i - 1);
try {
long sleepTime = tp.getReceiveTime() - old.getReceiveTime();
System.out.println("index:" + i + "sleep:"+sleepTime);
TimeUnit.MILLISECONDS.sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
} }
public static void runToLeft(StompSession stompSession,String tripNum){ public static void runToLeft(StompSession stompSession,String tripNum){