[修改]成都工业职业技术学院项目设备联动逻辑

This commit is contained in:
thesai 2024-04-17 10:42:05 +08:00
parent aae729b637
commit 5d15ba3240
17 changed files with 1189 additions and 893 deletions

View File

@ -70,6 +70,8 @@ public class WebConfig implements WebMvcConfigurer {
whiteList.add("/api/v2/paper/composition/oldData/handle"); whiteList.add("/api/v2/paper/composition/oldData/handle");
whiteList.add("/api/user/sync"); whiteList.add("/api/user/sync");
whiteList.add("/dataHandle"); whiteList.add("/dataHandle");
//modbus测试
whiteList.add("/api/test/modbus/writeCoil");
registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList); registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList);
} }

View File

@ -34,6 +34,8 @@ import club.joylink.rtss.vo.client.project.UDPClientConfigVO;
import club.joylink.rtss.vo.client.project.UDPLowConfigVO; import club.joylink.rtss.vo.client.project.UDPLowConfigVO;
import club.joylink.rtss.vo.client.project.VrIbpConfigVO; import club.joylink.rtss.vo.client.project.VrIbpConfigVO;
import club.joylink.rtss.vo.client.project.VrpsdConfigVO; import club.joylink.rtss.vo.client.project.VrpsdConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgySectionConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgySignalConfigVO; import club.joylink.rtss.vo.client.project.cgy.CgySignalConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgySwitchConfigVO; import club.joylink.rtss.vo.client.project.cgy.CgySwitchConfigVO;
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
@ -579,7 +581,7 @@ public class DeviceServiceImpl implements DeviceService {
plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name()); plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name());
plcGateway.setCreator(accountVO.getId()); plcGateway.setCreator(accountVO.getId());
plcGateway.setCreateTime(now); plcGateway.setCreateTime(now);
PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 16); PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 64);
plcGateway.setConfig(plcGatewayConfigVO.toJson()); plcGateway.setConfig(plcGatewayConfigVO.toJson());
list.add(plcGateway); list.add(plcGateway);
//SIGNAL //SIGNAL
@ -589,7 +591,7 @@ public class DeviceServiceImpl implements DeviceService {
signal1.setType(ProjectDeviceType.SIGNAL.name()); signal1.setType(ProjectDeviceType.SIGNAL.name());
signal1.setCreator(accountVO.getId()); signal1.setCreator(accountVO.getId());
signal1.setCreateTime(now); signal1.setCreateTime(now);
signal1.setConfig(new CgySignalConfigVO(null, 2, 3, 4, 11, 12, 13).toJson()); signal1.setConfig(new CgySignalConfigVO("S13289", 0, 1, 2, 3, 4, 5, 16, 17, 18, 19).toJson());
list.add(signal1); list.add(signal1);
ProjectDevice signal2 = new ProjectDevice(); ProjectDevice signal2 = new ProjectDevice();
signal2.setProjectCode(projectCode); signal2.setProjectCode(projectCode);
@ -597,7 +599,7 @@ public class DeviceServiceImpl implements DeviceService {
signal2.setType(ProjectDeviceType.SIGNAL.name()); signal2.setType(ProjectDeviceType.SIGNAL.name());
signal2.setCreator(accountVO.getId()); signal2.setCreator(accountVO.getId());
signal2.setCreateTime(now); signal2.setCreateTime(now);
signal2.setConfig(new CgySignalConfigVO(null, 5, 6, 7, 14, 15, 16).toJson()); signal2.setConfig(new CgySignalConfigVO("X44854", 6, 7, 8, 9, 10, 11, 20, 21, 22, 23).toJson());
list.add(signal2); list.add(signal2);
//SWITCH //SWITCH
ProjectDevice aSwitch = new ProjectDevice(); ProjectDevice aSwitch = new ProjectDevice();
@ -606,17 +608,50 @@ public class DeviceServiceImpl implements DeviceService {
aSwitch.setType(ProjectDeviceType.SWITCH.name()); aSwitch.setType(ProjectDeviceType.SWITCH.name());
aSwitch.setCreator(accountVO.getId()); aSwitch.setCreator(accountVO.getId());
aSwitch.setCreateTime(now); aSwitch.setCreateTime(now);
aSwitch.setConfig(new CgySwitchConfigVO().toJson()); aSwitch.setConfig(new CgySwitchConfigVO("W37779").toJson());
list.add(aSwitch); list.add(aSwitch);
// //SECTION //PSL
// ProjectDevice section = new ProjectDevice(); ProjectDevice psl = new ProjectDevice();
// section.setProjectCode(projectCode); psl.setProjectCode(projectCode);
// section.setCode(prefix + "section"); psl.setCode(prefix + "psl");
// section.setType(ProjectDeviceType.SECTION.name()); psl.setType(ProjectDeviceType.PSL.name());
// section.setCreator(accountVO.getId()); psl.setCreator(accountVO.getId());
// section.setCreateTime(now); psl.setCreateTime(now);
// section.setConfig(new CgySectionConfigVO().toJson()); psl.setConfig(new CgyPslConfigVO("PF59020_PSL").toJson());
// list.add(section); list.add(psl);
//SECTION
ProjectDevice section106 = new ProjectDevice();
section106.setProjectCode(projectCode);
section106.setCode(prefix + "section106");
section106.setType(ProjectDeviceType.SECTION.name());
section106.setCreator(accountVO.getId());
section106.setCreateTime(now);
section106.setConfig(new CgySectionConfigVO(null, 35).toJson());
list.add(section106);
ProjectDevice section104 = new ProjectDevice();
section104.setProjectCode(projectCode);
section104.setCode(prefix + "section104");
section104.setType(ProjectDeviceType.SECTION.name());
section104.setCreator(accountVO.getId());
section104.setCreateTime(now);
section104.setConfig(new CgySectionConfigVO(null, 36).toJson());
list.add(section104);
ProjectDevice section101 = new ProjectDevice();
section101.setProjectCode(projectCode);
section101.setCode(prefix + "section101");
section101.setType(ProjectDeviceType.SECTION.name());
section101.setCreator(accountVO.getId());
section101.setCreateTime(now);
section101.setConfig(new CgySectionConfigVO(null, 37).toJson());
list.add(section101);
ProjectDevice section102 = new ProjectDevice();
section102.setProjectCode(projectCode);
section102.setCode(prefix + "section102");
section102.setType(ProjectDeviceType.SECTION.name());
section102.setCreator(accountVO.getId());
section102.setCreateTime(now);
section102.setConfig(new CgySectionConfigVO(null, 38).toJson());
list.add(section102);
return list; return list;
} }

View File

@ -12,14 +12,13 @@ import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent; import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent;
import club.joylink.rtss.vo.client.psl.PslStatus; import club.joylink.rtss.vo.client.psl.PslStatus;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.Map;
@Service @Service
public class VirtualRealityPslService implements IVirtualRealityPslService { public class VirtualRealityPslService implements IVirtualRealityPslService {
@ -51,13 +50,15 @@ public class VirtualRealityPslService implements IVirtualRealityPslService {
} }
@Override @Override
public void pressTheButton(Simulation simulation, String standCode, VirtualRealityPsl.Button button) { public void pressTheButton(Simulation simulation, String standCode,
VirtualRealityPsl.Button button) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
VirtualRealityPsl vrPsl = collectStatus(stand); VirtualRealityPsl vrPsl = collectStatus(stand);
theButtonIsPressed(simulation, vrPsl, button); theButtonIsPressed(simulation, vrPsl, button);
} }
private void theButtonIsPressed(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button) { private void theButtonIsPressed(Simulation simulation, VirtualRealityPsl vrPsl,
VirtualRealityPsl.Button button) {
Stand stand = vrPsl.getStand(); Stand stand = vrPsl.getStand();
switch (button) { switch (button) {
case YXJZ: case YXJZ:
@ -68,10 +69,12 @@ public class VirtualRealityPslService implements IVirtualRealityPslService {
ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey()); ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey());
break; break;
case KM: case KM:
ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); ciApiService.openScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
break; break;
case GM: case GM:
ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); ciApiService.closeScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
break; break;
case SD: case SD:
vrPsl.setSdButton(!vrPsl.isSdButton()); vrPsl.setSdButton(!vrPsl.isSdButton());
@ -80,7 +83,8 @@ public class VirtualRealityPslService implements IVirtualRealityPslService {
} }
@Override @Override
public void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button, boolean on) { public void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl,
VirtualRealityPsl.Button button, boolean on) {
switch (button) { switch (button) {
case YXJZ: case YXJZ:
vrPsl.setYxjzKey(on); vrPsl.setYxjzKey(on);
@ -89,7 +93,10 @@ public class VirtualRealityPslService implements IVirtualRealityPslService {
vrPsl.setHsjcKey(on); vrPsl.setHsjcKey(on);
break; break;
case KM: case KM:
vrPsl.setKmButton(on);
break;
case GM: case GM:
vrPsl.setGmButton(on);
break; break;
case SD: case SD:
vrPsl.setSdButton(on); vrPsl.setSdButton(on);
@ -98,7 +105,8 @@ public class VirtualRealityPslService implements IVirtualRealityPslService {
effective(simulation, vrPsl.getStand(), button, on); effective(simulation, vrPsl.getStand(), button, on);
} }
private void effective(Simulation simulation, Stand stand, VirtualRealityPsl.Button button, boolean on) { private void effective(Simulation simulation, Stand stand, VirtualRealityPsl.Button button,
boolean on) {
switch (button) { switch (button) {
case YXJZ: case YXJZ:
break; break;
@ -106,12 +114,16 @@ public class VirtualRealityPslService implements IVirtualRealityPslService {
ciApiService.setOrCancelInterlockRelease(simulation, stand, on); ciApiService.setOrCancelInterlockRelease(simulation, stand, on);
break; break;
case KM: case KM:
if (on) if (on) {
ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); ciApiService.openScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
}
break; break;
case GM: case GM:
if (on) if (on) {
ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); ciApiService.closeScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
}
break; break;
case SD: case SD:
break; break;
@ -129,8 +141,9 @@ public class VirtualRealityPslService implements IVirtualRealityPslService {
Map<String, PslStatus> ibpStatusMap = repository.getPslStatusMap(); Map<String, PslStatus> ibpStatusMap = repository.getPslStatusMap();
Map<String, PslStatus> collectionMap = new HashMap<>(); Map<String, PslStatus> collectionMap = new HashMap<>();
for (Stand stand : repository.getStandList()) { for (Stand stand : repository.getStandList()) {
if (stand.getVrPsl() == null) if (stand.getVrPsl() == null) {
continue; continue;
}
VirtualRealityPsl vrPsl = this.collectStatus(stand); VirtualRealityPsl vrPsl = this.collectStatus(stand);
PslStatus pslStatus = ibpStatusMap.get(stand.getCode()); PslStatus pslStatus = ibpStatusMap.get(stand.getCode());
if (pslStatus == null) { if (pslStatus == null) {
@ -145,7 +158,8 @@ public class VirtualRealityPslService implements IVirtualRealityPslService {
} }
} }
if (!CollectionUtils.isEmpty(collectionMap)) { if (!CollectionUtils.isEmpty(collectionMap)) {
applicationContext.publishEvent(new SimulationPslStatusEvent(this, simulation, collectionMap)); applicationContext.publishEvent(
new SimulationPslStatusEvent(this, simulation, collectionMap));
} }
} }

View File

@ -6,14 +6,14 @@ import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement; import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService;
import java.util.List;
import java.util.Objects;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Objects;
@Component @Component
public class CiSwitchControlService { public class CiSwitchControlService {
@Autowired @Autowired
private VirtualRealityDeviceService virtualRealityDeviceService; private VirtualRealityDeviceService virtualRealityDeviceService;
@ -99,7 +99,14 @@ public class CiSwitchControlService {
*/ */
public SwitchIndication turn(Simulation simulation, Switch aSwitch) { public SwitchIndication turn(Simulation simulation, Switch aSwitch) {
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
boolean lastTurnToN = vrSwitch.isLastTurnToN(); boolean lastTurnToN; //最后转向的方向主要是为了解决失表的情况下每次转动道岔要向不同方向转动
if (vrSwitch.isPosN()) {
lastTurnToN = true;
} else if (vrSwitch.isPosR()) {
lastTurnToN = false;
} else {
lastTurnToN = vrSwitch.isLastTurnToN();
}
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) { if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch(); Switch linkedSwitch = aSwitch.queryLinkedSwitch();
if (Objects.nonNull(linkedSwitch)) { if (Objects.nonNull(linkedSwitch)) {
@ -133,7 +140,8 @@ public class CiSwitchControlService {
return false; return false;
} }
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
this.virtualRealityDeviceService.control(simulation, vrSwitch, VirtualRealitySwitch.Operation.NP); this.virtualRealityDeviceService.control(simulation, vrSwitch,
VirtualRealitySwitch.Operation.NP);
return true; return true;
} }
@ -149,7 +157,8 @@ public class CiSwitchControlService {
return false; return false;
} }
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
this.virtualRealityDeviceService.control(simulation, vrSwitch, VirtualRealitySwitch.Operation.RP); this.virtualRealityDeviceService.control(simulation, vrSwitch,
VirtualRealitySwitch.Operation.RP);
return true; return true;
} }
@ -161,20 +170,23 @@ public class CiSwitchControlService {
*/ */
private boolean checkTurnCondition(Switch aSwitch) { private boolean checkTurnCondition(Switch aSwitch) {
// 道岔锁闭 或者 道岔占用且无强扳授权则不能转动 // 道岔锁闭 或者 道岔占用且无强扳授权则不能转动
return !(aSwitch.isLocked() || (aSwitch.isSectionOccupied() && aSwitch.getForceTurnRemain() <= 0)); return !(aSwitch.isLocked() || (aSwitch.isSectionOccupied()
&& aSwitch.getForceTurnRemain() <= 0));
} }
/** /**
* 确保道岔位置正确 * 确保道岔位置正确
*/ */
public boolean ensureSwitchPosCurrent(Simulation simulation, List<SwitchElement> switchElements, boolean guideSetting) { public boolean ensureSwitchPosCurrent(Simulation simulation, List<SwitchElement> switchElements,
boolean guideSetting) {
boolean allOn = true; boolean allOn = true;
if (switchElements == null) { if (switchElements == null) {
return true; return true;
} }
for (SwitchElement switchElement : switchElements) { for (SwitchElement switchElement : switchElements) {
boolean onPos = this.turnRouteSwitch(simulation, switchElement); boolean onPos = this.turnRouteSwitch(simulation, switchElement);
if (!onPos && !(guideSetting && switchElement.getASwitch().isLoss() && switchElement.getASwitch().isGuideMasterLock())) { //不在正确位置并且不是办理引导进路中的引导总锁的失表道岔 if (!onPos && !(guideSetting && switchElement.getASwitch().isLoss()
&& switchElement.getASwitch().isGuideMasterLock())) { //不在正确位置并且不是办理引导进路中的引导总锁的失表道岔
allOn = false; allOn = false;
} }
} }

View File

@ -189,8 +189,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
Simulation.FunctionalType functionalType) { Simulation.FunctionalType functionalType) {
Objects.requireNonNull(mapId, "地图id不能为空"); Objects.requireNonNull(mapId, "地图id不能为空");
Objects.requireNonNull(functionalType, "仿真功能类型不能为空"); Objects.requireNonNull(functionalType, "仿真功能类型不能为空");
SimulationBuildParams params = this.prepareSimulationParams(loginUserInfoVO, mapId, SimulationBuildParams params = this.prepareSimulationParams(loginUserInfoVO, mapId, prdType,
prdType, functionalType); functionalType);
String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(),
mapId); mapId);
Simulation simulation = this.simulationLifeCycleService.create(params, group); Simulation simulation = this.simulationLifeCycleService.create(params, group);
@ -212,17 +212,13 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
List<RunPlanParkingTimeVO> parkTimeList = this.prepareParkTimeData(mapVO, loginUserInfoVO, List<RunPlanParkingTimeVO> parkTimeList = this.prepareParkTimeData(mapVO, loginUserInfoVO,
mapId); mapId);
// 获取操作定义数据 // 获取操作定义数据
List<CommandDefinitionVO> operationDefinitionList = this.iCommandService List<CommandDefinitionVO> operationDefinitionList = this.iCommandService.queryDefinitionsByLineCode(
.queryDefinitionsByLineCode(mapVO.getLineCode()); mapVO.getLineCode());
SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder(); SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder();
// 都有的属性构造 // 都有的属性构造
builder.loginUserInfo(loginUserInfoVO) builder.loginUserInfo(loginUserInfoVO).createTime(LocalDateTime.now()).map(mapVO)
.createTime(LocalDateTime.now()) .userRunLevelList(runLevelList).userParkTimeList(parkTimeList)
.map(mapVO) .operationDefinitionList(operationDefinitionList).prodType(prdType)
.userRunLevelList(runLevelList)
.userParkTimeList(parkTimeList)
.operationDefinitionList(operationDefinitionList)
.prodType(prdType)
.functionalType(functionalType); .functionalType(functionalType);
//运行图选择性构造 //运行图选择性构造
LocalDate runPlanDate = SimulationConstants.getRunPlanDate(); LocalDate runPlanDate = SimulationConstants.getRunPlanDate();
@ -236,9 +232,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId, schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId,
runPlanDate); runPlanDate);
} else { } else {
schedulingPlanNewVO = this.schedulingService schedulingPlanNewVO = this.schedulingService.querySchedulingPlanUserFirst(
.querySchedulingPlanUserFirst(loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), runPlanDate);
runPlanDate);
} }
builder.schedulingPlan(schedulingPlanNewVO); builder.schedulingPlan(schedulingPlanNewVO);
} }
@ -294,15 +289,12 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
// 获取地图数据 // 获取地图数据
MapVO mapVO = this.iMapService.getMapDetail(mapId); MapVO mapVO = this.iMapService.getMapDetail(mapId);
// 获取操作定义数据 // 获取操作定义数据
List<CommandDefinitionVO> operationDefinitionList = this.iCommandService List<CommandDefinitionVO> operationDefinitionList = this.iCommandService.queryDefinitionsByLineCode(
.queryDefinitionsByLineCode(mapVO.getLineCode()); mapVO.getLineCode());
SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder(); SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder();
// 都有的属性构造 // 都有的属性构造
builder.loginUserInfo(loginUserInfoVO) builder.loginUserInfo(loginUserInfoVO).createTime(LocalDateTime.now()).map(mapVO)
.createTime(LocalDateTime.now()) .operationDefinitionList(operationDefinitionList).prodType(prdType)
.map(mapVO)
.operationDefinitionList(operationDefinitionList)
.prodType(prdType)
.functionalType(functionalType); .functionalType(functionalType);
//运行图选择性构造 //运行图选择性构造
LocalDate runPlanDate = SimulationConstants.getRunPlanDate(); LocalDate runPlanDate = SimulationConstants.getRunPlanDate();
@ -314,9 +306,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId, schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId,
runPlanDate); runPlanDate);
} else { } else {
schedulingPlanNewVO = this.schedulingService schedulingPlanNewVO = this.schedulingService.querySchedulingPlanUserFirst(
.querySchedulingPlanUserFirst(loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), runPlanDate);
runPlanDate);
} }
builder.schedulingPlan(schedulingPlanNewVO); builder.schedulingPlan(schedulingPlanNewVO);
} }
@ -368,8 +359,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
confirmHasPermission(loginUserInfoVO.getAccountVO(), mapId, prodCode); confirmHasPermission(loginUserInfoVO.getAccountVO(), mapId, prodCode);
MapPrdTypeEnum prdType = MapPrdTypeEnum.getMapPrdTypeEnumByCode(prodCode); MapPrdTypeEnum prdType = MapPrdTypeEnum.getMapPrdTypeEnumByCode(prodCode);
Simulation simulation = this.create(loginUserInfoVO, mapId, Simulation simulation = this.create(loginUserInfoVO, mapId, prdType,
prdType,
Simulation.FunctionalType.SIMULATION); Simulation.FunctionalType.SIMULATION);
if (Objects.equals(MapPrdTypeEnum.BIG_SCREEN, prdType)) { if (Objects.equals(MapPrdTypeEnum.BIG_SCREEN, prdType)) {
@ -573,8 +563,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group); Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
this.simulationLifeCycleService.checkErrorThrow(simulation); this.simulationLifeCycleService.checkErrorThrow(simulation);
List<TripPlan> tripPlanList = simulation.getRepository().getAllTripPlanList(); List<TripPlan> tripPlanList = simulation.getRepository().getAllTripPlanList();
List<String> tripNumberList = tripPlanList.stream() List<String> tripNumberList = tripPlanList.stream().map(TripPlan::getTripNumber)
.map(TripPlan::getTripNumber)
.collect(Collectors.toList()); .collect(Collectors.toList());
return tripNumberList; return tripNumberList;
} }
@ -652,8 +641,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
RunPlanVO runPlan = this.iRunPlanTemplateService.getRunPlan(templateId); RunPlanVO runPlan = this.iRunPlanTemplateService.getRunPlan(templateId);
// 重新加载运行计划匹配的派班计划 // 重新加载运行计划匹配的派班计划
Long userId = simulation.getBuildParams().getUser().getId(); Long userId = simulation.getBuildParams().getUser().getId();
SchedulingPlanNewVO schedulingPlan = this.schedulingService SchedulingPlanNewVO schedulingPlan = this.schedulingService.querySchedulingPlanUserFirst(userId,
.querySchedulingPlanUserFirst(userId, templateId, SimulationConstants.getRunPlanDate()); templateId, SimulationConstants.getRunPlanDate());
this.simulationLifeCycleService.reloadRunPlan(simulation, runPlan, schedulingPlan); this.simulationLifeCycleService.reloadRunPlan(simulation, runPlan, schedulingPlan);
simulation.getRepository().clearChangeTrips(); //清除掉之前的车次计划变化信息 simulation.getRepository().clearChangeTrips(); //清除掉之前的车次计划变化信息
} }
@ -673,8 +662,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
ScriptBO scriptBO = iScriptService.getScriptBOById(scriptId, simulation); ScriptBO scriptBO = iScriptService.getScriptBOById(scriptId, simulation);
iScriptSimulationService.scriptCoverSimulation(simulation, scriptBO); iScriptSimulationService.scriptCoverSimulation(simulation, scriptBO);
SocketMessageVO<Boolean> message = SocketMessageFactory.build( SocketMessageVO<Boolean> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Script_Loaded, WebSocketMessageType.Simulation_Script_Loaded, simulation.getId(), true);
simulation.getId(), true);
Set<String> userIds = simulation.getSimulationUserIds(); Set<String> userIds = simulation.getSimulationUserIds();
stompMessageService.sendToUser(userIds, message); stompMessageService.sendToUser(userIds, message);
} }
@ -851,11 +839,9 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
@Override @Override
public List<SimulationVO> queryJointSimulationByUser(LoginUserInfoVO loginUserInfoVO) { public List<SimulationVO> queryJointSimulationByUser(LoginUserInfoVO loginUserInfoVO) {
List<Simulation> jointSimulationList = this.groupSimulationCache.queryAllJointSimulation(); List<Simulation> jointSimulationList = this.groupSimulationCache.queryAllJointSimulation();
List<Simulation> userJointSimulationList = jointSimulationList.stream() List<Simulation> userJointSimulationList = jointSimulationList.stream().filter(
.filter(simulation -> simulation -> simulation.isSame(loginUserInfoVO.getProject()) && simulation.containsUser(
simulation.isSame(loginUserInfoVO.getProject()) && loginUserInfoVO.getAccountVO().getId())).collect(Collectors.toList());
simulation.containsUser(loginUserInfoVO.getAccountVO().getId()))
.collect(Collectors.toList());
List<SimulationVO> simulationVOList = SimulationVO.convert2VOList(userJointSimulationList); List<SimulationVO> simulationVOList = SimulationVO.convert2VOList(userJointSimulationList);
return simulationVOList; return simulationVOList;
@ -864,13 +850,11 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
@Override @Override
public void kickOut(String group, Long userId, AccountVO user) { public void kickOut(String group, Long userId, AccountVO user) {
Simulation simulation = this.getSimulationByGroup(group); Simulation simulation = this.getSimulationByGroup(group);
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertTrue(simulation.isAdmin(user));
.assertTrue(simulation.isAdmin(user));
SimulationUser simulationUser = simulation.querySimulationUserById(userId); SimulationUser simulationUser = simulation.querySimulationUserById(userId);
if (Objects.nonNull(simulationUser)) { if (Objects.nonNull(simulationUser)) {
ProjectDeviceVO projectDevice = simulationUser.getProjectDevice(); ProjectDeviceVO projectDevice = simulationUser.getProjectDevice();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNull(projectDevice);
.assertNull(projectDevice);
this.kickOut(simulation, simulationUser); this.kickOut(simulation, simulationUser);
} }
} }
@ -903,12 +887,12 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
Simulation simulation = this.getSimulationByGroup(group); Simulation simulation = this.getSimulationByGroup(group);
List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList(); List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList();
if (!CollectionUtils.isEmpty(realDeviceList)) { if (!CollectionUtils.isEmpty(realDeviceList)) {
Set<ProjectDeviceType> displayDeviceTypes = Set<ProjectDeviceType> displayDeviceTypes = new HashSet<>(
new HashSet<>(
List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL,
ProjectDeviceType.PLC_GATEWAY, ProjectDeviceType.IBP, ProjectDeviceType.SECTION)); ProjectDeviceType.PLC_GATEWAY, ProjectDeviceType.IBP, ProjectDeviceType.SECTION,
realDeviceList = realDeviceList ProjectDeviceType.PSL));
.stream().filter(device -> displayDeviceTypes.contains(device.getDeviceType())) realDeviceList = realDeviceList.stream()
.filter(device -> displayDeviceTypes.contains(device.getDeviceType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
// List<RealDevice> showList = null; // List<RealDevice> showList = null;
@ -953,8 +937,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
//校验目标成员类型 //校验目标成员类型
SimulationMember targetMember = simulation.getSimulationMemberById( SimulationMember targetMember = simulation.getSimulationMemberById(
initiateVO.getTargetMemberId()); initiateVO.getTargetMemberId());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertEquals(targetMember.getType(),
.assertEquals(targetMember.getType(), commandType.getMemberType(), "目标成员不正确"); commandType.getMemberType(), "目标成员不正确");
ScriptBO script = simulation.getScript(); ScriptBO script = simulation.getScript();
if (script != null && script.isBgSet()) { //剧本背景已经保存 if (script != null && script.isBgSet()) { //剧本背景已经保存
@ -1008,15 +992,13 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
public void alarmConfirm(String group, List<String> codes, AccountVO accountVO) { public void alarmConfirm(String group, List<String> codes, AccountVO accountVO) {
Simulation simulation = groupSimulationCache.getSimulationByGroup(group); Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
simulation.getRepository().getAlarmList().stream() simulation.getRepository().getAlarmList().stream()
.filter(atsAlarm -> codes.contains(atsAlarm.getCode())) .filter(atsAlarm -> codes.contains(atsAlarm.getCode())).filter(atsAlarm -> {
.filter(atsAlarm -> {
if (atsAlarm.isConfirmed()) { if (atsAlarm.isConfirmed()) {
codes.remove(atsAlarm.getCode()); codes.remove(atsAlarm.getCode());
return false; return false;
} }
return true; return true;
}) }).forEach(atsAlarm -> atsAlarm.confirm(accountVO, simulation.getCorrectSystemTime()));
.forEach(atsAlarm -> atsAlarm.confirm(accountVO, simulation.getCorrectSystemTime()));
this.applicationContext.publishEvent(new SimulationAlarmConfirmEvent(this, simulation, codes)); this.applicationContext.publishEvent(new SimulationAlarmConfirmEvent(this, simulation, codes));
} }
@ -1057,20 +1039,15 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
int end = pageNum * queryVO.getPageSize(); int end = pageNum * queryVO.getPageSize();
start = Math.min(start, logs.size() - 1); start = Math.min(start, logs.size() - 1);
end = Math.min(end, logs.size()); end = Math.min(end, logs.size());
logs = logs.stream() logs = logs.stream().filter(log -> {
.filter(log -> { if (queryVO.getStartTime() != null && log.getTime().isBefore(queryVO.getStartTime())) {
if (queryVO.getStartTime() != null && log.getTime()
.isBefore(queryVO.getStartTime())) {
return false; return false;
} }
if (queryVO.getEndTime() != null && log.getTime().isAfter(queryVO.getEndTime())) { if (queryVO.getEndTime() != null && log.getTime().isAfter(queryVO.getEndTime())) {
return false; return false;
} }
return true; return true;
}) }).skip(start).limit(end - start).collect(Collectors.toList());
.skip(start)
.limit(end - start)
.collect(Collectors.toList());
pageVO.setList(logs); pageVO.setList(logs);
} else { } else {
pageVO.setPageNum(1); pageVO.setPageNum(1);
@ -1173,23 +1150,21 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
Long mapId, String prdType) { Long mapId, String prdType) {
if (accountVO.isThirdChildAccount()) { if (accountVO.isThirdChildAccount()) {
List<LoginUserInfoVO> loginInfos = this.loginSessionManager.getAllLoginUserInfos(); List<LoginUserInfoVO> loginInfos = this.loginSessionManager.getAllLoginUserInfos();
Set<LoginUserInfoVO> thirdLoginList = loginInfos.stream() Set<LoginUserInfoVO> thirdLoginList = loginInfos.stream().filter(
.filter(loginUserInfoVO -> loginUserInfoVO.getAccountVO().isThirdChildAccount() loginUserInfoVO -> loginUserInfoVO.getAccountVO().isThirdChildAccount()
&& loginUserInfoVO.getAccountVO().getParentAccount() && loginUserInfoVO.getAccountVO().getParentAccount()
.equals(accountVO.getParentAccount())) .equals(accountVO.getParentAccount())).collect(Collectors.toSet());
.collect(Collectors.toSet());
Set<String> thirdLoginAccountIdList = thirdLoginList.stream() Set<String> thirdLoginAccountIdList = thirdLoginList.stream()
.map(loginUserInfoVO -> loginUserInfoVO.getAccountVO().getId().toString()) .map(loginUserInfoVO -> loginUserInfoVO.getAccountVO().getId().toString())
.collect(Collectors.toSet()); .collect(Collectors.toSet());
long count = this.simulationManager.getSimulationList().stream() long count = this.simulationManager.getSimulationList().stream()
.filter(simulation -> simulation instanceof Simulation) .filter(simulation -> simulation instanceof Simulation)
.map(simulation -> ((Simulation) simulation)) .map(simulation -> ((Simulation) simulation)).filter(simulation -> {
.filter(simulation -> {
if (simulation.getBuildParams().getMap().getId().equals(mapId)) { if (simulation.getBuildParams().getMap().getId().equals(mapId)) {
if (!((MapPrdTypeEnum.JOINT.getCode().equals(prdType) && if (!((MapPrdTypeEnum.JOINT.getCode().equals(prdType) && MapPrdTypeEnum.JOINT.equals(
MapPrdTypeEnum.JOINT.equals(simulation.getBuildParams().getProdType())) || simulation.getBuildParams().getProdType())) || (
(!MapPrdTypeEnum.JOINT.getCode().equals(prdType) && !MapPrdTypeEnum.JOINT.getCode().equals(prdType) && !MapPrdTypeEnum.JOINT.equals(
!MapPrdTypeEnum.JOINT.equals(simulation.getBuildParams().getProdType())))) { simulation.getBuildParams().getProdType())))) {
return false; return false;
} }
for (String accountId : simulation.getSimulationUserIds()) { for (String accountId : simulation.getSimulationUserIds()) {
@ -1199,11 +1174,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
} }
} }
return false; return false;
}) }).count();
.count(); int sum = ups.stream().mapToInt(userPermissionVO -> userPermissionVO.getRemains()).sum();
int sum = ups.stream()
.mapToInt(userPermissionVO -> userPermissionVO.getRemains())
.sum();
if (sum <= count) { if (sum <= count) {
return false; return false;
} else { } else {

View File

@ -9,7 +9,8 @@ import lombok.Setter;
*/ */
@Getter @Getter
@Setter @Setter
public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealityScreenDoor.Operation> { public class VirtualRealityScreenDoor extends
ControllableVrDevice<VirtualRealityScreenDoor.Operation> {
public boolean isCommandOpen() { public boolean isCommandOpen() {
return Operation.K.equals(this.getCommand()); return Operation.K.equals(this.getCommand());
@ -19,9 +20,13 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
* 道岔支持的操作 * 道岔支持的操作
*/ */
public enum Operation { public enum Operation {
/** 开门 */ /**
* 开门
*/
K, K,
/** 关门 */ /**
* 关门
*/
G, G,
} }
@ -71,8 +76,9 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
@Override @Override
protected boolean checkConditionBeforeControl(Operation command) { protected boolean checkConditionBeforeControl(Operation command) {
if (command == null) if (command == null) {
return false; return false;
}
switch (command) { switch (command) {
case K: case K:
return !open2End; return !open2End;
@ -109,17 +115,19 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
} }
switch (command) { switch (command) {
case K: { case K: {
if (this.isOpen2End()) if (this.isOpen2End()) {
setRemain(0); setRemain(0);
else } else {
setClose(false); setClose(false);
}
break; break;
} }
case G: { case G: {
if (this.isLockAndClose()) if (this.isLockAndClose()) {
setRemain(0); setRemain(0);
else } else {
setOpen2End(false); setOpen2End(false);
}
break; break;
} }
default: default:
@ -150,14 +158,16 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
public void setClose(boolean close) { public void setClose(boolean close) {
if ((Fault.CANNOT_BE_CLOSED.equals(this.fault) && close) || if ((Fault.CANNOT_BE_CLOSED.equals(this.fault) && close) ||
(Fault.CANNOT_BE_OPENED.equals(this.fault) && !close)) (Fault.CANNOT_BE_OPENED.equals(this.fault) && !close)) {
return; return;
}
this.close = close; this.close = close;
} }
public void setLock(boolean lock) { public void setLock(boolean lock) {
if (Fault.NO_CLOSE_AND_LOCK.equals(this.fault) && lock) if (Fault.NO_CLOSE_AND_LOCK.equals(this.fault) && lock) {
return; return;
}
this.lock = lock; this.lock = lock;
} }
@ -217,16 +227,16 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
CANNOT_BE_CLOSED { CANNOT_BE_CLOSED {
@Override @Override
public void apply(VirtualRealityScreenDoor door) { public void apply(VirtualRealityScreenDoor door) {
door.setFault(null); // door.setFault(null);
door.control(Operation.K); // door.control(Operation.K);
door.setFault(this); door.setFault(this);
} }
}, },
CANNOT_BE_OPENED { CANNOT_BE_OPENED {
@Override @Override
public void apply(VirtualRealityScreenDoor door) { public void apply(VirtualRealityScreenDoor door) {
door.setFault(null); // door.setFault(null);
door.control(Operation.G); // door.control(Operation.G);
door.setFault(this); door.setFault(this);
} }
}, },
@ -241,8 +251,9 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
public abstract void apply(VirtualRealityScreenDoor door); public abstract void apply(VirtualRealityScreenDoor door);
public void fix(VirtualRealityScreenDoor vrPSD) { public void fix(VirtualRealityScreenDoor vrPSD) {
if (this.equals(vrPSD.getFault())) if (this.equals(vrPSD.getFault())) {
vrPSD.setFault(null); vrPSD.setFault(null);
} }
} }
} }
}

View File

@ -78,9 +78,13 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
* 道岔支持的操作 * 道岔支持的操作
*/ */
public enum Operation { public enum Operation {
/** 定操 */ /**
* 定操
*/
NP, NP,
/** 反操 */ /**
* 反操
*/
RP, RP,
} }
@ -120,8 +124,9 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
SPLIT { SPLIT {
@Override @Override
public boolean apply(VirtualRealitySwitch vrSwitch) { public boolean apply(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault())) if (this.equals(vrSwitch.getFault())) {
return false; return false;
}
vrSwitch.setFault(this); vrSwitch.setFault(this);
vrSwitch.setP(SwitchIndication.NO); vrSwitch.setP(SwitchIndication.NO);
return true; return true;
@ -133,8 +138,9 @@ public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwi
SQUEEZE { SQUEEZE {
@Override @Override
public boolean apply(VirtualRealitySwitch vrSwitch) { public boolean apply(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault())) if (this.equals(vrSwitch.getFault())) {
return false; return false;
}
vrSwitch.setFault(this); vrSwitch.setFault(this);
vrSwitch.setP(SwitchIndication.EX); vrSwitch.setP(SwitchIndication.EX);
return true; return true;

View File

@ -0,0 +1,26 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.RealDeviceConfig;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO;
import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO;
import lombok.Getter;
@Getter
public class CgyPslConfig extends RealDeviceConfig {
private CgyPslConfigVO configVO;
public CgyPslConfig(ProjectDeviceVO projectDevice) {
super(projectDevice);
if (projectDevice != null) {
this.configVO = JsonUtils.read(projectDevice.getConfig(), CgyPslConfigVO.class);
}
}
@Override
public String findDeviceCode() {
return configVO.findDeviceCode();
}
}

View File

@ -0,0 +1,86 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy;
import club.joylink.rtss.services.psl.IVirtualRealityPslService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl.Button;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.PlcGateway;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.RealDeviceConfig;
import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@Slf4j
@Component
public class CgyPslServiceImpl implements RealDeviceService {
@Autowired
private PlcGatewayService plcGatewayService;
@Autowired
private IVirtualRealityPslService virtualRealityPslService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof CgyPslConfig;
}
@Override
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
// PlcGateway plcGateway = simulation.getPlcGateway();
// CgyPslConfigVO configVO = ((CgyPslConfig) deviceConfig).getConfigVO();
// Channel channel = plcGateway.getChannel();
// int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_gm_light(), false, channel);
// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_km_light(), false, channel);
// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_psl_light(), false, channel);
// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_gbsj_light(), false, channel);
}
@Override
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
if (plcGateway == null) {
return;
}
CgyPslConfig config = (CgyPslConfig) deviceConfig;
CgyPslConfigVO configVO = config.getConfigVO();
if (!StringUtils.hasText(configVO.getPslCode())) {
return;
}
VirtualRealityPsl vrPsl = simulation.getRepository()
.getByCode(configVO.getPslCode(), VirtualRealityPsl.class);
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(),
configVO.getQuantity());
boolean r_km_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_km_btn());
boolean r_gm_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_gm_btn());
boolean r_yxjz_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yxjz_btn());
boolean r_hsjc_key = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_hsjc_key());
boolean r_xy_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xy_btn());
boolean w_km_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_km_light());
boolean w_gm_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gm_light());
boolean w_yxcz_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yxcz_light());
boolean w_gbsj_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gbsj_light());
//向vrPSL同步操作
virtualRealityPslService.updateStatus(simulation, vrPsl, Button.KM, r_km_btn);
virtualRealityPslService.updateStatus(simulation, vrPsl, Button.GM, r_gm_btn);
virtualRealityPslService.updateStatus(simulation, vrPsl, Button.YXJZ, r_yxjz_btn);
virtualRealityPslService.updateStatus(simulation, vrPsl, Button.HSJC, r_hsjc_key);
//向实体PSL同步状态
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
Channel channel = plcGateway.getChannel();
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_km_light(),
w_km_light, vrPsl.isKmLight(), channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gm_light(),
w_gm_light, vrPsl.isGmLight(), channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxcz_light(),
w_yxcz_light, vrPsl.isYxjzKey(), channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gbsj_light(),
w_gbsj_light, vrPsl.isQbgmLight(), channel);
}
}

View File

@ -46,29 +46,34 @@ public class CgySignalServiceImpl implements RealDeviceService {
Channel channel = plcGateway.getChannel(); Channel channel = plcGateway.getChannel();
switch (aspect) { switch (aspect) {
case No: case No:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel);
break; break;
case R: case R:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel);
break; break;
case G: case G:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), true, channel);
break; break;
case Y: case Y:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel);
break; break;
case RY: case RY:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel);
break; break;
default: default:
log.error("不支持的显示:{}", aspect); log.error("不支持的显示:{}", aspect);
@ -91,84 +96,82 @@ public class CgySignalServiceImpl implements RealDeviceService {
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(),
configVO.getQuantity()); configVO.getQuantity());
boolean r_r = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_red()); //同步信号显示
boolean r_g = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_green()); SignalAspect aspect = getAspect(deviceStatus, configVO);
boolean r_y = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yellow());
SignalAspect aspect = null;
if (!r_r && !r_g && !r_y) {
aspect = SignalAspect.No;
} else if (r_r && !r_g && !r_y) {
aspect = SignalAspect.R;
} else if (!r_r && r_g && !r_y) {
aspect = SignalAspect.G;
} else if (!r_r && !r_g && r_y) {
aspect = SignalAspect.Y;
} else if (r_r && !r_g && r_y) {
aspect = SignalAspect.RY;
}
if (aspect == null) {
log.error("未知的信号组合[红:%s][绿:%s][黄:%s]", r_r, r_g, r_y);
} else {
vrSignal.apply(aspect); vrSignal.apply(aspect);
} //驱动信号显示
if (vrSignal.isTurning()) { if (vrSignal.isTurning()) {
boolean w_r = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_red()); boolean w_ddj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_ddj());
boolean w_g = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_green()); boolean w_lxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_lxj());
boolean w_y = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yellow()); boolean w_yxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yxj());
boolean w_zxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_zxj());
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
Channel channel = plcGateway.getChannel(); Channel channel = plcGateway.getChannel();
SignalAspect command = vrSignal.getCommand(); SignalAspect command = vrSignal.getCommand();
switch (command) { switch (command) {
case No: case No:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj, true,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj,
false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj,
false, false,
channel); channel);
break; break;
case R: case R:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj,
false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj,
false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj,
false, false,
channel); channel);
break; break;
case G: case G:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj,
false, channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, true,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj, true,
channel);
break; break;
case Y: case Y:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, true,
true, channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj,
false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj,
false,
channel); channel);
break; break;
case RY: case RY:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj,
true, false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, true,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj,
false,
channel); channel);
break; break;
default: default:
@ -177,4 +180,22 @@ public class CgySignalServiceImpl implements RealDeviceService {
} }
} }
} }
private SignalAspect getAspect(ByteBuf deviceStatus, CgySignalConfigVO configVO) {
boolean r_ddj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_ddj());
boolean r_lxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_lxj());
boolean r_yxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yxj());
boolean r_zxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_zxj());
if (r_yxj) {
return SignalAspect.RY;
} else if (r_lxj && r_zxj) {
return SignalAspect.G;
} else if (r_lxj) {
return SignalAspect.Y;
} else if (!r_ddj) {
return SignalAspect.R;
} else {
return SignalAspect.No;
}
}
} }

