泰国沙盘改动(没有删除测试用的逻辑)

This commit is contained in:
joylink_zhangsai 2023-07-11 13:39:18 +08:00
parent 21afd1f82f
commit 2a08dab6c9
4 changed files with 170 additions and 138 deletions

View File

@ -1003,95 +1003,95 @@ public class DeviceServiceImpl implements DeviceService {
private void thailandFillTime(ThailandSectionConfigVO configVO, MapSectionNewVO section) {
Float headDelayTime = null;
Float tailDelayTime = null;
if (section.isStandTrack()) { //站台轨默认为车尾出清立即停车
if (section.isStandTrack()) {
headDelayTime = 5f;
}
switch (section.getCode()) {
case "T233": //X302G
headDelayTime = 7.3f;
break;
case "T232": //X303G
headDelayTime = 6.5f;
break;
case "T231": //X304G
headDelayTime = 5.5f;
break;
case "T178": //4站-3G
headDelayTime = 5.2f;
break;
case "T177": //4站-IG
headDelayTime = 5.4f;
break;
case "T175": //4站-IIG
headDelayTime = 6.6f;
break;
case "T174": //4站-4G
headDelayTime = 6.2f;
break;
case "T176": //4站-6G
headDelayTime = 5.9f;
break;
case "T179": //4站-5G
headDelayTime = 6.5f;
break;
case "T123": //3站-3G
headDelayTime = 5.2f;
break;
case "T122": //3站-IG
headDelayTime = 5.3f;
break;
case "T121": //3站-IIG
headDelayTime = 5.9f;
break;
case "T120": //3站-4G
headDelayTime = 5.5f;
break;
case "T78": //2站-IG
headDelayTime = 5.5f;
break;
case "T77": //2站-IIG
headDelayTime = 5.9f;
break;
case "T76": //2站-4G
headDelayTime = 5.7f;
break;
case "T22": //1站-1G
headDelayTime = 5.3f;
break;
case "T23": //1站-IIG
headDelayTime = 5.1f;
break;
case "T27": //1站-5G
headDelayTime = 4.9f;
break;
case "T26": //1站-3G
headDelayTime = 4.8f;
break;
case "T24": //1站-4G
headDelayTime = 5.1f;
break;
case "T25": //1站-6G
headDelayTime = 5.1f;
break;
case "T145": //QX04
headDelayTime = 1.9f;
break;
case "T146": //QS04
headDelayTime = 2.7f;
break;
case "T104": //QX03
tailDelayTime = 0f;
break;
case "T105": //QS03
tailDelayTime = 0f;
break;
case "T62": //QX02
tailDelayTime = 0f;
break;
case "T63": //QS02
tailDelayTime = 0f;
break;
}
// switch (section.getCode()) { 地图更新了code对应不上了
// case "T233": //X302G
// headDelayTime = 7.3f;
// break;
// case "T232": //X303G
// headDelayTime = 6.5f;
// break;
// case "T231": //X304G
// headDelayTime = 5.5f;
// break;
// case "T178": //4站-3G
// headDelayTime = 5.2f;
// break;
// case "T177": //4站-IG
// headDelayTime = 5.4f;
// break;
// case "T175": //4站-IIG
// headDelayTime = 6.6f;
// break;
// case "T174": //4站-4G
// headDelayTime = 6.2f;
// break;
// case "T176": //4站-6G
// headDelayTime = 5.9f;
// break;
// case "T179": //4站-5G
// headDelayTime = 6.5f;
// break;
// case "T123": //3站-3G
// headDelayTime = 5.2f;
// break;
// case "T122": //3站-IG
// headDelayTime = 5.3f;
// break;
// case "T121": //3站-IIG
// headDelayTime = 5.9f;
// break;
// case "T120": //3站-4G
// headDelayTime = 5.5f;
// break;
// case "T78": //2站-IG
// headDelayTime = 5.5f;
// break;
// case "T77": //2站-IIG
// headDelayTime = 5.9f;
// break;
// case "T76": //2站-4G
// headDelayTime = 5.7f;
// break;
// case "T22": //1站-1G
// headDelayTime = 5.3f;
// break;
// case "T23": //1站-IIG
// headDelayTime = 5.1f;
// break;
// case "T27": //1站-5G
// headDelayTime = 4.9f;
// break;
// case "T26": //1站-3G
// headDelayTime = 4.8f;
// break;
// case "T24": //1站-4G
// headDelayTime = 5.1f;
// break;
// case "T25": //1站-6G
// headDelayTime = 5.1f;
// break;
// case "T145": //QX04
// headDelayTime = 1.9f;
// break;
// case "T146": //QS04
// headDelayTime = 2.7f;
// break;
// case "T104": //QX03
// tailDelayTime = 0f;
// break;
// case "T105": //QS03
// tailDelayTime = 0f;
// break;
// case "T62": //QX02
// tailDelayTime = 0f;
// break;
// case "T63": //QS02
// tailDelayTime = 0f;
// break;
// }
configVO.setHeadDelayTime(headDelayTime);
configVO.setTailDelayTime(tailDelayTime);
}

View File

@ -144,7 +144,14 @@ public class ThailandRunPlanServiceImpl implements UDPRealDeviceService {
SimulationDataRepository repository = simulation.getRepository();
repository.getStandList()
.forEach(stand -> stand.setParkingTime(config.getParkingDuration()));
.forEach(stand -> {
if (stand.getSection().isParkingTrack()) {
stand.setParkingTime(0);
} else {
stand.setParkingTime(config.getParkingDuration());
}
stand.setParkingAlwaysValid(true);
});
Map<String, Route[]> routeMap = config.getRouteMap();
if (CollectionUtils.isEmpty(routeMap)) {

View File

@ -255,6 +255,7 @@ public class SimulationRobotService {
Signal throughSignal = robotDriveParam.getThroughSignal();
SignalAspect throughAspect = robotDriveParam.getThroughSignalAspect();
Section section = headPosition.getSection();
boolean parking = train.isParkingAt();
if (throughSignal != null && !Objects.equals(section,
throughSignal.getSection())) { //当车头与要越过的信号机不在同一区段
@ -282,26 +283,8 @@ public class SimulationRobotService {
}
}
// 取禁止信号前停车位置与当前目标停车位置中更近的一个
Signal signal = section.getSignalOf(right);
if (signal != null && !signal.isShunting()) { // 信号机不为调车信号机
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
SectionPosition signalPosition = signal.getPosition();
if (vrSignal != null && (i != 0 || signalPosition.isAheadOf(headPosition,
right))) { //有实体信号机且列车未越过信号机
if (Objects.equals(vrSignal.getAspect(), signal.getDefaultAspect()) //禁止信号
|| Objects.equals(vrSignal.getAspect(), signal.getGuideAspect())) { //引导信号
if (!Objects.equals(signal, throughSignal) || !Objects.equals(vrSignal.getAspect(),
throughAspect)) {
SectionPosition noPassPosition = CalculateService.calculateNextPositionByStartAndLen(
signalPosition, !right, 2, true);
if (targetPosition == null || noPassPosition.isAheadOf(targetPosition, !right)) {
targetPosition = noPassPosition;
}
}
}
}
}
targetPosition = updateTargetPositionOfSignal(headPosition, right,
throughSignal, throughAspect, section, i, targetPosition, train.isParkingAt());
if (targetPosition == null) {
if (selectedPosition != null && section.equals(
@ -336,7 +319,50 @@ public class SimulationRobotService {
if (targetPosition == null) { //上方的区段遍历完后即没有找到目标区段也没有找到轨道尽头
targetPosition = new SectionPosition(section, right ? 0 : section.getMaxOffset());
}
return Optional.ofNullable(targetPosition);
return Optional.of(targetPosition);
}
/**
* 获取以信号机为依据的目标位置
*
* @param i 区段的索引
* @return 如果计算出的targetPosition比参数中的更近则返回新的否则返回原来的
*/
private SectionPosition updateTargetPositionOfSignal(SectionPosition headPosition, boolean right,
Signal throughSignal, SignalAspect throughAspect, Section section, int i,
SectionPosition targetPosition, boolean parking) {
Signal signal = section.getSignalOf(right);
if (signal == null || signal.isShunting()) {
return targetPosition;
}
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
SectionPosition signalPosition = signal.getPosition();
if (vrSignal == null || (i == 0 && headPosition.isAheadOf(signalPosition, right))) {
//解释下||后面的条件如果i!=0则车头位置一定不可能在信号机前方即i==0只是为了减少计算对结果没有影响
return targetPosition;
}
if (targetPosition != null && signalPosition.isAheadOf(targetPosition, right)) {
//只要目标位置没有越过信号机则没必要一定和信号机保持2m距离
return targetPosition;
}
if (!Objects.equals(vrSignal.getAspect(), signal.getDefaultAspect())
&& !Objects.equals(vrSignal.getAspect(), signal.getGuideAspect())) { //非禁止/引导信号
return targetPosition;
}
if (Objects.equals(signal, throughSignal)
&& Objects.equals(vrSignal.getAspect(), throughAspect)) {
return targetPosition;
}
if (parking && section.equals(headPosition.getSection())) { //避免停站结束后向前移动到信号机前
return headPosition;
}
SectionPosition newPosition = CalculateService.calculateNextPositionByStartAndLen(
signalPosition, !right, 2, true);
if (targetPosition == null || newPosition.isAheadOf(targetPosition, !right)) {
return newPosition;
} else {
return targetPosition;
}
}
private void releaseEB(Simulation simulation, SimulationMember driver,

View File

@ -3,50 +3,49 @@ package club.joylink.rtss.websocket.interceptor;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.LoginSessionManager;
import club.joylink.rtss.vo.LoginUserInfoVO;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
import org.springframework.util.StringUtils;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.HandshakeInterceptor;
import java.util.HashMap;
import java.util.Map;
@Slf4j
public class SessionAuthHandshakeInterceptor extends BaseInterceptor {
private static final String Token_Key = "token";
public static final String ATTR_USER_KEY = "user";
private LoginSessionManager loginSessionManager;
public SessionAuthHandshakeInterceptor(LoginSessionManager loginSessionManager) {
this.loginSessionManager = loginSessionManager;
private static final String Token_Key = "token";
public static final String ATTR_USER_KEY = "user";
private LoginSessionManager loginSessionManager;
public SessionAuthHandshakeInterceptor(LoginSessionManager loginSessionManager) {
this.loginSessionManager = loginSessionManager;
}
@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response,
WebSocketHandler wsHandler,
Map<String, Object> attributes) throws Exception {
try {
LoginUserInfoVO loginUserInfoVO = getLoginUser(request);
attributes.put(ATTR_USER_KEY, loginUserInfoVO);
return true;
} catch (Throwable e) {
log.error("未登录或登陆已过期");
}
response.setStatusCode(HttpStatus.UNAUTHORIZED);
return false;
}
@Override
public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler,
Map<String, Object> attributes) throws Exception {
try {
LoginUserInfoVO loginUserInfoVO = getLoginUser(request);
attributes.put(ATTR_USER_KEY, loginUserInfoVO);
return true;
} catch (Throwable e) {
log.error("未登录或登陆已过期", e);
}
response.setStatusCode(HttpStatus.UNAUTHORIZED);
return false;
}
private LoginUserInfoVO getLoginUser(ServerHttpRequest request) {
private LoginUserInfoVO getLoginUser(ServerHttpRequest request) {
// String query = request.getURI().getQuery();
Map<String, String> map = this.findQueryParams(request);
log.info(String.format("webSocket handshake query: [%s]", map));
BusinessExceptionAssertEnum.NOT_LOGIN.assertTrue(StringUtils.hasText(map.get(Token_Key)));
return this.loginSessionManager.getLoginInfoByToken(map.get(Token_Key));
Map<String, String> map = this.findQueryParams(request);
log.info(String.format("webSocket handshake query: [%s]", map));
BusinessExceptionAssertEnum.NOT_LOGIN.assertTrue(StringUtils.hasText(map.get(Token_Key)));
return this.loginSessionManager.getLoginInfoByToken(map.get(Token_Key));
// AccountVO accountVO = loginInfoVO.getAccountVO();
// BusinessExceptionAssertEnum.NOT_LOGIN.assertNotNull(accountVO);
// return accountVO;
}
}
}