Merge remote-tracking branch 'origin/test-training2' into test-training2
This commit is contained in:
commit
fbdbd33e49
@ -9,6 +9,7 @@ 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.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,7 +39,7 @@ public class Training2DraftPublishService {
|
|||||||
//根据要发布的草稿名称来查找已发布的实训
|
//根据要发布的草稿名称来查找已发布的实训
|
||||||
//如果以有同名的则会被覆盖
|
//如果以有同名的则会被覆盖
|
||||||
PublishedTraining2Example ptExample = new PublishedTraining2Example();
|
PublishedTraining2Example ptExample = new PublishedTraining2Example();
|
||||||
ptExample.createCriteria().andNameEqualTo(draft.getName());
|
ptExample.createCriteria().andNameEqualTo(draft.getName()).andMapIdEqualTo(draft.getMapId());
|
||||||
List<PublishedTraining2> ptFinds = this.publishedDao.selectByExample(ptExample);
|
List<PublishedTraining2> ptFinds = this.publishedDao.selectByExample(ptExample);
|
||||||
//
|
//
|
||||||
if (null != ptFinds && !ptFinds.isEmpty()) {//已发布实训存在时则直接删除
|
if (null != ptFinds && !ptFinds.isEmpty()) {//已发布实训存在时则直接删除
|
||||||
|
@ -54,7 +54,7 @@ public class Training2DraftService {
|
|||||||
public CreateTraining2RspVo createTraining(CreateTraining2ReqVo req, AccountVO user) {
|
public CreateTraining2RspVo createTraining(CreateTraining2ReqVo req, AccountVO user) {
|
||||||
//校验是否已经有同名的实训
|
//校验是否已经有同名的实训
|
||||||
DraftTraining2Example example = new DraftTraining2Example();
|
DraftTraining2Example example = new DraftTraining2Example();
|
||||||
example.createCriteria().andNameEqualTo(req.getName());
|
example.createCriteria().andCreatorIdEqualTo(user.getId()).andNameEqualTo(req.getName()).andMapIdEqualTo(req.getMapId());
|
||||||
List<DraftTraining2> check = this.trainingDao.selectByExample(example);
|
List<DraftTraining2> check = this.trainingDao.selectByExample(example);
|
||||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionEmpty(check, "实训已经存在");
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertCollectionEmpty(check, "实训已经存在");
|
||||||
//
|
//
|
||||||
|
@ -34,6 +34,7 @@ import org.springframework.util.StringUtils;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -66,6 +67,16 @@ public class Training2Service {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private StompMessageService stompMessageService;
|
private StompMessageService stompMessageService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 完成步骤接口信号量
|
||||||
|
*/
|
||||||
|
private Semaphore completeStepSemaphore = new Semaphore(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 完成操作接口信号量
|
||||||
|
*/
|
||||||
|
private Semaphore completeOperationSemaphore = new Semaphore(1);
|
||||||
|
|
||||||
public void run(Simulation simulation) {
|
public void run(Simulation simulation) {
|
||||||
Training2 training2 = simulation.getTraining2();
|
Training2 training2 = simulation.getTraining2();
|
||||||
if (training2 == null || !training2.isStarted() || training2.isFinish()) {
|
if (training2 == null || !training2.isStarted() || training2.isFinish()) {
|
||||||
@ -81,47 +92,19 @@ public class Training2Service {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 获取步骤中未完成的操作
|
// 获取步骤中未完成的操作
|
||||||
Operation2 operation2 = step.getCurrentRunOperation();
|
Operation2 operation2 = getOperationAndTryTrigger(step, simulation);
|
||||||
// 操作全部完成的情况,检查步骤完成条件
|
|
||||||
if (operation2 == null) {
|
if (operation2 == null) {
|
||||||
// TODO 后续判断步骤完成情况
|
|
||||||
checkTrainStepCompletion(step, simulation);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 操作是否已触发
|
// 尝试执行操作
|
||||||
// 没有触发则检查触发状态,如果可以触发则继续,不能触发则返回(同步骤)
|
if (!tryDoOperation(simulation, step, operation2)) {
|
||||||
if (!Step2.StepStatus.isAlreadyTrigger(operation2.getStatus()) && !operation2.doTriggerVail()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean isRobot = step.getSimulationMember().isRobot(); // 角色是否是机器人
|
// 操作运行阶段,判断是否完成
|
||||||
boolean isClient = operation2 instanceof Operation2.ClientOperation2; // 客户端操作
|
tryCompleteOperation(simulation, step, operation2);
|
||||||
// 未操作过
|
|
||||||
if (Step2.StepStatus.isUndo(operation2.getStatus())) {
|
|
||||||
if (isRobot) {
|
|
||||||
if (isClient) { // 客户端操作
|
|
||||||
operation2.doOperated();
|
|
||||||
} else { // 仿真操
|
|
||||||
Operation2.SimOperation2 simOperation2 = (Operation2.SimOperation2) operation2;
|
|
||||||
atsOperationDispatcher.execute(simulation, step.getSimulationMember(),
|
|
||||||
simOperation2.getOperationType().name(), simOperation2.getParams());
|
|
||||||
}
|
|
||||||
} else { // 非机器人,暂停仿真等待用户操作
|
|
||||||
pauseOrStartSimulation(simulation, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 运行阶段,判断是否完成
|
|
||||||
if (Step2.StepStatus.isRunning(operation2.getStatus())) {
|
|
||||||
boolean completion = operation2.doCompletion();
|
|
||||||
// 发送操作完成信息
|
|
||||||
sendOperationFinish(operation2, simulation);
|
|
||||||
// 如果是最后一步,直接检查步骤有没有完成
|
|
||||||
if (step.getOperations().indexOf(operation2) == (step.getOperations().size() - 1) && completion) {
|
|
||||||
checkStepCompletionAndSendNext(step, simulation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 预览实训草稿
|
* 预览实训草稿
|
||||||
*/
|
*/
|
||||||
@ -263,6 +246,10 @@ public class Training2Service {
|
|||||||
if (Objects.equals(user.getId(), step.getSimulationMember().getId())) {
|
if (Objects.equals(user.getId(), step.getSimulationMember().getId())) {
|
||||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation, "无权限操作");
|
throw new SimulationException(SimulationExceptionType.Invalid_Operation, "无权限操作");
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
if (!step.isCompletion()) {
|
||||||
|
completeStepSemaphore.acquire(); // 控制多次请求
|
||||||
|
if (!step.isCompletion()) { //二次判断
|
||||||
boolean result = true;
|
boolean result = true;
|
||||||
for (Operation2 operation2 : step.getOperations()) {
|
for (Operation2 operation2 : step.getOperations()) {
|
||||||
if (operation2 instanceof Operation2.ClientOperation2) { // 前端操作,直接判断结果
|
if (operation2 instanceof Operation2.ClientOperation2) { // 前端操作,直接判断结果
|
||||||
@ -278,6 +265,13 @@ public class Training2Service {
|
|||||||
}
|
}
|
||||||
// 恢复前端运行
|
// 恢复前端运行
|
||||||
pauseOrStartSimulation(simulation, false);
|
pauseOrStartSimulation(simulation, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
completeStepSemaphore.release();
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,9 +301,21 @@ public class Training2Service {
|
|||||||
if (operation == null) {
|
if (operation == null) {
|
||||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation, "不存在操作");
|
throw new SimulationException(SimulationExceptionType.Invalid_Operation, "不存在操作");
|
||||||
}
|
}
|
||||||
operation.doOperated();
|
try {
|
||||||
|
if (!Step2.StepStatus.isCompletion(operation.getStatus())) {
|
||||||
|
completeOperationSemaphore.acquire();
|
||||||
|
if (!Step2.StepStatus.isCompletion(operation.getStatus())) {
|
||||||
|
operation.doOperated(); //操作过后
|
||||||
|
tryCompleteOperation(simulation, step, operation); // 尝试完成
|
||||||
// 恢复前端运行
|
// 恢复前端运行
|
||||||
pauseOrStartSimulation(simulation, false);
|
pauseOrStartSimulation(simulation, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} finally {
|
||||||
|
completeOperationSemaphore.release();
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,6 +521,66 @@ public class Training2Service {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取步骤中操作,并尝试触发
|
||||||
|
*/
|
||||||
|
private Operation2 getOperationAndTryTrigger(Step2 step, Simulation simulation) {
|
||||||
|
// 获取步骤中未完成的操作
|
||||||
|
Operation2 operation2 = step.getCurrentRunOperation();
|
||||||
|
// 操作全部完成的情况,检查步骤完成条件
|
||||||
|
if (operation2 == null) {
|
||||||
|
// TODO 后续判断步骤完成情况
|
||||||
|
checkTrainStepCompletion(step, simulation);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// 操作是否已触发
|
||||||
|
// 没有触发则检查触发状态,如果可以触发则继续,不能触发则返回(同步骤)
|
||||||
|
if (!Step2.StepStatus.isAlreadyTrigger(operation2.getStatus()) && !operation2.doTriggerVail()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return operation2;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 尝试操作动作
|
||||||
|
*/
|
||||||
|
private boolean tryDoOperation(Simulation simulation, Step2 step, Operation2 operation2) {
|
||||||
|
boolean isRobot = step.getSimulationMember().isRobot(); // 角色是否是机器人
|
||||||
|
boolean isClient = operation2 instanceof Operation2.ClientOperation2; // 客户端操作
|
||||||
|
// 未操作过
|
||||||
|
if (Step2.StepStatus.isUndo(operation2.getStatus())) {
|
||||||
|
if (isRobot) {
|
||||||
|
if (isClient) { // 客户端操作
|
||||||
|
operation2.doOperated();
|
||||||
|
} else { // 仿真操
|
||||||
|
Operation2.SimOperation2 simOperation2 = (Operation2.SimOperation2) operation2;
|
||||||
|
atsOperationDispatcher.execute(simulation, step.getSimulationMember(),
|
||||||
|
simOperation2.getOperationType().name(), simOperation2.getParams());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else { // 非机器人,暂停仿真等待用户操作
|
||||||
|
pauseOrStartSimulation(simulation, true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 尝试完成操作
|
||||||
|
*/
|
||||||
|
private void tryCompleteOperation(Simulation simulation, Step2 step, Operation2 operation2) {
|
||||||
|
if (Step2.StepStatus.isRunning(operation2.getStatus())) {
|
||||||
|
boolean completion = operation2.doCompletion();
|
||||||
|
// 发送操作完成信息
|
||||||
|
sendOperationFinish(operation2, simulation);
|
||||||
|
// 如果是最后一步,直接检查步骤有没有完成
|
||||||
|
if (step.getOperations().indexOf(operation2) == (step.getOperations().size() - 1) && completion) {
|
||||||
|
checkStepCompletionAndSendNext(step, simulation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直接完成并尝试触发下一步
|
* 直接完成并尝试触发下一步
|
||||||
*/
|
*/
|
||||||
@ -528,7 +594,9 @@ public class Training2Service {
|
|||||||
if (nextStep == null) {
|
if (nextStep == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tryTriggerStep(nextStep, simulation);
|
if (tryTriggerStep(nextStep, simulation)) {
|
||||||
|
getOperationAndTryTrigger(nextStep, simulation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.vo.CtcStationRunPlanLogVO;
|
|||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RouteSequenceVO;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.RouteSequenceVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.TrackViewVO;
|
import club.joylink.rtss.simulation.cbtc.CTC.data.vo.TrackViewVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.CTC.param.CtcRunPlanParam;
|
import club.joylink.rtss.simulation.cbtc.CTC.param.CtcRunPlanParam;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.DCMD;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
|
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||||
@ -112,7 +113,11 @@ public class CtcRepository {
|
|||||||
* 调度命令id生成器
|
* 调度命令id生成器
|
||||||
*/
|
*/
|
||||||
private AtomicInteger dispatchCommandIdGenerator = new AtomicInteger(0);
|
private AtomicInteger dispatchCommandIdGenerator = new AtomicInteger(0);
|
||||||
|
/**
|
||||||
|
* 新版调度命令
|
||||||
|
* k - 调度命令id
|
||||||
|
*/
|
||||||
|
private final Map<String, DCMD> dcmdMap = new ConcurrentHashMap<>();
|
||||||
/**
|
/**
|
||||||
* 调度命令
|
* 调度命令
|
||||||
* k - 调度命令id
|
* k - 调度命令id
|
||||||
|
@ -0,0 +1,122 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDReceiversManager;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令数据定义
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DCMD {
|
||||||
|
/**
|
||||||
|
* 唯一id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
private String title;
|
||||||
|
/**
|
||||||
|
* 调度命令号
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
/**
|
||||||
|
* 中转识别号
|
||||||
|
*/
|
||||||
|
private String transitId;
|
||||||
|
/**
|
||||||
|
* 发令时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime sendTime;
|
||||||
|
/**
|
||||||
|
* 发令人
|
||||||
|
*/
|
||||||
|
private String sender;
|
||||||
|
/**
|
||||||
|
* 发令单位(用户手写)
|
||||||
|
*/
|
||||||
|
private String company;
|
||||||
|
/**
|
||||||
|
* 调度命令创建平台(调度台或车站)
|
||||||
|
*/
|
||||||
|
private SimulationMember creator;
|
||||||
|
/**
|
||||||
|
* 授权时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime authTime;
|
||||||
|
/**
|
||||||
|
* 值班主任(仿真成员)
|
||||||
|
*/
|
||||||
|
private SimulationMember chiefOnDuty;
|
||||||
|
/**
|
||||||
|
* 需值班主任授权
|
||||||
|
*/
|
||||||
|
private Boolean chiefOnDutyAuth=false;
|
||||||
|
/**
|
||||||
|
* 授权状态
|
||||||
|
*/
|
||||||
|
private String authState;
|
||||||
|
/**
|
||||||
|
* 定稿时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime finishedTime;
|
||||||
|
/**
|
||||||
|
* 审核人(仿真成员)
|
||||||
|
*/
|
||||||
|
private SimulationMember reviewer;
|
||||||
|
/**
|
||||||
|
* 日计划号
|
||||||
|
*/
|
||||||
|
private String dailyPlanNum;
|
||||||
|
/**
|
||||||
|
* 拟令人(起草者、设计者)
|
||||||
|
*/
|
||||||
|
private String designer;
|
||||||
|
/**
|
||||||
|
* 调度命令类型
|
||||||
|
*/
|
||||||
|
private Type type;
|
||||||
|
/**
|
||||||
|
* 调度命令正文
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
/**
|
||||||
|
* 调度命令的受令者管理
|
||||||
|
*/
|
||||||
|
private DCMDReceiversManager receiversManager;
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 签收状态
|
||||||
|
*/
|
||||||
|
public enum SignStatus {
|
||||||
|
/**
|
||||||
|
*未签收
|
||||||
|
*/
|
||||||
|
UNSIGNED,
|
||||||
|
/**
|
||||||
|
* 签收
|
||||||
|
*/
|
||||||
|
SIGNED,
|
||||||
|
/**
|
||||||
|
* 代签
|
||||||
|
*/
|
||||||
|
PROXY,
|
||||||
|
;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 调度命令类型
|
||||||
|
*/
|
||||||
|
public enum Type {
|
||||||
|
/**
|
||||||
|
* 正常调度命令
|
||||||
|
*/
|
||||||
|
NORMAL,;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回执的定义
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DCMDReceipt {
|
||||||
|
/**
|
||||||
|
* 回执唯一id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
/**
|
||||||
|
* 调度命令号
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
/**
|
||||||
|
* 回执状态
|
||||||
|
*/
|
||||||
|
private String state;
|
||||||
|
/**
|
||||||
|
* 回执时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime time;
|
||||||
|
/**
|
||||||
|
* 签收单位
|
||||||
|
*/
|
||||||
|
private String sigCompany;
|
||||||
|
/**
|
||||||
|
* 签收人
|
||||||
|
*/
|
||||||
|
private String signedBy;
|
||||||
|
/**
|
||||||
|
* 车次号
|
||||||
|
*/
|
||||||
|
private String trainNum;
|
||||||
|
/**
|
||||||
|
* 机车号
|
||||||
|
*/
|
||||||
|
private VirtualRealityTrain train;
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令查询服务
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class RailDCMDFindService {
|
||||||
|
/**
|
||||||
|
* 调度台查询与自己相关的所有调度命令
|
||||||
|
* @param dispatcher 调度台
|
||||||
|
*/
|
||||||
|
public void findForDispatcher(Simulation simulation, SimulationMember dispatcher){
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 车站查询与自己相关的所有调度命令
|
||||||
|
*/
|
||||||
|
public void findForStation(Simulation simulation, Station station){
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 列控查询与自己相关的所有调度命令
|
||||||
|
*/
|
||||||
|
public void findForTsr(Simulation simulation, String tsrCode){
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 无线受令端查询与自己相关的所有调度命令
|
||||||
|
* @param trainCode 机车号
|
||||||
|
* @param trainNum 车次号
|
||||||
|
*/
|
||||||
|
public void findForTrain(Simulation simulation,String trainNum, String trainCode){
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,160 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
|
||||||
|
|
||||||
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDDisReceiver;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDStationReceiver;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDTrainReceiver;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDTsrReceiver;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令发送相关服务
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class RailDCMDSendService {
|
||||||
|
@Autowired
|
||||||
|
private RailDCMDService dCmdService;
|
||||||
|
/**
|
||||||
|
* 创建者(调度台或车站)发送调度命令
|
||||||
|
* @param creator 调度命令的创建平台
|
||||||
|
* @param dCmdId 调度命令的id
|
||||||
|
*/
|
||||||
|
public void sendByCreator(Simulation simulation, SimulationMember creator, String dCmdId){
|
||||||
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
|
DCMD cmd = ctcRepository.getDcmdMap().get(dCmdId);
|
||||||
|
//
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd, String.format("调度命令不存在,id=%s", dCmdId));
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(creator.getId().equals(cmd.getId()),String.format("调度命令(id=%s)的创建平台(SimulationMember.id=%s)校验失败",dCmdId,creator.getId()));
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(cmd.getReceiversManager().getPosSend(),String.format("调度命令(id=%s)被创建者(id=%s)重复发送",dCmdId,creator.getId()));
|
||||||
|
//发送给车站受令者
|
||||||
|
cmd.getReceiversManager().getStationReceivers().forEach(stationReceiver->{
|
||||||
|
this.sendToStationByCreator(simulation,stationReceiver);
|
||||||
|
});
|
||||||
|
//发送给列控服务器受令者
|
||||||
|
cmd.getReceiversManager().getTsrReceivers().forEach(tsrReceiver->{
|
||||||
|
this.sendToTsrByCreator(simulation,tsrReceiver);
|
||||||
|
});
|
||||||
|
//发送给调度台受令者
|
||||||
|
cmd.getReceiversManager().getDisReceivers().forEach(disReceiver->{
|
||||||
|
this.sendToDisByCreator(simulation,disReceiver);
|
||||||
|
});
|
||||||
|
//发送给无线受令者
|
||||||
|
cmd.getReceiversManager().getTrainReceivers().forEach(trainReceiver->{
|
||||||
|
this.sendToTrainByCreator(simulation,trainReceiver);
|
||||||
|
});
|
||||||
|
//至此该调度命令发送完,则该调度命令进入该创建者的 发令箱
|
||||||
|
cmd.getReceiversManager().setPosSend(true);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 发送给车站
|
||||||
|
*/
|
||||||
|
private void sendToStationByCreator(Simulation simulation, DCMDStationReceiver stationReceiver){
|
||||||
|
//发送到收令箱
|
||||||
|
if(!stationReceiver.getPosReceive()){
|
||||||
|
stationReceiver.setPosReceive(true);
|
||||||
|
stationReceiver.setReceivedTime(dCmdService.getSimLocalDateTime());
|
||||||
|
}
|
||||||
|
//todo 向前端发送收令通知
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 发送给列控服务器
|
||||||
|
*/
|
||||||
|
private void sendToTsrByCreator(Simulation simulation, DCMDTsrReceiver tsrReceiver){
|
||||||
|
//发送到收令箱
|
||||||
|
if(!tsrReceiver.getPosReceive()){
|
||||||
|
tsrReceiver.setPosReceive(true);
|
||||||
|
tsrReceiver.setReceivedTime(dCmdService.getSimLocalDateTime());
|
||||||
|
}
|
||||||
|
//todo 向前端发送收令通知
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 发送给调度台
|
||||||
|
*/
|
||||||
|
private void sendToDisByCreator(Simulation simulation, DCMDDisReceiver disReceiver){
|
||||||
|
//发送到收令箱
|
||||||
|
if(!disReceiver.getPosReceive()){
|
||||||
|
disReceiver.setPosReceive(true);
|
||||||
|
disReceiver.setReceivedTime(dCmdService.getSimLocalDateTime());
|
||||||
|
}
|
||||||
|
//todo 向前端发送收令通知
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 发送给无线机车
|
||||||
|
*/
|
||||||
|
private void sendToTrainByCreator(Simulation simulation, DCMDTrainReceiver trainReceiver){
|
||||||
|
//通过GSM移动网络,发送到机车收令箱
|
||||||
|
if(trainReceiver.isSendViaGSM()){
|
||||||
|
if(!trainReceiver.getPosReceive()){
|
||||||
|
trainReceiver.setPosReceive(true);
|
||||||
|
trainReceiver.setReceivedTime(dCmdService.getSimLocalDateTime());
|
||||||
|
//todo 向前端发送收令通知
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//车站自律机通过400M专有网络转发到机车收令箱
|
||||||
|
//此时先发送到车站自律机收令箱
|
||||||
|
if(trainReceiver.isSendViaSRM()){
|
||||||
|
if(!trainReceiver.getPosSrmReceive()){
|
||||||
|
trainReceiver.setPosSrmReceive(true);
|
||||||
|
//待自律机根据转发策略发送到机车
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 车站自律机能否发送无线调度命令检查
|
||||||
|
* <p>
|
||||||
|
* 当机车进入车站400M网络覆盖区时可以发送
|
||||||
|
*/
|
||||||
|
private boolean checkSrmCanSendBy400M(Station srmStation, DCMDTrainReceiver dCmdTrain){
|
||||||
|
//todo
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
////////////////////////////////////////自律机///////////////////////////////////////////////
|
||||||
|
/**
|
||||||
|
* 车站自律机智能自动转发无线调度命令服务
|
||||||
|
*/
|
||||||
|
public void srmAutoSendToTrainSv(Simulation simulation,Station srmStation){
|
||||||
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
|
//筛选出车站自律机收令箱中未转发过的调度命令
|
||||||
|
List<DCMDTrainReceiver> srmTrainReceiversNotSent = new LinkedList<>();
|
||||||
|
ctcRepository.getDcmdMap().forEach((dCmdId,dCmd)->{
|
||||||
|
List<DCMDTrainReceiver> trs= dCmd.getReceiversManager().getTrainReceivers().stream().filter(tr->{
|
||||||
|
//
|
||||||
|
return tr.isSendViaSRM() //须经过自律机转发
|
||||||
|
&&checkSrmCanSendBy400M(srmStation,tr)
|
||||||
|
&&srmStation.getCode().equals(tr.getDisStationCode())//车站自律机
|
||||||
|
&&tr.getPosSrmReceive()//已经在车站自律机收令箱中
|
||||||
|
&&!tr.getPosSrmSend();//自律机未转发过
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
if(null!=trs){
|
||||||
|
srmTrainReceiversNotSent.addAll(trs);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//
|
||||||
|
srmTrainReceiversNotSent.forEach(str->{
|
||||||
|
this.srmSendToTrain(simulation,srmStation,str);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 自律机转发无线调度命令
|
||||||
|
*/
|
||||||
|
private void srmSendToTrain(Simulation simulation,Station srmStation,DCMDTrainReceiver str){
|
||||||
|
log.debug("==>>自律机车站(code = %s)发送无线调度命令(code = %s)给机车(code = %s)",srmStation.getCode(),str.getDcmd().getCode(),str.getTrainCode());
|
||||||
|
//自律机转发无线调度命令
|
||||||
|
str.setPosSrmSend(true);
|
||||||
|
//无线调度命令进入机车的收令箱
|
||||||
|
str.setPosReceive(true);
|
||||||
|
str.setReceivedTime(dCmdService.getSimLocalDateTime());
|
||||||
|
//todo 向前端发送收令通知机车司机签收
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
|
||||||
|
|
||||||
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.*;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令基础服务
|
||||||
|
* <p>
|
||||||
|
* 调度命令分类:<br>
|
||||||
|
* 普通调度命令、施工调度命令、转发调度命令、请求调度命令、长效调度命令、班计划调度命令
|
||||||
|
* 调度命令由调度台开始发出:
|
||||||
|
* <p>
|
||||||
|
* 调度台1->调度台2<br>
|
||||||
|
* 调度台->车站车务终端<br>
|
||||||
|
* 无线调度命令立即发送:调度台->(通过GSM-R)车载终端<br>
|
||||||
|
* 无线调度命令智能发送:调度台->(中转)车站自律机->(通过无线通信)车载终端<br>
|
||||||
|
* 列控调度命令:调度台->TSR列控限速服务器
|
||||||
|
* <p>
|
||||||
|
* 调度命令由车站开始发出:<br>
|
||||||
|
* TDCS2.0车站调度命令管理:请求调度命令、车站调度命令、机车(无线)调度命令
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class RailDCMDService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建调度命令
|
||||||
|
* @param creator 调度台或车站
|
||||||
|
*/
|
||||||
|
public DCMD create(Simulation simulation, SimulationMember creator){
|
||||||
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
|
int id = ctcRepository.getDispatchCommandIdGenerator().getAndIncrement();
|
||||||
|
//
|
||||||
|
DCMD cmd = new DCMD();
|
||||||
|
cmd.setId(String.valueOf(id));
|
||||||
|
cmd.setCreator(creator);
|
||||||
|
//
|
||||||
|
cmd.setReceiversManager(new DCMDReceiversManager());
|
||||||
|
cmd.getReceiversManager().setDcmd(cmd);
|
||||||
|
// 默认设置编辑中状态
|
||||||
|
cmd.getReceiversManager().setPosEditing(true);
|
||||||
|
//
|
||||||
|
ctcRepository.getDcmdMap().put(cmd.getId(),cmd);
|
||||||
|
//
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 保存或缓存调度命令
|
||||||
|
* @param creator 调度台或车站
|
||||||
|
* @param dCmdId 调度命令id
|
||||||
|
* @param simulation 当前仿真
|
||||||
|
*/
|
||||||
|
public void save(Simulation simulation, SimulationMember creator , String dCmdId){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令监控服务
|
||||||
|
* <p>
|
||||||
|
* 监控调度命令签收情况;综合分析后向前端推送通知
|
||||||
|
*/
|
||||||
|
public void monitor(Simulation simulation){
|
||||||
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
|
|
||||||
|
}
|
||||||
|
////////////////////////////////////公共工具方法///////////////////////////////////////////////
|
||||||
|
public DCMD findDCMD(Simulation simulation,String cmdId){
|
||||||
|
CtcRepository ctcRepository = simulation.getCtcRepository();
|
||||||
|
DCMD cmd= ctcRepository.getDcmdMap().get(cmdId);
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取仿真当前时间
|
||||||
|
*/
|
||||||
|
public LocalDateTime getSimLocalDateTime(){
|
||||||
|
//暂时设置为系统时间
|
||||||
|
return LocalDateTime.now();
|
||||||
|
}
|
||||||
|
public Station getSimStation(Simulation simulation,String stationCode){
|
||||||
|
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=station,String.format("仿真车站不存在,id=%s",stationCode));
|
||||||
|
return station;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,140 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd;
|
||||||
|
|
||||||
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDDisReceiver;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDStationReceiver;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDTrainReceiver;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver.DCMDTsrReceiver;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调度命令签收相关服务
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class RailDCMDSignService {
|
||||||
|
@Autowired
|
||||||
|
private RailDCMDService dCmdService;
|
||||||
|
/**
|
||||||
|
* 列控受令者签收调度命令(前端操作)
|
||||||
|
* @param cmdId 调度命令id
|
||||||
|
* @param tsrCode 列控服务器id
|
||||||
|
* @param signedBy 签收人
|
||||||
|
* @param signType 签收类型:签收、代签
|
||||||
|
*/
|
||||||
|
public void signForTsr(Simulation simulation, String cmdId, String tsrCode, String signedBy, DCMD.SignStatus signType){
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType), String.format("调度命令(id=%s)签收类型(%s)不支持", cmdId, signType));
|
||||||
|
DCMD cmd = dCmdService.findDCMD(simulation,cmdId);
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId));
|
||||||
|
DCMDTsrReceiver target=null;
|
||||||
|
for(DCMDTsrReceiver tsrReceiver:cmd.getReceiversManager().getTsrReceivers()){
|
||||||
|
if(tsrCode.equals(tsrReceiver.getTsrCode())){
|
||||||
|
target = tsrReceiver;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的TSR列控服务器受令者(tsrCode=%s)不存在",cmdId,tsrCode));
|
||||||
|
//
|
||||||
|
target.setSignedBy(signedBy);
|
||||||
|
target.setSignedTime(dCmdService.getSimLocalDateTime());
|
||||||
|
target.setSigState(signType);
|
||||||
|
switch (signType){
|
||||||
|
case PROXY:target.setPosProxySigned(true);break;
|
||||||
|
case SIGNED:target.setPosSigned(true);break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 车站受令者签收调度命令(前端操作)
|
||||||
|
* @param cmdId 调度命令id
|
||||||
|
* @param stationCode 车站code
|
||||||
|
* @param signedBy 签收人
|
||||||
|
* @param signType 签收类型:签收、代签
|
||||||
|
*/
|
||||||
|
public void signForStation(Simulation simulation,String cmdId,String stationCode,String signedBy,DCMD.SignStatus signType){
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType));
|
||||||
|
DCMD cmd = dCmdService.findDCMD(simulation,cmdId);
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId));
|
||||||
|
DCMDStationReceiver target=null;
|
||||||
|
for(DCMDStationReceiver stationReceiver:cmd.getReceiversManager().getStationReceivers()){
|
||||||
|
if(stationCode.equals(stationReceiver.getStationCode())){
|
||||||
|
target = stationReceiver;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的车站受令者(stationCode=%s)不存在",cmdId,stationCode));
|
||||||
|
//
|
||||||
|
target.setSignedBy(signedBy);
|
||||||
|
target.setSignedTime(dCmdService.getSimLocalDateTime());
|
||||||
|
target.setSigState(signType);
|
||||||
|
switch (signType){
|
||||||
|
case PROXY:target.setPosProxySigned(true);break;
|
||||||
|
case SIGNED:target.setPosSigned(true);break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 调度台受令者签收调度命令(前端操作)
|
||||||
|
* @param cmdId 调度命令id
|
||||||
|
* @param disCode 调度台code
|
||||||
|
* @param signedBy 签收人
|
||||||
|
* @param signType 签收类型:签收、代签
|
||||||
|
*/
|
||||||
|
public void signForDispatcher(Simulation simulation,String cmdId,String disCode,String signedBy,DCMD.SignStatus signType){
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType));
|
||||||
|
DCMD cmd = dCmdService.findDCMD(simulation,cmdId);
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId));
|
||||||
|
DCMDDisReceiver target=null;
|
||||||
|
for(DCMDDisReceiver disReceiver:cmd.getReceiversManager().getDisReceivers()){
|
||||||
|
if(disCode.equals(disReceiver.getDisCode())){
|
||||||
|
target = disReceiver;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的调度台受令者(disCode=%s)不存在",cmdId,disCode));
|
||||||
|
//
|
||||||
|
target.setSignedBy(signedBy);
|
||||||
|
target.setSignedTime(dCmdService.getSimLocalDateTime());
|
||||||
|
target.setSigState(signType);
|
||||||
|
switch (signType){
|
||||||
|
case PROXY:target.setPosProxySigned(true);break;
|
||||||
|
case SIGNED:target.setPosSigned(true);break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 无线受令者签收调度命令(前端操作-车载终端)
|
||||||
|
* @param cmdId 调度命令id
|
||||||
|
* @param trainNum 车次号
|
||||||
|
* @param trainCode 机车号
|
||||||
|
* @param signedBy 签收人
|
||||||
|
* @param signType 签收类型:签收、代签
|
||||||
|
*/
|
||||||
|
public void signForTrain(Simulation simulation,String cmdId,String trainNum,String trainCode,String signedBy,DCMD.SignStatus signType){
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=signType&&!DCMD.SignStatus.UNSIGNED.equals(signType),String.format("调度命令(id=%s)签收类型(%s)不支持",cmdId,signType));
|
||||||
|
DCMD cmd = dCmdService.findDCMD(simulation,cmdId);
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=cmd,String.format("调度命令不存在,id=%s",cmdId));
|
||||||
|
DCMDTrainReceiver target=null;
|
||||||
|
for(DCMDTrainReceiver trainReceiver:cmd.getReceiversManager().getTrainReceivers()){
|
||||||
|
if(trainNum.equals(trainReceiver.getTrainNum())&&trainCode.equals(trainReceiver.getTrainCode())){
|
||||||
|
target = trainReceiver;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(null!=target,String.format("调度命令(id=%s)的无线受令者(车次号=%s , 机车号=%s)不存在",cmdId,trainNum,trainCode));
|
||||||
|
//
|
||||||
|
target.setSignedBy(signedBy);
|
||||||
|
target.setSignedTime(dCmdService.getSimLocalDateTime());
|
||||||
|
target.setSigState(signType);
|
||||||
|
switch (signType){
|
||||||
|
case PROXY:target.setPosProxySigned(true);break;
|
||||||
|
case SIGNED:target.setPosSigned(true);break;
|
||||||
|
}
|
||||||
|
if(target.isSendViaSRM()){//如果是车站自律机转发的
|
||||||
|
target.setPosSrmSigned(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DCMDDisReceiver extends DCMDReceiver {
|
||||||
|
/**
|
||||||
|
* 受令调度台code
|
||||||
|
*/
|
||||||
|
private String disCode;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.DCMD;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当调度命令创建编辑时,创建编辑者即是一个 Receiver
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DCMDReceiver {
|
||||||
|
/**
|
||||||
|
* 调度命令
|
||||||
|
*/
|
||||||
|
private DCMD dcmd;
|
||||||
|
/**
|
||||||
|
* 收令时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime receivedTime;
|
||||||
|
/**
|
||||||
|
* 签收状态
|
||||||
|
*/
|
||||||
|
private DCMD.SignStatus sigState = DCMD.SignStatus.UNSIGNED;
|
||||||
|
/**
|
||||||
|
* 签收人
|
||||||
|
*/
|
||||||
|
private String signedBy;
|
||||||
|
/**
|
||||||
|
* 签收时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime signedTime;
|
||||||
|
//////////////////////发送相关/////////////////////////////
|
||||||
|
/**
|
||||||
|
* 对该受令者已经发送该调度命令的次数
|
||||||
|
*/
|
||||||
|
private Integer sentCount;
|
||||||
|
//////////////////////位置状态/////////////////////////////
|
||||||
|
/**
|
||||||
|
* 缓存箱
|
||||||
|
*/
|
||||||
|
private Boolean posCache=false;
|
||||||
|
/**
|
||||||
|
* 收令箱
|
||||||
|
*/
|
||||||
|
private Boolean posReceive=false;
|
||||||
|
/**
|
||||||
|
* 发令箱
|
||||||
|
*/
|
||||||
|
private Boolean posSend=false;
|
||||||
|
/**
|
||||||
|
* 签收完成箱
|
||||||
|
*/
|
||||||
|
private Boolean posSigned=false;
|
||||||
|
/**
|
||||||
|
* 代签完成箱
|
||||||
|
*/
|
||||||
|
private Boolean posProxySigned=false;
|
||||||
|
/**
|
||||||
|
* 编辑中
|
||||||
|
*/
|
||||||
|
private Boolean posEditing=false;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.DCMD;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对应调度命令的宏观管理
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class DCMDReceiversManager {
|
||||||
|
/**
|
||||||
|
* 调度命令
|
||||||
|
*/
|
||||||
|
private DCMD dcmd;
|
||||||
|
/**
|
||||||
|
* 该调度命令的调度台受令者
|
||||||
|
*/
|
||||||
|
private final List<DCMDDisReceiver> disReceivers = new LinkedList<>();
|
||||||
|
/**
|
||||||
|
* 该调度命令的车站受令者
|
||||||
|
*/
|
||||||
|
private final List<DCMDStationReceiver> stationReceivers = new LinkedList<>();
|
||||||
|
/**
|
||||||
|
* 该调度命令的机车受令者
|
||||||
|
*/
|
||||||
|
private final List<DCMDTrainReceiver> trainReceivers = new LinkedList<>();
|
||||||
|
/**
|
||||||
|
* 该调度命令的列控受令者
|
||||||
|
*/
|
||||||
|
private final List<DCMDTsrReceiver> tsrReceivers = new LinkedList<>();
|
||||||
|
////////////////////////////////该调度命令在其创建平台中的状态////////////////////////////////////////
|
||||||
|
/**
|
||||||
|
* 缓存箱
|
||||||
|
*/
|
||||||
|
private Boolean posCache=false;
|
||||||
|
/**
|
||||||
|
* 发令箱
|
||||||
|
*/
|
||||||
|
private Boolean posSend=false;
|
||||||
|
/**
|
||||||
|
* 签收完成箱(当其所有受令者都签收时为true)
|
||||||
|
*/
|
||||||
|
private Boolean posSigned=false;
|
||||||
|
/**
|
||||||
|
* 编辑中
|
||||||
|
*/
|
||||||
|
private Boolean posEditing=false;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
public class DCMDStationReceiver extends DCMDReceiver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 受令人
|
||||||
|
*/
|
||||||
|
private String stationCode;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 无线受令者
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DCMDTrainReceiver extends DCMDReceiver {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 中转车站code
|
||||||
|
* <p>
|
||||||
|
* 当为Null时,通过GSM-R通信直接发送给机车;<br>
|
||||||
|
* 当不为空时,通过车站自律机智能中转;<br>
|
||||||
|
*/
|
||||||
|
private String disStationCode;
|
||||||
|
/**
|
||||||
|
* 车次号
|
||||||
|
*/
|
||||||
|
private String trainNum;
|
||||||
|
/**
|
||||||
|
* 机车号(train code)
|
||||||
|
*/
|
||||||
|
private String trainCode;
|
||||||
|
//////////////车站自律机对无线调度命令处理状态/////////
|
||||||
|
/**
|
||||||
|
* 自律机收令箱
|
||||||
|
*/
|
||||||
|
private Boolean posSrmReceive = false;
|
||||||
|
/**
|
||||||
|
* 自律机发令箱
|
||||||
|
*/
|
||||||
|
private Boolean posSrmSend = false;
|
||||||
|
/**
|
||||||
|
* 自律机签收完成箱
|
||||||
|
*/
|
||||||
|
private Boolean posSrmSigned = false;
|
||||||
|
////////////////////////////////////////////
|
||||||
|
/**
|
||||||
|
* 直接通过手机移动网络直接发送给机车
|
||||||
|
*/
|
||||||
|
public boolean isSendViaGSM(){
|
||||||
|
return !isSendViaSRM();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 通过车站自律机中转发送给机车
|
||||||
|
*/
|
||||||
|
public boolean isSendViaSRM(){
|
||||||
|
return null!=disStationCode&&disStationCode.trim().length()>0;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.CTC.rail.dcmd.receiver;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class DCMDTsrReceiver extends DCMDReceiver{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 受令列控服务器code
|
||||||
|
*/
|
||||||
|
private String tsrCode;
|
||||||
|
|
||||||
|
}
|
@ -41,6 +41,7 @@ public abstract class MayOutOfOrderDevice extends StatusDevice {
|
|||||||
@JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$2"),
|
@JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$2"),
|
||||||
@JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$3"),
|
@JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$3"),
|
||||||
@JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$4"),
|
@JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$4"),
|
||||||
|
@JsonSubTypes.Type(value = Section.AxleFault.class, name = "Section$AxleFault$5"),
|
||||||
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$1"),
|
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$1"),
|
||||||
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$2"),
|
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$2"),
|
||||||
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$3"),
|
@JsonSubTypes.Type(value = Stand.Fault.class, name = "Stand$Fault$3"),
|
||||||
@ -57,7 +58,9 @@ public abstract class MayOutOfOrderDevice extends StatusDevice {
|
|||||||
return false;
|
return false;
|
||||||
device.setFault(this);
|
device.setFault(this);
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
default void fix(MayOutOfOrderDevice device) {
|
default void fix(MayOutOfOrderDevice device) {
|
||||||
if (this.equals(device.fault))
|
if (this.equals(device.fault))
|
||||||
|
@ -84,8 +84,11 @@ public abstract class Operation2 {
|
|||||||
if (!result) { // 未失败
|
if (!result) { // 未失败
|
||||||
result = doSuccessVail();
|
result = doSuccessVail();
|
||||||
}
|
}
|
||||||
if (result) {
|
// 这里开始时间为空是因为前端触发太快导致,线程还未走操作触发操作
|
||||||
|
if (result && this.startTime != null) {
|
||||||
this.remainTime = this.operatedTime.getNano() - this.startTime.getNano();
|
this.remainTime = this.operatedTime.getNano() - this.startTime.getNano();
|
||||||
|
} else {
|
||||||
|
this.remainTime = 0;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -156,7 +156,11 @@ public class Step2 {
|
|||||||
*/
|
*/
|
||||||
public void completionAndCalculate() {
|
public void completionAndCalculate() {
|
||||||
// 整步骤完成耗费时间
|
// 整步骤完成耗费时间
|
||||||
|
if (this.startTime != null) {
|
||||||
this.remainTime = LocalDateTime.now().getNano() - this.startTime.getNano();
|
this.remainTime = LocalDateTime.now().getNano() - this.startTime.getNano();
|
||||||
|
} else {
|
||||||
|
this.remainTime = 0;
|
||||||
|
}
|
||||||
// 操作错误总数
|
// 操作错误总数
|
||||||
this.count = this.operations.stream().mapToInt(o -> o.getCount().get()).sum();
|
this.count = this.operations.stream().mapToInt(o -> o.getCount().get()).sum();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user