道岔钩锁操作联动

This commit is contained in:
joylink_zhangsai 2022-07-26 15:28:52 +08:00
parent fc353a5fad
commit 266463eb4c
2 changed files with 22 additions and 10 deletions

View File

@ -12,7 +12,6 @@ import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import lombok.extern.slf4j.Slf4j;
@ -295,11 +294,23 @@ public class SwitchOperateHandler {
*/
@OperateHandlerMapping(type = Operation.Type.Switch_Hook_Lock)
public void switchHookLock(Simulation simulation, String switchCode, Boolean normal) {
VirtualRealitySwitch vrSwitch = simulation.getRepository().getVRByCode(switchCode, VirtualRealitySwitch.class);
SimulationDataRepository repository = simulation.getRepository();
Switch aSwitch = repository.getByCode(switchCode, Switch.class);
if (normal) {
vrSwitch.setP(SwitchIndication.N);
aSwitch.getVirtualSwitch().setP(SwitchIndication.N);
} else {
vrSwitch.setP(SwitchIndication.R);
aSwitch.getVirtualSwitch().setP(SwitchIndication.R);
}
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (linkedSwitch != null) {
if (normal) {
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.N);
} else {
linkedSwitch.getVirtualSwitch().setP(SwitchIndication.R);
}
}
}
}

View File

@ -12,6 +12,13 @@ import lombok.Setter;
@Getter
@Setter
public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwitch.Operation> {
private SwitchIndication p;
// -------------运行逻辑控制参数-------------
private Fault fault;
@Override
protected boolean checkConditionBeforeControl(Operation command) {
switch (command) {
@ -66,12 +73,6 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
RP,
}
private SwitchIndication p;
// -------------运行逻辑控制参数-------------
private Fault fault;
public VirtualRealitySwitch(String code, String name, int turnTime) {
super(code, name, MapElement.DeviceType.SWITCH, turnTime * 1000);
this.p = SwitchIndication.N;