View File

@ -35,7 +35,7 @@ public class CgySwitchServiceImpl implements RealDeviceService {
CgySwitchConfigVO configVO = config.getConfigVO(); CgySwitchConfigVO configVO = config.getConfigVO();
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
Channel channel = plcGateway.getChannel(); Channel channel = plcGateway.getChannel();
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sj(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_js(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dc(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dc(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_fc(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_fc(), false, channel);
} }
@ -63,7 +63,7 @@ public class CgySwitchServiceImpl implements RealDeviceService {
boolean r_fb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_fb()); boolean r_fb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_fb());
vrSwitch.apply(r_db, r_fb); vrSwitch.apply(r_db, r_fb);
//以下操作实体设备的逻辑中防止继电器长期接通的逻辑将定反操视为技能共用3秒冷却技能持续时间也是3秒 //以下操作实体设备的逻辑中防止继电器长期接通的逻辑将定反操视为技能共用3秒冷却技能持续时间也是3秒
if (config.isEnd()) { //此判断既可视为操作是否冷却也可视为持续时间是否耗尽 if (config.isEnd()) { //此判断既可视为操作是否冷却也可视为持续时间是否耗尽
config.sync(r_db, r_fb); config.sync(r_db, r_fb);
release(deviceStatus, baseAddr, configVO, channel); //操作持续时间耗尽后断开所有继电器 release(deviceStatus, baseAddr, configVO, channel); //操作持续时间耗尽后断开所有继电器
@ -87,10 +87,10 @@ public class CgySwitchServiceImpl implements RealDeviceService {
private void turnToN(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO, private void turnToN(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO,
Channel channel) { Channel channel) {
boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_js());
boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc());
boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc());
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sb, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_js(), w_sb, true,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, true,
channel); channel);
@ -100,10 +100,10 @@ public class CgySwitchServiceImpl implements RealDeviceService {
private void turnToP(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO, private void turnToP(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO,
Channel channel) { Channel channel) {
boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); boolean w_js = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_js());
boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc());
boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc());
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sb, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_js(), w_js, true,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false,
channel); channel);
@ -113,10 +113,10 @@ public class CgySwitchServiceImpl implements RealDeviceService {
private void release(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO, private void release(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO,
Channel channel) { Channel channel) {
boolean w_sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); boolean w_sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_js());
boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc());
boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc());
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sj, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_js(), w_sj, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false,
channel); channel);

