添加指令循环执行任务
This commit is contained in:
parent
c97b7caccc
commit
3a283d1227
@ -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.ATS.service.AtsTrainLoadService;
|
||||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
|
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
|
||||||
import club.joylink.rtss.simulation.cbtc.command.CommandBO;
|
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.command.CommandInitiateVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo;
|
import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo;
|
||||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||||
@ -138,6 +139,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
|||||||
private IRunPlanRunlevelService iRunPlanRunlevelService;
|
private IRunPlanRunlevelService iRunPlanRunlevelService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private IRunPlanParktimeService iRunPlanParktimeService;
|
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);
|
CommandBO commandBO = new CommandBO(initiateVO.getCommandType(), member, targetMember, initiateVO.getParams(), steps);
|
||||||
targetMember.setCommand(commandBO);
|
targetMember.setCommand(commandBO);
|
||||||
|
commandExecuteService.addJobs(simulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -645,5 +645,6 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
|||||||
String controlDevice = "controlDevice";
|
String controlDevice = "controlDevice";
|
||||||
String queryDeviceStatus = "queryDeviceStatus";
|
String queryDeviceStatus = "queryDeviceStatus";
|
||||||
String UpdateDeviceStatusByCollection = "UpdateDeviceStatusByCollection";
|
String UpdateDeviceStatusByCollection = "UpdateDeviceStatusByCollection";
|
||||||
|
String commandExecuteRun = "commandExecuteRun";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,14 @@ package club.joylink.rtss.simulation.cbtc.command;
|
|||||||
|
|
||||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
|
import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService;
|
import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -25,6 +27,8 @@ public class CommandExecuteService {
|
|||||||
public void run(Simulation simulation) {
|
public void run(Simulation simulation) {
|
||||||
List<SimulationMember> haveCommandMember =
|
List<SimulationMember> haveCommandMember =
|
||||||
simulation.getSimulationMembers().stream().filter(member -> member.getCommand() != null).collect(Collectors.toList());
|
simulation.getSimulationMembers().stream().filter(member -> member.getCommand() != null).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(haveCommandMember))
|
||||||
|
removeJobs(simulation);
|
||||||
for (SimulationMember member : haveCommandMember) {
|
for (SimulationMember member : haveCommandMember) {
|
||||||
CommandBO command = member.getCommand();
|
CommandBO command = member.getCommand();
|
||||||
if (!member.isRobot()) {
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user