侧防锁闭逻辑bug修改

新仿真逻辑——CI功能开发
This commit is contained in:
walker-sheng 2021-04-02 19:41:34 +08:00
parent 28f992fb7c
commit 6798b74964
9 changed files with 90 additions and 27 deletions

View File

@ -56,13 +56,10 @@ public class RouteFls {
Signal pSignal = flsElement.getPSignal();
SwitchElement fpae = flsElement.getFpae();
if (pSignal != null) {
if (fpae == null) {
pSignal.fpUnlock();
}
} else {
if (fpae != null) {
fpae.getASwitch().fpUnlock();
}
pSignal.fpUnlock();
}
if (fpae != null) {
fpae.getASwitch().fpUnlock();
}
}
}
@ -78,14 +75,11 @@ public class RouteFls {
} else {
Signal pSignal = flsElement.getPSignal();
SwitchElement fpae = flsElement.getFpae();
if (pSignal != null) {
if (fpae == null) {
pSignal.fpLock();
}
} else {
if (fpae != null && (fpae.isOnPosition() || !fpae.getASwitch().isSectionOccupied())) {
fpae.getASwitch().fpLock();
}
if (pSignal != null && fpae == null) {
pSignal.fpLock();
}
if (fpae != null && (fpae.isOnPosition() || fpae.getASwitch().isLoss())) {
fpae.getASwitch().fpLock();
}
}
}

View File

@ -38,7 +38,7 @@ public class CilLogicService {
()-> this.collectDeviceState(rtSimulation, cilRepository),
DeviceStateCollectRate);
rtSimulation.addJob("cilMainLogic",
() -> this.mainLogic(cilRepository),
() -> this.mainLogic(rtSimulation, cilRepository),
CilMainLogicRate);
}
@ -69,7 +69,7 @@ public class CilLogicService {
}
}
private void mainLogic(CilRepository cilRepository) {
this.cilRouteLogicService.routeLogic(cilRepository);
private void mainLogic(RtSimulation rtSimulation, CilRepository cilRepository) {
this.cilRouteLogicService.routeLogic(rtSimulation, cilRepository);
}
}

View File