View File

@ -10,13 +10,13 @@ import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import org.springframework.stereotype.Component;
@Component @Component
public class TrainTargetUpdateService { public class TrainTargetUpdateService {
public static final String Model_Name = "TrainTargetUpdate"; public static final String Model_Name = "TrainTargetUpdate";
public static final int Rate = 5000; public static final int Rate = 5000;
@ -28,10 +28,10 @@ public class TrainTargetUpdateService {
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
List<VirtualRealityTrain> onlineTrain = repository.getOnlineTrainList(); List<VirtualRealityTrain> onlineTrain = repository.getOnlineTrainList();
for (VirtualRealityTrain train : onlineTrain) { for (VirtualRealityTrain train : onlineTrain) {
TrainInfo trainInfo = repository.getSupervisedTrainByGroup(train.getGroupNumber()); TrainInfo trainInfo = repository.findSupervisedTrainByGroup(train.getGroupNumber());
// if (!trainInfo.isManualTrain()) { if (trainInfo == null) {
// continue; continue;
// } }
Section target = train.getTarget(); Section target = train.getTarget();
Section newTarget = this.queryArriveTarget(train, trainInfo); Section newTarget = this.queryArriveTarget(train, trainInfo);
if (newTarget != null && !Objects.equals(target, newTarget)) { if (newTarget != null && !Objects.equals(target, newTarget)) {
@ -40,14 +40,16 @@ public class TrainTargetUpdateService {
} }
} }
private Section queryArriveTarget4Manual(VirtualRealityTrain train, TrainInfo trainInfo, Section target) { private Section queryArriveTarget4Manual(VirtualRealityTrain train, TrainInfo trainInfo,
Section target) {
SectionPosition headPosition = train.getHeadPosition(); SectionPosition headPosition = train.getHeadPosition();
boolean right = train.isRight(); boolean right = train.isRight();
Section newTarget = target; Section newTarget = target;
Section temp = headPosition.getSection(); Section temp = headPosition.getSection();
for (int i = 0; i < 50; i++) { for (int i = 0; i < 50; i++) {
if (temp == null) if (temp == null) {
break; break;
}
if (!temp.isFunctionTrack()) { if (!temp.isFunctionTrack()) {
temp = temp.findNextRunningSectionBaseRealSwitch(right); temp = temp.findNextRunningSectionBaseRealSwitch(right);
continue; continue;
@ -55,12 +57,14 @@ public class TrainTargetUpdateService {
Signal signal = temp.getSignalOf(right); Signal signal = temp.getSignalOf(right);
if (signal != null && !signal.isMainAspect()) { if (signal != null && !signal.isMainAspect()) {
newTarget = temp; newTarget = temp;
if (temp.isFunctionTrack()) if (temp.isFunctionTrack()) {
break; break;
} }
}
if (temp.isNormalStandTrack() || temp.isTransferTrack()) { if (temp.isNormalStandTrack() || temp.isTransferTrack()) {
if (temp.isNormalStandTrack()) { if (temp.isNormalStandTrack()) {
if (temp.getStandList().stream().anyMatch(stand -> stand.isJumpStop(train.getGroupNumber()))) { //该列车应在站台跳停 if (temp.getStandList().stream()
.anyMatch(stand -> stand.isJumpStop(train.getGroupNumber()))) { //该列车应在站台跳停
temp = temp.findNextRunningSectionBaseRealSwitch(right); temp = temp.findNextRunningSectionBaseRealSwitch(right);
continue; continue;
} }
@ -88,8 +92,9 @@ public class TrainTargetUpdateService {
private Section queryArriveTarget(VirtualRealityTrain train, TrainInfo trainInfo) { private Section queryArriveTarget(VirtualRealityTrain train, TrainInfo trainInfo) {
Section newTarget = null; Section newTarget = null;
MaService.Ma ma = train.getMa2(); MaService.Ma ma = train.getMa2();
if (ma == null) if (ma == null) {
return null; return null;
}
SectionPosition eoaPosition = ma.getEoaPosition(); SectionPosition eoaPosition = ma.getEoaPosition();
Section eoaSection = eoaPosition.getSection(); Section eoaSection = eoaPosition.getSection();
SectionPosition headPosition = train.getHeadPosition(); SectionPosition headPosition = train.getHeadPosition();

View File

@ -4,6 +4,7 @@ import club.joylink.rtss.constants.ProjectCode;
import club.joylink.rtss.constants.ProjectDeviceType; import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.entity.ProjectDevice; import club.joylink.rtss.entity.ProjectDevice;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgyPslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySectionConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySectionConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySignalConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySignalConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySwitchConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySwitchConfig;
@ -175,6 +176,9 @@ public class ProjectDeviceVO {
case SECTION: case SECTION:
list.add(new CgySectionConfig(deviceVO)); list.add(new CgySectionConfig(deviceVO));
break; break;
case PSL:
list.add(new CgyPslConfig(deviceVO));
break;
} }
} }
return list; return list;

View File

@ -0,0 +1,71 @@
package club.joylink.rtss.vo.client.project.cgy;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CgyPslConfigVO extends RealConfigVO {
private String pslCode;
/**
* 开门按钮
*/
private Integer r_km_btn = 32;
/**
* 关门按钮
*/
private Integer r_gm_btn = 33;
/**
* 就地允许/禁止按钮
*/
private Integer r_yxjz_btn = 34;
/**
* 互锁解除钥匙true-互锁解除
*/
private Integer r_hsjc_key = 46;
/**
* 消音按钮不知道消的啥音
*/
private Integer r_xy_btn = 47;
/**
* 控制-开门指示灯
*/
private Integer w_km_light = 48;
/**
* 控制-关门指示灯
*/
private Integer w_gm_light = 49;
/**
* 控制-psl允许操作指示灯
*/
private Integer w_yxcz_light = 50;
/**
* 控制-关闭锁紧指示灯
*/
private Integer w_gbsj_light = 55;
public CgyPslConfigVO(String pslCode) {
this();
this.pslCode = pslCode;
}
public CgyPslConfigVO() {
super(0, 64);
}
@Override
public String findDeviceCode() {
return pslCode;
}
}

View File

@ -11,10 +11,16 @@ public class CgySectionConfigVO extends RealConfigVO {
/** /**
* 出清 * 出清
*/ */
private Integer r_occupied = 6; private Integer r_occupied;
public CgySectionConfigVO(String sectionCode, Integer r_occupied) {
this();
this.sectionCode = sectionCode;
this.r_occupied = r_occupied;
}
public CgySectionConfigVO() { public CgySectionConfigVO() {
super(0, 32); super(0, 64);
} }
@Override @Override

View File

@ -1,46 +1,62 @@
package club.joylink.rtss.vo.client.project.cgy; package club.joylink.rtss.vo.client.project.cgy;
import club.joylink.rtss.vo.client.project.RealConfigVO; import club.joylink.rtss.vo.client.project.RealConfigVO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
/**
* 红灯常亮DDJ吸起红灯灭 Lxj吸起黄灯 YxJ红黄 LXJZXJ吸起绿灯
*/
@Getter @Getter
@Setter @Setter
public class CgySignalConfigVO extends RealConfigVO { public class CgySignalConfigVO extends RealConfigVO {
private String signalCode; private String signalCode;
/** private Integer r_ddj;
*
*/ private Integer r_lxj;
private Integer r_red;
/** /**
* 绿 * 主灯丝报警
*/ */
private Integer r_green; private Integer r_dj;
private Integer r_zxj;
private Integer r_yxj;
/** /**
* * 副灯丝报警
*/ */
private Integer r_yellow; private Integer r_dj2;
private Integer w_red; private Integer w_ddj;
private Integer w_green; private Integer w_lxj;
private Integer w_yellow; private Integer w_zxj;
public CgySignalConfigVO(String signalCode, Integer r_red, private Integer w_yxj;
Integer r_green, Integer r_yellow, Integer w_red, Integer w_green, Integer w_yellow) {
super(0, 24); public CgySignalConfigVO(String signalCode, Integer r_ddj,
Integer r_lxj, Integer r_dj, Integer r_zxj, Integer r_yxj, Integer r_dj2, Integer w_ddj,
Integer w_lxj, Integer w_zxj, Integer w_yxj) {
this();
this.signalCode = signalCode; this.signalCode = signalCode;
this.r_red = r_red; this.r_ddj = r_ddj;
this.r_green = r_green; this.r_lxj = r_lxj;
this.r_yellow = r_yellow; this.r_dj = r_dj;
this.w_red = w_red; this.r_zxj = r_zxj;
this.w_green = w_green; this.r_yxj = r_yxj;
this.w_yellow = w_yellow; this.r_dj2 = r_dj2;
this.w_ddj = w_ddj;
this.w_lxj = w_lxj;
this.w_zxj = w_zxj;
this.w_yxj = w_yxj;
} }
public CgySignalConfigVO() { public CgySignalConfigVO() {

View File

@ -10,30 +10,39 @@ public class CgySwitchConfigVO extends RealConfigVO {
private String switchCode; private String switchCode;
/**
* 解锁表示
*/
private Integer r_js = 12;
/** /**
* 定表 * 定表
*/ */
private Integer r_db = 0; private Integer r_db = 13;
/** /**
* 反表 * 反表
*/ */
private Integer r_fb = 1; private Integer r_fb = 14;
/** /**
* *
*/ */
private Integer w_sj = 8; private Integer w_js = 24;
/** /**
* 定操 * 定操
*/ */
private Integer w_dc = 9; private Integer w_dc = 25;
/** /**
* 反操 * 反操
*/ */
private Integer w_fc = 10; private Integer w_fc = 26;
public CgySwitchConfigVO(String switchCode) {
this();
this.switchCode = switchCode;
}
public CgySwitchConfigVO() { public CgySwitchConfigVO() {
super(0, 32); super(0, 32);