挤岔故障恢复逻辑修改为恢复并转换到另一个位置

This commit is contained in:
joylink_zhangsai 2023-10-30 11:03:40 +08:00
parent 1be9cccc4a
commit 9b4480f376
3 changed files with 31 additions and 15 deletions

View File

@ -99,30 +99,25 @@ public class CiSwitchControlService {
*/
public SwitchIndication turn(Simulation simulation, Switch aSwitch) {
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
boolean isRP;
if (vrSwitch.getCommand() != null) {
isRP = vrSwitch.getCommand().equals(VirtualRealitySwitch.Operation.RP);
} else {
isRP = vrSwitch.isPosR();
}
boolean lastTurnToN = vrSwitch.isLastTurnToN();
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) {
if (isRP) {
this.turn2NormalPosition(simulation, linkedSwitch);
} else {
if (lastTurnToN) {
this.turn2ReversePosition(simulation, linkedSwitch);
} else {
this.turn2NormalPosition(simulation, linkedSwitch);
}
}
}
if (isRP) {
if (this.turn2NormalPosition(simulation, aSwitch)) {
return SwitchIndication.N;
}
} else {
if (lastTurnToN) {
if (this.turn2ReversePosition(simulation, aSwitch)) {
return SwitchIndication.R;
}
} else {
if (this.turn2NormalPosition(simulation, aSwitch)) {
return SwitchIndication.N;
}
}
return null;
}

View File

@ -678,7 +678,11 @@ public class Switch extends DelayUnlockDevice {
Switch aSwitch = (Switch) device;
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
VirtualRealitySwitch.Fault.SQUEEZE.fix(vrSwitch);
vrSwitch.control(VirtualRealitySwitch.Operation.NP);
if (vrSwitch.isLastTurnToN()) {
vrSwitch.control(VirtualRealitySwitch.Operation.RP);
} else {
vrSwitch.control(VirtualRealitySwitch.Operation.NP);
}
}
},

View File

@ -19,6 +19,17 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
private Fault fault;
private Operation lastOperation;
@Override
public boolean control(Operation command) {
boolean control = super.control(command);
if (control && command != null) {
this.lastOperation = command;
}
return control;
}
@Override
protected boolean checkConditionBeforeControl(Operation command) {
switch (command) {
@ -83,6 +94,7 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
super.reset();
this.p = SwitchIndication.N;
this.fault = null;
this.lastOperation = Operation.NP;
}
public void apply(boolean normalPosition, boolean reversePosition) {
@ -99,6 +111,11 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
}
}
//最后一次是否是转向定位
public boolean isLastTurnToN() {
return this.lastOperation == Operation.NP;
}
public enum Fault {
SPLIT {
@Override