轨道交通仿真——添加道岔转动三个操作
This commit is contained in:
parent
e7db868c99
commit
a3b9a6c81f
@ -27,7 +27,7 @@ public class SimulationOperationHandlerManager implements ApplicationContextAwar
|
||||
if (operationMapping == null) {
|
||||
continue;
|
||||
}
|
||||
String name = operationMapping.name();
|
||||
String name = operationMapping.value();
|
||||
BusinessExceptionAssertEnum.DATA_ALREADY_EXIST.assertNotTrue(handlerMap.containsKey(name));
|
||||
OperationHandlerMethod handlerMethod = new OperationHandlerMethod(handler, method);
|
||||
handlerMap.put(name, handlerMethod);
|
||||
|
@ -8,5 +8,6 @@ import java.lang.annotation.Target;
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface SimulationOperationMapping {
|
||||
String name();
|
||||
|
||||
String value() default "";
|
||||
}
|
||||
|
@ -0,0 +1,40 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL;
|
||||
|
||||
import club.joylink.rtss.simulation.rt.CIL.bo.CilSwitch;
|
||||
import club.joylink.rtss.simulation.rt.RtSimulation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CilApiService {
|
||||
|
||||
@Autowired
|
||||
private CilSwitchLogicService cilSwitchLogicService;
|
||||
|
||||
/**
|
||||
* 转动道岔
|
||||
* @param simulation
|
||||
* @param id
|
||||
*/
|
||||
public void turnSwitch(RtSimulation simulation, String id) {
|
||||
this.cilSwitchLogicService.turn(simulation, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 定操
|
||||
* @param simulation
|
||||
* @param id
|
||||
*/
|
||||
public void turnSwitchToNormal(RtSimulation simulation, String id) {
|
||||
this.cilSwitchLogicService.turn(simulation, id, CilSwitch.NORMAL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 反操
|
||||
* @param simulation
|
||||
* @param id
|
||||
*/
|
||||
public void turnSwitchToReverse(RtSimulation simulation, String id) {
|
||||
this.cilSwitchLogicService.turn(simulation, id, CilSwitch.REVERSE);
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package club.joylink.rtss.simulation.rt.CIL;
|
||||
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.SimulationRepository;
|
||||
import club.joylink.rtss.simulation.rt.CIL.bo.CilRepository;
|
||||
import club.joylink.rtss.simulation.rt.CIL.bo.CilSwitch;
|
||||
import club.joylink.rtss.simulation.rt.CIL.bo.CilSwitchPosition;
|
||||
@ -18,6 +17,14 @@ public class CilSwitchLogicService {
|
||||
@Autowired
|
||||
private SrdApiService srdApiService;
|
||||
|
||||
public void turn(RtSimulation rtSimulation, String id) {
|
||||
CilRepository repository = rtSimulation.getRepository(CilRepository.NAME, CilRepository.class);
|
||||
CilSwitch aSwitch = repository.getSwitchById(id);
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(aSwitch.isLocked(), "道岔锁闭,无法转动");
|
||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(aSwitch.isOccupy(), "道岔占用,无法转动");
|
||||
srdApiService.turnSwitch(rtSimulation, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 道岔转动
|
||||
*/
|
||||
|
@ -37,6 +37,16 @@ public class SrdApiService {
|
||||
return repository.getPsdList();
|
||||
}
|
||||
|
||||
public void turnSwitch(RtSimulation rtSimulation, String switchId) {
|
||||
SrdRepository repository = this.getSrdRepository(rtSimulation);
|
||||
SrSwitch srSwitch = repository.getSwitchById(switchId);
|
||||
if (srSwitch.isReversePosition() || srSwitch.isTurningToReverse()) {
|
||||
srSwitch.turnToNormal(rtSimulation.getSystemTime());
|
||||
} else if (srSwitch.isNormalPosition() || srSwitch.isTurningToNormal()) {
|
||||
srSwitch.turnToReverse(rtSimulation.getSystemTime());
|
||||
}
|
||||
}
|
||||
|
||||
public void turnSwitch(RtSimulation rtSimulation, String switchId, int position) {
|
||||
SrdRepository repository = this.getSrdRepository(rtSimulation);
|
||||
SrSwitch srSwitch = repository.getSwitchById(switchId);
|
||||
|
@ -70,6 +70,14 @@ public class SrSwitch extends SrDevice {
|
||||
return NONE != this.command.get();
|
||||
}
|
||||
|
||||
public boolean isTurningToNormal() {
|
||||
return NORMAL == this.command.get();
|
||||
}
|
||||
|
||||
public boolean isTurningToReverse() {
|
||||
return REVERSE == this.command.get();
|
||||
}
|
||||
|
||||
public boolean turnToNormal(LocalDateTime systemTime) {
|
||||
if (this.isNormalPosition() || this.command.get() == NORMAL) {
|
||||
return false;
|
||||
|
@ -0,0 +1,32 @@
|
||||
package club.joylink.rtss.simulation.rt.operation;
|
||||
|
||||
import club.joylink.rtss.simulation.operation.SimulationOperationController;
|
||||
import club.joylink.rtss.simulation.operation.SimulationOperationMapping;
|
||||
import club.joylink.rtss.simulation.rt.CIL.CilApiService;
|
||||
import club.joylink.rtss.simulation.rt.RtSimulation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@SimulationOperationController()
|
||||
public class SwitchOperationHandler {
|
||||
@Autowired
|
||||
private CilApiService cilApiService;
|
||||
|
||||
@SimulationOperationMapping("Switch_Turn")
|
||||
public boolean turn(RtSimulation simulation, String id) {
|
||||
this.cilApiService.turnSwitch(simulation, id);
|
||||
return true;
|
||||
}
|
||||
|
||||
@SimulationOperationMapping("Switch_Normal_Position")
|
||||
public boolean turnToNormal(RtSimulation simulation, String id) {
|
||||
this.cilApiService.turnSwitchToNormal(simulation, id);
|
||||
return true;
|
||||
}
|
||||
|
||||
@SimulationOperationMapping("Switch_Reverse_Position")
|
||||
public boolean turnToReverse(RtSimulation simulation, String id) {
|
||||
this.cilApiService.turnSwitchToReverse(simulation, id);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user