Merge remote-tracking branch 'origin/test' into master-huawei

This commit is contained in:
thesai 2021-11-25 12:10:47 +08:00
commit 5ac9c9ca41
56 changed files with 1021 additions and 440 deletions

View File

@ -6,10 +6,14 @@ import club.joylink.rtss.services.training.generatornew.GeneratorNew;
import club.joylink.rtss.services.training.generatornew.annotation.GeneratorSelectorNew;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
import club.joylink.rtss.simulation.cbtc.tool.DeviceStatusModifyTool;
import club.joylink.rtss.vo.client.training.TrainingNewVO;
import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -22,6 +26,9 @@ public class SectionGeneratorNew implements GeneratorNew {
private static final int LIMITED_SPEED = 5;
@Autowired
private DeviceStatusModifyTool deviceStatusModifyTool;
@Override
public List<TrainingNewVO> generate(GenerateConfig config, Simulation simulation, OperateDefinitionVO operateDefinitionVO) {
List<TrainingNewVO> trainingVOList = new ArrayList<>();
@ -103,11 +110,11 @@ public class SectionGeneratorNew implements GeneratorNew {
break;
case Section_Fault_Unlock:
// 设置区段故障锁闭这只是区故解的一种情况后面再补其他情况
section.setFaultLock(true);
// section.setFaultLock(true);
section.setRouteLock(true);
if (section.isShowLogic()) {
section.getLogicList().forEach(s -> {
s.setFaultLock(true);
// s.setFaultLock(true);
s.setRouteLock(true);
});
}
@ -122,6 +129,32 @@ public class SectionGeneratorNew implements GeneratorNew {
virtualAxleCounter.setLeftCount(2);
virtualAxleCounter.setRightCount(2);
break;
case Stand_Early_Depart:
if (section.isStandTrack()) {
List<Route> routeList = simulation.getRepository().getRouteList();
Stand stand = section.getStandList().get(0);
Route route = routeList.stream().filter(route1 ->
(route1.getStart().getSection() == section || route1.containSection(section)
&& !route1.routeLastSection(section))
&& Objects.equals(stand.isRight(), route1.getStart().isRight()))
.findAny().orElse(null);
if (Objects.nonNull(route)) {
deviceStatusModifyTool.openRouteDirect(simulation, route);
}
deviceStatusModifyTool.loadManualTrainOfGroup(simulation, "001", section, stand.isRight());
} else {
continue;
}
break;
case Stand_Set_Reentry_Strategy:
if (section.isStandTrack() && section.isTurnBackTrack()) {
Stand stand = section.getStandList().get(0);
stand.setTypeStrategy(Stand.TurnBackType.AUTO);
deviceStatusModifyTool.loadManualTrainOfGroup(simulation, "001", section, stand.isRight());
} else {
continue;
}
break;
default:
// 其他操作不生成
continue;

View File

@ -107,6 +107,9 @@ public class SignalGeneratorNew implements GeneratorNew {
}
case Signal_Set_CI_Auto_Trigger: {
if (!CollectionUtils.isEmpty(routeList)) {
if (routeList.stream().noneMatch(Route::isArs)) {
continue;
}
if (routeLikeHa1) {
if (simulation.getRepository().getConfig().isSignalHumanControlBeforeSetAtsControlOrCIAutoTrigger()) {
routeList.forEach(route -> route.setAtsControl(false));
@ -152,7 +155,7 @@ public class SignalGeneratorNew implements GeneratorNew {
if (route.isGuide()) { // 引导进路跳过
continue;
}
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
// 仿真重置
this.resetSimulation(simulation);
}
@ -248,7 +251,7 @@ public class SignalGeneratorNew implements GeneratorNew {
continue;
}
route.setAtsControl(false);
trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO));
trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO));
// 仿真重置
this.resetSimulation(simulation);
}

View File

@ -60,6 +60,7 @@ public class StandGeneratorNew implements GeneratorNew {
break;
}
case Stand_Force_Cancel_Hold_Train:
case Stand_Cancel_Setting:
stand.setCenterHoldTrain(true);
break;
case Stand_Cancel_Hold_Train:

View File

@ -1,12 +1,15 @@
package club.joylink.rtss.services.training.generatornew.base;
import club.joylink.rtss.constants.BusinessConsts;
import club.joylink.rtss.constants.MapPrdTypeEnum;
import club.joylink.rtss.services.training.data.GenerateConfig;
import club.joylink.rtss.services.training.generatornew.GeneratorNew;
import club.joylink.rtss.services.training.generatornew.annotation.GeneratorSelectorNew;
import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.tool.DeviceStatusModifyTool;
import club.joylink.rtss.vo.client.training.TrainingNewVO;
import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO;
@ -14,15 +17,17 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
@GeneratorSelectorNew(operateObject = Operation.Object.Station)
public class StationGeneratorNew implements GeneratorNew {
@Autowired
private DeviceStatusModifyTool deviceStatusModifyTool;
@Autowired
private AtsOperationDispatcher atsOperationDispatcher;
@Override
public List<TrainingNewVO> generate(GenerateConfig config, Simulation simulation, OperateDefinitionVO operateDefinitionVO) {
List<TrainingNewVO> trainingVOList = new ArrayList<>();
@ -36,7 +41,12 @@ public class StationGeneratorNew implements GeneratorNew {
switch (Operation.Type.valueOf (operateDefinitionVO.getOperateType())) {
case Station_Set_CI_Auto_Trigger:
if(!station.isInterlock())continue;
if (MapPrdTypeEnum.LOCAL.equals(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType()))) {
station.setControlMode(Station.ControlMode.Local);
}
simulation.getRepository().getRouteList().stream()
.filter(route -> route.getInterlockStation().equals(station))
.forEach(route -> route.setAtsControl(false));
// List<Route> routeList1 = simulation.getRepository().getRouteList();
// for (Route route : routeList1) {
// if (Objects.equals(route.getInterlockStation(), station)) {
@ -46,7 +56,9 @@ public class StationGeneratorNew implements GeneratorNew {
break;
case Station_Cancel_CI_Auto_Trigger:
if(!station.isInterlock())continue;
if (MapPrdTypeEnum.LOCAL.equals(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType()))) {
station.setControlMode(Station.ControlMode.Local);
}
List<Route> routeList2 = simulation.getRepository().getRouteList();
for (Route route : routeList2) {
if (Objects.equals(route.getInterlockStation(), station)) {
@ -81,7 +93,13 @@ public class StationGeneratorNew implements GeneratorNew {
break;
case Station_CIArea_Close_AllSignal:
if(!station.isInterlock())continue;
station.getDeviceStation().setControlMode(Station.ControlMode.Center);
if (MapPrdTypeEnum.LOCAL.equals(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType()))) {
if (station.isCentralized()) {
station.setControlMode(Station.ControlMode.Local);
} else {
station.getDeviceStation().setControlMode(Station.ControlMode.Local);
}
}
// simulation.getRepository().getSignalList().stream()
// .filter(s -> Objects.equals(station.getCode(), s.getInterlockStation().getCode()))
// .forEach(signal -> {
@ -224,6 +242,32 @@ public class StationGeneratorNew implements GeneratorNew {
}
}
break;
case Station_Restart: {
if(!station.isInterlock())continue;
if (BusinessConsts.MapPrd.PrdType.Type01.equals(config.getPrdType())) {
if(station.isCentralized()) {
station.setControlMode(Station.ControlMode.Local);
}else{
station.getDeviceStation().setControlMode(Station.ControlMode.Local);
}
}
SimulationMember member = new SimulationMember("", SimulationMember.Type.DISPATCHER, null);
String operate = Operation.Type.Station_Restart_Interlock_Machine.name();
Map<String, Object> param = new HashMap<>();
param.put("stationCode", station.getCode());
atsOperationDispatcher.execute(simulation, member, operate, param);
station.setInterlockMachineStarting(true);
break;
}
case Station_Release: {
if(!station.isInterlock())continue;
SimulationMember member = new SimulationMember("", SimulationMember.Type.DISPATCHER, null);
String operate = Operation.Type.Server_ATP_Restart.name();
Map<String, Object> param = new HashMap<>();
atsOperationDispatcher.execute(simulation, member, operate, param);
station.setInterlockMachineStarting(true);
break;
}
default:
// 其他操作不生成
continue;

View File

@ -41,6 +41,9 @@ public class SwitchGeneratorNew implements GeneratorNew {
case Switch_Set_Limit_Speed:
case Switch_Section_Block:
break;
case Switch_Force_Turn:
Switch.SwitchFault.AXLE_FAULT.apply(aSwitch);
break;
case Switch_Normal_Position: {
// 背景为道岔反位
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
@ -91,10 +94,13 @@ public class SwitchGeneratorNew implements GeneratorNew {
break;
}
case Switch_Fault_Unlock:{
// 背景为道岔区段故障锁闭
aSwitch.getA().setFaultLock(true);
aSwitch.getB().setFaultLock(true);
aSwitch.getC().setFaultLock(true);
// // 背景为道岔区段故障锁闭
// aSwitch.getA().setFaultLock(true);
// aSwitch.getB().setFaultLock(true);
// aSwitch.getC().setFaultLock(true);
aSwitch.setRouteLock(true);
aSwitch.getA().setRouteLock(true);
aSwitch.getB().setRouteLock(true);
break;
}
case Switch_Axle_Pre_Reset:{
@ -112,6 +118,9 @@ public class SwitchGeneratorNew implements GeneratorNew {
aSwitch.getA().getParent().judgeAsNctOccupied();
break;
}
case Switch_Squeeze_Recovery:
Switch.SwitchFault.SQUEEZE.apply(aSwitch);
break;
default:
// 其他操作不生成
continue;

View File

@ -431,6 +431,10 @@ public class Operation {
RunPlan_Add_Trip,
/** 删除计划 */
RunPlan_Delete_Trip,
//--------------------------- 服务器 ---------------------------
/** ATP系统重启 */
Server_ATP_Restart
}
/**操作对象枚举*/

View File

@ -43,6 +43,9 @@ public class FaultOperateHandler {
@Autowired
private StationFaultService stationFaultService;
@Autowired
private ServerFaultService serverFaultService;
/**
* 设备设置故障
*
@ -155,6 +158,13 @@ public class FaultOperateHandler {
}
catenaryFaultService.fixFault(simulation, mayOutOfOrderDevice, param);
return;
case SERVER:
if (isSet) {
serverFaultService.setFault(simulation, mayOutOfOrderDevice, param);
} else {
serverFaultService.fixFault(simulation, mayOutOfOrderDevice, param);
}
return;
default:
break;
}

View File

@ -0,0 +1,22 @@
package club.joylink.rtss.simulation.cbtc.ATS.operation.handler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Server;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@OperateHandler
public class ServerOperateHandle {
@OperateHandlerMapping(type = Operation.Type.Server_ATP_Restart)
public void atpRestart(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository();
repository.getSectionList().forEach(section -> {
section.setSpeedLimitBeforeFault(section.getSpeedUpLimit());
section.setSpeedUpLimit(5);
});
}
}

View File

@ -0,0 +1,68 @@
package club.joylink.rtss.simulation.cbtc.ATS.operation.service;
import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.FaultParam;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.MayOutOfOrderDevice;
import club.joylink.rtss.simulation.cbtc.data.map.Server;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.map.StatusDevice;
import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceFaultOverEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceFaultSetEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ServerFaultService implements DeviceFaultService{
@Autowired
private ApplicationContext applicationContext;
@Override
public void setFault(Simulation simulation, MayOutOfOrderDevice device, FaultParam param) {
Server.Fault deviceFault = checkAndGetFault(param);
boolean apply = deviceFault.apply(device);
SimulationDataRepository repository = simulation.getRepository();
switch (deviceFault) {
case ATP_FAULT:
repository.getSectionList().forEach(section -> {
section.setSpeedLimitBeforeFault(section.getSpeedUpLimit());
section.setSpeedUpLimit(5);
});
break;
case ATS_FAULT:
List<StatusDevice> statusDevices = repository.getStatusDevices();
statusDevices.forEach(statusDevice -> statusDevice.setAtsNoStatus(true));
break;
}
if (apply) {
this.applicationContext.publishEvent(new SimulationDeviceFaultSetEvent(this,
simulation, new DeviceFaultInfo(device.getCode(), device.getDeviceType(), deviceFault)));
}
}
@Override
public void fixFault(Simulation simulation, MayOutOfOrderDevice device, FaultParam param) {
Server.Fault fault = checkAndGetFault(param);
fault.fix(device);
SimulationDataRepository repository = simulation.getRepository();
switch (fault) {
case ATP_FAULT:
break;
case ATS_FAULT:
List<StatusDevice> statusDevices = repository.getStatusDevices();
statusDevices.forEach(statusDevice -> statusDevice.setAtsNoStatus(false));
break;
}
this.applicationContext.publishEvent(new SimulationDeviceFaultOverEvent(this,
simulation, new DeviceFaultInfo(device.getCode(), device.getDeviceType(), fault)));
}
@Override
public Server.Fault checkAndGetFault(FaultParam param) {
return Server.Fault.valueOf(param.getFaultType());
}
}

View File

@ -233,6 +233,7 @@ public class AtsRouteService {
for (Route route : routeList) {
if (route.isCiControl()) {
route.setCiControl(false);
route.setAtsControl(false);
}
}
}

View File

@ -453,7 +453,7 @@ public class AtsStandService {
*/
public void cancelSetting(Simulation simulation, String standCode) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
if (stand.isStationHoldTrain()) {
if (stand.isStationHoldTrain() || stand.isCenterHoldTrain()) {
cancelHoldTrain(simulation, standCode);
} else if (stand.isAllSkip()) {
cancelJumpStop(simulation, standCode, null);

View File

@ -514,7 +514,17 @@ public class AtsStationService {
}
station.setInterlockMachineStarting(true);
station.setRestartTime(LocalTime.now());
Station.Fault.INTERLOCK_FAULT.fix(station);
Station.Fault.INTERLOCK_FAULT.fix(station); //恢复联锁机故障
SimulationDataRepository repository = simulation.getRepository();
for (StatusDevice value : station.getDeviceMap().values()) {
if (value instanceof Section) { //联锁区所有区段故障锁闭
Section section = (Section) value;
section.recursivelySetFaultLock(true);
} else if (value instanceof Station) { //联锁区所有车站交出控制权
Station station1 = (Station) value;
station1.setControlMode(Station.ControlMode.None);
}
}
}
public void openAutoSetting(Simulation simulation, String stationCode) {

View File

@ -95,6 +95,12 @@ public class CiApiServiceImpl2 implements CiApiService {
log.info(String.format("道岔[%s(%s)]锁闭,不能转动", aSwitch.getName(), aSwitch.getCode()));
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操");
}
if (Switch.SwitchFault.SPLIT_4.equals(aSwitch.getFault())) {
int times = aSwitch.getTurnTimes().incrementAndGet();
if (times == 4) {
Switch.SwitchFault.SPLIT_4.fix(aSwitch);
}
}
}
@Override
@ -258,9 +264,14 @@ public class CiApiServiceImpl2 implements CiApiService {
}
}
}
if (!lockSwitchRoutes.isEmpty()) {
for (Route lockedRoute : lockSwitchRoutes) {
this.routeService.switchFaultUnlock(simulation, aSwitch, lockedRoute);
}
} else {
aSwitch.faultUnlock();
aSwitch.sectionFaultUnlock();
}
}
@Override
@ -460,11 +471,21 @@ public class CiApiServiceImpl2 implements CiApiService {
deviceStation = station.getDeviceStation();
}
deviceStation.setInterlockMachineStarting(false);
SimulationDataRepository repository = simulation.getRepository();
repository.getSectionList().forEach(section -> section.setFaultLock(false)); //所有区段取消故障锁闭
}
@Override
public void release(Simulation simulation, Station station) {
for (Section section : simulation.getRepository().getSectionList()) {
Integer speedLimitBeforeFault = section.getSpeedLimitBeforeFault();
if (speedLimitBeforeFault != null) {
section.setSpeedUpLimit(speedLimitBeforeFault);
section.setSpeedLimitBeforeFault(null);
}
}
Server server = simulation.getRepository().getByCode(Server.CODE, Server.class);
Server.Fault.ATP_FAULT.fix(server);
}
@Override
@ -516,7 +537,7 @@ public class CiApiServiceImpl2 implements CiApiService {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(),
section.debugStr() + "不是计轴区段也不归属于任何计轴区段");
VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter();
if (!virtualAxleCounter.isOccupy()){
if (!virtualAxleCounter.isOccupy()) {
VirtualRealitySectionAxleCounter.Fault.FAULT.apply(virtualAxleCounter);
Section.AxleFault.ARB.apply(axleSection);
}

View File

@ -34,7 +34,7 @@ public class CiDeviceStatusCollector {
private void collectPsd(SimulationDataRepository repository, List<PSD> psdList) {
for (PSD psd : psdList) {
VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor();
if (vrPsd != null) {
if (psd.isNoStatus() || vrPsd != null) {
psd.apply(vrPsd.isClose(), vrPsd.isLock(), vrPsd.isInterlockRelease());
}
}

View File

@ -164,6 +164,11 @@ public class CiService {
}
}
level = Signal.LEVEL_Guide; // 引导级
Signal signal = route.getStart();
if (Signal.SignalFault.JZJTS.equals(signal.getFault())
|| (!signal.isCbtcMode() && Signal.SignalFault.LIGHTING_UNIT_FAULT_NAME.equals(signal.getFault()))
|| (!signal.isCbtcMode() && Signal.SignalFault.LIGHTING_UNIT_FAULT_HEAD.equals(signal.getFault())))
return level;
// 进路侧防检查
List<RouteFls> flsList = route.getFlsList();
if (!CollectionUtils.isEmpty(flsList)) {
@ -231,7 +236,7 @@ public class CiService {
}
}
}
if (route.getStart().isCbtcMode()) {
if (signal.isCbtcMode()) {
level = Signal.LEVEL_Atp; // ATP级
}
// 区段占用检查

View File

@ -30,6 +30,9 @@ public class MapDeviceBuilder {
Map<String, MapElement> elementMap = mapDataBuildResult.getDeviceMap();
Map<String, VirtualRealityDevice> deviceMap = mapDataBuildResult.getVrDeviceMap();
List<String> errMsgList = mapDataBuildResult.getErrMsgList();
// server
Server server = new Server();
elementMap.put(server.getCode(), server);
// ZC
List<MapZcVO> zcList = graphData.getZcList();
zcList.forEach(mapZcVO -> {

View File

@ -660,6 +660,40 @@ public class CalculateService {
return list;
}
/**
* 查找上一个信号机的进路
* @param start
* @param last
* @param right
* @param routePath
*/
private static void queryLastSignalRoute(Section start, Section last, Boolean right, RoutePath routePath) {
Section section = last.getSectionOf(!right);
if (section == null) {
if (last.isSwitchTrack()) {
Switch relSwitch = last.getRelSwitch();
if (relSwitch.isA(last)) {
section = relSwitch.getB();
} else {
section = relSwitch.getA();
}
} else {
return;
}
}
Signal signal = section.getSignalOf(right);
if (signal == null) {
queryLastSignalRoute(start, section, right, routePath);
} else {
for (Route route : signal.getRouteList()) {
if (route.containSection(start)) {
routePath.addRoute(route);
break;
}
}
}
}
/**
* 查询道岔最少的进路路径
*
@ -725,6 +759,9 @@ public class CalculateService {
if (Objects.equals(next, end)) {
// 找到结束
list.add(routePath);
if (routePath.getStart().getSignalOf(right) == null) {
queryLastSignalRoute(routePath.getStart(), routePath.getStart(), right, routePath);
}
} else {
// 添加并进行迭代
routePath.addSection(next);
@ -755,22 +792,22 @@ public class CalculateService {
if (!CollectionUtils.isEmpty(routeList)) {
// 进路
boolean find = false;
if (signal.isVirtual()) { // 虚拟信号机应该只有一条进路
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(routeList.size() == 1);
Route route = routeList.get(0);
routePath.addRoute(route);
List<Section> sectionList = route.getSectionList();
int i = sectionList.indexOf(end);
if (i >= 0) {
// 找到
routePath.addSections(sectionList.subList(0, i));
list.add(routePath);
} else {
routePath.addSections(sectionList);
queryRoutePaths(iter + 1, iterTimes, route.getLastRouteSection(), routePath, list, warnList);
}
return;
}
// if (signal.isVirtual()) { // 虚拟信号机应该只有一条进路
// BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(routeList.size() == 1);
// Route route = routeList.get(0);
// routePath.addRoute(route);
// List<Section> sectionList = route.getSectionList();
// int i = sectionList.indexOf(end);
// if (i >= 0) {
// // 找到
// routePath.addSections(sectionList.subList(0, i));
// list.add(routePath);
// } else {
// routePath.addSections(sectionList);0
// queryRoutePaths(iter + 1, iterTimes, route.getLastRouteSection(), routePath, list, warnList);
// }
// return;
// }
Map<Section, List<Route>> routeMap = new HashMap<>(); // 进路终端对应进路列表(ATP进路合并进正常进路终端)
routeList.sort(Comparator.comparing(Route::isAtp)); // 将ATP进路排在最后处理
for (Route route : routeList) {
@ -826,6 +863,9 @@ public class CalculateService {
}
if (find) {
list.add(routePath);
if (routePath.getStart().getSignalOf(right) == null) {
queryLastSignalRoute(routePath.getStart(), routePath.getStart(), right, routePath);
}
return;
} else {
for (RoutePath clone : iterList) {
@ -846,6 +886,9 @@ public class CalculateService {
// 找到
routePath.addSections(sectionList.subList(0, i));
list.add(routePath);
if (routePath.getStart().getSignalOf(right) == null) {
queryLastSignalRoute(routePath.getStart(), routePath.getStart(), right, routePath);
}
return;
} else {
// 顺着区段找下一个有信号机的区段为止

View File

@ -1187,4 +1187,11 @@ public class SimulationDataRepository {
.assertNotNull(vrPsl, String.format("%s无对应的vrPsl", vrPsd.debugStr()));
return vrPsl;
}
public List<StatusDevice> getStatusDevices() {
return deviceMap.values().stream()
.filter(device -> device instanceof StatusDevice)
.map(device -> (StatusDevice) device)
.collect(Collectors.toList());
}
}

View File

@ -65,6 +65,8 @@ public abstract class MapElement {
IBP,
/** 就地控制盘 */
PSL,
/** 服务器 */
SERVER,
}
/** 设备唯一编号 */

View File

@ -41,7 +41,12 @@ public abstract class MayOutOfOrderDevice extends StatusDevice {
@JsonSubTypes.Type(value = ZC.Fault.class, name = "ZC$Fault$1")
})
public interface DeviceFault {
boolean apply(MayOutOfOrderDevice device);
default boolean apply(MayOutOfOrderDevice device) {
if (this.equals(device.getFault()))
return false;
device.setFault(this);
return true;
};
default void fix(MayOutOfOrderDevice device) {
if (this.equals(device.fault))

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.data.map;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.support.RoutePath;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
@ -219,6 +220,11 @@ public class Section extends DelayUnlockDevice {
*/
private int speedUpLimit = -1;
/**
* ATP故障前的限速
*/
private Integer speedLimitBeforeFault;
/**
* 延时解锁
*/
@ -253,6 +259,7 @@ public class Section extends DelayUnlockDevice {
this.invalid = false;
this.faultLock = false;
this.speedUpLimit = -1;
this.speedLimitBeforeFault = null;
this.delayUnlock = false;
this.closeInit = false;
this.openInit = false;
@ -1085,6 +1092,13 @@ public class Section extends DelayUnlockDevice {
}
}
public Section getAxleCounterSection() {
Section axleSection = findAxleCounterSection();
BusinessExceptionAssertEnum.DATA_ERROR.assertNotNull(axleSection,
this.debugStr() + "无归属计轴区段");
return axleSection;
}
public boolean isAheadOf(SimulationDataRepository repository, Section other, boolean right) {
List<RoutePath> routePaths = repository.queryRoutePathsByEndAndContainsSection(this, other);
if (CollectionUtils.isEmpty(routePaths))
@ -1208,6 +1222,36 @@ public class Section extends DelayUnlockDevice {
return null;
}
@Override
public void loseStatus() {
setNoStatus(true);
if (!CollectionUtils.isEmpty(this.getLogicList())) {
for (Section section : this.getLogicList()) {
section.loseStatus();
}
}
}
@Override
public void restoreStatus() {
setNoStatus(false);
if (!CollectionUtils.isEmpty(this.getLogicList())) {
for (Section section : this.getLogicList()) {
section.restoreStatus();
}
}
}
/**
* 递归地设置故障锁闭
*/
public void recursivelySetFaultLock(boolean faultLock) {
this.setFaultLock(faultLock);
if (!CollectionUtils.isEmpty(this.logicList)) {
logicList.forEach(section -> section.recursivelySetFaultLock(faultLock));
}
}
public enum SectionRoadType {
/**
* 左行线
@ -1270,17 +1314,27 @@ public class Section extends DelayUnlockDevice {
},
/**
* 无法从真实设备采集状态哈尔滨灰显可能没用了
* 无法从真实设备采集状态哈尔滨灰显
*/
UNABLE_COLLECT_STATUS {
@Override
public boolean apply(MayOutOfOrderDevice device) {
Section section = (Section) device;
if (this.equals(section.getFault()))
Section axleSection = section.getAxleCounterSection();
if (this.equals(axleSection.getFault()))
return false;
section.setFault(this);
axleSection.setFault(this);
axleSection.loseStatus();
return true;
}
@Override
public void fix(MayOutOfOrderDevice device) {
super.fix(device);
Section section = (Section) device;
Section axleSection = section.getAxleCounterSection();
axleSection.restoreStatus();
}
},
CBTC_OCCUPIED_FAULT {

View File

@ -0,0 +1,21 @@
package club.joylink.rtss.simulation.cbtc.data.map;
import lombok.Getter;
/**
* 服务器
*/
@Getter
public class Server extends MayOutOfOrderDevice{
public static final String CODE = "Server";
public Server() {
super(CODE, CODE, DeviceType.SERVER);
}
public enum Fault implements DeviceFault{
ATP_FAULT,
ATS_FAULT,
}
}

View File

@ -694,7 +694,19 @@ public class Signal extends DelayUnlockDevice {
}
return true;
}
};
},
/**
* 机柱机头闪信号机最多只能到引导级
*/
JZJTS,
/**
* 轨旁无线服务器故障-点灯单元故障CTC级别正常不知道怎么算不正常无影响非CTC级别只能到引导级
*/
//信号机编号闪
LIGHTING_UNIT_FAULT_NAME,
//机头闪
LIGHTING_UNIT_FAULT_HEAD,
;
@Override
public void fix(MayOutOfOrderDevice device) {

View File

@ -550,7 +550,7 @@ public class Station extends MayOutOfOrderDevice {
station = station.getDeviceStation();
}
for (StatusDevice statusDevice : station.deviceMap.values()) {
statusDevice.setNoStatus(true);
statusDevice.loseStatus();
}
if (Objects.equals(this, station.getFault())) {
return false;
@ -568,7 +568,7 @@ public class Station extends MayOutOfOrderDevice {
if (!Objects.equals(this, device.getFault()))
return;
for (StatusDevice statusDevice : station.deviceMap.values()) {
statusDevice.setNoStatus(false);
statusDevice.restoreStatus();
}
station.setFault(null);
}

View File

@ -9,11 +9,23 @@ public abstract class StatusDevice extends MapNamedElement {
/** 无状态(灰显) */
private boolean noStatus;
/** 行调界面无状态 */
private boolean atsNoStatus;
protected StatusDevice(String code, String name, DeviceType deviceType) {
super(code, name, deviceType);
}
public void reset() {
this.noStatus = false;
this.atsNoStatus = false;
}
public void loseStatus() {
setNoStatus(true);
}
public void restoreStatus() {
setNoStatus(false);
}
}

View File

@ -6,6 +6,7 @@ import lombok.Getter;
import lombok.Setter;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -132,6 +133,11 @@ public class Switch extends DelayUnlockDevice {
*/
private Boolean lastTurnToNormal;
/**
* 该道岔转动次数仅在道岔应用了转动4次后恢复的故障时记录
*/
private AtomicInteger turnTimes;
@Override
public void reset() {
super.reset();
@ -152,6 +158,7 @@ public class Switch extends DelayUnlockDevice {
this.init = false;
this.lastTurnToNormal = null;
this.forceTurnRemain = 0;
this.turnTimes = null;
}
/**
@ -561,6 +568,23 @@ public class Switch extends DelayUnlockDevice {
}
},
/**
* 转动4次后恢复的失表故障
*/
SPLIT_4{
@Override
public boolean apply(MayOutOfOrderDevice device) {
Switch aSwitch = (Switch) device;
if (Objects.equals(aSwitch.getFault(), this)) {
return false;
}
aSwitch.setFault(this);
aSwitch.setPos(SwitchIndication.NO);
aSwitch.setTurnTimes(new AtomicInteger(0));
return true;
}
},
/**
* 定位失表
*/
@ -657,6 +681,32 @@ public class Switch extends DelayUnlockDevice {
Switch aSwitch = (Switch) device;
Section.AxleFault.CBTC_OCCUPIED_FAULT.fix(aSwitch.getA());
}
},
/**
* 道岔区段灰显
*/
SECTION_NO_STATUS {
@Override
public boolean apply(MayOutOfOrderDevice device) {
boolean apply = super.apply(device);
if (!apply)
return false;
Switch aSwitch = (Switch) device;
aSwitch.loseStatus();
aSwitch.getAllSections().forEach(Section::loseStatus);
aSwitch.getA().getParent().loseStatus();
return true;
}
@Override
public void fix(MayOutOfOrderDevice device) {
super.fix(device);
Switch aSwitch = (Switch) device;
aSwitch.restoreStatus();
aSwitch.getAllSections().forEach(Section::restoreStatus);
aSwitch.getA().getParent().restoreStatus();
}
}
}
}

View File

@ -36,6 +36,9 @@ public class PSDStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean atsNoStatus;
public PSDStatus(PSD psd) {
super(psd.getCode(), psd.getDeviceType());
this.close = psd.isCloseAndLock();
@ -68,6 +71,11 @@ public class PSDStatus extends DeviceStatus {
status.setNoStatus(noStatus);
change = true;
}
if (!Objects.equals(this.atsNoStatus, psd.isAtsNoStatus())) {
this.atsNoStatus = psd.isAtsNoStatus();
status.setAtsNoStatus(atsNoStatus);
change = true;
}
return change;
}
@ -77,6 +85,7 @@ public class PSDStatus extends DeviceStatus {
statusVO.setClose(close);
statusVO.setInterlockRelease(interlockRelease);
statusVO.setNoStatus(noStatus);
statusVO.setAtsNoStatus(atsNoStatus);
return statusVO;
}

View File

@ -1,6 +1,7 @@
package club.joylink.rtss.simulation.cbtc.data.status;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.MayOutOfOrderDevice;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO;
import club.joylink.rtss.simulation.cbtc.data.vo.SectionStatusVO;
@ -81,6 +82,12 @@ public class SectionStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean noStatus;
/**
* ats无状态
*/
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean atsNoStatus;
/**
* 计轴预复位
*/
@ -108,6 +115,7 @@ public class SectionStatus extends DeviceStatus {
this.faultLock = section.isFaultLock();
this.speedUpLimit = section.getSpeedUpLimit();
this.noStatus = section.isNoStatus();
this.atsNoStatus = section.isAtsNoStatus();
this.preReset = section.isPreReset();
this.delayUnlock = section.isDelayUnlock();
this.closed = section.isClosed();
@ -174,6 +182,11 @@ public class SectionStatus extends DeviceStatus {
status.setNoStatus(noStatus);
change = true;
}
if (!Objects.equals(this.atsNoStatus, section.isAtsNoStatus())) {
this.atsNoStatus = section.isAtsNoStatus();
status.setAtsNoStatus(atsNoStatus);
change = true;
}
if (!Objects.equals(this.preReset, section.isPreReset())) {
this.preReset = section.isPreReset();
status.setPreReset(this.preReset);
@ -189,6 +202,12 @@ public class SectionStatus extends DeviceStatus {
status.setClosed(this.closed);
change = true;
}
String fault = section.getFault() == null ? null : section.getFault().toString();
if (!Objects.equals(this.fault, fault)) {
this.fault = fault;
status.setFault(fault);
change = true;
}
return change;
}
@ -206,9 +225,11 @@ public class SectionStatus extends DeviceStatus {
statusVO.setLockRight(lockRight);
statusVO.setBlockade(blockade);
statusVO.setNoStatus(noStatus);
statusVO.setAtsNoStatus(atsNoStatus);
statusVO.setPreReset(preReset);
statusVO.setDelayUnlock(delayUnlock);
statusVO.setClosed(closed);
statusVO.setFault(fault);
return statusVO;
}

View File

@ -55,6 +55,9 @@ public class SignalStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean atsNoStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean approachLock;
@ -74,6 +77,7 @@ public class SignalStatus extends DeviceStatus {
this.aspect = signal.getAspect();
this.remainTime = signal.getRemain();
this.noStatus = signal.isNoStatus();
this.atsNoStatus = signal.isAtsNoStatus();
this.approachLock = signal.isApproachLock();
this.overlapLock = signal.isOverlapLock();
this.fault = Objects.nonNull(signal.getFault())?((Signal.SignalFault)signal.getFault()).name():null;
@ -129,6 +133,11 @@ public class SignalStatus extends DeviceStatus {
status.setNoStatus(noStatus);
change = true;
}
if (!Objects.equals(this.atsNoStatus, signal.isAtsNoStatus())) {
this.atsNoStatus = signal.isAtsNoStatus();
status.setAtsNoStatus(this.atsNoStatus);
change = true;
}
if (!Objects.equals(this.approachLock, signal.isApproachLock())) {
this.approachLock = signal.isApproachLock();
status.setApproachLock(approachLock);
@ -163,6 +172,7 @@ public class SignalStatus extends DeviceStatus {
statusVO.setReblockade(this.reblockade);
statusVO.setLockedRouteCode(lockedRouteCode);
statusVO.setNoStatus(noStatus);
statusVO.setAtsNoStatus(atsNoStatus);
statusVO.setApproachLock(approachLock);
statusVO.setOverlapLock(overlapLock);
statusVO.setFault(fault);

View File

@ -85,6 +85,9 @@ public class StandStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean atsNoStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean closed;
@ -120,6 +123,7 @@ public class StandStatus extends DeviceStatus {
this.parkingAlwaysValid = stand.isParkingAlwaysValid();
this.typeStrategy = stand.getTypeStrategy();
this.noStatus = stand.isNoStatus();
this.atsNoStatus = stand.isAtsNoStatus();
this.closed = stand.isClosed();
this.fault = Objects.nonNull(stand.getFault())?((Stand.Fault)stand.getFault()).name():null;
}
@ -232,6 +236,11 @@ public class StandStatus extends DeviceStatus {
status.setNoStatus(noStatus);
change = true;
}
if (!Objects.equals(this.atsNoStatus, stand.isAtsNoStatus())) {
this.atsNoStatus = stand.isAtsNoStatus();
status.setAtsNoStatus(this.atsNoStatus);
change = true;
}
if (!Objects.equals(this.closed, stand.isClosed())) {
this.closed = stand.isClosed();
status.setClosed(this.closed);
@ -270,6 +279,7 @@ public class StandStatus extends DeviceStatus {
statusVO.setTrainParking(trainParking);
statusVO.setRemainTime(remainTime);
statusVO.setNoStatus(noStatus);
statusVO.setAtsNoStatus(atsNoStatus);
statusVO.setClosed(closed);
statusVO.setFault(fault);
return statusVO;

View File

@ -74,6 +74,8 @@ public class StationStatus extends DeviceStatus {
*/
private int preResetValidDuration;
private boolean interlockMachineStarting;
public StationStatus(Station station) {
super(station.getCode(), station.getDeviceType());
this.controlMode = station.getControlMode();
@ -87,6 +89,7 @@ public class StationStatus extends DeviceStatus {
this.emergencyController = station.isEmergencyController();
this.controlApplicant = station.getControlApplicantId();
this.preResetValidDuration = station.getPreResetValidDurationInSeconds();
this.interlockMachineStarting = station.isInterlockMachineStarting();
}
@Override
@ -150,6 +153,11 @@ public class StationStatus extends DeviceStatus {
this.preResetValidDuration = station.getPreResetValidDurationInSeconds();
status.setPreResetValidDuration(this.preResetValidDuration);
}
if (!Objects.equals(this.interlockMachineStarting, station.isInterlockMachineStarting())) {
change = true;
this.interlockMachineStarting = station.isInterlockMachineStarting();
status.setInterlockMachineStarting(this.interlockMachineStarting);
}
return change;
}
@ -167,6 +175,7 @@ public class StationStatus extends DeviceStatus {
statusVO.setEmergencyController(emergencyController);
statusVO.setControlApplicant(controlApplicant);
statusVO.setPreResetValidDuration(preResetValidDuration);
statusVO.setInterlockMachineStarting(interlockMachineStarting);
return statusVO;
}
}

View File

@ -59,6 +59,9 @@ public class SwitchStatus extends DeviceStatus {
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean atsNoStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean preReset;
@ -97,11 +100,13 @@ public class SwitchStatus extends DeviceStatus {
this.pos = aSwitch.getPos();
this.delayTime = aSwitch.getRemain() / 1000;
this.noStatus = aSwitch.isNoStatus();
this.atsNoStatus = aSwitch.isAtsNoStatus();
this.preReset = aSwitch.isPreReset();
this.auto = aSwitch.isAuto();
this.dispatcherReserve = aSwitch.isDispatcherReserve();
this.interlockReserve = aSwitch.isInterlockReserve();
this.blockadeInvalid = aSwitch.isBlockadeInvalid();
this.fault = (Switch.SwitchFault) aSwitch.getFault();
}
@Override
@ -150,6 +155,11 @@ public class SwitchStatus extends DeviceStatus {
status.setNoStatus(this.noStatus);
change = true;
}
if (!Objects.equals(this.atsNoStatus, aSwitch.isAtsNoStatus())) {
this.atsNoStatus = aSwitch.isAtsNoStatus();
status.setAtsNoStatus(this.atsNoStatus);
change = true;
}
if (!Objects.equals(this.preReset, aSwitch.isPreReset())) {
this.preReset = aSwitch.isPreReset();
status.setPreReset(this.preReset);
@ -193,6 +203,7 @@ public class SwitchStatus extends DeviceStatus {
statusVO.setBlockade(blockade);
statusVO.setSingleLock(singleLock);
statusVO.setNoStatus(noStatus);
statusVO.setAtsNoStatus(atsNoStatus);
statusVO.setPreReset(preReset);
statusVO.setAuto(auto);
statusVO.setDispatcherReserve(dispatcherReserve);

View File

@ -1,13 +1,13 @@
package club.joylink.rtss.simulation.cbtc.data.storage.device;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Catenary;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer;
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@ -15,7 +15,7 @@ import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class StorageCatenary extends StorageDevice {
public class StorageCatenary extends StorageMayOutOfOrderDevice {
/**
* 是否带电
@ -24,21 +24,32 @@ public class StorageCatenary extends StorageDevice {
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean on;
public StorageCatenary(String code) {
super(code);
public StorageCatenary(Catenary catenary) {
super(catenary);
}
public static StorageCatenary convert2Storage(Catenary catenary) {
StorageCatenary storageCatenary = new StorageCatenary(catenary.getCode());
if (!catenary.isOn()) {
storageCatenary.setOn(catenary.isOn());
StorageCatenary storageCatenary = new StorageCatenary(catenary);
if (storageCatenary.convert(catenary)) {
return storageCatenary;
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = super.convert(element);
Catenary catenary = (Catenary) element;
if (!catenary.isOn()) {
change = true;
this.setOn(catenary.isOn());
}
return change;
}
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
super.recover2Simulation(element, simulation, repository);
Catenary catenary = (Catenary) element;
catenary.setOn(on != null ? on : false);
}

View File

@ -14,7 +14,7 @@ import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class StorageCycle extends StorageMayOutOfOrderDevice {
public class StorageCycle extends StorageDevice {
/** 是否已经设置 */
@ -22,23 +22,29 @@ public class StorageCycle extends StorageMayOutOfOrderDevice {
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean setUp;
public StorageCycle(String code, MayOutOfOrderDevice.DeviceFault fault) {
super(code, fault);
public StorageCycle(Cycle cycle) {
super(cycle.getCode());
}
public static StorageCycle convert2Storage(Cycle cycle) {
boolean change = false;
StorageCycle storageCycle = new StorageCycle(cycle.getCode(), null);
if (cycle.isSetUp()) {
change = true;
storageCycle.setSetUp(cycle.isSetUp());
}
if (change) {
StorageCycle storageCycle = new StorageCycle(cycle);
if (storageCycle.convert(cycle)) {
return storageCycle;
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = false;
Cycle cycle = (Cycle) element;
if (cycle.isSetUp()) {
change = true;
this.setSetUp(cycle.isSetUp());
}
return change;
}
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
Cycle cycle = (Cycle) element;

View File

@ -1,27 +1,46 @@
package club.joylink.rtss.simulation.cbtc.data.storage.device;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.DelayUnlockDevice;
import club.joylink.rtss.simulation.cbtc.data.map.MayOutOfOrderDevice;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class StorageDelayUnlockDevice extends StorageMayOutOfOrderDevice {
private int remain;
public StorageDelayUnlockDevice(String code, MayOutOfOrderDevice.DeviceFault fault) {
super(code, fault);
public StorageDelayUnlockDevice(DelayUnlockDevice device) {
super(device);
}
public void saveFrom(DelayUnlockDevice device) {
// public void saveFrom(DelayUnlockDevice device) {
// this.remain = device.getRemain();
// }
// protected void recoverTo(DelayUnlockDevice device, SimulationDataRepository repository) {
// device.recover(this.remain);
// }
@Override
public boolean convert(MapElement element) {
boolean change = super.convert(element);
DelayUnlockDevice device = (DelayUnlockDevice) element;
if (device.getRemain() > 0) {
change = true;
this.remain = device.getRemain();
}
return change;
}
protected void recoverTo(DelayUnlockDevice device, SimulationDataRepository repository) {
device.recover(this.remain);
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
super.recover2Simulation(element, simulation, repository);
DelayUnlockDevice device = (DelayUnlockDevice) element;
device.recover(remain);
}
}

View File

@ -17,5 +17,7 @@ public abstract class StorageDevice {
this.code = code;
}
public abstract boolean convert(MapElement element);
public abstract void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository);
}

View File

@ -29,18 +29,22 @@ public class StorageESP extends StorageDevice {
}
public static StorageESP convert2Storage(ESP esp) {
boolean change = false;
StorageESP storageESP = new StorageESP(esp.getCode());
if (esp.isEffective()) {
change = true;
storageESP.setEffective(esp.isEffective());
}
if (change) {
if (storageESP.convert(esp)) {
return storageESP;
} else {
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = false;
ESP esp = (ESP) element;
if (esp.isEffective()) {
change = true;
this.setEffective(esp.isEffective());
}
return change;
}
@Override
@ -48,4 +52,5 @@ public class StorageESP extends StorageDevice {
ESP esp = (ESP) element;
esp.setEffective(effective != null ? effective : false);
}
}

View File

@ -11,16 +11,27 @@ import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class StorageMayOutOfOrderDevice extends StorageDevice {
public class StorageMayOutOfOrderDevice extends StorageStatusDevice {
private MayOutOfOrderDevice.DeviceFault fault;
public StorageMayOutOfOrderDevice(String code, MayOutOfOrderDevice.DeviceFault fault) {
super(code);
this.fault = fault;
public StorageMayOutOfOrderDevice(MayOutOfOrderDevice device) {
super(device);
}
@Override
public boolean convert(MapElement element) {
boolean change = super.convert(element);
MayOutOfOrderDevice device = (MayOutOfOrderDevice) element;
if (device.getFault() != null) {
change = true;
this.fault = device.getFault();
}
return change;
}
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
super.recover2Simulation(element, simulation, repository);
MayOutOfOrderDevice mayOutOfOrderDevice = (MayOutOfOrderDevice) element;
mayOutOfOrderDevice.setFault(fault);
}

View File

@ -15,7 +15,7 @@ import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class StoragePSD extends StorageDevice {
public class StoragePSD extends StorageStatusDevice {
/**
* 屏蔽门是否关闭
@ -38,13 +38,6 @@ public class StoragePSD extends StorageDevice {
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean interlockRelease;
/**
* 无状态
*/
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean noStatus;
// public StoragePSD(PSD psd) {
// super(psd.getCode());
// if (!psd.isClose()) {
@ -58,43 +51,43 @@ public class StoragePSD extends StorageDevice {
// }
// }
public StoragePSD(String code) {
super(code);
public StoragePSD(PSD psd) {
super(psd);
}
public static StoragePSD convert2Storage(PSD psd) {
boolean change = false;
StoragePSD storagePSD = new StoragePSD(psd.getCode());
StoragePSD storagePSD = new StoragePSD(psd);
if (storagePSD.convert(psd)) {
return storagePSD;
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = super.convert(element);
PSD psd = (PSD) element;
if (!psd.isClose()) {
change = true;
storagePSD.setClose(psd.isClose());
this.setClose(psd.isClose());
}
if (!psd.isLock()) {
change = true;
storagePSD.setLock(psd.isLock());
this.setLock(psd.isLock());
}
if (psd.isInterlockRelease()) {
change = true;
storagePSD.setInterlockRelease(psd.isInterlockRelease());
}
if (psd.isNoStatus()) {
change = true;
storagePSD.setNoStatus(psd.isNoStatus());
}
if (change) {
return storagePSD;
} else {
return null;
this.setInterlockRelease(psd.isInterlockRelease());
}
return change;
}
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
super.recover2Simulation(element, simulation, repository);
PSD psd = (PSD) element;
psd.setClose(close != null ? close : true);
psd.setLock(lock != null ? lock : true);
psd.setInterlockRelease(interlockRelease != null ? interlockRelease : false);
psd.setNoStatus(noStatus != null ? noStatus : false);
}
}

View File

@ -104,52 +104,57 @@ public class StorageRoute extends StorageDevice {
}
public static StorageRoute convert2Storage(Route route) {
boolean change = false;
StorageRoute storageRoute = new StorageRoute(route.getCode());
if (!route.isAtsControl()) {
change = true;
storageRoute.setAtsControl(route.isAtsControl());
}
if (route.isFleetMode()) {
change = true;
storageRoute.setFleetMode(route.isFleetMode());
}
if (route.isCiControl()) {
change = true;
storageRoute.setCiControl(route.isCiControl());
}
if (route.isSetting()) {
change = true;
storageRoute.setSetting(route.isSetting());
storageRoute.setSettingStartTime(route.getSettingStartTime());
}
if (route.isGuideSetting()) {
change = true;
storageRoute.setSettingGuide(route.isGuideSetting());
}
if (route.isLock()) {
change = true;
storageRoute.setLock(route.isLock());
}
if (route.getDelayUnlockDevice() != null) {
change = true;
storageRoute.setDelayUnlockDevice(route.getDelayUnlockDevice().getCode());
}
if (route.isNormalUnlock()) {
change = true;
storageRoute.setNormalUnlock(route.isNormalUnlock());
}
if (Objects.nonNull(route.getUnlockedSection())) {
change = true;
storageRoute.setUnlockedSection(route.getUnlockedSection().getCode());
}
if (change) {
if (storageRoute.convert(route)) {
return storageRoute;
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = false;
Route route = (Route) element;
if (!route.isAtsControl()) {
change = true;
this.setAtsControl(route.isAtsControl());
}
if (route.isFleetMode()) {
change = true;
this.setFleetMode(route.isFleetMode());
}
if (route.isCiControl()) {
change = true;
this.setCiControl(route.isCiControl());
}
if (route.isSetting()) {
change = true;
this.setSetting(route.isSetting());
this.setSettingStartTime(route.getSettingStartTime());
}
if (route.isGuideSetting()) {
change = true;
this.setSettingGuide(route.isGuideSetting());
}
if (route.isLock()) {
change = true;
this.setLock(route.isLock());
}
if (route.getDelayUnlockDevice() != null) {
change = true;
this.setDelayUnlockDevice(route.getDelayUnlockDevice().getCode());
}
if (route.isNormalUnlock()) {
change = true;
this.setNormalUnlock(route.isNormalUnlock());
}
if (Objects.nonNull(route.getUnlockedSection())) {
change = true;
this.setUnlockedSection(route.getUnlockedSection().getCode());
}
return change;
}
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
Route route = (Route) element;
@ -168,4 +173,5 @@ public class StorageRoute extends StorageDevice {
route.setUnlockedSection(repository.getByCode(this.unlockedSection, Section.class));
}
}
}

View File

@ -49,36 +49,40 @@ public class StorageRouteOverlap extends StorageDevice {
}
public static StorageRouteOverlap convert2Storage(RouteOverlap overlap) {
boolean change = false;
StorageRouteOverlap storageOverlap = new StorageRouteOverlap(overlap.getCode());
if (overlap.isReleasing()) {
change = true;
storageOverlap.setReleasing(overlap.isReleasing());
}
if (overlap.isSetting()) {
change = true;
storageOverlap.setSetting(overlap.isSetting());
}
if (overlap.isLock()) {
change = true;
storageOverlap.setLock(overlap.isLock());
}
if (overlap.getRemainTime() > 0) {
change = true;
storageOverlap.setRemainTime(overlap.getRemainTime());
}
if (Objects.nonNull(overlap.getSettingStartTime())) {
change = true;
storageOverlap.setSettingStartTime(overlap.getSettingStartTime());
}
if (change) {
if (storageOverlap.convert(overlap)) {
return storageOverlap;
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = false;
RouteOverlap overlap = (RouteOverlap) element;
if (overlap.isReleasing()) {
change = true;
this.setReleasing(overlap.isReleasing());
}
if (overlap.isSetting()) {
change = true;
this.setSetting(overlap.isSetting());
}
if (overlap.isLock()) {
change = true;
this.setLock(overlap.isLock());
}
if (overlap.getRemainTime() > 0) {
change = true;
this.setRemainTime(overlap.getRemainTime());
}
if (Objects.nonNull(overlap.getSettingStartTime())) {
change = true;
this.setSettingStartTime(overlap.getSettingStartTime());
}
return change;
}
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
RouteOverlap overlap = (RouteOverlap) element;

View File

@ -15,6 +15,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
@Getter
@Setter
@ -88,103 +89,79 @@ public class StorageSection extends StorageDelayUnlockDevice {
*/
private Integer speedUpLimit;
private Integer speedLimitBeforeFault;
/**
* 区故解第一根延时解锁剩余时间
*/
private Integer delayTime;
/**
* 无状态
*/
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean noStatus;
public StorageSection(String code, MayOutOfOrderDevice.DeviceFault fault) {
super(code, fault);
public StorageSection(Section section) {
super(section);
}
// public StorageSection(Section section) {
// super(section.getCode());
// blockade = section.isBlockade();
// routeCode = section.getRouteCode();
// routeLock = section.isRouteLock();
// overlapLock = section.isOverlapLock();
// ctOccupied = section.isCtOccupied();
// nctOccupied = section.isNctOccupied();
// cutOff = section.isCutOff();
// invalid = section.isInvalid();
// faultLock = section.isFaultLock();
// speedUpLimit = section.getSpeedUpLimit();
// }
public static StorageSection convert2Storage(Section section) {
boolean change = false;
StorageSection storageSection = new StorageSection(section.getCode(), section.getFault());
if (storageSection.isFault()) {
change = true;
StorageSection storageSection = new StorageSection(section);
if (storageSection.convert(section)) {
return storageSection;
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = super.convert(element);
Section section = (Section) element;
if (section.isBlockade()) {
change = true;
storageSection.setBlockade(section.isBlockade());
this.setBlockade(section.isBlockade());
}
if (section.isRouteLock()) {
change = true;
storageSection.setRouteLock(section.isRouteLock());
this.setRouteLock(section.isRouteLock());
}
Route route = section.getRoute();
if (route != null) {
change = true;
storageSection.setRoute(route.getCode());
this.setRoute(route.getCode());
}
if (section.isLockRight()) {
change = true;
storageSection.setLockRight(section.isLockRight());
this.setLockRight(section.isLockRight());
}
if (section.isOverlapLock()) {
change = true;
storageSection.setOverlapLock(section.isOverlapLock());
this.setOverlapLock(section.isOverlapLock());
}
if (section.isCtOccupied()) {
change = true;
storageSection.setCtOccupied(section.isCtOccupied());
this.setCtOccupied(section.isCtOccupied());
}
if (section.isNctOccupied()) {
change = true;
storageSection.setNctOccupied(section.isNctOccupied());
this.setNctOccupied(section.isNctOccupied());
}
if (section.isCutOff()) {
change = true;
storageSection.setCutOff(section.isCutOff());
this.setCutOff(section.isCutOff());
}
if (section.isInvalid()) {
change = true;
storageSection.setInvalid(section.isInvalid());
this.setInvalid(section.isInvalid());
}
if (section.isFaultLock()) {
change = true;
storageSection.setFaultLock(section.isFaultLock());
this.setFaultLock(section.isFaultLock());
}
if (!Objects.equals(section.getSpeedUpLimit(), -1)) {
change = true;
storageSection.setSpeedUpLimit(section.getSpeedUpLimit());
this.setSpeedUpLimit(section.getSpeedUpLimit());
}
if (section.getRemain() > 0) {
if (section.getSpeedLimitBeforeFault() != null) {
change = true;
storageSection.saveFrom(section);
this.speedLimitBeforeFault = section.getSpeedLimitBeforeFault();
}
if (section.isNoStatus()) {
change = true;
storageSection.setNoStatus(section.isNoStatus());
}
if (section.isFault()) {
change = true;
}
if (change) {
return storageSection;
}
return null;
return change;
}
@Override
@ -202,9 +179,6 @@ public class StorageSection extends StorageDelayUnlockDevice {
section.setInvalid(invalid != null? invalid : false);
section.setFaultLock(faultLock != null ? faultLock : false);
section.setSpeedUpLimit(speedUpLimit != null? speedUpLimit : -1);
if (this.getRemain() > 0) {
this.recoverTo(section, repository);
}
section.setNoStatus(noStatus != null ? noStatus : false);
section.setSpeedLimitBeforeFault(speedLimitBeforeFault);
}
}

View File

@ -81,73 +81,57 @@ public class StorageSignal extends StorageDelayUnlockDevice {
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean redOpen;
/**
* 无状态
*/
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean noStatus;
public StorageSignal(String code, MayOutOfOrderDevice.DeviceFault fault) {
super(code, fault);
public StorageSignal(Signal signal) {
super(signal);
}
public static StorageSignal convert2Storage(Signal signal) {
boolean change = false;
StorageSignal storageSignal = new StorageSignal(signal.getCode(), signal.getFault());
if (storageSignal.isFault()) {
change = true;
}
if (signal.getLockedRouteCode() != null) {
change = true;
storageSignal.setLockedRouteCode(signal.getLockedRouteCode());
}
if (signal.isBlockade()) {
change = true;
storageSignal.setBlockade(signal.isBlockade());
}
if (signal.getLevel() != 1) {
change = true;
storageSignal.setLevel(signal.getLevel());
}
if (signal.isReblockade()) {
change = true;
storageSignal.setReblockade(signal.isReblockade());
}
if (signal.isFpl()) {
change = true;
storageSignal.setFpl(signal.isFpl());
}
if (!signal.isLogicLight()) {
change = true;
storageSignal.setLogicLight(signal.isLogicLight());
}
if (!signal.getSignalModel().getDefaultAspect().equals(signal.getAspect())) {
change = true;
storageSignal.setAspect(signal.getAspect());
}
if (signal.isForbidden()) {
change = true;
storageSignal.setForbidden(signal.isForbidden());
}
if (signal.getRemain() > 0) {
change = true;
storageSignal.saveFrom(signal);
}
if (signal.isNoStatus()) {
change = true;
storageSignal.setNoStatus(signal.isNoStatus());
}
if (signal.isFault()) {
change = true;
}
if (change) {
StorageSignal storageSignal = new StorageSignal(signal);
if (storageSignal.convert(signal)) {
return storageSignal;
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = super.convert(element);
Signal signal = (Signal) element;
if (signal.getLockedRouteCode() != null) {
change = true;
this.setLockedRouteCode(signal.getLockedRouteCode());
}
if (signal.isBlockade()) {
change = true;
this.setBlockade(signal.isBlockade());
}
if (signal.getLevel() != 1) {
change = true;
this.setLevel(signal.getLevel());
}
if (signal.isReblockade()) {
change = true;
this.setReblockade(signal.isReblockade());
}
if (signal.isFpl()) {
change = true;
this.setFpl(signal.isFpl());
}
if (!signal.isLogicLight()) {
change = true;
this.setLogicLight(signal.isLogicLight());
}
if (!signal.getSignalModel().getDefaultAspect().equals(signal.getAspect())) {
change = true;
this.setAspect(signal.getAspect());
}
if (signal.isForbidden()) {
change = true;
this.setForbidden(signal.isForbidden());
}
return change;
}
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
super.recover2Simulation(element, simulation, repository);
@ -163,9 +147,5 @@ public class StorageSignal extends StorageDelayUnlockDevice {
signal.setAspect(aspect);
}
signal.setForbidden(this.forbidden == null ? false : this.forbidden);
if (this.getRemain() > 0) {
this.recoverTo(signal, repository);
}
signal.setNoStatus(noStatus != null ? noStatus : false);
}
}

View File

@ -105,15 +105,8 @@ public class StorageStand extends StorageMayOutOfOrderDevice {
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean parkingAlwaysValid;
/**
* 无状态
*/
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean noStatus;
public StorageStand(String code, MayOutOfOrderDevice.DeviceFault fault) {
super(code, fault);
public StorageStand(Stand stand) {
super(stand);
}
// public StorageStand(Stand stand) {
@ -133,78 +126,73 @@ public class StorageStand extends StorageMayOutOfOrderDevice {
// }
public static StorageStand convert2Storage(Stand stand) {
boolean change = false;
StorageStand storageStand = new StorageStand(stand.getCode(), stand.getFault());
if (storageStand.isFault()) {
change = true;
}
StorageESP storageESP = StorageESP.convert(stand.getEsp());
if (storageESP != null) {
change = true;
storageStand.setEsp(storageESP);
}
if (stand.isTrainParking()) {
change = true;
storageStand.setTrainParking(stand.isTrainParking());
}
if (stand.isEmergencyClosed()) {
change = true;
storageStand.setEmergencyClosed(stand.isEmergencyClosed());
}
if (stand.getRemainTime() > 0) {
change = true;
storageStand.setRemainTime(stand.getRemainTime());
}
if (stand.isStationHoldTrain()) {
change = true;
storageStand.setStationHoldTrain(stand.isStationHoldTrain());
}
if (stand.isCenterHoldTrain()) {
change = true;
storageStand.setCenterHoldTrain(stand.isCenterHoldTrain());
}
if (stand.isAutoHoldTrain()) {
change = true;
storageStand.setAutoHoldTrain(stand.isAutoHoldTrain());
}
if (stand.isAllSkip()) {
change = true;
storageStand.setAllSkip(stand.isAssignSkip());
}
if (!CollectionUtils.isEmpty(stand.getSkipSet())) {
change = true;
storageStand.setSkipSet(stand.getSkipSet());
}
if (!Objects.equals(stand.getRunLevelTime(), 0)) {
change = true;
storageStand.setRunLevelTime(stand.getRunLevelTime());
}
if (stand.isRunLevelTimeForever()) {
change = true;
storageStand.setRunLevelTimeForever(stand.isRunLevelTimeForever());
}
if (!Objects.equals(stand.getParkingTime(), -1)) {
change = true;
storageStand.setParkingTime(stand.getParkingTime());
}
if (stand.isParkingAlwaysValid()) {
change = true;
storageStand.setParkingAlwaysValid(stand.isParkingAlwaysValid());
}
if (stand.isNoStatus()) {
change = true;
storageStand.setNoStatus(stand.isNoStatus());
}
if (stand.isFault()) {
change = true;
}
if (change) {
StorageStand storageStand = new StorageStand(stand);
if (storageStand.convert(stand)) {
return storageStand;
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = super.convert(element);
Stand stand = (Stand) element;
StorageESP storageESP = StorageESP.convert(stand.getEsp());
if (storageESP != null) {
change = true;
this.setEsp(storageESP);
}
if (stand.isTrainParking()) {
change = true;
this.setTrainParking(stand.isTrainParking());
}
if (stand.isEmergencyClosed()) {
change = true;
this.setEmergencyClosed(stand.isEmergencyClosed());
}
if (stand.getRemainTime() > 0) {
change = true;
this.setRemainTime(stand.getRemainTime());
}
if (stand.isStationHoldTrain()) {
change = true;
this.setStationHoldTrain(stand.isStationHoldTrain());
}
if (stand.isCenterHoldTrain()) {
change = true;
this.setCenterHoldTrain(stand.isCenterHoldTrain());
}
if (stand.isAutoHoldTrain()) {
change = true;
this.setAutoHoldTrain(stand.isAutoHoldTrain());
}
if (stand.isAllSkip()) {
change = true;
this.setAllSkip(stand.isAssignSkip());
}
if (!CollectionUtils.isEmpty(stand.getSkipSet())) {
change = true;
this.setSkipSet(stand.getSkipSet());
}
if (!Objects.equals(stand.getRunLevelTime(), 0)) {
change = true;
this.setRunLevelTime(stand.getRunLevelTime());
}
if (stand.isRunLevelTimeForever()) {
change = true;
this.setRunLevelTimeForever(stand.isRunLevelTimeForever());
}
if (!Objects.equals(stand.getParkingTime(), -1)) {
change = true;
this.setParkingTime(stand.getParkingTime());
}
if (stand.isParkingAlwaysValid()) {
change = true;
this.setParkingAlwaysValid(stand.isParkingAlwaysValid());
}
return change;
}
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
super.recover2Simulation(element, simulation, repository);
@ -221,7 +209,6 @@ public class StorageStand extends StorageMayOutOfOrderDevice {
stand.setRunLevelTimeForever(runLevelTimeForever != null ? runLevelTimeForever : false);
stand.setParkingTime(parkingTime != null ? parkingTime : -1);
stand.setParkingAlwaysValid(parkingAlwaysValid != null ? parkingAlwaysValid : false);
stand.setNoStatus(noStatus != null ? noStatus : false);
}
@Getter

View File

@ -19,7 +19,7 @@ import java.util.concurrent.atomic.AtomicInteger;
@Getter
@Setter
@NoArgsConstructor
public class StorageStation extends StorageDevice {
public class StorageStation extends StorageStatusDevice {
/**
* 是否有控制模式
@ -65,8 +65,8 @@ public class StorageStation extends StorageDevice {
private Integer preResetValidDuration;
public StorageStation(String code) {
super(code);
public StorageStation(Station station) {
super(station);
}
// public StorageStation(Station station) {
@ -76,35 +76,42 @@ public class StorageStation extends StorageDevice {
// }
public static StorageStation convert2Storage(Station station) {
StorageStation storageStation = new StorageStation(station.getCode());
storageStation.setControlMode(station.getControlMode());
storageStation.setTbStrategyId(station.getTbStrategyId());
if (station.isTotalGuideLock()) {
storageStation.setTotalGuideLock(station.isTotalGuideLock());
}
if (station.getApplicant() != null) {
storageStation.setApplicant(station.getApplicant().getId());
}
if (station.getApply2TheControlMode() != null) {
storageStation.setApply2TheControlMode(station.getApply2TheControlMode());
}
if (station.getValidDuration() != null) {
storageStation.setValidDuration(station.getValidDuration());
}
if (station.isInterlockMachineStarting()) {
storageStation.setInterlockMachineStarting(station.isInterlockMachineStarting());
}
storageStation.setRestartTime(station.getRestartTime());
storageStation.setController(station.getControllerId());
if (station.isEmergencyController()) {
storageStation.setEmergencyController(station.isEmergencyController());
}
storageStation.setControlApplicant(station.getControlApplicantId());
if (station.getPreResetValidDuration() != null && station.getPreResetValidDuration().get() != 0) {
storageStation.setPreResetValidDuration(station.getPreResetValidDuration().get());
StorageStation storageStation = new StorageStation(station);
storageStation.convert(station);
return storageStation;
}
return storageStation;
@Override
public boolean convert(MapElement element) {
super.convert(element);
Station station = (Station) element;
this.setControlMode(station.getControlMode());
this.setTbStrategyId(station.getTbStrategyId());
if (station.isTotalGuideLock()) {
this.setTotalGuideLock(station.isTotalGuideLock());
}
if (station.getApplicant() != null) {
this.setApplicant(station.getApplicant().getId());
}
if (station.getApply2TheControlMode() != null) {
this.setApply2TheControlMode(station.getApply2TheControlMode());
}
if (station.getValidDuration() != null) {
this.setValidDuration(station.getValidDuration());
}
if (station.isInterlockMachineStarting()) {
this.setInterlockMachineStarting(station.isInterlockMachineStarting());
}
this.setRestartTime(station.getRestartTime());
this.setController(station.getControllerId());
if (station.isEmergencyController()) {
this.setEmergencyController(station.isEmergencyController());
}
this.setControlApplicant(station.getControlApplicantId());
if (station.getPreResetValidDuration() != null && station.getPreResetValidDuration().get() != 0) {
this.setPreResetValidDuration(station.getPreResetValidDuration().get());
}
return true;
}
@Override

View File

@ -0,0 +1,53 @@
package club.joylink.rtss.simulation.cbtc.data.storage.device;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.StatusDevice;
import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer;
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
public class StorageStatusDevice extends StorageDevice{
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean atsNoStatus;
public StorageStatusDevice(StatusDevice device) {
super(device.getCode());
}
@Override
public boolean convert(MapElement element) {
StatusDevice device = (StatusDevice) element;
boolean change = false;
if (device.isNoStatus()) {
change = true;
this.noStatus = true;
}
if (device.isAtsNoStatus()) {
change = true;
this.setAtsNoStatus(true);
}
return change;
}
@Override
public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) {
StatusDevice device = (StatusDevice) element;
device.setNoStatus(this.noStatus == null ? false : this.noStatus);
device.setAtsNoStatus(this.atsNoStatus == null ? false : this.atsNoStatus);
}
}

View File

@ -76,75 +76,62 @@ public class StorageSwitch extends StorageDelayUnlockDevice {
*/
private SwitchIndication pos;
@JsonSerialize(using = Boolean2NumSerializer.class)
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean noStatus;
public StorageSwitch(String code, MayOutOfOrderDevice.DeviceFault fault) {
super(code, fault);
public StorageSwitch(Switch aSwitch) {
super(aSwitch);
}
public static StorageSwitch convert2Storage(Switch s) {
boolean change = false;
StorageSwitch storageSwitch = new StorageSwitch(s.getCode(), s.getFault());
if (storageSwitch.isFault()) {
change = true;
StorageSwitch storageSwitch = new StorageSwitch(s);
if (storageSwitch.convert(s)) {
return storageSwitch;
}
return null;
}
@Override
public boolean convert(MapElement element) {
boolean change = super.convert(element);
Switch s = (Switch) element;
if (s.isSingleLock()) {
change = true;
storageSwitch.setSingleLock(s.isSingleLock());
this.setSingleLock(s.isSingleLock());
}
if (s.isBlockade()) {
change = true;
storageSwitch.setBlockade(s.isBlockade());
this.setBlockade(s.isBlockade());
}
if (s.isRouteLock()) {
change = true;
storageSwitch.setRouteLock(s.isRouteLock());
this.setRouteLock(s.isRouteLock());
}
// Route route = s.getRoutes();
// if (route != null) {
// change = true;
// storageSwitch.setRoute(route.getCode());
// this.setRoute(route.getCode());
// }
Set<Route> routes = s.getRoutes();
if (!CollectionUtils.isEmpty(routes)) {
change = true;
Set<String> routeCodes = routes.stream().map(MapElement::getCode).collect(Collectors.toSet());
storageSwitch.setRoutes(routeCodes);
this.setRoutes(routeCodes);
}
if (s.isFpLock()) {
change = true;
storageSwitch.setFpLock(s.isFpLock());
this.setFpLock(s.isFpLock());
}
if (s.isOverlapLock()) {
change = true;
storageSwitch.setOverlapLock(s.isOverlapLock());
this.setOverlapLock(s.isOverlapLock());
}
if (s.isMasterGuideLock()) {
change = true;
storageSwitch.setMasterGuideLock(s.isMasterGuideLock());
this.setMasterGuideLock(s.isMasterGuideLock());
}
if (!SwitchIndication.N.equals(s.getPos())) {
change = true;
storageSwitch.setPos(s.getPos());
this.setPos(s.getPos());
}
if (s.getRemain() > 0) {
change = true;
storageSwitch.saveFrom(s);
}
if (s.isNoStatus()) {
change = true;
storageSwitch.setNoStatus(s.isNoStatus());
}
if (s.isFault()) {
change = true;
}
if (change) {
return storageSwitch;
}
return null;
return change;
}
@Override
@ -171,9 +158,5 @@ public class StorageSwitch extends StorageDelayUnlockDevice {
if (pos != null) {
s.setPos(pos);
}
if (this.getRemain() > 0) {
this.recoverTo(s, repository);
}
s.setNoStatus(noStatus != null ? noStatus : false);
}
}

View File

@ -14,17 +14,12 @@ import lombok.Setter;
public class StorageZC extends StorageMayOutOfOrderDevice {
private StorageZC (ZC zc) {
super(zc.getCode(), zc.getFault());
super(zc);
}
public static StorageZC convert2Storage(ZC zc) {
boolean change = false;
StorageZC storageZC = new StorageZC(zc);
if (zc.isFault()) {
change = true;
}
if (change) {
if (storageZC.convert(zc)) {
return storageZC;
}
return null;

View File

@ -75,7 +75,7 @@ public class RoutePath {
}
}
public void addRoute(Route route) {
public void addRouteAndSignal(Route route) {
if (this.routeList.contains(route)) {
return;
}
@ -83,10 +83,17 @@ public class RoutePath {
this.addSignal(route.getStart());
}
public void addRoute(Route route) {
if (this.routeList.contains(route)) {
return;
}
this.routeList.add(route);
}
public void addRoutes(List<Route> routeList) {
if (!CollectionUtils.isEmpty(routeList)) {
for (Route route : routeList) {
this.addRoute(route);
this.addRouteAndSignal(route);
}
}
}

View File

@ -29,6 +29,9 @@ public class PSDStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean atsNoStatus;
public PSDStatusVO(PSD psd) {
super(psd.getCode(), psd.getDeviceType());
}

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.data.vo;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import lombok.Setter;
@ -55,6 +56,9 @@ public class SectionStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean atsNoStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean preReset;
@ -64,6 +68,7 @@ public class SectionStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean closed;
@JsonInclude
private String fault;
public SectionStatusVO(Section section) {

View File

@ -51,6 +51,9 @@ public class SignalStatusVO extends DeviceStatusVO{
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean atsNoStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean approachLock;

View File

@ -86,6 +86,9 @@ public class StandStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean atsNoStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean closed;

View File

@ -70,6 +70,8 @@ public class StationStatusVO extends DeviceStatusVO {
private Integer preResetValidDuration;
private Boolean interlockMachineStarting;
public StationStatusVO(Station station) {
super(station.getCode(), station.getDeviceType());
}

View File

@ -52,6 +52,9 @@ public class SwitchStatusVO extends DeviceStatusVO {
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean noStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private boolean atsNoStatus;
@JsonSerialize(using = Boolean2NumSerializer.class)
private Boolean preReset;
@ -73,4 +76,12 @@ public class SwitchStatusVO extends DeviceStatusVO {
public SwitchStatusVO(Switch aSwitch) {
super(aSwitch.getCode(), aSwitch.getDeviceType());
}
public void setAtsNoStatus(boolean atsNoStatus) {
this.atsNoStatus = atsNoStatus;
}
public boolean getAtsNoStatus() {
return atsNoStatus;
}
}

View File

@ -1445,10 +1445,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice {
* 是否比该模式级别更高
*/
public boolean isHigherThan(PreselectionMode mode) {
if (this.runLevel.isHigherThan(mode.runLevel)) {
return true;
}
if (this.runLevel.equals(mode.runLevel)) {
return this.driveMode.isHigherThan(mode.driveMode);
} else {
return this.runLevel.isHigherThan(mode.runLevel);
}
}
}