大铁仿真创建后自动按计划行车;增加大铁按计划行车逻辑

This commit is contained in:
joylink_zhangsai 2022-11-28 14:56:25 +08:00
parent 1a9c156379
commit 44a77be43a
2 changed files with 26 additions and 1 deletions

View File

@ -412,6 +412,9 @@ public class CTCLogicLoop {
* @param simulation 仿真信息
*/
private void loadSignRunPlanTrain(Simulation simulation) {
if (!simulation.isPlanRunning()) {
return;
}
// 没有加载过计划始发计划已发送至占线板计划时间比当前时间相差5分钟
simulation.getCtcRepository().getAllRunPlanList().stream()
.filter(r -> {

View File

@ -14,6 +14,7 @@ import club.joylink.rtss.simulation.cbtc.build.InterlockBuilder2;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
import club.joylink.rtss.simulation.cbtc.communication.Joylink3DMessageService;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.RouteFls;
import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop;
@ -26,12 +27,16 @@ import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.client.CommandDefinitionVO;
import club.joylink.rtss.vo.client.WebSocketMessageType;
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam;
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
import club.joylink.rtss.vo.map.MapLogicDataNewVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.websocket.StompMessageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@ -39,6 +44,7 @@ import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Slf4j
@Service
@ -75,6 +81,10 @@ public class RailwaySimulationWorkServiceImpl implements SimulationWorkService {
private SimulationLifeCycleService simulationLifeCycleService;
@Autowired
private SimulationWorkServiceManager simulationWorkServiceManager;
@Autowired
private StompMessageService stompMessageService;
@Autowired
private ApplicationContext applicationContext;
@Override
public Simulation.Type getType() {
@ -134,11 +144,23 @@ public class RailwaySimulationWorkServiceImpl implements SimulationWorkService {
if (!CollectionUtils.isEmpty(itemMap)) {
loadItem(simulation);
}
//按计划行车
simulation.setPlanRunning(true);
}
@Override
public void runAsPlan(Simulation simulation, RunAsPlanParam param) {
//重置仿真
this.simulationLifeCycleService.reset(simulation);
//修改仿真时间设置按计划行车状态
LocalDateTime simulationTime = Simulation.convert2SimulationTime(param.getTime());
simulation.setSystemTime(simulationTime);
simulation.setPlanRunning(true);
//发送按计划行车消息
// this.applicationContext.publishEvent(new SimulationRunAsPlanEvent(this, simulation));
Set<String> userIds = simulation.getSimulationUserIds();
this.stompMessageService.sendToUser(userIds,
SocketMessageFactory.build(WebSocketMessageType.Simulation_RunAsPlan_Start, simulation.getId(), simulationTime.plusHours(SimulationConstants.RUN_DIAGRAM_TRANS_TIME)));
}
@Override