武汉8号线列车位置显示功能

This commit is contained in:
tiger_zhou 2022-09-07 08:57:34 +08:00
parent a7ff59fc91
commit 6a3c4ad645
7 changed files with 113 additions and 7 deletions

View File

@ -13,6 +13,7 @@ public enum MapPrdTypeEnum {
BIG_SCREEN("07", "大屏工作站", null),
RUN_PLAN_MAKE("08", "运行图编制工作站", null),
DEPOT_IL("09", "车辆段联锁工作站", null),
BIG_SCREEN_TRAIN_POSITION("10", "大屏车辆真实工作站", null),
// CTC("10", "CTC工作站")
;

View File

@ -0,0 +1,67 @@
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.vo.ws.TrainPosition;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Service
@Slf4j
public class TrainPositionService {
@Resource
AtsTrainLoadService atsTrainLoadService;
@Resource
SimulationManager simulationManager;
final Map<Section.SectionRoadType,List<Section>> map = new ConcurrentHashMap<>();
public void initTrainOrUpdate(String mapName,TrainPosition tp){
// this.simulationManager.getSimulationList().stream().filter(d->d.getb)
List<Simulation> simulationList = this.findSimulationList(mapName);
if(Objects.equals(true, CollectionUtils.isEmpty(simulationList))){
log.error("");
return;
}
for (Simulation sim : simulationList) {
}
}
private void findSection(Simulation sim,TrainPosition tp,Section.SectionRoadType roadType){
/* Section.SectionRoadType roadType = Section.SectionRoadType.LEFT;
if(tp.getDirection() == 1){
roadType = Section.SectionRoadType.RIGHT;
}*/
List<Section> list = sim.getRepository().getSectionList();
list.stream().filter(d->d.getRoadType() == roadType).sorted((o1, o2) -> Integer.compare(1,2)).collect(Collectors.toList());
}
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();
boolean same = Objects.equals(mapName,params.getMap().getName()) && params.getProdType() == MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION;
return same;
}
return false;
}).map(d->(Simulation) d).collect(Collectors.toList());
}
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.entity.Ibp;
import club.joylink.rtss.services.IVirtualRealityIbpService;
import club.joylink.rtss.services.IVoiceCommandService;
@ -191,14 +192,19 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
iscsLogicLoop.addJob(simulation);
}
atpLogicLoop.addJobs(simulation);
atsLogicLoop.addJobs(simulation);
if(simulation.getBuildParams().getProdType() != MapPrdTypeEnum.BIG_SCREEN_TRAIN_POSITION){
//非武汉大屏车辆定位
atsLogicLoop.addJobs(simulation);
simulationRobotService.addJobs(simulation);
}
vrTrainRunningService.addJobs(simulation);
ciLogic.addJobs(simulation);
vrDeviceLogicLoop.addJobs(simulation);
atsMessageCollectAndDispatcher.addJobs(simulation);
joylink3DMessageService.addJobs(simulation);
faultGenerator.addJobs(simulation);
simulationRobotService.addJobs(simulation);
}
@Override

View File

@ -0,0 +1,12 @@
package club.joylink.rtss.vo.ws;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class TrainPosition {
private String trainTripNum;
private int direction;
private float location;
}

View File

@ -28,4 +28,12 @@ public class WebSocketController {
SocketMessageVO<String> message = SocketMessageFactory.buildVrMessage(group, json);
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
}
@MessageMapping("/{mapId}/trainPosition")
public void mlbs( String json,@DestinationVariable String mapId) {
// Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
// SocketMessageVO<String> message = SocketMessageFactory.buildVrMessage(group, json);
// stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
System.out.println("aaaaaaaaaaaaa");
}
}

View File

@ -43,13 +43,11 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
registry.addEndpoint("/joylink-websocket")
.addInterceptors(new SessionAuthHandshakeInterceptor(loginSessionManager))
.setHandshakeHandler(new DefaultHandshakeHandler() {
@Override
protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler,
Map<String, Object> attributes) {
return new MyPrincipal((LoginUserInfoVO) attributes.get(SessionAuthHandshakeInterceptor.ATTR_USER_KEY));
}
})
.setAllowedOrigins("*");
registry.addEndpoint("/joylink-wm-websocket")
@ -64,6 +62,8 @@ public class WebsocketConfig implements WebSocketMessageBrokerConfigurer {
})
.setAllowedOrigins("*");
registry.addEndpoint("/joylink-tbi-websocket")
.setAllowedOrigins("*");
}
/**

View File

@ -1,11 +1,16 @@
package club.joylink.rtss.websocket.client;
import club.joylink.rtss.util.JsonUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.stomp.StompSession;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.messaging.WebSocketStompClient;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
@Slf4j
@ -18,10 +23,17 @@ public class StompClientManager {
WebSocketStompClient stompClient = new WebSocketStompClient(socketClient);
SimulationSessionHandler handler = new SimulationSessionHandler();
ListenableFuture<StompSession> future = stompClient
.connect("ws://192.168.3.120:9000/joylink-websocket?token=cc789dc2b2f003b2593f5eafbf4763bd",
handler, "null");
.connect("ws://127.0.0.1:9000/joylink-tbi-websocket",handler, "null");
StompSession stompSession = future.get();
stompSession.subscribe("/user/queue/simulation/11/ats", handler);
Map<String,Object> dataMap = new HashMap<>();
dataMap.put("trainTripNum","train001");
dataMap.put("direction",1);
dataMap.put("location",19.99);
ObjectMapper om = new ObjectMapper();
String val = JsonUtils.writeValueNullableFieldAsString(dataMap);
System.out.println(val);
stompSession.send("/app/测试中文/trainPosition",val.getBytes(StandardCharsets.UTF_8));
}
}