@ -1,6 +1,9 @@
package club.joylink.rtss.simulation.rt.CIL;
import club.joylink.rtss.simulation.rt.CIL.bo.*;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.srd.SrdApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashSet;
@ -9,12 +12,16 @@ import java.util.Set;
@Component
public class CilRouteLogicService {
public void routeLogic(CilRepository cilRepository) {
@Autowired
private SrdApiService srdApiService;
public void routeLogic(RtSimulation rtSimulation, CilRepository cilRepository) {
List<CilRoute> supervisedRouteList = cilRepository.getSupervisedRouteList();
for (CilRoute cilRoute : supervisedRouteList) {
switch (cilRoute.getStage()) {
case CilRoute.STAGE_SETTING:
this.settingProgress(cilRoute, cilRepository.getConfig());
this.settingProgress(rtSimulation, cilRoute, cilRepository.getConfig());
break;
case CilRoute.STAGE_WATCH:
this.watchRoute(cilRoute);
@ -23,12 +30,30 @@ public class CilRouteLogicService {
}
}
private void settingProgress(CilRoute cilRoute, CilConfig config) {
private void settingProgress(RtSimulation rtSimulation, CilRoute cilRoute, CilConfig config) {
if (config.isLockFirst()) {
// 预先锁闭进路区段
this.lockRouteSections(cilRoute);
}
// 进路道岔征用
CilRoutePathElement pathElement = cilRoute.getPathElement();
List<CilSwitchPosition> switchPositionList = pathElement.getSwitchPositionList();
boolean onPosition = true;
for (CilSwitchPosition cilSwitchPosition : switchPositionList) {
CilSwitch cilSwitch = cilSwitchPosition.getCilSwitch();
if (cilSwitch.getRouteUseToPosition() == CilDevice.NONE) {
cilSwitch.routeUse(cilSwitchPosition.getPosition());
if (!cilSwitchPosition.isOnPosition()) {
this.srdApiService.turnSwitch(rtSimulation, cilSwitch.getId(), cilSwitchPosition.getPosition());
}
}
if (!cilSwitchPosition.isOnPosition()) {
onPosition = false;
}
}
if (onPosition) { // 道岔已经转到位
}
}
private void lockRouteSections(CilRoute cilRoute) {

View File

@ -1,8 +1,7 @@
package club.joylink.rtss.simulation.rt.CIL.bo;
public class CilDevice {
public static final int OFF = 0;
public static final int ON = 1;
public static final int NONE = 0;
String id;
String name;

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.rt.CIL.bo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import lombok.Getter;
@Getter
@ -15,6 +16,8 @@ public class CilSwitch extends CilDevice {
public static final int REVERSE = 2; // 反位
public static final int SQUEEZING = 4; // 挤叉
int routeUseToPosition; // 进路征用到位置, 0 为未征用
boolean bl; // 封锁
boolean sl; // 单锁
boolean rl; // 进路锁闭
@ -45,4 +48,9 @@ public class CilSwitch extends CilDevice {
b.belongSwitch = this;
c.belongSwitch = this;
}
public void routeUse(int position) {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(NORMAL == position || REVERSE == position);
this.routeUseToPosition = position;
}
}

View File

@ -19,4 +19,8 @@ public class CilSwitchPosition {
public CilSwitchPosition(CilSwitch cilSwitch, boolean normal) {
this(cilSwitch, normal ? CilSwitch.NORMAL : CilSwitch.REVERSE);
}
public boolean isOnPosition() {
return this.cilSwitch.position == this.position;
}
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.rt.srd;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.rt.RtSimulation;
import club.joylink.rtss.simulation.rt.srd.bo.*;
import org.springframework.stereotype.Component;
@ -8,23 +9,42 @@ import java.util.List;
@Component
public class SrdApiService {
public List<SrAXC> queryAllAxc(RtSimulation rtSimulation) {
private SrdRepository getSrdRepository(RtSimulation rtSimulation) {
SrdRepository repository = rtSimulation.getRepository(SrdRepository.NAME, SrdRepository.class);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(repository);
return repository;
}
public List<SrAXC> queryAllAxc(RtSimulation rtSimulation) {
SrdRepository repository = this.getSrdRepository(rtSimulation);
return repository.getAxcList();
}
public List<SrSwitch> queryAllSwitch(RtSimulation rtSimulation) {
SrdRepository repository = rtSimulation.getRepository(SrdRepository.NAME, SrdRepository.class);
SrdRepository repository = this.getSrdRepository(rtSimulation);
return repository.getSwitchList();
}
public List<SrSignal> queryAllSignal(RtSimulation rtSimulation) {
SrdRepository repository = rtSimulation.getRepository(SrdRepository.NAME, SrdRepository.class);
SrdRepository repository = this.getSrdRepository(rtSimulation);
return repository.getSignalList();
}
public List<SrPSD> queryAllPsd(RtSimulation rtSimulation) {
SrdRepository repository = rtSimulation.getRepository(SrdRepository.NAME, SrdRepository.class);
SrdRepository repository = this.getSrdRepository(rtSimulation);
return repository.getPsdList();
}
public void turnSwitch(RtSimulation rtSimulation, String switchId, int position) {
SrdRepository repository = this.getSrdRepository(rtSimulation);
SrSwitch srSwitch = repository.getSwitchById(switchId);
if (SrSwitch.NORMAL == position) {
srSwitch.turnToNormal(rtSimulation.getSystemTime());
} else if (SrSwitch.REVERSE == position) {
srSwitch.turnToReverse(rtSimulation.getSystemTime());
} else {
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception();
}
}
}

View File

@ -67,10 +67,16 @@ public class SrSwitch extends SrDevice {
}
public void turnToNormal(LocalDateTime systemTime) {
if (this.isNormalPosition()) {
return;
}
this.startTurn(systemTime, NORMAL);
}
public void turnToReverse(LocalDateTime systemTime) {
if (this.isReversePosition()) {
return;
}
this.startTurn(systemTime, REVERSE);
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.rt.srd.bo;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.SimulationRepository;
import java.util.ArrayList;
@ -51,4 +52,10 @@ public class SrdRepository extends SimulationRepository {
public List<SrAXC> getAxcList() {
return new ArrayList<>(this.axcMap.values());
}
public SrSwitch getSwitchById(String id) {
SrSwitch srSwitch = this.switchMap.get(id);
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(srSwitch);
return srSwitch;
}
}