From 3a283d1227087614f3062fb41754c124ca898646 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Wed, 26 May 2021 14:35:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=87=E4=BB=A4=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=89=A7=E8=A1=8C=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../simulation/cbtc/GroupSimulationServiceImpl.java | 4 ++++ .../joylink/rtss/simulation/cbtc/Simulation.java | 1 + .../cbtc/command/CommandExecuteService.java | 12 ++++++++++++ 3 files changed, 17 insertions(+) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java index b2f56b4ba..3c6106607 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -24,6 +24,7 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainLoadService; import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams; import club.joylink.rtss.simulation.cbtc.command.CommandBO; +import club.joylink.rtss.simulation.cbtc.command.CommandExecuteService; import club.joylink.rtss.simulation.cbtc.command.CommandInitiateVO; import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; @@ -138,6 +139,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { private IRunPlanRunlevelService iRunPlanRunlevelService; @Autowired private IRunPlanParktimeService iRunPlanParktimeService; + @Autowired + private CommandExecuteService commandExecuteService; // /** // * 创建仿真并进行缓存 // * @@ -931,6 +934,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { } CommandBO commandBO = new CommandBO(initiateVO.getCommandType(), member, targetMember, initiateVO.getParams(), steps); targetMember.setCommand(commandBO); + commandExecuteService.addJobs(simulation); } @Override diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java index f90e4aba9..367dcbea1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java @@ -645,5 +645,6 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation haveCommandMember = simulation.getSimulationMembers().stream().filter(member -> member.getCommand() != null).collect(Collectors.toList()); + if (CollectionUtils.isEmpty(haveCommandMember)) + removeJobs(simulation); for (SimulationMember member : haveCommandMember) { CommandBO command = member.getCommand(); if (!member.isRobot()) { @@ -59,4 +63,12 @@ public class CommandExecuteService { } } } + + public void addJobs(Simulation simulation) { + simulation.addJobIfAbsent(Simulation.JobName.commandExecuteRun, () -> this.run(simulation), SimulationConstants.COMMAND_EXECUTE_RATE); + } + + public void removeJobs(Simulation simulation) { + simulation.removeJob(Simulation.JobName.commandExecuteRun); + } }