Merge branch 'test-zhouyin' into test
This commit is contained in:
commit
88c0ac23b0
@ -51,7 +51,8 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class NewAtsTrainLoadService {
|
||||
|
||||
@Autowired
|
||||
private VRTrainRunningService vrTrainRunningService;
|
||||
public void loadTripNumberTrain(Simulation simulation, TrainPosition tp,Section section) {
|
||||
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, section.getStopPointByDirection(right));
|
||||
// SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
|
||||
// boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
|
||||
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
|
||||
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);
|
||||
}
|
||||
|
@ -37,16 +37,21 @@ 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());
|
||||
// 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;
|
||||
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;
|
||||
|
@ -182,7 +182,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
|
||||
private void addJobs(Simulation simulation) {
|
||||
if(simulation.getBuildParams().getProdType() == MapPrdTypeEnum.YJDDZH){
|
||||
//非武汉大屏车辆定位
|
||||
atsLogicLoop.addJobs(simulation);
|
||||
// atsLogicLoop.addJobs(simulation);
|
||||
atsMessageCollectAndDispatcher.addJobs(simulation);
|
||||
vrDeviceLogicLoop.addJobs(simulation);
|
||||
ciLogic.addJobs(simulation);
|
||||
|
@ -17,6 +17,7 @@ public class TrainPosition {
|
||||
private int direction;
|
||||
private float location;
|
||||
private Long receiveTime;
|
||||
private String sectionCode;
|
||||
public Section.SectionRoadType getRoadType(){
|
||||
Section.SectionRoadType type = Section.SectionRoadType.LEFT;
|
||||
if(this.direction == 1){
|
||||
|
@ -1,6 +1,10 @@
|
||||
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.test.LogTest;
|
||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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 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.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -26,10 +35,38 @@ public class StompClientManager {
|
||||
ListenableFuture<StompSession> future = stompClient
|
||||
.connect("ws://127.0.0.1:9000/joylink-tbi-websocket",handler, "null");
|
||||
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");
|
||||
runToRight(stompSession,"002");
|
||||
public static void send(StompSession stompSession,List<TrainPosition> list){
|
||||
//48,55,56,65,75,121,127,138,150,155,162。。,183
|
||||
//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){
|
||||
|
Loading…
Reference in New Issue
Block a user