修改泰国沙盘逻辑,提高UDP真实设备逻辑运行速度

This commit is contained in:
joylink_zhangsai 2023-06-07 17:54:58 +08:00
parent b70d829c65
commit 6a9b4c43c9
6 changed files with 109 additions and 51 deletions

View File

@ -994,44 +994,65 @@ public class DeviceServiceImpl implements DeviceService {
}
switch (section.getCode()) {
case "T233": //X302G
headDelayTime = 7f;
headDelayTime = 7.3f;
break;
case "T232": //X303G
headDelayTime = 7f;
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.5f;
headDelayTime = 6.6f;
break;
case "T174": //4站-4G
headDelayTime = 6.2f;
break;
case "T176": //4站-6G
headDelayTime = 6f;
break;
case "T179": //4站-5G
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.1f;
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 = 6.1f;
headDelayTime = 5.9f;
break;
case "T76": //2站-4G
headDelayTime = 5.7f;
break;
case "T22": //1站-1G
headDelayTime = 5.1f;
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;
@ -1039,10 +1060,10 @@ public class DeviceServiceImpl implements DeviceService {
headDelayTime = 5.1f;
break;
case "T145": //QX04
tailDelayTime = 0f;
headDelayTime = 1.9f;
break;
case "T146": //QS04
tailDelayTime = 0f;
headDelayTime = 2.7f;
break;
case "T104": //QX03
tailDelayTime = 0f;

View File

@ -23,7 +23,7 @@ public class UDPRealDeviceThread {
* <p>
* 因沙盘对延迟要求较高所以将频率提高
*/
public static final int RATE = 100;
public static final int RATE = 10;
@Autowired
private UDPRealDeviceServiceManager udpRealDeviceServiceManager;

View File

@ -24,6 +24,8 @@ public class ThailandSectionServiceImpl implements UDPRealDeviceService {
@Autowired
private MaService maService;
@Autowired
private ThailandTrainServiceImpl thailandTrainService;
@Override
public boolean isMatch(RealDeviceConfig realDevice) {

View File

@ -5,6 +5,8 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainLoadService;
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
@ -18,10 +20,12 @@ import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.udp.thailand.config.ThailandSectionConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.thailand.config.ThailandTrainConfig;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
import club.joylink.rtss.vo.client.project.thailand.ThailandSectionConfigVO;
import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -40,6 +44,8 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
private GroupSimulationService groupSimulationService;
@Autowired
private AtsTrainLoadService atsTrainLoadService;
@Autowired
private SimulationRobotService simulationRobotService;
@Override
public boolean isMatch(UDPLowConfig udpLowConfig) {
@ -64,8 +70,7 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
config.setManualGear(null);
config.setGear(null);
}
updateTrainPosition(simulation, train, config);
updateTrainSpeed(simulation, train, config);
updateTrainPositionAndSpeed(simulation, train, config);
//减少关门后的延迟发车时间
if (train.getDelayTime() > 3000) {
train.setDelayTime(3000);
@ -84,7 +89,7 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
* 1.如果列车占压新的区段则先将列车车头位置更新至该区段的停车点之前保证列车可以继续运行 2.根据区段的配置信息决定列车何时将车头位置更新至停车点
* 3.根据上一步设置的停车时间判断执行更新车头位置至停车点逻辑触发列车停车逻辑
*/
private void updateTrainPosition(Simulation simulation, VirtualRealityTrain train,
private void updateTrainPositionAndSpeed(Simulation simulation, VirtualRealityTrain train,
ThailandTrainConfig config) {
//判断列车是否到达新区段
boolean right = train.isRight(); //车头方向
@ -130,15 +135,46 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
}
//根据当前时间判断更新车头位置至停车点
LocalDateTime timeOfArriveStopPoint = config.getTimeOfArriveStopPoint();
Optional<SectionPosition> stopPositionOptional = simulationRobotService.calculateTargetPosition(
simulation, train);
SectionPosition stopPosition = stopPositionOptional.orElse(null);
if (timeOfArriveStopPoint != null && !now.isBefore(timeOfArriveStopPoint)) {
SectionPosition stopPosition = train.getRobotDriveParam().getStopPosition();
if (stopPosition != null && stopPosition.getSection().equals(headSection)) {
train.setHeadPosition(stopPosition);
} else if (stopPosition == null || !stopPosition.getSection().equals(headSection)) {
} else {
float offset = right ? headSection.getMaxOffset() : 0;
train.setHeadPosition(new SectionPosition(headSection, offset));
}
}
//更新速度由于沙盘对延时要求很高机器人驾驶逻辑频率有点低所以选择不利用机器人驾驶的逻辑
if (config.getManualGear() != null) {
return;
}
if (stopPosition != null) {
Float distance = CalculateService.calculateDistance(train.getHeadPosition(), stopPosition,
right, false);
if (distance == null || distance <= SimulationConstants.PARK_POINT_MAX_OFFSET) {
train.setSpeed(0);
return;
}
float highSpeed = 20 / 3.6f;
float lowSpeed = 10 / 3.6f;
if (headSection.isStandTrack()) {
train.setSpeed(lowSpeed);
return;
}
if (stopPosition.getSection().isStandTrack()) {
Section stopPreviousSection = stopPosition.getSection().getNextRunningSectionOf(!right);
if (stopPreviousSection != null && Objects.equals(stopPreviousSection.findAxle(),
headSection.findAxle())) { //当前车头在站台轨的前一个计轴区段
train.setSpeed(lowSpeed);
return;
}
}
train.setSpeed(highSpeed);
} else {
train.setSpeed(0);
}
}
/**
@ -184,19 +220,6 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
}
private void updateTrainSpeed(Simulation simulation, VirtualRealityTrain train,
ThailandTrainConfig config) {
//更新速度
if (config.getManualGear() != null) {
return;
}
if (train.getFk() > train.getFb()) {
train.setSpeed(10 / 3.6f);
} else if (train.getFb() > train.getFk()) {
train.setSpeed(0);
}
}
private byte[] buildData(VirtualRealityTrain train, ThailandTrainConfig config) {
int gear;
if (train.isStop()) {
@ -235,44 +258,65 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
}
switch (section.getCode()) {
case "T233": //X302G
headDelayTime = 7f;
headDelayTime = 7.3f;
break;
case "T232": //X303G
headDelayTime = 7f;
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.5f;
headDelayTime = 6.6f;
break;
case "T174": //4站-4G
headDelayTime = 6.2f;
break;
case "T176": //4站-6G
headDelayTime = 6f;
break;
case "T179": //4站-5G
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.1f;
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 = 6.1f;
headDelayTime = 5.9f;
break;
case "T76": //2站-4G
headDelayTime = 5.7f;
break;
case "T22": //1站-1G
headDelayTime = 5.1f;
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;
@ -280,10 +324,10 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
headDelayTime = 5.1f;
break;
case "T145": //QX04
tailDelayTime = 0f;
headDelayTime = 1.9f;
break;
case "T146": //QS04
tailDelayTime = 0f;
headDelayTime = 2.7f;
break;
case "T104": //QX03
tailDelayTime = 0f;

View File

@ -207,7 +207,7 @@ public class SimulationRobotService {
/**
* 计算目标位置
*/
private Optional<SectionPosition> calculateTargetPosition(Simulation simulation,
public Optional<SectionPosition> calculateTargetPosition(Simulation simulation,
VirtualRealityTrain train) {
DriveParamVO robotDriveParam = train.getRobotDriveParam();
if (train.isEB()) {
@ -345,11 +345,8 @@ public class SimulationRobotService {
*/
private void robotDrive(Simulation simulation, SimulationMember driver, VirtualRealityTrain train,
SectionPosition targetPosition) {
train.getRobotDriveParam().setStopPosition(targetPosition);
if (!train.isInTheGear(VirtualRealityTrain.Handwheel.MANUAL)) { //确保当前在手动档位
return;
// CommandBO.Step step = CommandBO.buildGearChangeStep(train.getGroupNumber(), VirtualRealityTrain.Handwheel.MANUAL);
// atsOperationDispatcher.execute(simulation, driver, step.getOperationType().name(), step.getOperationParams());
}
if (train.isEB()) {
if (train.getRobotDriveParam().isReleaseEB()) {

View File

@ -57,12 +57,6 @@ public class DriveParamVO {
*/
private int through;
/**
* 这个停车位置是机器人驾驶逻辑计算出来的这个字段仅供泰国沙盘的列车逻辑使用
*/
@JsonIgnore
private SectionPosition stopPosition;
public static final int NO = 0;
public static final int RED_SIGNAL = 1;
public static final int GUIDE_SIGNAL = 2;