diff --git a/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java b/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java index f4503c99f..d4c1d3a87 100644 --- a/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java +++ b/src/main/java/club/joylink/rtss/constants/MapPrdTypeEnum.java @@ -11,7 +11,8 @@ public enum MapPrdTypeEnum { SCHEDULING("05", "派班工作站"), ISCS("06", "ISCS工作站"), BIG_SCREEN("07", "大屏工作站"), - RUN_PLAN_MAKE("08", "运行图编制工作站") + RUN_PLAN_MAKE("08", "运行图编制工作站"), + DEPOT_IL("09", "车辆段联锁工作站"), ; private String code; diff --git a/src/main/java/club/joylink/rtss/constants/Project.java b/src/main/java/club/joylink/rtss/constants/Project.java index bac7f7fb2..22e6279d7 100644 --- a/src/main/java/club/joylink/rtss/constants/Project.java +++ b/src/main/java/club/joylink/rtss/constants/Project.java @@ -34,8 +34,10 @@ public enum Project { ZZWW, /** 郑州共赢测试 */ ZZWWTEST, - /** 中航锐创(第三方教学合作) */ + /** 中航锐创(第三方教学合作,第三方登录) */ RICHOR, + /** 中航锐创(实训室,连设备,设备登录) */ + RICHOR_JOINT, ; public static boolean isDefault(Project project) { diff --git a/src/main/java/club/joylink/rtss/constants/ProjectDeviceType.java b/src/main/java/club/joylink/rtss/constants/ProjectDeviceType.java index 116dcd5eb..5363c73f2 100644 --- a/src/main/java/club/joylink/rtss/constants/ProjectDeviceType.java +++ b/src/main/java/club/joylink/rtss/constants/ProjectDeviceType.java @@ -26,6 +26,8 @@ public enum ProjectDeviceType { IBP, /** PLC网关 */ PLC_GATEWAY, + /** 单元控制器 */ + DCU, /* -----------plc device end---------- */ /* -----------client device start---------- */ @@ -65,6 +67,7 @@ public enum ProjectDeviceType { PSL, IBP, SWITCH, - SIGNAL); + SIGNAL, + DCU); } } diff --git a/src/main/java/club/joylink/rtss/controller/MapDataHandleController.java b/src/main/java/club/joylink/rtss/controller/MapDataHandleController.java new file mode 100644 index 000000000..cc0561c6a --- /dev/null +++ b/src/main/java/club/joylink/rtss/controller/MapDataHandleController.java @@ -0,0 +1,34 @@ +package club.joylink.rtss.controller; + +import club.joylink.rtss.services.draftData.DraftMapDataHandleService; +import club.joylink.rtss.services.publishData.PublishMapDataHandler; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 地图数据处理 + */ +@Slf4j +@RestController +@RequestMapping("/api/mapData/handle") +public class MapDataHandleController { + + @Autowired + private DraftMapDataHandleService draftMapDataHandleService; + @Autowired + private PublishMapDataHandler publishMapDataHandler; + + @PutMapping("") + public void dataHandle() { + this.publishMapDataHandler.dataHandle(); + } + + @PutMapping("/xian3") + public void overlapSetHandle() { + this.publishMapDataHandler.xian3Handle(); + } + +} diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java index 5cc8565eb..c0f7aa65e 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapController.java @@ -11,6 +11,7 @@ import club.joylink.rtss.vo.client.validGroup.DraftMapCreateCheck; import club.joylink.rtss.vo.client.validGroup.DraftMapCreateFromCheck; import club.joylink.rtss.vo.client.validGroup.DraftMapPublishCheck; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.logic.*; import club.joylink.rtss.vo.map.query.MapAutoReentryQueryVO; import club.joylink.rtss.vo.map.query.MapDestinationCodeDefinitionQueryVO; import club.joylink.rtss.vo.map.query.MapParkTimeQueryVO; @@ -104,9 +105,6 @@ public class DraftMapController { this.iDraftMapService.updateCheckConfig(id, checkConfig); } - /** - * 保存地图元素信息 - */ /** *保存地图草稿对象数据 */ @@ -123,6 +121,14 @@ public class DraftMapController { return this.draftMapCiDataGenerator.generate(id); } + /** + * 生成车辆段联锁数据 + */ + @PostMapping(path = "/{id}/ci/generateAndSaveDepot") + public int generateAndSaveDepot(@PathVariable Long id, String stationCode) { + return this.draftMapCiDataGenerator.generateDepot(id, stationCode); + } + /** *草稿地图导出 */ @@ -148,9 +154,6 @@ public class DraftMapController { iDraftMapService.createFrom(draftMapVO.getId(), draftMapVO.getName(), user); } - /** - * 删除地图草稿 - */ /** *删除地图草稿 */ @@ -159,6 +162,11 @@ public class DraftMapController { iDraftMapService.deleteMap(id, user); } + @DeleteMapping(path = "/delete/all") + public void clearAllMap(@RequestAttribute AccountVO user) { + this.iDraftMapService.deleteAllUserDraftMap(user); + } + /** *数据校验 */ diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapFlankProtectionController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapFlankProtectionController.java index ad366dc55..a8756e703 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapFlankProtectionController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapFlankProtectionController.java @@ -2,7 +2,7 @@ package club.joylink.rtss.controller.draft; import club.joylink.rtss.services.draftData.DraftMapFlankProtectionService; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; import club.joylink.rtss.vo.map.query.MapRouteFlankProtectionQueryVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapFlsController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapFlsController.java index 268122a71..eceaf22b5 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapFlsController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapFlsController.java @@ -2,7 +2,7 @@ package club.joylink.rtss.controller.draft; import club.joylink.rtss.services.draftData.DraftMapFlsService; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; import club.joylink.rtss.vo.map.query.MapRouteFlankProtectionQueryVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapOverlapController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapOverlapController.java index b479db135..72b97e272 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapOverlapController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapOverlapController.java @@ -2,7 +2,7 @@ package club.joylink.rtss.controller.draft; import club.joylink.rtss.services.draftData.DraftMapOverlapService; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapOverlapVO; +import club.joylink.rtss.vo.map.logic.MapOverlapVO; import club.joylink.rtss.vo.map.query.MapOverlapQueryVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapOverrunController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapOverrunController.java index dd05a0de3..1f2d7f59a 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapOverrunController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapOverrunController.java @@ -3,8 +3,7 @@ package club.joylink.rtss.controller.draft; import club.joylink.rtss.services.draftData.DraftMapOverrunService; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapRouteOverrunQueryVO; -import club.joylink.rtss.vo.map.MapRouteNewVO; -import club.joylink.rtss.vo.map.MapRouteOverrunVO; +import club.joylink.rtss.vo.map.logic.MapRouteOverrunVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapParkTimeController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapParkTimeController.java index f9703d25f..cbaf1f724 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapParkTimeController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapParkTimeController.java @@ -1,7 +1,7 @@ package club.joylink.rtss.controller.draft; import club.joylink.rtss.services.draftData.ParkTimeService; -import club.joylink.rtss.vo.map.MapStationParkingTimeVO; +import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapRouteController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapRouteController.java index 5ebb0a392..4e4861bf8 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapRouteController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapRouteController.java @@ -3,7 +3,7 @@ package club.joylink.rtss.controller.draft; import club.joylink.rtss.services.draftData.DraftMapRouteService; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapRouteQueryVO; -import club.joylink.rtss.vo.map.MapRouteNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapRunLevelController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapRunLevelController.java index 5455b1a17..2050160ee 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapRunLevelController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapRunLevelController.java @@ -1,7 +1,7 @@ package club.joylink.rtss.controller.draft; import club.joylink.rtss.services.draftData.RunLevelService; -import club.joylink.rtss.vo.map.MapStationRunLevelVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapSignalApproachSectionController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapSignalApproachSectionController.java index 1a4733595..4f25f4a75 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapSignalApproachSectionController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapSignalApproachSectionController.java @@ -3,7 +3,7 @@ package club.joylink.rtss.controller.draft; import club.joylink.rtss.services.draftData.DraftMapSignalApproachSectionService; import club.joylink.rtss.services.draftData.SignalApproachSectionGenerator; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapSignalApproachSectionVO; +import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO; import club.joylink.rtss.vo.map.query.MapSASQueryVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/club/joylink/rtss/controller/draft/DraftMapStationRunLevelController.java b/src/main/java/club/joylink/rtss/controller/draft/DraftMapStationRunLevelController.java index 0ec9c132b..50e11b14f 100644 --- a/src/main/java/club/joylink/rtss/controller/draft/DraftMapStationRunLevelController.java +++ b/src/main/java/club/joylink/rtss/controller/draft/DraftMapStationRunLevelController.java @@ -2,7 +2,7 @@ package club.joylink.rtss.controller.draft; import club.joylink.rtss.services.draftData.DraftMapRunLevelService; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapStationRunLevelVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import club.joylink.rtss.vo.map.query.MapRunLevelQueryVO; import club.joylink.rtss.vo.map.validate.RunLevelCreateCheck; import club.joylink.rtss.vo.map.validate.RunLevelUpdateCheck; diff --git a/src/main/java/club/joylink/rtss/controller/project/DeviceController.java b/src/main/java/club/joylink/rtss/controller/project/DeviceController.java index 6b3c87468..ab6eeb6ae 100644 --- a/src/main/java/club/joylink/rtss/controller/project/DeviceController.java +++ b/src/main/java/club/joylink/rtss/controller/project/DeviceController.java @@ -230,4 +230,10 @@ public class DeviceController { AccountVO accountVO) { this.deviceService.addOrUpdateSdyDeviceConfig(accountVO); } + + @PostMapping("/richor/addOrUpdate") + public void addOrUpdateRichorDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) + AccountVO accountVO) { + this.deviceService.addOrUpdateRichorDeviceConfig(accountVO); + } } diff --git a/src/main/java/club/joylink/rtss/controller/publish/MapController.java b/src/main/java/club/joylink/rtss/controller/publish/MapController.java index 8d4bce2fa..7fd24aad0 100644 --- a/src/main/java/club/joylink/rtss/controller/publish/MapController.java +++ b/src/main/java/club/joylink/rtss/controller/publish/MapController.java @@ -14,6 +14,10 @@ import club.joylink.rtss.vo.client.map.MapCopyOption; import club.joylink.rtss.vo.client.map.MapInfoUpdateVO; import club.joylink.rtss.vo.client.validGroup.MapInfoSortCheck; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapPSDVO; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java index efa5a0da0..5e595d2b6 100644 --- a/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java +++ b/src/main/java/club/joylink/rtss/controller/runplan/RunPlanDraftController.java @@ -13,7 +13,7 @@ import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO; import club.joylink.rtss.vo.client.validGroup.RunPlanCreateCheck; import club.joylink.rtss.vo.client.validGroup.RunPlanNameCheck; import club.joylink.rtss.vo.client.validGroup.ValidList; -import club.joylink.rtss.vo.map.MapStationRunLevelVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import club.joylink.rtss.vo.runplan.RunPlanInputData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.CollectionUtils; diff --git a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java index 2e00f8d29..bf461d96a 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java @@ -28,7 +28,7 @@ import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; import club.joylink.rtss.vo.client.simulationv1.SimulationLogPagedQueryVO; import club.joylink.rtss.vo.client.simulationv1.SimulationMemberVO; import club.joylink.rtss.vo.client.simulationv1.SimulationUserVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import club.joylink.rtss.vo.map.MapVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.format.annotation.DateTimeFormat; diff --git a/src/main/java/club/joylink/rtss/controller/test/ModbusTestController.java b/src/main/java/club/joylink/rtss/controller/test/ModbusTestController.java index dda44adb9..aa186eb3d 100644 --- a/src/main/java/club/joylink/rtss/controller/test/ModbusTestController.java +++ b/src/main/java/club/joylink/rtss/controller/test/ModbusTestController.java @@ -25,17 +25,11 @@ public class ModbusTestController { /** * 测试modbustcp写网关(使用功能码05:写单线圈) - * @param code - * @param addr - * @param val - * @param accountVO - * @return */ @Role(SuperAdmin) @PostMapping("/writeCoil") public void modbusWriteSingleCoil(String code, - int addr, boolean val, - @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) AccountVO accountVO) { + int addr, boolean val) { this.modbusTcpTestService.writeSingleCoil(this.plcGatewayConnectManager.getChannel(code), addr, val); } diff --git a/src/main/java/club/joylink/rtss/services/DraftMapService.java b/src/main/java/club/joylink/rtss/services/DraftMapService.java index 9dba9d13c..2354dbeb5 100644 --- a/src/main/java/club/joylink/rtss/services/DraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/DraftMapService.java @@ -15,6 +15,8 @@ import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.TreeNode; import club.joylink.rtss.vo.client.map.*; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.logic.*; import club.joylink.rtss.vo.map.query.MapAutoReentryQueryVO; import club.joylink.rtss.vo.map.query.MapDestinationCodeDefinitionQueryVO; import club.joylink.rtss.vo.map.query.MapParkTimeQueryVO; @@ -395,6 +397,15 @@ public class DraftMapService implements IDraftMapService { draftMapDAO.deleteByPrimaryKey(id); } + @Override + public void deleteAllUserDraftMap(AccountVO user) { + DraftMapExample example = new DraftMapExample(); + example.createCriteria() + .andAuthorIdEqualTo(user.getId()); + List maps = this.draftMapDAO.selectByExample(example); + maps.forEach(map -> this.deleteMap(map.getId(), user)); + } + private void confirmDraftMapNameNotExist(DraftMap map) { BusinessExceptionAssertEnum.DATA_UNIQUE_PROPERTY_REPEAT.assertNotTrue(checkDraftMapNameExist(map)); } diff --git a/src/main/java/club/joylink/rtss/services/IDraftMapService.java b/src/main/java/club/joylink/rtss/services/IDraftMapService.java index 9451735e8..daa6b1467 100644 --- a/src/main/java/club/joylink/rtss/services/IDraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/IDraftMapService.java @@ -5,7 +5,11 @@ import club.joylink.rtss.vo.client.PageQueryVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.TreeNode; import club.joylink.rtss.vo.client.map.*; -import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.Map3dDataVO; +import club.joylink.rtss.vo.map.MapCheckConfig; +import club.joylink.rtss.vo.map.MapGraphDataNewVO; +import club.joylink.rtss.vo.map.MapVO; +import club.joylink.rtss.vo.map.logic.*; import club.joylink.rtss.vo.map.query.MapAutoReentryQueryVO; import club.joylink.rtss.vo.map.query.MapDestinationCodeDefinitionQueryVO; import club.joylink.rtss.vo.map.query.MapParkTimeQueryVO; @@ -136,6 +140,12 @@ public interface IDraftMapService { */ void deleteMap(Long id, AccountVO user); + /** + * 清空用户所有草稿地图数据 + * @param user + */ + void deleteAllUserDraftMap(AccountVO user); + /** * 创建联动道岔关系 * @param vo diff --git a/src/main/java/club/joylink/rtss/services/IMapService.java b/src/main/java/club/joylink/rtss/services/IMapService.java index 07eeec67f..e4735be1e 100644 --- a/src/main/java/club/joylink/rtss/services/IMapService.java +++ b/src/main/java/club/joylink/rtss/services/IMapService.java @@ -11,6 +11,10 @@ import club.joylink.rtss.vo.client.map.MapCopyOption; import club.joylink.rtss.vo.client.map.MapDataVO; import club.joylink.rtss.vo.client.map.MapInfoUpdateVO; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapPSDVO; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; import java.util.List; @@ -60,6 +64,12 @@ public interface IMapService { */ MapVO getMapDetail(Long id); + /** + * 清除地图缓存 + * @param id + */ + void removeCache(Long id); + /** * 获取地图基本信息 * @param id diff --git a/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java index 6c050be95..932775d84 100644 --- a/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/IRunPlanDraftService.java @@ -5,7 +5,7 @@ import club.joylink.rtss.vo.LoginUserInfoVO; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapRoutingSectionVO; import club.joylink.rtss.vo.client.runplan.*; -import club.joylink.rtss.vo.map.MapStationRunLevelVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.runplan.RunPlanInputData; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/club/joylink/rtss/services/MapService.java b/src/main/java/club/joylink/rtss/services/MapService.java index aaf1cb2ab..3df9b6ff3 100644 --- a/src/main/java/club/joylink/rtss/services/MapService.java +++ b/src/main/java/club/joylink/rtss/services/MapService.java @@ -34,6 +34,11 @@ import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapPSDVO; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import lombok.extern.slf4j.Slf4j; @@ -266,6 +271,11 @@ public class MapService implements IMapService { return mapVO; } + @Override + public void removeCache(Long id) { + this.iCacheService.remove(BusinessConsts.CachePrefix.Map + id); + } + private MapDataVO getMapData(Long mapId, String version) { Objects.requireNonNull(mapId, "mapId不能为空"); MapDataExample example = new MapDataExample(); @@ -708,7 +718,7 @@ public class MapService implements IMapService { } if (update) { this.mapInfoDAO.updateByPrimaryKey(mapInfo); - this.iCacheService.remove(BusinessConsts.CachePrefix.Map + id); + this.removeCache(id); } } diff --git a/src/main/java/club/joylink/rtss/services/ReleaseService.java b/src/main/java/club/joylink/rtss/services/ReleaseService.java index 57a62e9da..c0fa9679d 100644 --- a/src/main/java/club/joylink/rtss/services/ReleaseService.java +++ b/src/main/java/club/joylink/rtss/services/ReleaseService.java @@ -200,8 +200,10 @@ public class ReleaseService implements IReleaseService { if (!CollectionUtils.isEmpty(releaseVO.getRunPlanTemplateList())) { //删除旧的运行图相关数据 - List runPlanTemplates = releaseVO.getRunPlanTemplateList(); - for (RunPlanTemplate runPlanTemplate : runPlanTemplates) { + RunPlanTemplateExample runPlanTemplateExample = new RunPlanTemplateExample(); + runPlanTemplateExample.createCriteria().andMapIdEqualTo(mapId); + List oldRunPlans = runPlanTemplateDAO.selectByExample(runPlanTemplateExample); + for (RunPlanTemplate runPlanTemplate : oldRunPlans) { iRunPlanTemplateService.deletePlan(runPlanTemplate.getId(), user); } // //删除旧的运行图加载数据 @@ -218,6 +220,7 @@ public class ReleaseService implements IReleaseService { // runPlanTemplateDAO.deleteByExample(runPlanTemplateExample); //插入新的模板运行图数据并记录id变化 Map runPlanTemplateIdMap = new HashMap<>(); + List runPlanTemplates = releaseVO.getRunPlanTemplateList(); for (RunPlanTemplate template : runPlanTemplates) { long oldId = template.getId(); template.setId(null); diff --git a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java index 6efc1b419..0c0b574f2 100644 --- a/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java +++ b/src/main/java/club/joylink/rtss/services/RunPlanDraftService.java @@ -22,6 +22,11 @@ import club.joylink.rtss.vo.client.runplan.*; import club.joylink.rtss.vo.client.runplan.user.RunPlanRoutingVO; import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import club.joylink.rtss.vo.runplan.RunPlanInputData; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; diff --git a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java index 5b7ca93b7..e8e9e4617 100644 --- a/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java +++ b/src/main/java/club/joylink/rtss/services/VirtualRealityIbpService.java @@ -122,37 +122,20 @@ public class VirtualRealityIbpService implements IVirtualRealityIbpService { break; case KM: { element.setOn(true); - List key; - if (element.getUp()) { - key = ibp.query(VirtualRealityIbp.Mean.SXYS, element.getUp()); - } else { - key = ibp.query(VirtualRealityIbp.Mean.XXYS, element.getUp()); - } - if (key.stream().allMatch(VirtualRealityIbp.IbpElement::isOn)) { - stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode())); - } + stands.forEach(stand -> ciApiService.openScreenDoor(simulation, stand.getCode())); break; } case GM: { element.setOn(true); - List key; - if (element.getUp() != null) { - if (element.getUp()) { - key = ibp.query(VirtualRealityIbp.Mean.SXYS, element.getUp()); - } else { - key = ibp.query(VirtualRealityIbp.Mean.XXYS, element.getUp()); - } - } else { - key = ibp.queryByType(VirtualRealityIbp.Type.KEY); - } - if (key.stream().allMatch(VirtualRealityIbp.IbpElement::isOn)) { - stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode())); - } + stands.forEach(stand -> ciApiService.closeScreenDoor(simulation, stand.getCode())); break; } case XXYS: case SXYS: element.setOn(!element.isOn()); + stands.forEach(stand -> { + stand.getPsd().getVirtualScreenDoor().setIbpControl(true); + }); break; case AXLE_RESET: element.setOn(true); diff --git a/src/main/java/club/joylink/rtss/services/check/MapDataCheckService.java b/src/main/java/club/joylink/rtss/services/check/MapDataCheckService.java index 495b8f02c..a86572f41 100644 --- a/src/main/java/club/joylink/rtss/services/check/MapDataCheckService.java +++ b/src/main/java/club/joylink/rtss/services/check/MapDataCheckService.java @@ -1,9 +1,9 @@ package club.joylink.rtss.services.check; import club.joylink.rtss.vo.map.MapGraphDataNewVO; -import club.joylink.rtss.vo.map.MapSectionNewVO; -import club.joylink.rtss.vo.map.MapSwitchVO; import club.joylink.rtss.vo.map.MapVO; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapSwitchVO; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGenerator.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGenerator.java index f85c5b2a7..ab9653707 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGenerator.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGenerator.java @@ -14,4 +14,10 @@ public interface DraftMapCiDataGenerator { */ CiGenerateResultVO generate(Long mapId); + /** + * 生成车辆段联锁 + * @param mapId + * @return + */ + int generateDepot(Long mapId, String stationCode); } diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java index d901a9ea7..7b2689c52 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapCiDataGeneratorImpl.java @@ -1,14 +1,21 @@ package club.joylink.rtss.services.draftData; +import club.joylink.rtss.entity.DraftMapRoute; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.constant.SignalModel; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.CiGenerateResultVO; +import club.joylink.rtss.vo.map.MapCiGenerateConfig; +import club.joylink.rtss.vo.map.MapRoutingSectionNewVO; +import club.joylink.rtss.vo.map.MapVO; +import club.joylink.rtss.vo.map.logic.*; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -28,6 +35,10 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { @Autowired private DraftMapService draftMapService; + + @Autowired + private DraftMapRouteService draftMapRouteService; + @Autowired private RoutingGenerator routingGenerator; @@ -91,6 +102,69 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { return result.convert2VO(); } + @Transactional + @Override + public int generateDepot(Long mapId, String stationCode) { + // 先校验地图基础数据 + MapVO mapVO = this.draftMapService.getDraftMapData(mapId); + SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildBasicMapData(mapVO); + BusinessExceptionAssertEnum.DATA_ERROR.assertCollectionEmpty(buildResult.getErrMsgList(), + String.format("地图基础数据有错误: %s", JsonUtils.writeValueAsString(buildResult.getErrMsgList()))); + MapCiGenerateConfig generateConfig = mapVO.getGraphDataNew().getGenerateConfig(); + Map deviceMap = buildResult.getDeviceMap(); + // 处理旧数据 + List routeList = this.draftMapRouteService.queryAllRoutes(mapId); + List deletingList = new ArrayList<>(); + Integer routeCodeIndex = routeList.stream().peek(mapRouteNewVO -> { + if (mapRouteNewVO.getStationCode().equals(stationCode)) { + deletingList.add(mapRouteNewVO.getId()); + } + }).map(MapRouteNewVO::getCode) + .map(c -> Integer.parseInt(c.substring(CodeGenerator.Prefix_Route.length()))) + .max(Integer::compareTo).orElse(0); + // 联锁关系数据生成 + List errorList = new ArrayList<>(); + List generatedRouteList = new ArrayList<>(); + CodeGenerator routeCodeGenerator = CodeGenerator.getRouteCodeGenerator(routeCodeIndex); + // 获取所有信号机 + List signalList = deviceMap.values().stream() + .filter(mapElement -> mapElement.getDeviceType().equals(MapElement.DeviceType.SIGNAL)) + .map(mapElement -> ((Signal) mapElement)) + .filter(signal -> signal.getInterlockStation().getCode().equals(stationCode)) + .collect(Collectors.toList()); + log.info(String.format("共有信号机[%s]个", signalList.size())); + signalList.sort((signal1, signal2) -> { + String s1 = signal1.getShowName(); + String s2 = signal2.getShowName(); + return s1.length() != s2.length() ? s1.length() - s2.length() : s1.compareTo(s2); + }); + for (Signal signal : signalList) { + // 列车兼调车信号机、调车信号机 + if (signal.getType().equals(Signal.SignalType.SHUNTING2)) { + signal.setType(Signal.SignalType.SHUNTING); + generatedRouteList.addAll(this.generateRouteDepot(signal, routeCodeGenerator, generateConfig, errorList)); + signal.setType(Signal.SignalType.SHUNTING2); + generatedRouteList.addAll(this.generateRouteDepot(signal, routeCodeGenerator, generateConfig, errorList)); + } else if (signal.getType().equals(Signal.SignalType.SHUNTING)) { + generatedRouteList.addAll(this.generateRouteDepot(signal, routeCodeGenerator, generateConfig, errorList)); + } + } + log.info(String.format("生成一般进路[%s]条", generatedRouteList.size())); +// // 进路敌对关系构建 + this.buildRouteConflict(generatedRouteList); + + if (!CollectionUtils.isEmpty(errorList)) { + for (String errMsg : errorList) { + log.warn(String.format("联锁数据生成警告信息:[%s]", errMsg)); + } + } + // 删除旧数据,保存新数据 + this.draftMapRouteService.deleteRoutes(deletingList); + this.draftMapRouteService.createRoutes(mapId, generatedRouteList.stream() + .map(MapRouteNewVO::fromBO).collect(Collectors.toList())); + return generatedRouteList.size(); + } + /** * 唯一编码生成器 */ @@ -519,7 +593,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { clone.setInterlockStation(route.getInterlockStation()); clone.setStart(route.getStart()); clone.setDestination(route.getDestination()); - clone.setOpenGreen(route.isOpenGreen()); + clone.setAspect(route.getAspect()); clone.setSectionList(route.getSectionList()); clone.setSwitchList(route.getSwitchList()); clone.setPsdList(route.getPsdList()); @@ -644,6 +718,73 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { return routeList; } + private List generateRouteDepot(Signal start, CodeGenerator routeCodeGenerator, + MapCiGenerateConfig config, List errorList) { + boolean right = start.isRight(); + Section startSection = start.getSection().getSectionOf(right); + List routePathList = new ArrayList<>(); + getRoutePathOfDepot(start, startSection, new SectionPath(right), routePathList, config, errorList); + return buildRouteFromPathDepot(start, routeCodeGenerator, routePathList, config, errorList); + } + + private List buildRouteFromPathDepot(Signal startSignal, CodeGenerator routeCodeGenerator, List routePathList, + MapCiGenerateConfig config, List errorList) { + boolean right = startSignal.isRight(); + List routeList = new ArrayList<>(); + if (!CollectionUtils.isEmpty(routePathList)) { + for (SectionPath sectionPath : routePathList) { + Section lastSection = sectionPath.getLastSection(); + Signal.SignalType startSignalType = startSignal.getType(); + // 终端信号机 + Signal endSignal = lastSection.getSignalOf(right); + Signal.SignalType endSignalType = Objects.nonNull(endSignal) ? endSignal.getType() : null; + // 反向信号机 + Signal endOpSignal = lastSection.getSignalOf(!right); + Signal.SignalType endOpSignalType = Objects.nonNull(endOpSignal) ? endOpSignal.getType() : null; + Section nextSection = lastSection.getSectionOf(right); + // 下个区段反向信号机 + Signal nextOpSignal = Objects.nonNull(nextSection) ? nextSection.getSignalOf(!right) : null; + Signal clickEnd; + + SignalAspect signalAspect; + if (startSignalType.equals(endSignalType) && Signal.SignalType.SHUNTING2.equals(startSignalType)) { + // 列车进路 + signalAspect = SignalAspect.Y; + if (Objects.nonNull(endOpSignal) && endOpSignalType.equals(startSignalType)) { + clickEnd = endOpSignal; + } else { + clickEnd = endSignal; + } + } else { + // 调车进路 + signalAspect = SignalAspect.W; + if (Objects.nonNull(nextOpSignal)) { + // 下个区段反向信号机存在,则使用 + clickEnd = nextOpSignal; + } else if ((Objects.isNull(nextSection) || Signal.SignalType.BLOCKING.equals(endSignalType)) + && Objects.nonNull(endOpSignal) && sectionPath.getSectionList().size() > 1) { + // 尽头/阻挡信号机,使用反向信号机,过滤列车兼调车信号机至尽头 + clickEnd = endOpSignal; + } else { + // 其余设置为终端信号机,可能为null + clickEnd = endSignal; + } + } + + String endName = Objects.nonNull(endSignal) ? endSignal.getShowName() : lastSection.getName(); + // 构建进路 + String code = routeCodeGenerator.next(); + String name = String.format("%s-%s", startSignal.getShowName(), endName); + Route route = this.buildRouteDepot(code, name, startSignal, endSignal, clickEnd, sectionPath, signalAspect); + routeList.add(route); + } + } else { + errorList.add(String.format("以[%s(%s)]为始端信号(%s)的进路未搜索到", startSignal.getShowName(), + startSignal.getCode(), startSignal.getType())); + } + return routeList; + } + /** * 查询距给给定信号机最近的信号机 * @@ -1187,7 +1328,7 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { tbRoute.setSwitchList(route.getSwitchList()); tbRoute.setSetOverlapInCtc(route.isSetOverlapInCtc()); tbRoute.setOverlap(route.getOverlap()); - tbRoute.setOpenGreen(route.isOpenGreen()); + tbRoute.setAspect(route.getAspect()); // 根据信号机和区段是否同向,设置进路联锁自排和是否车队模式 tbRoute.setFlt(route.isFlt()); tbRoute.setArs(route.isArs()); @@ -1288,19 +1429,18 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { route.setSectionList(sectionPath.getSectionList()); route.setSwitchList(sectionPath.getSwitchList()); route.setOverlap(routeOverlap); - if (alwaysGreen) { // 进路始端信号机是否总是开绿灯 - route.setOpenGreen(true); - } else { // 根据进路道岔是否有反位,设置开绿灯/黄灯 - boolean greenOpen = true; - if (!CollectionUtils.isEmpty(sectionPath.getSwitchList())) { - for (SwitchElement switchElement : sectionPath.getSwitchList()) { - if (!switchElement.isNormal()) { - greenOpen = false; - break; - } + SignalModel signalModel = start.getSignalModel(); + switch (signalModel) { + case RGY:{ + route.setAspect(SignalAspect.G); + if (!alwaysGreen && sectionPath.containRpSwitch()) { + route.setAspect(SignalAspect.Y); } + break; } - route.setOpenGreen(greenOpen); + case BW: + route.setAspect(SignalAspect.W); + break; } route.setTurnBack(false); // 根据信号机和区段是否同向,设置进路联锁自排和是否车队模式 @@ -1356,6 +1496,24 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { return route; } + /** + * 构建车辆段进路 + */ + private Route buildRouteDepot(String code, String name, Signal start, Signal end, + Signal endButton, SectionPath sectionPath, SignalAspect signalAspect) { + Route route = new Route(code, name); + route.setInterlockStation(start.getInterlockStation()); + route.setStart(start); + route.setDestination(end); + route.setDestinationButtonSignal(endButton); + route.setSectionList(sectionPath.getSectionList()); + route.setSwitchList(sectionPath.getSwitchList()); + route.setAspect(signalAspect); + route.setPsdList(Collections.emptyList()); + route.setEspList(Collections.emptyList()); + return route; + } + /** * 根据路径创建延续保护 * @@ -1763,6 +1921,121 @@ public class DraftMapCiDataGeneratorImpl implements DraftMapCiDataGenerator { } } + private void getRoutePathOfDepot(Signal startSignal, Section section, + SectionPath tempPath, List routePathList, + MapCiGenerateConfig config, List errorList) { + boolean right = startSignal.isRight(); + if (!CollectionUtils.isEmpty(tempPath.getSectionList())) { + Signal signal = tempPath.getLastSection().getSignalOf(right); + if (startSignal.getType().equals(Signal.SignalType.SHUNTING2)) { + // 同向类型相同信号机, // 列车兼调车信号机 -> 列车兼调车信号机 + if (Objects.nonNull(signal) && signal.getType().equals(startSignal.getType())) { + routePathList.add(tempPath); + return; + } + if (Objects.isNull(section)) { + Signal lastSignal = tempPath.getLastSection().getSignalOf(!right); + if (Objects.nonNull(lastSignal) && lastSignal.getType().equals(startSignal.getType())) { + routePathList.add(tempPath); + } + return; + } + } else { + // 同向类型相同信号机 + if (Objects.nonNull(signal)) { + // 调车信号机 -> 调车信号机, 过滤只有一个区段的情况(进段信号机 -> 调车信号机) + if (signal.getType().equals(startSignal.getType())) { + if (tempPath.getSectionList().size() > 1) { + routePathList.add(tempPath); + } + return; + } + // 调车信号机 -> 列车兼调车信号机, 存在只有一个区段的情况 + if (signal.getType().equals(Signal.SignalType.SHUNTING2)) { + routePathList.add(tempPath); + return; + } + // 调车信号机 -> 阻挡信号机 + if (signal.getType().equals(Signal.SignalType.BLOCKING)) { + routePathList.add(tempPath); + return; + } + } + if (Objects.isNull(section)) { + // 尽头有反向信号机 + if (Objects.nonNull(tempPath.getLastSection().getSignalOf(!right))) { + routePathList.add(tempPath); + } + return; + } + } + } + tempPath.addSection(section); + if (section.isSwitchTrack()) { + Switch relSwitch = section.getRelSwitch(); + Switch linkedSwitch = relSwitch.queryLinkedSwitch(); + if (relSwitch.isA(section)) { + // 路径存在两种情况,道岔定位从A->B和道岔反位从A->C + // 产生分化递归 + SectionPath npPath = tempPath.cloneNew();// 定位路径 + npPath.addSection(relSwitch.getB()); + npPath.addSwitchElement(new SwitchElement(relSwitch, true)); + // 没有侧防,且联动道岔存在 + if (!config.isGenerateFls() && Objects.nonNull(linkedSwitch)) { + npPath.addSwitchElement(new SwitchElement(linkedSwitch, true)); + } + getRoutePathOfDepot(startSignal, relSwitch.getB().getSectionOf(right), npPath, routePathList, config, errorList); + SectionPath rpPath = tempPath.cloneNew();// 反位路径 + rpPath.addSection(relSwitch.getC()); + rpPath.addSwitchElement(new SwitchElement(relSwitch, false)); + // 如果是同一道岔计轴,添加另一道岔定位 + Switch otherSwitch = relSwitch.queryAxleRelatedOtherSwitch(); + if (!config.isGenerateFls() && Objects.nonNull(otherSwitch) && relSwitch.isBConnectTo(otherSwitch)) { + rpPath.addSwitchElement(new SwitchElement(otherSwitch, true)); + // 另一道岔联动道岔也需要 + Switch otherLinkSwitch = otherSwitch.queryLinkedSwitch(); + if (otherLinkSwitch != null) { + rpPath.addSwitchElement(new SwitchElement(otherLinkSwitch, true)); + } + } + getRoutePathOfDepot(startSignal, relSwitch.getC().getSectionOf(right), rpPath, routePathList, config, errorList); + } else if (relSwitch.isB(section)) { + // 只有一条路径,从B->A,道岔定位 + tempPath.addSection(relSwitch.getA()); + tempPath.addSwitchElement(new SwitchElement(relSwitch, true)); + // 没有侧防,且联动道岔存在 + if (!config.isGenerateFls() && Objects.nonNull(linkedSwitch)) { + tempPath.addSwitchElement(new SwitchElement(linkedSwitch, true)); + } + getRoutePathOfDepot(startSignal, relSwitch.getA().getSectionOf(right), tempPath, routePathList, config, errorList); + } else if (relSwitch.isC(section)) { + // 只有一条路径,从C->A,道岔反位 + tempPath.addSection(relSwitch.getA()); + tempPath.addSwitchElement(new SwitchElement(relSwitch, false)); + // 如果是同一道岔计轴,添加另一道岔定位 + Switch otherSwitch = relSwitch.queryAxleRelatedOtherSwitch(); + if (!config.isGenerateFls() && Objects.nonNull(otherSwitch)) { + tempPath.addSwitchElement(new SwitchElement(otherSwitch, true)); + // 另一道岔联动道岔也需要 + Switch otherLinkSwitch = otherSwitch.queryLinkedSwitch(); + if (otherLinkSwitch != null) { + tempPath.addSwitchElement(new SwitchElement(otherLinkSwitch, true)); + } + } + getRoutePathOfDepot(startSignal, relSwitch.getA().getSectionOf(right), tempPath, routePathList, config, errorList); + } else { + errorList.add(String.format("地图基础数据有错误:区段[%s(%s)]关联了道岔[%s(%s)],却不是此道岔的关联区段", + section.getName(), section.getCode(), + relSwitch.getName(), relSwitch.getCode())); + return; + } + } else { + // 非道岔区段 + Section next = section.getSectionOf(right); + getRoutePathOfDepot(startSignal, next, tempPath, routePathList, config, errorList); + } + } + /** * 生成接近区段 * diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapDataHandleService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapDataHandleService.java index 8cf6fae1f..3776baac9 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapDataHandleService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapDataHandleService.java @@ -14,4 +14,6 @@ public interface DraftMapDataHandleService { void handleDoublePathRoute(Long mapId); void handleSignalApproach(Long mapId); + + void handleRouteSignalAspect(); } diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapDataHandleServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapDataHandleServiceImpl.java index d40465e92..cba530ea0 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapDataHandleServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapDataHandleServiceImpl.java @@ -8,11 +8,19 @@ import club.joylink.rtss.entity.*; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.IDraftMapService; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.rt.repo.CommonRepository; import club.joylink.rtss.simulation.rt.repo.CommonRepositoryBuilder; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapSignalNewVO; +import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; +import club.joylink.rtss.vo.map.graph.MapSwitchVO; +import club.joylink.rtss.vo.map.graph.Point; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; +import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -32,7 +40,8 @@ public class DraftMapDataHandleServiceImpl implements DraftMapDataHandleService @Autowired private DraftMapRouteDAO draftMapRouteDAO; - + @Autowired + private DraftMapRouteService draftMapRouteService; @Autowired private DraftMapOverlapDAO draftMapOverlapDAO; @Autowired @@ -230,6 +239,24 @@ public class DraftMapDataHandleServiceImpl implements DraftMapDataHandleService } } + @Override + public void handleRouteSignalAspect() { + List all = this.draftMapDAO.selectByExample(null); + for (DraftMap draftMap : all) { + Long mapId = draftMap.getId(); + List allRoutes = this.draftMapRouteService.queryAllRoutes(mapId); + for (MapRouteNewVO route : allRoutes) { + if (route.isGreenOpen()) { + route.setAspect(SignalAspect.G); + } else { + route.setAspect(SignalAspect.Y); + } + DraftMapRoute draft = route.convert2Draft(); + this.draftMapRouteDAO.updateByPrimaryKeyWithBLOBs(draft); + } + } + } + private void calculateSectionLengthThroughStationKmPostVal(MapVO mapVO) { SimulationBuilder.SimulationDeviceBuildResult buildResult = SimulationBuilder.checkAndBuildBasicMapData(mapVO); for (String errMsg : buildResult.getErrMsgList()) { diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlankProtectionService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlankProtectionService.java index 0285f0400..c97327d4d 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlankProtectionService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlankProtectionService.java @@ -1,7 +1,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; import club.joylink.rtss.vo.map.query.MapRouteFlankProtectionQueryVO; public interface DraftMapFlankProtectionService { diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlankProtectionServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlankProtectionServiceImpl.java index 0624bba97..a1f5e9d13 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlankProtectionServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlankProtectionServiceImpl.java @@ -5,7 +5,7 @@ import club.joylink.rtss.entity.DraftMapRouteFlankProtection; import club.joylink.rtss.entity.DraftMapRouteFlankProtectionExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; import club.joylink.rtss.vo.map.query.MapRouteFlankProtectionQueryVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlsService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlsService.java index 85bbca5ae..eb9d42793 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlsService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlsService.java @@ -1,7 +1,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; import club.joylink.rtss.vo.map.query.MapRouteFlankProtectionQueryVO; import java.util.List; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlsServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlsServiceImpl.java index b3685fb62..22f29b3aa 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlsServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapFlsServiceImpl.java @@ -5,7 +5,7 @@ import club.joylink.rtss.entity.DraftMapRouteFlankProtection; import club.joylink.rtss.entity.DraftMapRouteFlankProtectionExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; import club.joylink.rtss.vo.map.query.MapRouteFlankProtectionQueryVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverlapService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverlapService.java index 48bbccf40..503d1f57d 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverlapService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverlapService.java @@ -1,7 +1,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapOverlapVO; +import club.joylink.rtss.vo.map.logic.MapOverlapVO; import club.joylink.rtss.vo.map.query.MapOverlapQueryVO; import java.util.List; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverlapServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverlapServiceImpl.java index 389c4953f..c28570fcf 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverlapServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverlapServiceImpl.java @@ -5,7 +5,7 @@ import club.joylink.rtss.entity.DraftMapOverlap; import club.joylink.rtss.entity.DraftMapOverlapExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapOverlapVO; +import club.joylink.rtss.vo.map.logic.MapOverlapVO; import club.joylink.rtss.vo.map.query.MapOverlapQueryVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverrunService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverrunService.java index 88689f053..1ab048e94 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverrunService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverrunService.java @@ -2,7 +2,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapRouteOverrunQueryVO; -import club.joylink.rtss.vo.map.MapRouteOverrunVO; +import club.joylink.rtss.vo.map.logic.MapRouteOverrunVO; import java.util.List; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverrunServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverrunServiceImpl.java index adb74d387..8117cb8d4 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverrunServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapOverrunServiceImpl.java @@ -6,7 +6,7 @@ import club.joylink.rtss.entity.DraftMapRouteOverrunExample; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapRouteOverrunQueryVO; -import club.joylink.rtss.vo.map.MapRouteOverrunVO; +import club.joylink.rtss.vo.map.logic.MapRouteOverrunVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteService.java index 4c12848ef..d381c00fa 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteService.java @@ -2,7 +2,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapRouteQueryVO; -import club.joylink.rtss.vo.map.MapRouteNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; import java.util.List; @@ -13,13 +13,17 @@ public interface DraftMapRouteService { List queryAllRoutes(Long id); - void update(Long id, String routeCode, MapRouteNewVO routeNewVO); + void update(Long mapId, String routeCode, MapRouteNewVO routeNewVO); void deleteRoute(Long id, String code); + void deleteRoutes(List ids); + void deleteStandHoldList(Long mapId); void setSetOverlapInCtcFalse(Long mapId); void createRoute(long draftMapId, MapRouteNewVO routeNewVO); + + void createRoutes(Long draftMapId, List routeList); } diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java index 263c090e8..a5aa0df09 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRouteServiceImpl.java @@ -10,7 +10,7 @@ import club.joylink.rtss.simulation.rt.repo.CommonRepositoryBuilder; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapRouteQueryVO; import club.joylink.rtss.vo.map.MapGraphDataNewVO; -import club.joylink.rtss.vo.map.MapRouteNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; @@ -106,11 +106,11 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { } @Override - public void update(Long id, String routeCode, MapRouteNewVO routeNewVO) { + public void update(Long mapId, String routeCode, MapRouteNewVO routeNewVO) { BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertHasText(routeNewVO.getName()); DraftMapRouteExample example = new DraftMapRouteExample(); example.createCriteria() - .andMapIdEqualTo(id) + .andMapIdEqualTo(mapId) .andCodeEqualTo(routeCode); List draftMapRoutes = this.draftMapRouteDAO.selectByExampleWithBLOBs(example); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(draftMapRoutes); @@ -154,6 +154,16 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { } } + @Override + public void deleteRoutes(List ids) { + if (CollectionUtils.isEmpty(ids)) { + return; + } + DraftMapRouteExample example = new DraftMapRouteExample(); + example.createCriteria().andIdIn(ids); + this.draftMapRouteDAO.deleteByExample(example); + } + @Override public void deleteStandHoldList(Long mapId) { List mapRouteNewVOS = queryAllRoutes(mapId); @@ -190,4 +200,12 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService { routeNewVO.setCode(code); draftMapRouteDAO.insert(routeNewVO.convert2Draft()); } + + @Override + public void createRoutes(Long draftMapId, List routeList) { + routeList.forEach(mapRouteNewVO -> { + mapRouteNewVO.setMapId(draftMapId); + draftMapRouteDAO.insert(mapRouteNewVO.convert2Draft()); + }); + } } diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRunLevelService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRunLevelService.java index ffb582736..d38fcd30c 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRunLevelService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRunLevelService.java @@ -1,7 +1,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapStationRunLevelVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import club.joylink.rtss.vo.map.query.MapRunLevelQueryVO; public interface DraftMapRunLevelService { diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRunLevelServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRunLevelServiceImpl.java index 16846304c..ad8e09755 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapRunLevelServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapRunLevelServiceImpl.java @@ -11,8 +11,8 @@ import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.map.MapDataVO; -import club.joylink.rtss.vo.map.MapRoutingDataVO; -import club.joylink.rtss.vo.map.MapStationRunLevelVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.query.MapRunLevelQueryVO; import com.github.pagehelper.Page; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapService.java index c149e7a10..3ee8e842f 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapService.java @@ -1,6 +1,16 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.logic.MapAutoReentryVO; +import club.joylink.rtss.vo.map.logic.MapAutoSignalNewVO; +import club.joylink.rtss.vo.map.logic.MapDestinationCodeDefinitionVO; +import club.joylink.rtss.vo.map.logic.MapOverlapVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; +import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO; +import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import java.util.List; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapServiceImpl.java index 1a8de662b..1a9c6e6c3 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapServiceImpl.java @@ -4,6 +4,16 @@ import club.joylink.rtss.dao.*; import club.joylink.rtss.entity.*; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.logic.MapAutoReentryVO; +import club.joylink.rtss.vo.map.logic.MapAutoSignalNewVO; +import club.joylink.rtss.vo.map.logic.MapDestinationCodeDefinitionVO; +import club.joylink.rtss.vo.map.logic.MapOverlapVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; +import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO; +import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapSignalApproachSectionService.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapSignalApproachSectionService.java index 24a22e2b1..8b03fcce4 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapSignalApproachSectionService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapSignalApproachSectionService.java @@ -1,7 +1,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapSignalApproachSectionVO; +import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO; import club.joylink.rtss.vo.map.query.MapSASQueryVO; import java.util.List; diff --git a/src/main/java/club/joylink/rtss/services/draftData/DraftMapSignalApproachSectionServiceImpl.java b/src/main/java/club/joylink/rtss/services/draftData/DraftMapSignalApproachSectionServiceImpl.java index 9fb667928..bc1900036 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/DraftMapSignalApproachSectionServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/draftData/DraftMapSignalApproachSectionServiceImpl.java @@ -7,7 +7,7 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.rt.repo.CommonRepository; import club.joylink.rtss.simulation.rt.repo.CommonRepositoryBuilder; import club.joylink.rtss.vo.client.PageVO; -import club.joylink.rtss.vo.map.MapSignalApproachSectionVO; +import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.query.MapSASQueryVO; import com.github.pagehelper.Page; diff --git a/src/main/java/club/joylink/rtss/services/draftData/ParkTimeService.java b/src/main/java/club/joylink/rtss/services/draftData/ParkTimeService.java index d5378ff8b..d51593c82 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/ParkTimeService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/ParkTimeService.java @@ -7,7 +7,7 @@ import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.vo.map.MapStationParkingTimeVO; +import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO; import club.joylink.rtss.vo.map.MapVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/club/joylink/rtss/services/draftData/RailwayRouteGenerator.java b/src/main/java/club/joylink/rtss/services/draftData/RailwayRouteGenerator.java index e0306a6ce..33aab59b0 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/RailwayRouteGenerator.java +++ b/src/main/java/club/joylink/rtss/services/draftData/RailwayRouteGenerator.java @@ -3,7 +3,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.rt.repo.*; import club.joylink.rtss.vo.map.MapCISwitchVO; -import club.joylink.rtss.vo.map.MapRouteNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; diff --git a/src/main/java/club/joylink/rtss/services/draftData/RoutingGenerator.java b/src/main/java/club/joylink/rtss/services/draftData/RoutingGenerator.java index e23dbac37..9f6676ac8 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/RoutingGenerator.java +++ b/src/main/java/club/joylink/rtss/services/draftData/RoutingGenerator.java @@ -1,7 +1,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.simulation.cbtc.data.map.*; -import club.joylink.rtss.vo.map.MapRoutingDataVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; @@ -175,7 +175,9 @@ public class RoutingGenerator { } } if (!finish) { - queryList.add(route.getDestination()); + if (route.getDestination() != null) { + queryList.add(route.getDestination()); + } } } for (Signal next : queryList) { diff --git a/src/main/java/club/joylink/rtss/services/draftData/RunLevelService.java b/src/main/java/club/joylink/rtss/services/draftData/RunLevelService.java index 25fa15ffe..ab97bc5f4 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/RunLevelService.java +++ b/src/main/java/club/joylink/rtss/services/draftData/RunLevelService.java @@ -9,9 +9,9 @@ import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.vo.map.MapRoutingDataVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; import club.joylink.rtss.vo.map.MapRoutingSectionNewVO; -import club.joylink.rtss.vo.map.MapStationRunLevelVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import club.joylink.rtss.vo.map.MapVO; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; diff --git a/src/main/java/club/joylink/rtss/services/draftData/SignalApproachSectionGenerator.java b/src/main/java/club/joylink/rtss/services/draftData/SignalApproachSectionGenerator.java index d632ee18e..18777fc78 100644 --- a/src/main/java/club/joylink/rtss/services/draftData/SignalApproachSectionGenerator.java +++ b/src/main/java/club/joylink/rtss/services/draftData/SignalApproachSectionGenerator.java @@ -2,7 +2,7 @@ package club.joylink.rtss.services.draftData; import club.joylink.rtss.simulation.rt.repo.*; import club.joylink.rtss.vo.map.MapSectionPathVO; -import club.joylink.rtss.vo.map.MapSignalApproachSectionVO; +import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO; import lombok.Getter; import lombok.Setter; import org.springframework.stereotype.Component; diff --git a/src/main/java/club/joylink/rtss/services/project/DeviceService.java b/src/main/java/club/joylink/rtss/services/project/DeviceService.java index 3d4adb8b1..28951a1cb 100644 --- a/src/main/java/club/joylink/rtss/services/project/DeviceService.java +++ b/src/main/java/club/joylink/rtss/services/project/DeviceService.java @@ -179,4 +179,6 @@ public interface DeviceService { void addOrUpdateGzbDeviceConfig(AccountVO accountVO); void addOrUpdateSdyDeviceConfig(AccountVO accountVO); + + void addOrUpdateRichorDeviceConfig(AccountVO accountVO); } diff --git a/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java b/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java index 03996a85f..07b3e804f 100644 --- a/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/project/DeviceServiceImpl.java @@ -12,6 +12,10 @@ import club.joylink.rtss.vo.client.PageVO; import club.joylink.rtss.vo.client.project.*; import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; import club.joylink.rtss.vo.client.project.gzb.GzbSwitchConfigVO; +import club.joylink.rtss.vo.client.project.richor.RichorDcuConfigVO; +import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO; +import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO; +import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO; import club.joylink.rtss.vo.client.project.sdy.SdyPsdConfigVO; import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO; import club.joylink.rtss.vo.client.project.xty.XtyPsdConfigVO; @@ -378,6 +382,78 @@ public class DeviceServiceImpl implements DeviceService { } } + @Override + public void addOrUpdateRichorDeviceConfig(AccountVO accountVO) { + // 删除旧配置 + ProjectDeviceExample example = new ProjectDeviceExample(); + example.createCriteria() + .andProjectCodeEqualTo(Project.RICHOR_JOINT.name()) + .andTypeIn(ProjectDeviceType.PlcDeviceList().stream() + .map(Enum::name).collect(Collectors.toList())); + this.projectDeviceDAO.deleteByExample(example); + // 保存新配置 + List list = this.buildRichorProjectDevices(accountVO); + for (ProjectDevice projectDevice : list) { + this.projectDeviceDAO.insert(projectDevice); + } + } + + private List buildRichorProjectDevices(AccountVO accountVO) { + LocalDateTime now = LocalDateTime.now(); + List list = new ArrayList<>(); + // PLC网关 + ProjectDevice plcGateway = new ProjectDevice(); + plcGateway.setProjectCode(Project.RICHOR_JOINT.name()); + plcGateway.setCode("richorJoint-gateway"); + plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name()); + plcGateway.setCreator(accountVO.getId()); + plcGateway.setCreateTime(now); + PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 144); + plcGateway.setConfig(plcGatewayConfigVO.toJson()); + list.add(plcGateway); + // 屏蔽门 + ProjectDevice psd = new ProjectDevice(); + psd.setProjectCode(Project.RICHOR_JOINT.name()); + psd.setCode("richorJoint-psd"); + psd.setType(ProjectDeviceType.PSD.name()); + psd.setCreator(accountVO.getId()); + psd.setCreateTime(now); + RichorPsdConfigVO psdConfigVO = new RichorPsdConfigVO(); + psd.setConfig(psdConfigVO.toJson()); + list.add(psd); + // IBP盘 + ProjectDevice ibp = new ProjectDevice(); + ibp.setProjectCode(Project.RICHOR_JOINT.name()); + ibp.setCode("richorJoint-ibp"); + ibp.setType(ProjectDeviceType.IBP.name()); + ibp.setCreator(accountVO.getId()); + ibp.setCreateTime(now); + RichorIbpConfigVO ibpConfigVO = new RichorIbpConfigVO(); + ibp.setConfig(ibpConfigVO.toJson()); + list.add(ibp); + // PSL + ProjectDevice psl = new ProjectDevice(); + psl.setProjectCode(Project.RICHOR_JOINT.name()); + psl.setCode("richorJoint-psl"); + psl.setType(ProjectDeviceType.PSL.name()); + psl.setCreator(accountVO.getId()); + psl.setCreateTime(now); + RichorPslConfigVO pslConfigVO = new RichorPslConfigVO(); + psl.setConfig(pslConfigVO.toJson()); + list.add(psl); +// // DCU +// ProjectDevice dcu = new ProjectDevice(); +// dcu.setProjectCode(Project.RICHOR_JOINT.name()); +// dcu.setCode("richorJoint-dcu"); +// dcu.setType(ProjectDeviceType.DCU.name()); +// dcu.setCreator(accountVO.getId()); +// dcu.setCreateTime(now); +// RichorDcuConfigVO dcuConfigVO = new RichorDcuConfigVO(); +// dcu.setConfig(dcuConfigVO.toJson()); +// list.add(dcu); + return list; + } + private List buildSdyProjectDevices(AccountVO accountVO) { LocalDateTime now = LocalDateTime.now(); List list = new ArrayList<>(); diff --git a/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java b/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java index 670496a20..6481c79f2 100644 --- a/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java +++ b/src/main/java/club/joylink/rtss/services/psl/VirtualRealityPslService.java @@ -1,7 +1,7 @@ package club.joylink.rtss.services.psl; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.simulation.cbtc.CI.service.StandService; +import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService; import club.joylink.rtss.simulation.cbtc.GroupSimulationService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; @@ -10,6 +10,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.PSD; 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.VirtualRealityScreenDoor; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent; import club.joylink.rtss.vo.client.psl.PslStatus; import org.springframework.beans.factory.annotation.Autowired; @@ -30,7 +31,9 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{ private ApplicationContext applicationContext; @Autowired - private StandService standService; + private CiStandService standService; + @Autowired + private VirtualRealityDeviceService virtualRealityDeviceService; @Override public PslStatus getStatus(String group, String standCode) { @@ -68,13 +71,13 @@ public class VirtualRealityPslService implements IVirtualRealityPslService{ // vrPsl.setKmButton(!vrPsl.isKmButton()); // if (vrPsl.isKmButton()) if (vrPsl.isYxjzKey() && vrPsd.isLockAndClose()) - standService.controlVrPSD(simulation, vrPsd, true); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.K); break; case GM: // vrPsl.setGmButton(!vrPsl.isGmButton()); // if (vrPsl.isGmButton()) if (vrPsl.isYxjzKey() && vrPsd.isOpen2End()) - standService.controlVrPSD(simulation, vrPsd, false); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.G); break; case SD: vrPsl.setSdButton(!vrPsl.isSdButton()); diff --git a/src/main/java/club/joylink/rtss/services/publishData/PublishMapDataHandler.java b/src/main/java/club/joylink/rtss/services/publishData/PublishMapDataHandler.java new file mode 100644 index 000000000..97875630e --- /dev/null +++ b/src/main/java/club/joylink/rtss/services/publishData/PublishMapDataHandler.java @@ -0,0 +1,169 @@ +package club.joylink.rtss.services.publishData; + +import club.joylink.rtss.constants.MapStatus; +import club.joylink.rtss.dao.MapDataDAO; +import club.joylink.rtss.dao.MapInfoDAO; +import club.joylink.rtss.entity.MapDataWithBLOBs; +import club.joylink.rtss.entity.MapInfo; +import club.joylink.rtss.entity.MapInfoExample; +import club.joylink.rtss.services.IMapService; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.constant.SignalModel; +import club.joylink.rtss.simulation.cbtc.data.map.Signal; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.util.VersionUtil; +import club.joylink.rtss.vo.map.MapCheckConfig; +import club.joylink.rtss.vo.map.MapGraphDataNewVO; +import club.joylink.rtss.vo.map.MapLogicDataNewVO; +import club.joylink.rtss.vo.map.MapVO; +import club.joylink.rtss.vo.map.graph.MapSignalNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.validation.constraints.NotBlank; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Service +public class PublishMapDataHandler { + @Autowired + private IMapService iMapService; + @Autowired + private MapInfoDAO mapInfoDAO; + @Autowired + private MapDataDAO mapDataDAO; + + public List queryMapInfos() { + MapInfoExample example = new MapInfoExample(); + example.createCriteria().andStatusNotEqualTo(MapStatus.Delete.getCode()); + List mapInfos = this.mapInfoDAO.selectByExample(example); + return mapInfos; + } + + public void dataHandle() { + List mapInfos = this.queryMapInfos(); + for (MapInfo mapInfo : mapInfos) { + this.handle(mapInfo); + } + } + + @Transactional + public void handle(MapInfo mapInfo) { + Long mapId = mapInfo.getId(); + MapVO detail = this.iMapService.getMapDetail(mapId); + MapGraphDataNewVO graphDataNew = detail.getGraphDataNew(); + List signalList = graphDataNew.getSignalList(); + for (MapSignalNewVO signal : signalList) { + Signal.SignalType type = signal.getType(); + switch (type) { + case PROTECTION: + case PASSING: + signal.setSignalModel(SignalModel.RGY.name()); + break; + case BLOCKING: + signal.setSignalModel(SignalModel.R.name()); + break; + case SHUNTING: + signal.setSignalModel(SignalModel.BW.name()); + break; + case ARRIVAL: + signal.setSignalModel(SignalModel.YGRYW.name()); + break; + case EXIT: + signal.setSignalModel(SignalModel.YGRGW.name()); + break; + } + } + MapLogicDataNewVO logicDataNew = detail.getLogicDataNew(); + List routeList = logicDataNew.getRouteList(); + for (MapRouteNewVO route : routeList) { + if (route.isGreenOpen()) { + route.setAspect(SignalAspect.G); + } else { + route.setAspect(SignalAspect.Y); + } + } + //地图数据 + MapDataWithBLOBs mapData = new MapDataWithBLOBs(); + mapData.setMapId(mapId); + mapData.setGraphData(JsonUtils.writeValueAsString(graphDataNew)); + mapData.setLogicData(JsonUtils.writeValueAsString(detail.getLogicDataNew())); + if (detail.getCheckConfig() != null) { + mapData.setCheckConfig(detail.getCheckConfig().toJson()); + } else { + mapData.setCheckConfig(new MapCheckConfig().toJson()); + } + mapData.setVersion(VersionUtil.generateNext(this.iMapService.findMapVersion(mapId))); + mapData.setNote("处理进路信号显示"); + mapData.setTime(LocalDateTime.now()); + mapData.setUserId(1L); + mapDataDAO.insert(mapData); + // 更新地图当前使用的地图数据版本 + MapInfo map = new MapInfo(); + map.setId(mapId); + map.setVersion(mapData.getVersion()); + mapInfoDAO.updateByPrimaryKeySelective(map); + this.iMapService.removeCache(mapId); + } + + public void xian3Handle() { + MapInfoExample example = new MapInfoExample(); + example.createCriteria() + .andLineCodeEqualTo("11") + .andStatusNotEqualTo(MapStatus.Delete.getCode()); + List mapInfos = this.mapInfoDAO.selectByExample(example); + for (MapInfo mapInfo : mapInfos) { + handleSignal(mapInfo); + } + } + + private void handleSignal(MapInfo mapInfo) { + Long mapId = mapInfo.getId(); + MapVO detail = this.iMapService.getMapDetail(mapId); + MapGraphDataNewVO graphDataNew = detail.getGraphDataNew(); + List signalList = graphDataNew.getSignalList(); + MapLogicDataNewVO logicDataNew = detail.getLogicDataNew(); + List routeList = logicDataNew.getRouteList(); + Map routeMap = new HashMap<>(); + for (MapRouteNewVO mapRouteNewVO : routeList) { + if (mapRouteNewVO.getEndSignalCode() != null) { + if (!routeMap.containsKey(mapRouteNewVO.getEndSignalCode())) { + routeMap.put(mapRouteNewVO.getEndSignalCode(), mapRouteNewVO); + } + } + } + for (MapSignalNewVO signalVO : signalList) { + MapRouteNewVO route = routeMap.get(signalVO.getCode()); + if (route != null) { + signalVO.setCtcSetOverlap(route.isSetOverlapInCtc()); + } + } + //地图数据 + MapDataWithBLOBs mapData = new MapDataWithBLOBs(); + mapData.setMapId(mapId); + mapData.setGraphData(JsonUtils.writeValueAsString(graphDataNew)); + mapData.setLogicData(JsonUtils.writeValueAsString(detail.getLogicDataNew())); + if (detail.getCheckConfig() != null) { + mapData.setCheckConfig(detail.getCheckConfig().toJson()); + } else { + mapData.setCheckConfig(new MapCheckConfig().toJson()); + } + mapData.setVersion(VersionUtil.generateNext(this.iMapService.findMapVersion(mapId))); + mapData.setNote("处理信号机CTC级别是否办理延续保护"); + mapData.setTime(LocalDateTime.now()); + mapData.setUserId(1L); + mapDataDAO.insert(mapData); + // 更新地图当前使用的地图数据版本 + MapInfo map = new MapInfo(); + map.setId(mapId); + map.setVersion(mapData.getVersion()); + mapInfoDAO.updateByPrimaryKeySelective(map); + this.iMapService.removeCache(mapId); + } +} diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/BeiJingLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/BeiJingLine1RunPlanNew.java index dde1bf402..d5c125c64 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/BeiJingLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/BeiJingLine1RunPlanNew.java @@ -4,7 +4,7 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine1RunPlanNew.java index 1507bf41e..dec3ed569 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine1RunPlanNew.java @@ -6,7 +6,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine3RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine3RunPlanNew.java index a7764354f..c9e7f9785 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine3RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/ChengDuLine3RunPlanNew.java @@ -5,7 +5,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/DefaultRunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/DefaultRunPlanNew.java index 88574450a..4e8ab15df 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/DefaultRunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/DefaultRunPlanNew.java @@ -3,7 +3,7 @@ package club.joylink.rtss.services.runplan.importReal; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import java.util.List; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java index ff59b23c4..6d42920c0 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/FoshanTramRunPlanNew.java @@ -6,7 +6,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/FuZhouLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/FuZhouLine1RunPlanNew.java index 6fa9852dd..900dcbc0e 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/FuZhouLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/FuZhouLine1RunPlanNew.java @@ -5,7 +5,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/HarBinLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/HarBinLine1RunPlanNew.java index c0649439d..b87d94016 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/HarBinLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/HarBinLine1RunPlanNew.java @@ -6,7 +6,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/IRunPlanStrategyNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/IRunPlanStrategyNew.java index 922fd9472..387c82947 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/IRunPlanStrategyNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/IRunPlanStrategyNew.java @@ -6,9 +6,9 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapSectionNewVO; -import club.joylink.rtss.vo.map.MapStationNewVO; -import club.joylink.rtss.vo.map.MapStationStandNewVO; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; import org.springframework.util.StringUtils; import java.util.*; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine1RunPlanNew.java index 9d5a21d01..4553edb15 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine1RunPlanNew.java @@ -6,7 +6,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java index b47312878..a4a8e5e0f 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/NingBoLine3RunPlanNew.java @@ -6,7 +6,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine1RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine1RunPlanNew.java index e6abe4fea..cb498bfbc 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine1RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine1RunPlanNew.java @@ -5,7 +5,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine2RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine2RunPlanNew.java index f16ba4379..9fe25fd13 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine2RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine2RunPlanNew.java @@ -6,7 +6,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanArrivalTime; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine3RunPlanNew.java b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine3RunPlanNew.java index e5afcb8ca..1315e175b 100644 --- a/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine3RunPlanNew.java +++ b/src/main/java/club/joylink/rtss/services/runplan/importReal/XianLine3RunPlanNew.java @@ -4,7 +4,7 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.client.runplan.RunPlanImport; import club.joylink.rtss.vo.client.runplan.RunPlanTripTimeVO; import club.joylink.rtss.vo.client.runplan.RunPlanTripVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.extern.slf4j.Slf4j; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java index 1c659ca43..21cd23c14 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/GeneratorNew.java @@ -13,6 +13,10 @@ import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; import club.joylink.rtss.vo.client.training.definition.OperatePlaceholderVO; import club.joylink.rtss.vo.client.training.definition.OperateStepVO; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapAutomaticRouteButtonVO; +import club.joylink.rtss.vo.map.graph.MapCycleButtonVO; +import club.joylink.rtss.vo.map.graph.MapTotalGuideLockButtonVO; +import club.joylink.rtss.vo.map.graph.MapTurnBackStrategyVO; import org.springframework.util.StringUtils; import java.util.ArrayList; @@ -26,6 +30,11 @@ public interface GeneratorNew { List generate(GenerateConfig config, Simulation simulationData, OperateDefinitionVO operateDefinitionVO); + default void resetSimulation(Simulation simulation) { + simulation.reset(); + simulation.getRepository().vrDeviceReset(); + } + /** * 构建实训数据 * diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/ControlGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/ControlGeneratorNew.java index 58e735c95..6bdddc581 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/ControlGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/ControlGeneratorNew.java @@ -7,8 +7,8 @@ import club.joylink.rtss.services.training.generatornew.annotation.GeneratorSele import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.Station; -import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; import club.joylink.rtss.vo.client.training.TrainingNewVO; +import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; import java.util.ArrayList; import java.util.List; @@ -51,7 +51,7 @@ public class ControlGeneratorNew implements GeneratorNew { } trainingVOList.add(build(config, simulation, station, null,operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } return trainingVOList; } diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SectionGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SectionGeneratorNew.java index 2ab87261f..eb14419ba 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SectionGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SectionGeneratorNew.java @@ -8,8 +8,8 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; -import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; import club.joylink.rtss.vo.client.training.TrainingNewVO; +import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -126,7 +126,7 @@ public class SectionGeneratorNew implements GeneratorNew { } trainingVOList.add(this.build(config, simulation, section, null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } return trainingVOList; } diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SignalGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SignalGeneratorNew.java index ad24b814e..c23ef9341 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SignalGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SignalGeneratorNew.java @@ -16,7 +16,6 @@ import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; -import java.util.Objects; import java.util.stream.Collectors; @GeneratorSelectorNew(operateObject = Operation.Object.Signal) @@ -38,14 +37,14 @@ public class SignalGeneratorNew implements GeneratorNew { .stream().filter(mapCycleButtonVO -> mapCycleButtonVO.getCycleCode().equals(cycle.getCode())) .forEach(button -> { trainingVOList.add(this.build(config, simulation, cycle,button, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); }); continue; }else { trainingVOList.add(this.build(config, simulation, cycle,null, operateDefinitionVO)); } // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } return trainingVOList; } @@ -59,14 +58,14 @@ public class SignalGeneratorNew implements GeneratorNew { .stream().filter(mapCycleButtonVO -> mapCycleButtonVO.getCycleCode().equals(cycle.getCode())) .forEach(button -> { trainingVOList.add(this.build(config, simulation, cycle,button, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); }); continue; }else{ trainingVOList.add(this.build(config, simulation, cycle,null, operateDefinitionVO)); } // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } return trainingVOList; } @@ -95,7 +94,7 @@ public class SignalGeneratorNew implements GeneratorNew { } trainingVOList.add(this.build(config, simulation, route,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } continue; @@ -107,7 +106,7 @@ public class SignalGeneratorNew implements GeneratorNew { routeList.forEach(route -> route.setAtsControl(false)); } trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); continue; } else { for (Route route : routeList) { @@ -125,7 +124,7 @@ public class SignalGeneratorNew implements GeneratorNew { } trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } @@ -135,7 +134,7 @@ public class SignalGeneratorNew implements GeneratorNew { if (!CollectionUtils.isEmpty(routeList)) { if (routeLikeHa1 || operateDefinitionVO.onlyOperateSignal()) { trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); continue; } else { for (Route route : routeList) { @@ -149,7 +148,7 @@ public class SignalGeneratorNew implements GeneratorNew { } trainingVOList.add(this.build(config, simulation, route,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } } @@ -171,7 +170,7 @@ public class SignalGeneratorNew implements GeneratorNew { deviceStatusModifyTool.openRouteDirect(simulation, route); trainingVOList.add(this.build(config, simulation, route, null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } continue; @@ -186,7 +185,7 @@ public class SignalGeneratorNew implements GeneratorNew { // todo 在接近区段设置一辆列车 trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } continue; } @@ -200,7 +199,7 @@ public class SignalGeneratorNew implements GeneratorNew { this.deviceStatusModifyTool.openRouteDirect(simulation, route); trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } continue; @@ -216,7 +215,7 @@ public class SignalGeneratorNew implements GeneratorNew { this.deviceStatusModifyTool.closeSignalDirectly(route.getStart()); trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } continue; @@ -235,7 +234,7 @@ public class SignalGeneratorNew implements GeneratorNew { } trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } else { for (Route route : routeList) { if (route.isGuide()) { // 引导进路不生成Signal_Cancel_CI_Auto_Trigger @@ -244,7 +243,7 @@ public class SignalGeneratorNew implements GeneratorNew { route.setAtsControl(false); trainingVOList.add(this.build(config, simulation, route,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } } @@ -265,14 +264,14 @@ public class SignalGeneratorNew implements GeneratorNew { .stream().filter(automaticRouteButtonVO -> automaticRouteButtonVO.getAutomaticRouteCode().equals(route.getCode())) .forEach(button -> { trainingVOList.add(this.build(config, simulation, route.getStart(), button, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); }); continue; } else { trainingVOList.add(this.build(config, simulation, route.getStart(), null, operateDefinitionVO)); } // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } continue; @@ -291,14 +290,14 @@ public class SignalGeneratorNew implements GeneratorNew { .stream().filter(automaticRouteButtonVO -> automaticRouteButtonVO.getAutomaticRouteCode().equals(route.getCode())) .forEach(button -> { trainingVOList.add(this.build(config, simulation,signal, button, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); }); continue; } else { trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); } // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } continue; @@ -315,13 +314,13 @@ public class SignalGeneratorNew implements GeneratorNew { } trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } else { for (Route route : arcRouteList) { route.setCiControl(true); trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } } @@ -351,76 +350,76 @@ public class SignalGeneratorNew implements GeneratorNew { deviceStatusModifyTool.loadManualTrainOfGroup(simulation, "001",signal.getSection(),signal.isRight()); if(operateDefinitionVO.onlyOperateSignal()){ trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); break; } trainingVOList.add(this.build(config, simulation, route,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } // } continue; } - case Signal_Close_Guide: { - // 若信号可开放引导信号,生成实训,背景设置为开放引导进路/开放引导信号 - if (signal.isCallOn()) { - if (!CollectionUtils.isEmpty(routeList)) { - for (Route route : routeList) { - if (!route.isTurnBack()) { - this.deviceStatusModifyTool.openGuideRouteDirect(simulation, route); - trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO)); - // 仿真重置 - simulation.reset(); - } - } - } else if (Objects.nonNull(signal.getAutoSignal())) { // 信号机是自动信号 - this.deviceStatusModifyTool.openGuideSignalDirectly(signal); - trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO)); - // 仿真重置 - simulation.reset(); - } - } - continue; - } - case Signal_Cancel_Guide: { - // 若信号可开放引导信号,生成实训,背景设置为开放引导进路/开放引导信号 +// case Signal_Close_Guide: { +// // 若信号可开放引导信号,生成实训,背景设置为开放引导进路/开放引导信号 // if (signal.isCallOn()) { - if (!CollectionUtils.isEmpty(routeList)) { - for (Route route : routeList) { - if (routeLikeHa1 && - !route.isGuide()) { - // 对于类似ATP、地面、引导类进路线路,非引导进路跳过 - continue; - } - if (!route.isTurnBack()) { - this.deviceStatusModifyTool.openGuideRouteDirect(simulation, route); - if(operateDefinitionVO.onlyOperateSignal()){ - trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); - simulation.reset(); - break; - } - trainingVOList.add(this.build(config, simulation, route,null, operateDefinitionVO)); - // 仿真重置 - simulation.reset(); - } - } -// } -// else if(Objects.nonNull(signal.getAutoSignal())) { // 信号机是自动信号 +// if (!CollectionUtils.isEmpty(routeList)) { +// for (Route route : routeList) { +// if (!route.isTurnBack()) { +// this.deviceStatusModifyTool.openGuideRouteDirect(simulation, route); +// trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO)); +// // 仿真重置 +// this.resetSimulation(simulation); +// } +// } +// } else if (Objects.nonNull(signal.getAutoSignal())) { // 信号机是自动信号 // this.deviceStatusModifyTool.openGuideSignalDirectly(signal); -// trainingVOList.add(this.build(config, simulation, signal, operateDefinitionVO)); +// trainingVOList.add(this.build(config, simulation, signal, null, operateDefinitionVO)); // // 仿真重置 -// simulation.reset(); +// this.resetSimulation(simulation); // } - } - continue; - } +// } +// continue; +// } +// case Signal_Cancel_Guide: { +// // 若信号可开放引导信号,生成实训,背景设置为开放引导进路/开放引导信号 +//// if (signal.isCallOn()) { +// if (!CollectionUtils.isEmpty(routeList)) { +// for (Route route : routeList) { +// if (routeLikeHa1 && +// !route.isGuide()) { +// // 对于类似ATP、地面、引导类进路线路,非引导进路跳过 +// continue; +// } +// if (!route.isTurnBack()) { +// this.deviceStatusModifyTool.openGuideRouteDirect(simulation, route); +// if(operateDefinitionVO.onlyOperateSignal()){ +// trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); +// this.resetSimulation(simulation); +// break; +// } +// trainingVOList.add(this.build(config, simulation, route,null, operateDefinitionVO)); +// // 仿真重置 +// this.resetSimulation(simulation); +// } +// } +//// } +//// else if(Objects.nonNull(signal.getAutoSignal())) { // 信号机是自动信号 +//// this.deviceStatusModifyTool.openGuideSignalDirectly(signal); +//// trainingVOList.add(this.build(config, simulation, signal, operateDefinitionVO)); +//// // 仿真重置 +//// this.resetSimulation(simulation); +//// } +// } +// continue; +// } default: // 其他操作,不生成 continue; } trainingVOList.add(this.build(config, simulation, signal,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } return trainingVOList; } diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SpeedLimitGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SpeedLimitGeneratorNew.java index 6bf20fd46..512792bed 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SpeedLimitGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SpeedLimitGeneratorNew.java @@ -13,7 +13,7 @@ import club.joylink.rtss.vo.client.training.TrainingStepVO; import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; import club.joylink.rtss.vo.client.training.definition.OperatePlaceholderVO; import club.joylink.rtss.vo.client.training.definition.OperateStepVO; -import club.joylink.rtss.vo.map.MapTempSpeedLimitVO; +import club.joylink.rtss.vo.map.graph.MapTempSpeedLimitVO; import org.springframework.beans.factory.annotation.Autowired; import java.util.ArrayList; @@ -36,7 +36,7 @@ public class SpeedLimitGeneratorNew implements GeneratorNew { List tempSpeedLimitList = simulation.getBuildParams().getMap().getGraphDataNew().getTempSpeedLimitList(); tempSpeedLimitList.forEach(mapTempSpeedLimitVO -> { trainingVOList.add(this.build(config, simulation,null,mapTempSpeedLimitVO, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); }); break; } diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/StandGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/StandGeneratorNew.java index 07f4bf089..25fbe5552 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/StandGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/StandGeneratorNew.java @@ -1,28 +1,23 @@ package club.joylink.rtss.services.training.generatornew.base; +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.Operation; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.constant.TrainType; -import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; 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.constants.MapPrdTypeEnum; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; -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.vr.VirtualRealityDevice; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.tool.DeviceStatusModifyTool; -import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; 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 java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; @GeneratorSelectorNew(operateObject = Operation.Object.Stand) @@ -108,7 +103,7 @@ public class StandGeneratorNew implements GeneratorNew { } trainingVOList.add(this.build(config, simulation, stand,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } return trainingVOList; } diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/StationGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/StationGeneratorNew.java index 97c71a179..f667ab929 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/StationGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/StationGeneratorNew.java @@ -8,8 +8,8 @@ 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.tool.DeviceStatusModifyTool; -import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; 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; @@ -113,7 +113,7 @@ public class StationGeneratorNew implements GeneratorNew { .stream().filter(turnBackStrategyO -> turnBackStrategyO.getStationCode().equals(station.getCode())) .forEach(button -> { trainingVOList.add(this.build(config, simulation, station,button, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); }); continue; } @@ -141,7 +141,7 @@ public class StationGeneratorNew implements GeneratorNew { aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).collect(Collectors.toList()); collect.forEach(aSwitch -> aSwitch.setFault(Switch.SwitchFault.SPLIT)); trainingVOList.add(this.build(config, simulation, station, button, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); }); continue; } @@ -170,7 +170,7 @@ public class StationGeneratorNew implements GeneratorNew { List switchList1 = simulation.getRepository().getSwitchList(); switchList1.stream().filter(aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).forEach(aSwitch -> aSwitch.setSingleLock(true)); trainingVOList.add(this.build(config, simulation, station, button, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); }); continue; } @@ -180,7 +180,7 @@ public class StationGeneratorNew implements GeneratorNew { switchList1.stream().filter(aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).forEach(aSwitch -> aSwitch.setSingleLock(true)); trainingVOList.add(this.build(config, simulation, station, null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); break; } } @@ -195,7 +195,7 @@ public class StationGeneratorNew implements GeneratorNew { List switchList1 = simulation.getRepository().getSwitchList(); switchList1.stream().filter(aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).forEach(aSwitch -> aSwitch.setSingleLock(true)); trainingVOList.add(this.build(config, simulation, station, button, operateDefinitionVO)); - simulation.reset(); + this.resetSimulation(simulation); }); return; } @@ -205,7 +205,7 @@ public class StationGeneratorNew implements GeneratorNew { switchList1.stream().filter(aSwitch -> Objects.equals(aSwitch.getDeviceStation(), station)).forEach(aSwitch -> aSwitch.setSingleLock(true)); trainingVOList.add(this.build(config, simulation, station, null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } } }); @@ -227,7 +227,7 @@ public class StationGeneratorNew implements GeneratorNew { } trainingVOList.add(build(config, simulation, station,null, operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } // List tbStationList = simulation.getRepository().getStationList() // .stream() @@ -238,7 +238,7 @@ public class StationGeneratorNew implements GeneratorNew { // station.setControlMode(Station.ControlMode.Center); // trainingVOList.add(build(config, simulation, station,null, operateDefinitionVO)); // // 仿真重置 -// simulation.reset(); +// this.resetSimulation(simulation); // } // }); return trainingVOList; diff --git a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SwitchGeneratorNew.java b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SwitchGeneratorNew.java index 993e6822d..6dbd00393 100644 --- a/src/main/java/club/joylink/rtss/services/training/generatornew/base/SwitchGeneratorNew.java +++ b/src/main/java/club/joylink/rtss/services/training/generatornew/base/SwitchGeneratorNew.java @@ -9,8 +9,8 @@ import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; import club.joylink.rtss.simulation.cbtc.tool.DeviceStatusModifyTool; -import club.joylink.rtss.vo.client.training.definition.OperateDefinitionVO; 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 java.util.ArrayList; @@ -116,7 +116,7 @@ public class SwitchGeneratorNew implements GeneratorNew { } trainingVOList.add(this.build(config, simulation, aSwitch, null,operateDefinitionVO)); // 仿真重置 - simulation.reset(); + this.resetSimulation(simulation); } return trainingVOList; } diff --git a/src/main/java/club/joylink/rtss/simulation/Simulation.java b/src/main/java/club/joylink/rtss/simulation/Simulation.java index dcacae845..e1f2eabf0 100644 --- a/src/main/java/club/joylink/rtss/simulation/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/Simulation.java @@ -32,7 +32,7 @@ public abstract class Simulation collectAndSendSignalApproachMessage2CI(Simulation simulation, - List onlineTrainList, - Map> trainAtpSectionMap) { - List signalApproachMessageList = new ArrayList<>(); // 信号机列车接近信息 + public void changeSignalModeByTrainApproach(Simulation simulation, + List onlineTrainList, + Map> trainAtpSectionMap) { List signalList = simulation.getRepository().getSignalList(); - Map nctApproachSignalMap = new HashMap<>(); signalList.forEach(signal -> { -// if (!signal.isNormalOpen()) { -// for (VirtualRealityTrain train : onlineTrainList) { -// List
atpSectionList = trainAtpSectionMap.get(train.getGroupNumber()); -// List
physicalList = this.convert2PhysicalSectionList(atpSectionList); -// if (!train.isCBTC() && signal.containsApproachPhysicalSection(physicalList)) { //非通信车在物理接近区段上 -// nctApproachSignalMap.put(train, signal); -// } -// } -// return; -// } - SignalApproachMessage.ApproachMessage approachMsg = SignalApproachMessage.ApproachMessage.NULL; + int a = 0; // 列车接近信号消息:0-无车接近,1-通信车接近,2-非通信车接近 for (VirtualRealityTrain train : onlineTrainList) { List
atpSectionList = trainAtpSectionMap.get(train.getGroupNumber()); List
physicalList = this.convert2PhysicalSectionList(atpSectionList); - if (train.isCommunicable() && signal.containsApproachAtpSection(atpSectionList)) { //通信车在atp接近区段上 - approachMsg = SignalApproachMessage.ApproachMessage.CBTC; - } else if (!train.isCommunicable() && signal.containsApproachPhysicalSection(physicalList)) { //非通信车在物理接近区段上 - approachMsg = SignalApproachMessage.ApproachMessage.NCT; - nctApproachSignalMap.put(train, signal); + if (train.isCommunicable() && signal.containsApproachAtpSection(atpSectionList)) { //存在通信车接近,继续 + a = 1; + } else if (!train.isCommunicable() && signal.containsApproachPhysicalSection(physicalList)) { //存在非通信车接近,结束 + a = 2; + break; } - - /*if (!Objects.equals(SignalApproachMessage.ApproachMessage.NCT, approachMsg)) { // 不为非通信车占用时 - if (!SignalApproachMessage.ApproachMessage.CBTC.equals(approachMsg) && - train.isCBTC() && signal.containsApproachAtpSection(atpSectionList)) { - approachMsg = SignalApproachMessage.ApproachMessage.CBTC; - } else if (!train.isCBTC() && signal.containsApproachPhysicalSection(physicalList)) { - approachMsg = SignalApproachMessage.ApproachMessage.NCT; - nctApproachSignalMap.put(train, signal); - } - }*/ } - String signalCode = signal.getCode(); - signalApproachMessageList.add(new SignalApproachMessage(signalCode, approachMsg)); + if (1 == a) { // 只有通信车接近 + signal.changeToCbtcMode(); + this.signalControlService.controlLightOfSignal(simulation, signal); + } else if (2 == a) { // 有非通信车接近 + signal.changeToBackupMode(); + this.signalControlService.controlLightOfSignal(simulation, signal); + } signal.updateApproachLock();//更新信号机接近锁闭状态 }); - this.ciApiService.handleSignalApproachMessage(simulation, signalApproachMessageList); - return nctApproachSignalMap; } private List
convert2PhysicalSectionList(List
sectionList) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/GroundAtpApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/GroundAtpApiServiceImpl.java index 0bac83756..67a23772b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/GroundAtpApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/GroundAtpApiServiceImpl.java @@ -5,7 +5,6 @@ import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.Section; -import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import org.springframework.beans.factory.annotation.Autowired; @@ -81,9 +80,8 @@ public class GroundAtpApiServiceImpl implements GroundAtpApiService { section.nonCommunicateTrainOccupy(train.isRight()); } })); - // 信号机接近信息、停稳信息通知 - Map nctApproachSignalMap = - this.atpSectionService.collectAndSendSignalApproachMessage2CI(simulation, onlineTrainList, trainAtpSectionMap); + // 信号机接近信息 + this.atpSectionService.changeSignalModeByTrainApproach(simulation, onlineTrainList, trainAtpSectionMap); // 移除下线列车区段占用 this.atpSectionService.removeOfflineTrainOccupySections(simulation, onlineTrainList); @@ -104,7 +102,7 @@ public class GroundAtpApiServiceImpl implements GroundAtpApiService { .forEach(aSwitch -> aSwitch.ctcOccupy()); // 发送区段状态 - this.atsApiService.handleDeviceStatus(simulation, repository.getSectionList()); +// this.atsApiService.handleDeviceStatus(simulation, repository.getSectionList()); // 为ctc列车计算移动授权 this.maService.calculateMaOfCtcTrains(simulation); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java index a88d51a1d..11e9b47b1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/MaService.java @@ -190,6 +190,8 @@ public class MaService { break; } case Closed_Section: + case UnLock_Section: + case Reverse_Lock_Section: case Fault_Route:{ Section section = (Section) this.device; eoa = new SectionPosition(section, right ? 0 : section.getLen()); @@ -313,6 +315,10 @@ public class MaService { ZC_Boundary, /** 关闭的区段 */ Closed_Section, + /** 进路锁闭反向的区段 */ + Reverse_Lock_Section, + /** 未锁闭的区段 */ + UnLock_Section, /** 进路联锁条件不再完备 */ Fault_Route, /** 站台问题(屏蔽门或紧急停车) */ @@ -344,7 +350,7 @@ public class MaService { public void calculateAndUpdateItcMa(Simulation simulation, VirtualRealityTrain train, Responder responder) { Ma ma = null; Signal signal = responder.getSignal(); - if (signal.isNormalOpen()) { + if (signal.isMainAspect()) { if (signal.isAutoSignal()) { boolean right = signal.isRight(); Section section = signal.getSection().getNextRunningSectionOf(right); @@ -371,7 +377,7 @@ public class MaService { boolean right = train.isRight(); Signal signal = section.getSignalOf(right); if (signal != null) { // 车头所在区段前方信号机开放 - if (signal.isNormalOpen()) { + if (signal.isMainAspect()) { Float distance = CalculateService.calculateDistance(headPosition, new SectionPosition(section, signal.getOffset()), right); if (distance != null) { // 此处距离为暂时的估计值, Route lockedRoute = signal.getLockedRoute(); @@ -417,19 +423,19 @@ public class MaService { ma = this.checkAndUpdateMa(ma, new Ma(train, section, MaType.Fault_Route)); } // 反向锁闭区段 - if (right != route.getStart().isRight()) { // 列车方向和区段进路方向相反 + if (front && right != route.getStart().isRight()) { // 列车方向和区段进路方向相反 Signal aheadSignal = section.getSignalOf(right); if (aheadSignal == null || aheadSignal.getLockedRoute() == null || - !aheadSignal.getLockedRoute().isOpen()) { - ma = this.checkAndUpdateMa(ma, new Ma(train, section, MaType.Closed_Section)); + !aheadSignal.getLockedRoute().isOpenMain()) { + ma = this.checkAndUpdateMa(ma, new Ma(train, section, MaType.Reverse_Lock_Section)); } } } else if(front) { - if (!section.isRouteLock() && !section.isOverlapLock()) {//列车前方区段未锁闭 + if (!section.isRouteLock() && !section.isOverlapLock() && !section.isLogicOverlapLock()) {//列车前方区段未锁闭 Signal aheadSignal = section.getSignalOf(right); if (aheadSignal == null || aheadSignal.getLockedRoute() == null || - !aheadSignal.getLockedRoute().isOpen()) { - ma = this.checkAndUpdateMa(ma, new Ma(train, section, MaType.Closed_Section)); + !aheadSignal.getLockedRoute().isOpenMain()) { + ma = this.checkAndUpdateMa(ma, new Ma(train, section, MaType.UnLock_Section)); } } } @@ -444,7 +450,7 @@ public class MaService { Section next = section.getNextRunningSectionOf(right); if (front) { // 车头前方 Signal signal = section.getSignalOf(right); - if (signal != null && !signal.isNormalOpen()) { + if (signal != null && !signal.isMainAspect()) { // 限制信号机 if (signal.isOverlapLock()) { ma = this.checkAndUpdateMa(ma, new Ma(train, signal, MaType.Limit_Signal_With_Overlap)); @@ -542,7 +548,7 @@ public class MaService { switchFault = true; break; } else { - RouteFls fls = route.getRouteFlsOfSwitch(aSwitch); + RouteFls fls = route.queryRouteFlsOfSwitch(aSwitch); if (fls != null) { List level1List = fls.getLevel1List(); for (RouteFls.FlsElement flsElement : level1List) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java index 852b2aac4..f43c8acee 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATP/ground/ZCLogicLoop.java @@ -1,547 +1,496 @@ -package club.joylink.rtss.simulation.cbtc.ATP.ground; - -import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.simulation.cbtc.ATS.AtsApiService; -import club.joylink.rtss.simulation.cbtc.CI.service.RouteService; -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.constant.RunLevel; -import club.joylink.rtss.simulation.cbtc.data.CalculateService; -import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; -import club.joylink.rtss.simulation.cbtc.data.map.*; -import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority; -import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; -import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService; -import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.*; -import java.util.stream.Collectors; - -/** - * ZC逻辑循环 - */ -@Slf4j -@Component -public class ZCLogicLoop { - - @Autowired - private OnboardAtpApiService onboardAtpApiService; - - @Autowired - private ATPService ATPService; - - @Autowired - private AtsApiService atsApiService; - - @Autowired - private MaService maService; - - @Autowired - private RouteService routeService; - - public void run(Simulation simulation) { - List trainList = simulation.getRepository().getOnlineTrainList(); - trainList.forEach(train -> { - SectionPosition headPosition = train.getHeadPosition(); - Station deviceStation = headPosition.getSection().getDeviceStation(); - RunLevel defaultRunLevel = simulation.getRepository().getConfig().getRunMode(); - if (RunLevel.ITC.equals(defaultRunLevel)) { //如果线路最高运行级别为ITC级别 - if (!Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { - this.calculateMAOfITC(simulation, train); - } - } else if (RunLevel.CBTC.equals(defaultRunLevel)) { - //更新ITC ma - if (!simulation.getRepository().hasResponder()) { - if (!Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { - Float distance2NextSignal = train.calculateDistance2NextNormalOpenSignal(); - if (distance2NextSignal != null && distance2NextSignal <= 5) { - train.setPositioned(true); - this.calculateMAOfITC(simulation, train); - } - } - } else { - simulation.getRepository().getSectionRespondersMap().forEach((section, responders) -> - responders.stream() - .filter(Responder::isVB) - .forEach(responder -> { - if (responder.getSignal().isNormalOpen()) { - responder.setMa(this.calculateMAOfITC(simulation, responder)); - } - })); - } - //更新CBTC ma - if (train.isCommunicable()) { - this.calculateMAOfCBTC(simulation, train, trainList); - } - } - }); - } - - private void calculateMAOfCBTC(Simulation simulation, VirtualRealityTrain train, - List trainList) { - // 查找移动授权终端列表 - List endList = this.findMaEnd(simulation, train, trainList); - // 根据查找到的授权终端,比较并构建最终的移动授权数据 - MovementAuthority ma = this.compareAndBuildMa(train, endList); - // 通知车载ATP - this.onboardAtpApiService.updateMA4CBTC(train, ma); - } - - /** - * 计算移动授权终端 - * - * @param simulation - * @param train - * @param trainList - * @return - */ - private List findMaEnd(Simulation simulation, VirtualRealityTrain train, List trainList) { - // 从车尾开始找(车尾主要查看是否在站台轨上,且站台轨屏蔽门开放) - boolean right = train.isRight(); - SectionPosition headPosition = train.getHeadPosition(); - SectionPosition tailPosition = train.calculateTailPosition(); - Section tailSection = tailPosition.getSection(); - MovementAuthority.End openPsdEnd = checkPsdOpenOrClose(tailSection); - List endList = new ArrayList<>(); - if (openPsdEnd != null) - endList.add(openPsdEnd); - MovementAuthority.End ecStandEnd = checkEC(simulation.getRepository().getConfig(), tailSection); - if (ecStandEnd != null) - endList.add(ecStandEnd); - MovementAuthority.End closedSection = checkClosedSection(tailSection); - if (closedSection != null) - return List.of(closedSection); - // 如果车尾正常,从车头开始往前查找 - Section section = headPosition.getSection(); - MovementAuthority.End switchEnd = checkSwitch(tailSection, section, right); - if (switchEnd != null) - return List.of(switchEnd); - // 检查列车当前所在进路是否锁闭 -// MovementAuthority.End end1 = this.checkRouteLock(simulation, section, tailSection, right, train); -// if (Objects.nonNull(end1)) { -// endList.add(end1); +//package club.joylink.rtss.simulation.cbtc.ATP.ground; +// +//import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +//import club.joylink.rtss.simulation.cbtc.ATS.AtsApiService; +//import club.joylink.rtss.simulation.cbtc.CI.service.RouteService; +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.constant.RunLevel; +//import club.joylink.rtss.simulation.cbtc.data.CalculateService; +//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +//import club.joylink.rtss.simulation.cbtc.data.map.*; +//import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority; +//import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; +//import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService; +//import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import java.util.*; +//import java.util.stream.Collectors; +// +///** +// * ZC逻辑循环 +// */ +//@Slf4j +//@Component +//public class ZCLogicLoop { +// +// @Autowired +// private OnboardAtpApiService onboardAtpApiService; +// +// @Autowired +// private ATPService ATPService; +// +// @Autowired +// private AtsApiService atsApiService; +// +// @Autowired +// private MaService maService; +// +// @Autowired +// private RouteService routeService; +// +// public void run(Simulation simulation) { +// List trainList = simulation.getRepository().getOnlineTrainList(); +// trainList.forEach(train -> { +// SectionPosition headPosition = train.getHeadPosition(); +// Station deviceStation = headPosition.getSection().getDeviceStation(); +// RunLevel defaultRunLevel = simulation.getRepository().getConfig().getRunMode(); +// if (RunLevel.ITC.equals(defaultRunLevel)) { //如果线路最高运行级别为ITC级别 +// if (!Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { +// this.calculateMAOfITC(simulation, train); +// } +// } else if (RunLevel.CBTC.equals(defaultRunLevel)) { +// //更新ITC ma +// if (!simulation.getRepository().hasResponder()) { +// if (!Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { +// Float distance2NextSignal = train.calculateDistance2NextNormalOpenSignal(); +// if (distance2NextSignal != null && distance2NextSignal <= 5) { +// train.setPositioned(true); +// this.calculateMAOfITC(simulation, train); +// } +// } +// } else { +// simulation.getRepository().getSectionRespondersMap().forEach((section, responders) -> +// responders.stream() +// .filter(Responder::isVB) +// .forEach(responder -> { +// if (responder.getSignal().isNormalOpen()) { +// responder.setMa(this.calculateMAOfITC(simulation, responder)); +// } +// })); +// } +// //更新CBTC ma +// if (train.isCommunicable()) { +// this.calculateMAOfCBTC(simulation, train, trainList); +// } +// } +// }); +// } +// +// private void calculateMAOfCBTC(Simulation simulation, VirtualRealityTrain train, +// List trainList) { +// // 查找移动授权终端列表 +// List endList = this.findMaEnd(simulation, train, trainList); +// // 根据查找到的授权终端,比较并构建最终的移动授权数据 +// MovementAuthority ma = this.compareAndBuildMa(train, endList); +// // 通知车载ATP +// this.onboardAtpApiService.updateMA4CBTC(train, ma); +// } +// +// /** +// * 计算移动授权终端 +// * +// * @param simulation +// * @param train +// * @param trainList +// * @return +// */ +// private List findMaEnd(Simulation simulation, VirtualRealityTrain train, List trainList) { +// // 从车尾开始找(车尾主要查看是否在站台轨上,且站台轨屏蔽门开放) +// boolean right = train.isRight(); +// SectionPosition headPosition = train.getHeadPosition(); +// SectionPosition tailPosition = train.calculateTailPosition(); +// Section tailSection = tailPosition.getSection(); +// MovementAuthority.End openPsdEnd = checkPsdOpenOrClose(tailSection); +// List endList = new ArrayList<>(); +// if (openPsdEnd != null) +// endList.add(openPsdEnd); +// MovementAuthority.End ecStandEnd = checkEC(simulation.getRepository().getConfig(), tailSection); +// if (ecStandEnd != null) +// endList.add(ecStandEnd); +// MovementAuthority.End closedSection = checkClosedSection(tailSection); +// if (closedSection != null) +// return List.of(closedSection); +// // 如果车尾正常,从车头开始往前查找 +// Section section = headPosition.getSection(); +// MovementAuthority.End switchEnd = checkSwitch(tailSection, section, right); +// if (switchEnd != null) +// return List.of(switchEnd); +// // 检查列车当前所在进路是否锁闭 +//// MovementAuthority.End end1 = this.checkRouteLock(simulation, section, tailSection, right, train); +//// if (Objects.nonNull(end1)) { +//// endList.add(end1); +//// return endList; +//// } +//// // 检查车头区段是否故障 +//// if (headPosition.getSection().isFault()) { +//// endList.add(new MovementAuthority.End(headPosition.getSection(), MovementAuthority.EndType.FAULT_SECTION)); +//// } +// //非通信车占用区段 +// if (section.hasNctOccupy() && !section.isInvalid()) { +// endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); // return endList; // } -// // 检查车头区段是否故障 -// if (headPosition.getSection().isFault()) { -// endList.add(new MovementAuthority.End(headPosition.getSection(), MovementAuthority.EndType.FAULT_SECTION)); +// //通信车占用区段 +// List
occupiedLogicSectionList = simulation.getRepository().queryTrainOccupyAtpSectionList(train.getGroupNumber()); +// Set
occupiedLogicSectionSet; +// if (!CollectionUtils.isEmpty(occupiedLogicSectionList)) { +// occupiedLogicSectionSet = new HashSet<>(occupiedLogicSectionList); +// } else { +// occupiedLogicSectionSet = new HashSet<>(); // } - //非通信车占用区段 - if (section.hasNctOccupy() && !section.isInvalid()) { - endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); - return endList; - } - //通信车占用区段 - List
occupiedLogicSectionList = simulation.getRepository().queryTrainOccupyAtpSectionList(train.getGroupNumber()); - Set
occupiedLogicSectionSet; - if (!CollectionUtils.isEmpty(occupiedLogicSectionList)) { - occupiedLogicSectionSet = new HashSet<>(occupiedLogicSectionList); - } else { - occupiedLogicSectionSet = new HashSet<>(); - } - List
logicList = section.getLogicList(); - if (!CollectionUtils.isEmpty(logicList)) { - Section logicSection = headPosition.getLogicSection(); - int index = logicList.indexOf(logicSection); - if (right) { - for (int i = index + 1; i < logicList.size(); i++) { - MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right, occupiedLogicSectionSet); - if (end != null) - endList.add(end); - } - } else { - for (int i = index - 1; i >= 0; i--) { - MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right, occupiedLogicSectionSet); - if (end != null) - endList.add(end); - } - } - } - int count = 0; - while (count < 50) { - ++count; -// // 区段未进路锁闭或延时解锁中(转换轨除外,因为出库列车加载到转换轨没有进路) -// if (!section.isTransferTrack()) { -// if (section.isDelayUnlock()) { -// deviceEnd = new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION); -// break; +// List
logicList = section.getLogicList(); +// if (!CollectionUtils.isEmpty(logicList)) { +// Section logicSection = headPosition.getLogicSection(); +// int index = logicList.indexOf(logicSection); +// if (right) { +// for (int i = index + 1; i < logicList.size(); i++) { +// MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right, occupiedLogicSectionSet); +// if (end != null) +// endList.add(end); // } -// if (!section.isRouteLock()) { -// deviceEnd = new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION); -// break; -// } -// } - // 站台屏蔽门 - MovementAuthority.End psdEnd = checkPsdOpenOrClose(section); - if (psdEnd != null) - endList.add(psdEnd); - // 紧急关闭的站台 - MovementAuthority.End standEnd = checkEC(simulation.getRepository().getConfig(), section); - if (standEnd != null) - endList.add(standEnd); - // 信号机 - MovementAuthority.End signalEnd = checkSignal(section, right); - if (Objects.nonNull(signalEnd)) { - endList.add(signalEnd); - MovementAuthority.End unlockedOverlapEnd = this.checkUnlockedOverlap(simulation, section, right); - if (Objects.nonNull(unlockedOverlapEnd)) { - endList.add(unlockedOverlapEnd); - } - } - // 道岔 - MovementAuthority.End end = checkSwitch(section, right); - if (end != null) - endList.add(end); - // 轨道尽头/问题道岔 - Section temp = section.getNextRunningSectionOf(right); - if (Objects.isNull(temp)) { // 到尽头 - if (!section.isSwitchTrack()) { // 问题道岔 - endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.END_TRACK)); - } - break; - } - //通信车占用区段 - MovementAuthority.End trainEnd = checkSectionOccupied(temp, right, occupiedLogicSectionSet); - if (trainEnd != null) - endList.add(trainEnd); - //非通信车占用区段 - if (temp.hasNctOccupy() && !temp.isInvalid()) { - endList.add(new MovementAuthority.End(temp, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); - } - //检查关闭的区段 - MovementAuthority.End cs = checkClosedSection(section); - if (cs != null) - endList.add(cs); - - if (endList.stream().anyMatch(end2 -> !MovementAuthority.EndType.CLOSED_SIGNAL.equals(end2.getType()))) { - break; - } - section = temp; - } -// // 前方列车 -// VirtualRealityTrain frontTrain = this.queryFrontTrain(train, trainList); -// if (Objects.nonNull(frontTrain)) { -// Section baseSection; -// if (Objects.equals(frontTrain.isRight(), train.isRight())) { -// baseSection = frontTrain.calculateTailPosition().getSection(); // } else { -// baseSection = frontTrain.getHeadPosition().getSection(); +// for (int i = index - 1; i >= 0; i--) { +// MovementAuthority.End end = checkSectionOccupied(logicList.get(i), right, occupiedLogicSectionSet); +// if (end != null) +// endList.add(end); +// } // } -// endList.add(new MovementAuthority.End(frontTrain, -// MovementAuthority.EndType.FRONT_TRAIN, -// baseSection)); // } - return endList; - } - - private MovementAuthority.End checkSectionOccupied(Section section, boolean right, Set
occupiedLogicSectionSet) { - List
logicList = section.getLogicList(); - if (!CollectionUtils.isEmpty(logicList)) { - if (right) { - for (Section logic : logicList) { - if (logic.isCtOccupied() && !occupiedLogicSectionSet.contains(logic)) { - return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null); - } - } - } else { - for (int i = logicList.size() - 1; i >= 0; i--) { - Section logic = logicList.get(i); - if (logic.isCtOccupied() && !occupiedLogicSectionSet.contains(logic)) { - return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null); - } - } - } - } else { - if (section.isCtOccupied() && !occupiedLogicSectionSet.contains(section)) { - return new MovementAuthority.End(section, MovementAuthority.EndType.FRONT_TRAIN, null); - } - } - return null; - } - - private MovementAuthority.End checkSwitch(Section tailSection, Section headSection, boolean right) { - Section section = tailSection; - for (int i = 0; i < 10; i++) { - if (section == null || section.equals(headSection)) - break; - MovementAuthority.End end = checkSwitch(section, right); - if (end != null) - return end; - section = section.getNextRunningSectionOf(right); - } - return null; - } - - private MovementAuthority.End checkSwitch(Section section, boolean right) { - Switch relSwitch = section.getRelSwitch(); - Section nextSection = section.getNextRunningSectionOf(right); - if (relSwitch != null) { //是道岔区段 - Route route = relSwitch.getRoute(); - Section previousSection = section.getNextRunningSectionOf(!right); - if (previousSection == null) - return null; - if (route != null) { //道岔进路锁闭 - if (relSwitch.isLoss()) { //失表且下个区段 - return new MovementAuthority.End(relSwitch, MovementAuthority.EndType.FAULT_SWITCH, previousSection); - } else { - List flsList = route.getFlsList(); - if (!CollectionUtils.isEmpty(flsList)) { - List fls = flsList.stream() - .filter(routeFls -> routeFls.getBase().getASwitch().equals(relSwitch)) - .collect(Collectors.toList()); - if (!routeService.isFlsCheckPass(fls)) { - return new MovementAuthority.End(relSwitch, MovementAuthority.EndType.FAULT_SWITCH, previousSection); - } - } - } - } - } - return null; - } - - private MovementAuthority.End checkClosedSection(Section section) { - if (section.isClosed()) { - return new MovementAuthority.End(section, MovementAuthority.EndType.CLOSED_SECTION); - } - return null; - } - - private MovementAuthority.End checkEC(MapConfig config, Section section) { - if (section.isNormalStandTrack()) { - Station station = section.getStation(); - if (config.isSharingECStation(station.getCode())) { - for (Stand stand : station.getAllStandList()) { - if (stand.isEmergencyClosed()) { - return new MovementAuthority.End(stand, MovementAuthority.EndType.EC_STAND, section); - } - } - } else { - List standList = section.getStandList(); - for (Stand stand : standList) { - if (stand.isEmergencyClosed()) { - return new MovementAuthority.End(stand, MovementAuthority.EndType.EC_STAND, section); - } - } - } - } - return null; - } - - private MovementAuthority.End checkUnlockedOverlap(Simulation simulation, Section section, boolean right) { - SimulationDataRepository repository = simulation.getRepository(); - // 判断是否已经办理进路的区段 - Route route = null; - if (section.isRouteLock()) { - List settingRoutes = repository.getSettingRoutes(); - for (Route settingRoute : settingRoutes) { - if (settingRoute.isLastRouteSection(section)) { - route = settingRoute; - break; - } - } - } - if (Objects.nonNull(route) && repository.isOverlapNeedSetting(route)) { // 进路需要办理延续保护 - RouteOverlap overlap = route.getOverlap(); - if (!overlap.isLock()) { // 延续保护未锁闭 - return new MovementAuthority.End(overlap, - MovementAuthority.EndType.UNLOCKED_OVERLAP, overlap.getSection()); - } - } - return null; - } - - public void calculateMAOfITC(Simulation simulation, VirtualRealityTrain train) { - // 查找移动授权终端列表 - List endList = this.findItcMaEnd(train.getHeadPosition(), train.isRight()); - if (CollectionUtils.isEmpty(endList)) { // 未找到授权终点 - return; - } - // 根据查找到的授权终端,比较并构建最终的移动授权数据 - MovementAuthority ma = this.compareAndBuildMa(train, endList); - // 通知车载ATP - this.onboardAtpApiService.updateMA4ITC(train, ma); - } - - public MovementAuthority calculateMAOfITC(Simulation simulation, Responder responder) { - // 查找移动授权终端列表 - List endList = this.findItcMaEnd(responder.getPosition(), responder.getSignal().isRight()); - if (CollectionUtils.isEmpty(endList)) { // 未找到授权终点 - return null; - } - // 根据查找到的授权终端,比较并构建最终的移动授权数据 - MovementAuthority ma = this.compareAndBuildMa(responder.getSignal().isRight(), endList); - // 通知车载ATP - return ma; - } - - private List findItcMaEnd(SectionPosition position, boolean right) { - List endList = new ArrayList<>(); - MovementAuthority.End deviceEnd = null; - Section section = position.getSection(); - int count = 0; - while (Objects.nonNull(section) && count < 20) { - if (count > 1 && !CollectionUtils.isEmpty(endList)) - break; - ++count; - // 信号机 - MovementAuthority.End signalEnd = checkGroundSignal(section, right); - if (Objects.nonNull(signalEnd)) { - endList.add(signalEnd); -// deviceEnd = signalEnd; - break; - } - // 轨道尽头/问题道岔 - Section temp = section.getNextRunningSectionOf(right); - if (Objects.isNull(temp)) { // 到尽头 - if (!section.isSwitchTrack()) { // 问题道岔 - endList.add(new MovementAuthority.End(section, - MovementAuthority.EndType.END_TRACK)); - } - break; - } - } - if (Objects.nonNull(deviceEnd)) { - endList.add(deviceEnd); - } - return endList; - } - - /** - * 比较并构建移动授权数据 - * - * @param train - * @param endList - * @return - */ - private MovementAuthority compareAndBuildMa(VirtualRealityTrain train, List endList) { - return compareAndBuildMa(train.isRight(), endList); - } - - /** - * 比较并构建移动授权数据 - * - * @param endList - * @return - */ - private MovementAuthority compareAndBuildMa(boolean right, List endList) { - MovementAuthority.End end = null; - if (endList.size() == 1) { // 只有一个,直接构建移动授权 - end = endList.get(0); - } else { - for (MovementAuthority.End temp : endList) { - if (Objects.isNull(end)) { - end = temp; - } else { - if (end.isAheadOf(temp, right)) { - end = temp; - } - } - } - } - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(end); - end.confirmEndPosition(right); - return new MovementAuthority(end); - } - - private VirtualRealityTrain queryFrontTrain(VirtualRealityTrain train, List trainList) { - boolean right = train.isRight(); - SectionPosition headPosition = train.getHeadPosition(); - VirtualRealityTrain front = null; - Float distance = null; - for (VirtualRealityTrain other : trainList) { - if (Objects.equals(other, train)) { - continue; - } - SectionPosition otherTrainPosition; - if (Objects.equals(right, other.isRight())) { - // 同向列车,取车尾 - otherTrainPosition = other.calculateTailPosition(); - - } else { - // 反向列车,取车头 - otherTrainPosition = other.getHeadPosition(); - } - Float tempDistance = CalculateService.calculateDistance(headPosition, otherTrainPosition, right); - if (Objects.isNull(tempDistance) || tempDistance < 0) { - // 未找到 - continue; - } else { - if (Objects.isNull(front) || tempDistance < distance) { - front = other; - distance = tempDistance; - } - } - } -// if (Objects.nonNull(front)) { -// log.debug(String.format("列车[%s-%s|%s|%s]前方列车为[%s-%s|%s|%s]", -// train.getGroupNumber(), train.getServiceNumber(), -// train.getTripNumber(), train.getDestinationCode(), -// front.getGroupNumber(), front.getServiceNumber(), -// front.getTripNumber(), front.getDestinationCode())); +// int count = 0; +// while (count < 50) { +// ++count; +//// // 区段未进路锁闭或延时解锁中(转换轨除外,因为出库列车加载到转换轨没有进路) +//// if (!section.isTransferTrack()) { +//// if (section.isDelayUnlock()) { +//// deviceEnd = new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION); +//// break; +//// } +//// if (!section.isRouteLock()) { +//// deviceEnd = new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION); +//// break; +//// } +//// } +// // 站台屏蔽门 +// MovementAuthority.End psdEnd = checkPsdOpenOrClose(section); +// if (psdEnd != null) +// endList.add(psdEnd); +// // 紧急关闭的站台 +// MovementAuthority.End standEnd = checkEC(simulation.getRepository().getConfig(), section); +// if (standEnd != null) +// endList.add(standEnd); +// // 信号机 +// MovementAuthority.End signalEnd = checkSignal(section, right); +// if (Objects.nonNull(signalEnd)) { +// endList.add(signalEnd); +// MovementAuthority.End unlockedOverlapEnd = this.checkUnlockedOverlap(simulation, section, right); +// if (Objects.nonNull(unlockedOverlapEnd)) { +// endList.add(unlockedOverlapEnd); +// } +// } +// // 道岔 +// MovementAuthority.End end = checkSwitch(section, right); +// if (end != null) +// endList.add(end); +// // 轨道尽头/问题道岔 +// Section temp = section.getNextRunningSectionOf(right); +// if (Objects.isNull(temp)) { // 到尽头 +// if (!section.isSwitchTrack()) { // 问题道岔 +// endList.add(new MovementAuthority.End(section, MovementAuthority.EndType.END_TRACK)); +// } +// break; +// } +// //通信车占用区段 +// MovementAuthority.End trainEnd = checkSectionOccupied(temp, right, occupiedLogicSectionSet); +// if (trainEnd != null) +// endList.add(trainEnd); +// //非通信车占用区段 +// if (temp.hasNctOccupy() && !temp.isInvalid()) { +// endList.add(new MovementAuthority.End(temp, MovementAuthority.EndType.NCT_OCCUPIED_SECTION)); +// } +// //检查关闭的区段 +// MovementAuthority.End cs = checkClosedSection(section); +// if (cs != null) +// endList.add(cs); +// +// if (endList.stream().anyMatch(end2 -> !MovementAuthority.EndType.CLOSED_SIGNAL.equals(end2.getType()))) { +// break; +// } +// section = temp; // } - return front; - } - - private MovementAuthority.End checkRouteLock(Simulation simulation, Section section, Section tailSection, boolean right, VirtualRealityTrain train) { - if (section.isTransferTrack()) - return null; - SimulationDataRepository repository = simulation.getRepository(); - // 判断前方是否有信号机(如果存在信号机,则不判断进路锁闭,以兼容现在列车加载到转换轨没有进路情况) -// Signal aheadSignal = section.getSignalOf(right); -// if (Objects.nonNull(aheadSignal)) { +//// // 前方列车 +//// VirtualRealityTrain frontTrain = this.queryFrontTrain(train, trainList); +//// if (Objects.nonNull(frontTrain)) { +//// Section baseSection; +//// if (Objects.equals(frontTrain.isRight(), train.isRight())) { +//// baseSection = frontTrain.calculateTailPosition().getSection(); +//// } else { +//// baseSection = frontTrain.getHeadPosition().getSection(); +//// } +//// endList.add(new MovementAuthority.End(frontTrain, +//// MovementAuthority.EndType.FRONT_TRAIN, +//// baseSection)); +//// } +// return endList; +// } +// +// private MovementAuthority.End checkSectionOccupied(Section section, boolean right, Set
occupiedLogicSectionSet) { +// List
logicList = section.getLogicList(); +// if (!CollectionUtils.isEmpty(logicList)) { +// if (right) { +// for (Section logic : logicList) { +// if (logic.isCtOccupied() && !occupiedLogicSectionSet.contains(logic)) { +// return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null); +// } +// } +// } else { +// for (int i = logicList.size() - 1; i >= 0; i--) { +// Section logic = logicList.get(i); +// if (logic.isCtOccupied() && !occupiedLogicSectionSet.contains(logic)) { +// return new MovementAuthority.End(logic, MovementAuthority.EndType.FRONT_TRAIN, null); +// } +// } +// } +// } else { +// if (section.isCtOccupied() && !occupiedLogicSectionSet.contains(section)) { +// return new MovementAuthority.End(section, MovementAuthority.EndType.FRONT_TRAIN, null); +// } +// } +// return null; +// } +// +// private MovementAuthority.End checkSwitch(Section tailSection, Section headSection, boolean right) { +// Section section = tailSection; +// for (int i = 0; i < 10; i++) { +// if (section == null || section.equals(headSection)) +// break; +// MovementAuthority.End end = checkSwitch(section, right); +// if (end != null) +// return end; +// section = section.getNextRunningSectionOf(right); +// } +// return null; +// } +// +// private MovementAuthority.End checkSwitch(Section section, boolean right) { +// Switch relSwitch = section.getRelSwitch(); +// Section nextSection = section.getNextRunningSectionOf(right); +// if (relSwitch != null) { //是道岔区段 +// Route route = relSwitch.getRoute(); +// Section previousSection = section.getNextRunningSectionOf(!right); +// if (previousSection == null) +// return null; +// if (route != null) { //道岔进路锁闭 +// if (relSwitch.isLoss()) { //失表且下个区段 +// return new MovementAuthority.End(relSwitch, MovementAuthority.EndType.FAULT_SWITCH, previousSection); +// } else { +// List flsList = route.getFlsList(); +// if (!CollectionUtils.isEmpty(flsList)) { +// List fls = flsList.stream() +// .filter(routeFls -> routeFls.getBase().getASwitch().equals(relSwitch)) +// .collect(Collectors.toList()); +// if (!routeService.isFlsCheckPass(fls)) { +// return new MovementAuthority.End(relSwitch, MovementAuthority.EndType.FAULT_SWITCH, previousSection); +// } +// } +// } +// } +// } +// return null; +// } +// +// private MovementAuthority.End checkClosedSection(Section section) { +// if (section.isClosed()) { +// return new MovementAuthority.End(section, MovementAuthority.EndType.CLOSED_SECTION); +// } +// return null; +// } +// +// private MovementAuthority.End checkEC(MapConfig config, Section section) { +// if (section.isNormalStandTrack()) { +// Station station = section.getStation(); +// if (config.isSharingECStation(station.getCode())) { +// for (Stand stand : station.getAllStandList()) { +// if (stand.isEmergencyClosed()) { +// return new MovementAuthority.End(stand, MovementAuthority.EndType.EC_STAND, section); +// } +// } +// } else { +// List standList = section.getStandList(); +// for (Stand stand : standList) { +// if (stand.isEmergencyClosed()) { +// return new MovementAuthority.End(stand, MovementAuthority.EndType.EC_STAND, section); +// } +// } +// } +// } +// return null; +// } +// +// private MovementAuthority.End checkUnlockedOverlap(Simulation simulation, Section section, boolean right) { +// SimulationDataRepository repository = simulation.getRepository(); +// // 判断是否已经办理进路的区段 +// Route route = null; +// if (section.isRouteLock()) { +// List settingRoutes = repository.getSettingRoutes(); +// for (Route settingRoute : settingRoutes) { +// if (settingRoute.isLastRouteSection(section)) { +// route = settingRoute; +// break; +// } +// } +// } +// if (Objects.nonNull(route) && repository.isOverlapNeedSetting(route)) { // 进路需要办理延续保护 +// RouteOverlap overlap = route.getOverlap(); +// if (!overlap.isLock()) { // 延续保护未锁闭 +// return new MovementAuthority.End(overlap, +// MovementAuthority.EndType.UNLOCKED_OVERLAP, overlap.getSection()); +// } +// } +// return null; +// } +// +// public void calculateMAOfITC(Simulation simulation, VirtualRealityTrain train) { +// // 查找移动授权终端列表 +// List endList = this.findItcMaEnd(train.getHeadPosition(), train.isRight()); +// if (CollectionUtils.isEmpty(endList)) { // 未找到授权终点 +// return; +// } +// // 根据查找到的授权终端,比较并构建最终的移动授权数据 +// MovementAuthority ma = this.compareAndBuildMa(train, endList); +// // 通知车载ATP +// this.onboardAtpApiService.updateMA4ITC(train, ma); +// } +// +// public MovementAuthority calculateMAOfITC(Simulation simulation, Responder responder) { +// // 查找移动授权终端列表 +// List endList = this.findItcMaEnd(responder.getPosition(), responder.getSignal().isRight()); +// if (CollectionUtils.isEmpty(endList)) { // 未找到授权终点 // return null; // } - // 先查询是否是已排列的锁闭进路 - List settingRoutes = repository.getSettingRoutes(); - boolean lock = false; - if (!CollectionUtils.isEmpty(settingRoutes)) { - for (Route route : settingRoutes) { - if (route.isRouteSection(section) -// && !route.isSetting() - ) { - Signal signal = section.getSignalOf(right); - if (route.isRight() == right || (signal == null || signal.isNormalOpen())) { - lock = true; - break; - } - } - } - } - if (!lock) { // 未找到锁闭进路,判断是否自动信号 - Section base = section; - int count = 0; - while (Objects.nonNull(base) && count < 20) { - ++count; - // 向反方向查找,找信号机,判断是否自动信号 - Section pre = base.getNextRunningSectionOf(!right); - if (Objects.nonNull(pre)) { - Signal signal = pre.getSignalOf(right); - if (Objects.nonNull(signal)) { - if (signal.isAutoSignal()) { - lock = true; // 如果是自动信号,也相当于锁闭 - } - break; // 找到信号机,结束 - } - } - base = pre; - } - } - if (!lock) { - // 未锁闭进路中,设置移动授权终点 - return new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION); - } - return null; - - +// // 根据查找到的授权终端,比较并构建最终的移动授权数据 +// MovementAuthority ma = this.compareAndBuildMa(responder.getSignal().isRight(), endList); +// // 通知车载ATP +// return ma; +// } +// +// private List findItcMaEnd(SectionPosition position, boolean right) { +// List endList = new ArrayList<>(); +// MovementAuthority.End deviceEnd = null; +// Section section = position.getSection(); +// int count = 0; +// while (Objects.nonNull(section) && count < 20) { +// if (count > 1 && !CollectionUtils.isEmpty(endList)) +// break; +// ++count; +// // 信号机 +// MovementAuthority.End signalEnd = checkGroundSignal(section, right); +// if (Objects.nonNull(signalEnd)) { +// endList.add(signalEnd); +//// deviceEnd = signalEnd; +// break; +// } +// // 轨道尽头/问题道岔 +// Section temp = section.getNextRunningSectionOf(right); +// if (Objects.isNull(temp)) { // 到尽头 +// if (!section.isSwitchTrack()) { // 问题道岔 +// endList.add(new MovementAuthority.End(section, +// MovementAuthority.EndType.END_TRACK)); +// } +// break; +// } +// } +// if (Objects.nonNull(deviceEnd)) { +// endList.add(deviceEnd); +// } +// return endList; +// } +// +// /** +// * 比较并构建移动授权数据 +// * +// * @param train +// * @param endList +// * @return +// */ +// private MovementAuthority compareAndBuildMa(VirtualRealityTrain train, List endList) { +// return compareAndBuildMa(train.isRight(), endList); +// } +// +// /** +// * 比较并构建移动授权数据 +// * +// * @param endList +// * @return +// */ +// private MovementAuthority compareAndBuildMa(boolean right, List endList) { +// MovementAuthority.End end = null; +// if (endList.size() == 1) { // 只有一个,直接构建移动授权 +// end = endList.get(0); +// } else { +// for (MovementAuthority.End temp : endList) { +// if (Objects.isNull(end)) { +// end = temp; +// } else { +// if (end.isAheadOf(temp, right)) { +// end = temp; +// } +// } +// } +// } +// BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(end); +// end.confirmEndPosition(right); +// return new MovementAuthority(end); +// } +// +// private VirtualRealityTrain queryFrontTrain(VirtualRealityTrain train, List trainList) { +// boolean right = train.isRight(); +// SectionPosition headPosition = train.getHeadPosition(); +// VirtualRealityTrain front = null; +// Float distance = null; +// for (VirtualRealityTrain other : trainList) { +// if (Objects.equals(other, train)) { +// continue; +// } +// SectionPosition otherTrainPosition; +// if (Objects.equals(right, other.isRight())) { +// // 同向列车,取车尾 +// otherTrainPosition = other.calculateTailPosition(); +// +// } else { +// // 反向列车,取车头 +// otherTrainPosition = other.getHeadPosition(); +// } +// Float tempDistance = CalculateService.calculateDistance(headPosition, otherTrainPosition, right); +// if (Objects.isNull(tempDistance) || tempDistance < 0) { +// // 未找到 +// continue; +// } else { +// if (Objects.isNull(front) || tempDistance < distance) { +// front = other; +// distance = tempDistance; +// } +// } +// } +//// if (Objects.nonNull(front)) { +//// log.debug(String.format("列车[%s-%s|%s|%s]前方列车为[%s-%s|%s|%s]", +//// train.getGroupNumber(), train.getServiceNumber(), +//// train.getTripNumber(), train.getDestinationCode(), +//// front.getGroupNumber(), front.getServiceNumber(), +//// front.getTripNumber(), front.getDestinationCode())); +//// } +// return front; +// } +// +// private MovementAuthority.End checkRouteLock(Simulation simulation, Section section, Section tailSection, boolean right, VirtualRealityTrain train) { +// if (section.isTransferTrack()) +// return null; // SimulationDataRepository repository = simulation.getRepository(); // // 判断前方是否有信号机(如果存在信号机,则不判断进路锁闭,以兼容现在列车加载到转换轨没有进路情况) -// if (section.isTransferTrack()) { -// return null; -// } //// Signal aheadSignal = section.getSignalOf(right); //// if (Objects.nonNull(aheadSignal)) { //// return null; @@ -550,21 +499,15 @@ public class ZCLogicLoop { // List settingRoutes = repository.getSettingRoutes(); // boolean lock = false; // if (!CollectionUtils.isEmpty(settingRoutes)) { -// boolean headRoute = false; -// boolean tailRoute = false; // for (Route route : settingRoutes) { -// if (route.isRight() == right && (route.isRouteSection(section) || route.isRouteSection(tailSection))) { -// if (route.isRouteSection(section)) -// headRoute = true; -// if (route.isRouteSection(tailSection)) -// tailRoute = true; -// lock = true; -// List switches = screenSwitchesInFront(route, tailSection); -// if (!this.checkRouteSwitchPosition(route, switches) || !this.isFlsCheckPass(route.getFlsList(), switches)) { -// return new MovementAuthority.End(section, MovementAuthority.EndType.ROUTE_INTERLOCK_NOT_MET); -// } -// if (headRoute && tailRoute) +// if (route.isRouteSection(section) +//// && !route.isSetting() +// ) { +// Signal signal = section.getSignalOf(right); +// if (route.isRight() == right || (signal == null || signal.isNormalOpen())) { +// lock = true; // break; +// } // } // } // } @@ -587,101 +530,158 @@ public class ZCLogicLoop { // base = pre; // } // } -// if (!lock && section.getSignalOf(right) == null) { +// if (!lock) { // // 未锁闭进路中,设置移动授权终点 // return new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION); // } // return null; - } - - private boolean checkRouteSwitchPosition(Route route, List switches) { - List collect = route.getSwitchList().stream() - .filter(element -> switches.contains(element.getASwitch())) - .collect(Collectors.toList()); - return routeService.checkRouteSwitchPosition(collect); - } - - private boolean isFlsCheckPass(List flsList, List switches) { - if (!CollectionUtils.isEmpty(flsList) && !CollectionUtils.isEmpty(switches)) { - List collect = flsList.stream().filter(fls -> switches.contains(fls.getBase().getASwitch())).collect(Collectors.toList()); - return routeService.isFlsCheckPass(collect); - } - return true; - } - - /** - * 筛选前方的道岔 - */ - private List screenSwitchesInFront(Route route, Section section) { - boolean right = route.isRight(); - List
sectionList = route.getSectionList(); - List sectionRelSwitches = new ArrayList<>(); - for (int i = 0; i < 10; i++) { - if (sectionList.contains(section)) - break; - else - section = section.getNextRunningSectionOf(right); - } - while (sectionList.contains(section)) { - if (section.getRelSwitch() != null) - sectionRelSwitches.add(section.getRelSwitch()); - section = section.getNextRunningSectionOf(right); - } - return sectionRelSwitches; - } - - /** - * 检查地面真实信号机是否未开放/故障信号机 - * - * @param section - * @param right - * @return - */ - private MovementAuthority.End checkGroundSignal(Section section, boolean right) { - Signal signal = section.getSignalOf(right); - if (Objects.nonNull(signal) && !signal.isVirtual() && !signal.isNormalOpen()) { - return new MovementAuthority.End(signal, - MovementAuthority.EndType.CLOSED_SIGNAL); - } - return null; - } - - /** - * 检查是否未开放/故障信号机 - * - * @param section - * @param right - * @return - */ - private MovementAuthority.End checkSignal(Section section, boolean right) { - Signal signal = section.getSignalOf(right); - if (Objects.nonNull(signal) && !signal.isNormalOpen()) { - return new MovementAuthority.End(signal, - MovementAuthority.EndType.CLOSED_SIGNAL); - } - return null; - } - - /** - * 检查是否站台屏蔽门开门 - */ - private MovementAuthority.End checkPsdOpenOrClose(Section section) { - if (section.isStandTrack()) { - List standList = section.getStandList(); - for (Stand stand : standList) { - if (!stand.isPsdSafe()) { - return new MovementAuthority.End(stand, MovementAuthority.EndType.OPENED_PSD, section); - } - if (stand.isClosed()) { - return new MovementAuthority.End(stand, MovementAuthority.EndType.CLOSED_STAND, section); - } - } - } - return null; - } - -// public void addJobs(Simulation simulation) { -//// simulation.addJob(SimulationModule.ZC.name(), () -> this.run(simulation), SimulationConstants.ZC_LOOP_RATE); -// simulation.addJob("MaCal", () -> this.maService.calculateMaOfCtcTrains(simulation), 1000); +// +// +//// SimulationDataRepository repository = simulation.getRepository(); +//// // 判断前方是否有信号机(如果存在信号机,则不判断进路锁闭,以兼容现在列车加载到转换轨没有进路情况) +//// if (section.isTransferTrack()) { +//// return null; +//// } +////// Signal aheadSignal = section.getSignalOf(right); +////// if (Objects.nonNull(aheadSignal)) { +////// return null; +////// } +//// // 先查询是否是已排列的锁闭进路 +//// List settingRoutes = repository.getSettingRoutes(); +//// boolean lock = false; +//// if (!CollectionUtils.isEmpty(settingRoutes)) { +//// boolean headRoute = false; +//// boolean tailRoute = false; +//// for (Route route : settingRoutes) { +//// if (route.isRight() == right && (route.isRouteSection(section) || route.isRouteSection(tailSection))) { +//// if (route.isRouteSection(section)) +//// headRoute = true; +//// if (route.isRouteSection(tailSection)) +//// tailRoute = true; +//// lock = true; +//// List switches = screenSwitchesInFront(route, tailSection); +//// if (!this.checkRouteSwitchPosition(route, switches) || !this.isFlsCheckPass(route.getFlsList(), switches)) { +//// return new MovementAuthority.End(section, MovementAuthority.EndType.ROUTE_INTERLOCK_NOT_MET); +//// } +//// if (headRoute && tailRoute) +//// break; +//// } +//// } +//// } +//// if (!lock) { // 未找到锁闭进路,判断是否自动信号 +//// Section base = section; +//// int count = 0; +//// while (Objects.nonNull(base) && count < 20) { +//// ++count; +//// // 向反方向查找,找信号机,判断是否自动信号 +//// Section pre = base.getNextRunningSectionOf(!right); +//// if (Objects.nonNull(pre)) { +//// Signal signal = pre.getSignalOf(right); +//// if (Objects.nonNull(signal)) { +//// if (signal.isAutoSignal()) { +//// lock = true; // 如果是自动信号,也相当于锁闭 +//// } +//// break; // 找到信号机,结束 +//// } +//// } +//// base = pre; +//// } +//// } +//// if (!lock && section.getSignalOf(right) == null) { +//// // 未锁闭进路中,设置移动授权终点 +//// return new MovementAuthority.End(section, MovementAuthority.EndType.UNLOCK_SECTION); +//// } +//// return null; // } -} +// +// private boolean checkRouteSwitchPosition(Route route, List switches) { +// List collect = route.getSwitchList().stream() +// .filter(element -> switches.contains(element.getASwitch())) +// .collect(Collectors.toList()); +// return routeService.checkRouteSwitchPosition(collect); +// } +// +// private boolean isFlsCheckPass(List flsList, List switches) { +// if (!CollectionUtils.isEmpty(flsList) && !CollectionUtils.isEmpty(switches)) { +// List collect = flsList.stream().filter(fls -> switches.contains(fls.getBase().getASwitch())).collect(Collectors.toList()); +// return routeService.isFlsCheckPass(collect); +// } +// return true; +// } +// +// /** +// * 筛选前方的道岔 +// */ +// private List screenSwitchesInFront(Route route, Section section) { +// boolean right = route.isRight(); +// List
sectionList = route.getSectionList(); +// List sectionRelSwitches = new ArrayList<>(); +// for (int i = 0; i < 10; i++) { +// if (sectionList.contains(section)) +// break; +// else +// section = section.getNextRunningSectionOf(right); +// } +// while (sectionList.contains(section)) { +// if (section.getRelSwitch() != null) +// sectionRelSwitches.add(section.getRelSwitch()); +// section = section.getNextRunningSectionOf(right); +// } +// return sectionRelSwitches; +// } +// +// /** +// * 检查地面真实信号机是否未开放/故障信号机 +// * +// * @param section +// * @param right +// * @return +// */ +// private MovementAuthority.End checkGroundSignal(Section section, boolean right) { +// Signal signal = section.getSignalOf(right); +// if (Objects.nonNull(signal) && !signal.isVirtual() && !signal.isNormalOpen()) { +// return new MovementAuthority.End(signal, +// MovementAuthority.EndType.CLOSED_SIGNAL); +// } +// return null; +// } +// +// /** +// * 检查是否未开放/故障信号机 +// * +// * @param section +// * @param right +// * @return +// */ +// private MovementAuthority.End checkSignal(Section section, boolean right) { +// Signal signal = section.getSignalOf(right); +// if (Objects.nonNull(signal) && !signal.isNormalOpen()) { +// return new MovementAuthority.End(signal, +// MovementAuthority.EndType.CLOSED_SIGNAL); +// } +// return null; +// } +// +// /** +// * 检查是否站台屏蔽门开门 +// */ +// private MovementAuthority.End checkPsdOpenOrClose(Section section) { +// if (section.isStandTrack()) { +// List standList = section.getStandList(); +// for (Stand stand : standList) { +// if (!stand.isPsdSafe()) { +// return new MovementAuthority.End(stand, MovementAuthority.EndType.OPENED_PSD, section); +// } +// if (stand.isClosed()) { +// return new MovementAuthority.End(stand, MovementAuthority.EndType.CLOSED_STAND, section); +// } +// } +// } +// return null; +// } +// +//// public void addJobs(Simulation simulation) { +////// simulation.addJob(SimulationModule.ZC.name(), () -> this.run(simulation), SimulationConstants.ZC_LOOP_RATE); +//// simulation.addJob("MaCal", () -> this.maService.calculateMaOfCtcTrains(simulation), 1000); +//// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSMessageCollectAndDispatcher.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSMessageCollectAndDispatcher.java index 1920cf138..7d96087f3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSMessageCollectAndDispatcher.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/ATSMessageCollectAndDispatcher.java @@ -10,7 +10,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.plan.RealRun; import club.joylink.rtss.simulation.cbtc.data.status.*; import club.joylink.rtss.simulation.cbtc.data.vo.*; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.event.SimulationOperationMessageEvent; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.vo.client.SocketMessageVO; @@ -39,93 +38,36 @@ public class ATSMessageCollectAndDispatcher { @Autowired private ApplicationContext applicationContext; - public void run(Simulation simulation) { -// long start = System.currentTimeMillis(); - this.trainTracking(simulation); - // 收集设备状态 - List filterList = this.collect(simulation); - if (CollectionUtils.isEmpty(filterList)) { - return; - } - // 构建并发送设备状态消息 - SocketMessageVO deviceStatusMessage = - SocketMessageFactory.build(WebSocketMessageType.Simulation_DeviceStatus, - simulation.getId(), filterList); - Set sessions = simulation.getSimulationUserIds(); -// System.out.println(String.format("发送用户数:[%s], 发送状态条数:[%s]", -// sessions.size(), filterList.size())); - this.stompMessageService.sendToUser(sessions, deviceStatusMessage); -// long end = System.currentTimeMillis(); -// System.out.println(String.format("收集并发送设备状态用时: [%s ms]", (end - start))); - } - - private void trainTracking(Simulation simulation) { - SimulationDataRepository repository = simulation.getRepository(); - List onlineTrainList = repository.getOnlineTrainList(); - onlineTrainList.forEach(train -> { - TrainInfo trainInfo = repository.findSupervisedTrainByGroup(train.getGroupNumber()); - if (Objects.nonNull(trainInfo)) { - trainInfo.tracking(train); - } - }); - } +// public void run(Simulation simulation) { +//// long start = System.currentTimeMillis(); +//// this.trainTracking(simulation); +// // 收集设备状态 +//// List filterList = this.collect(simulation); +//// if (CollectionUtils.isEmpty(filterList)) { +//// return; +//// } +//// // 构建并发送设备状态消息 +//// SocketMessageVO deviceStatusMessage = +//// SocketMessageFactory.build(WebSocketMessageType.Simulation_DeviceStatus, +//// simulation.getId(), filterList); +//// Set sessions = simulation.getSimulationUserIds(); +////// System.out.println(String.format("发送用户数:[%s], 发送状态条数:[%s]", +////// sessions.size(), filterList.size())); +//// this.stompMessageService.sendToUser(sessions, deviceStatusMessage); +//// long end = System.currentTimeMillis(); +//// System.out.println(String.format("收集并发送设备状态用时: [%s ms]", (end - start))); +// } /** - * 收集当前所有设备(除区段和道岔)状态 + * 收集仿真所有设备状态并发送给仿真用户 */ - private List collect(Simulation simulation) { - List totalList = new ArrayList<>(); - SimulationDataRepository repository = simulation.getRepository(); - Map deviceMap = repository.getDeviceMap(); - deviceMap.values().forEach(device -> { - if (Objects.equals(device.getDeviceType(), MapElement.DeviceType.SECTION) || - Objects.equals(device.getDeviceType(), MapElement.DeviceType.SWITCH)) { - return; - } - DeviceStatus deviceStatus = repository.findStatusByCode(device.getCode()); - if (Objects.isNull(deviceStatus)) { - deviceStatus = this.buildDeviceStatus(device); - if (Objects.nonNull(deviceStatus)) { - repository.addDeviceInfo(deviceStatus); - totalList.add(deviceStatus.convert2VO(device)); - } - } else { - DeviceStatusVO statusVO =this.buildDeviceStatusVO(device); - if (deviceStatus.compareAndChange(device,statusVO)) { - totalList.add(statusVO); - } - } - }); - // 列车状态 - List trainList = repository.getSuperviseTrainList(); - trainList.forEach(train -> { - TrainStatus trainStatus = repository.findStatusByCode(train.getGroupNumber(), TrainStatus.class); - if (Objects.isNull(trainStatus)) { - trainStatus = new TrainStatus(train); - repository.addDeviceInfo(trainStatus); - totalList.add(trainStatus.convert2VO(train)); - } else { - DeviceStatusVO statusVO = new TrainStatusVO(train); - if (trainStatus.compareAndChange(train,statusVO)) { - totalList.add(statusVO); - } - } - }); - // 回库删除的列车状态 - List inboundTrainList = new ArrayList<>(); - List trainStatusList = repository.getTrainStatusList(); - if (!CollectionUtils.isEmpty(trainStatusList)) { - for (TrainStatus trainStatus : trainStatusList) { - TrainInfo trainInfo = repository.findSupervisedTrainByGroup(trainStatus.getGroupNumber()); - if (Objects.isNull(trainInfo)) { - totalList.add(TrainStatusVO.buildDispose(trainStatus.getGroupNumber())); - inboundTrainList.add(trainStatus); - repository.deleteDeviceStatus(trainStatus.getCode()); - } - } - } - this.joylink3DMessageService.handleTrainInbound(simulation, inboundTrainList); - return totalList; + public void collectAllAndSend(Simulation simulation) { + List deviceStatuses = collectAll(simulation); + // 构建并发送设备状态消息 + SocketMessageVO> deviceStatusMessage = + SocketMessageFactory.buildSimulationDeviceStatusesMessage(simulation.getId(), deviceStatuses); + Set sessions = simulation.getSimulationUserIds(); + this.stompMessageService.sendToUser(sessions, deviceStatusMessage); } /** @@ -182,18 +124,6 @@ public class ATSMessageCollectAndDispatcher { return totalList; } - /** - * 收集仿真所有设备状态并发送给仿真用户 - */ - public void collectAllAndSend(Simulation simulation) { - List deviceStatuses = collectAll(simulation); - // 构建并发送设备状态消息 - SocketMessageVO> deviceStatusMessage = - SocketMessageFactory.buildSimulationDeviceStatusesMessage(simulation.getId(), deviceStatuses); - Set sessions = simulation.getSimulationUserIds(); - this.stompMessageService.sendToUser(sessions, deviceStatusMessage); - } - public void collectDeviceStatusAndSend(Simulation simulation, List deviceList) { if (!CollectionUtils.isEmpty(deviceList)) { List filterList = new ArrayList<>(); @@ -350,6 +280,6 @@ public class ATSMessageCollectAndDispatcher { public void addJobs(Simulation simulation) { simulation.addJob(SimulationModule.SYNC_TIME.name(), () -> this.syncTime(simulation), SimulationConstants.SYNC_TIME_RATE); - simulation.addFixedRateJob(SimulationModule.MESSAGE.name(), () -> this.run(simulation), SimulationConstants.SEND_CLIENT_RATE); + simulation.addFixedRateJob(SimulationModule.MESSAGE.name(), () -> this.collectAllAndSend(simulation), SimulationConstants.SEND_CLIENT_RATE); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/AtsApiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/AtsApiService.java index bdd23b938..15562c88b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/AtsApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/AtsApiService.java @@ -1,23 +1,20 @@ package club.joylink.rtss.simulation.cbtc.ATS; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.client.runplan.RunPlanServiceConfigVO; -import java.util.List; - /** * ATS系统接口 */ public interface AtsApiService { - /** - * 处理设备状态 - * @param simulation - * @param deviceList - */ - void handleDeviceStatus(Simulation simulation, List deviceList); +// /** +// * 处理设备状态 +// * @param simulation +// * @param deviceList +// */ +// void handleDeviceStatus(Simulation simulation, List deviceList); /** * 添加车次计划(加线) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/AtsApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/AtsApiServiceImpl.java index e6c8fdbbc..f7d557151 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/AtsApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/AtsApiServiceImpl.java @@ -4,7 +4,6 @@ import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.IRunPlanDraftService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.build.RunPlanBuilder; -import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.event.SimulationTripPlanChangeEvent; import club.joylink.rtss.util.JsonUtils; @@ -36,11 +35,11 @@ public class AtsApiServiceImpl implements AtsApiService { @Autowired private ApplicationContext applicationContext; - - @Override - public void handleDeviceStatus(Simulation simulation, List deviceList) { - this.atsMessageCollectAndDispatcher.collectDeviceStatusAndSend(simulation, deviceList); - } +// +// @Override +// public void handleDeviceStatus(Simulation simulation, List deviceList) { +// this.atsMessageCollectAndDispatcher.collectDeviceStatusAndSend(simulation, deviceList); +// } @Override public void addTripPlan(Simulation simulation, RunPlanServiceConfigVO serviceConfig, AccountVO user) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index 443bd727c..3e1869b16 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -157,8 +157,6 @@ public class Operation { Signal_Set_CI_Auto_Trigger(), /** 取消联锁自动触发 */ Signal_Cancel_CI_Auto_Trigger(), - /** 关闭进路引导信号 */ - Signal_Close_Guide, /** 设置自动折返进路 */ Signal_Set_Auto_Turn_Back, /** 取消自动折返进路 */ @@ -171,8 +169,6 @@ public class Operation { Signal_Cancel_Guide_Initialization, /** 办理引导 */ Signal_Set_Guide, - /** 取消引导 */ - Signal_Cancel_Guide, //--------------------------- 站台操作 --------------------------- /** 设置跳停 */ @@ -412,6 +408,10 @@ public class Operation { Driver_Change_Head, /** 列车车门开关 */ Driver_Door_On_Off, + /** 列车门模式 */ + Driver_Door_Mode, + /** 列车门选择 */ + Driver_Door_Selection, //--------------------------- 方向杆 --------------------------- /** 方向转换 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java index e04e6b107..6c0c4dce9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/DriverOperateHandler.java @@ -1,15 +1,11 @@ package club.joylink.rtss.simulation.cbtc.ATS.operation.handler; -import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService; -import club.joylink.rtss.simulation.cbtc.ATP.ground.ZCLogicLoop; 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.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.ControlGear; import club.joylink.rtss.simulation.cbtc.constant.DriveMode; -import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; @@ -18,7 +14,6 @@ import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import java.util.List; import java.util.Objects; /** @@ -34,12 +29,6 @@ public class DriverOperateHandler { @Autowired private ATPService ATPService; - @Autowired - private ZCLogicLoop zcLogicLoop; - - @Autowired - private GroundAtpApiService groundAtpApiService; - @OperateHandlerMapping(type = Operation.Type.Driver_Force_Change) public void changeTrainForce(Simulation simulation, String groupNumber, Float percent) { Objects.requireNonNull(percent); @@ -171,5 +160,33 @@ public class DriverOperateHandler { ATPService.openOrCloseDoor(simulation, train, right, open); } + /** + * 设置门模式 + * + * @param groupNumber 车组号 + */ + @OperateHandlerMapping(type = Operation.Type.Driver_Door_Mode) + public void setDriverDoorMode(Simulation simulation, String groupNumber, + VirtualRealityTrain.DoorMode doorMode) { + if (Objects.isNull(doorMode)) { + throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门模式不能为空"); + } + VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); + train.setDoorMode(doorMode); + } + /** + * 设置门选择 + * + * @param groupNumber 车组号 + */ + @OperateHandlerMapping(type = Operation.Type.Driver_Door_Selection) + public void setDriverDoorSelection(Simulation simulation, String groupNumber, + VirtualRealityTrain.DoorSelection doorSelection) { + if (Objects.isNull(doorSelection)) { + throw new SimulationException(SimulationExceptionType.Illegal_Argument, "门选择不能为空"); + } + VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber); + train.setDoorSelection(doorSelection); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SignalOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SignalOperateHandler.java index f8f719191..459aea039 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SignalOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SignalOperateHandler.java @@ -50,11 +50,10 @@ public class SignalOperateHandler { @OperateHandlerMapping(type = Operation.Type.Signal_Cancel_Route) public void cancelRoute(Simulation simulation, String signalCode) { //是否接近区段占用仍执行取消进路 - if (simulation.getRepository().getConfig().isSignalForceCancelRoute()) { - Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode); - if (Objects.nonNull(route)) { - this.ciApiService.forceUnlockRoute(simulation, route.getCode()); - } + Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode); + if (route != null && route.isApproachLock() && + simulation.getRepository().getConfig().isSignalForceCancelRoute()) { + this.ciApiService.humanCancel(simulation, route.getCode()); return; } this.atsRouteService.cancelRoute(simulation, signalCode); @@ -258,14 +257,6 @@ public class SignalOperateHandler { // this.iciSubsystem.openGuideSignalCheckRoute(simulation, signalCode); // } - /** - * 关闭进路引导信号 - */ - @OperateHandlerMapping(type = Operation.Type.Signal_Close_Guide) - public void closeGuide(Simulation simulation, String signalCode) { - this.ciApiService.closeGuideSignal(simulation, signalCode); - } - /** * 设置自动折返进路 */ @@ -314,11 +305,4 @@ public class SignalOperateHandler { ciApiService.setGuide(simulation, signalCode, routeCode); } - /** - * 取消引导 - */ - @OperateHandlerMapping(type = Operation.Type.Signal_Cancel_Guide) - public void cancelGuide(Simulation simulation, String signalCode, String routeCode) { - ciApiService.cancelGuide(simulation, signalCode); - } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java index bf709c5b0..941afe730 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/SwitchOperateHandler.java @@ -8,6 +8,7 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler import club.joylink.rtss.simulation.cbtc.ATS.service.AtsSectionService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; @@ -52,7 +53,7 @@ public class SwitchOperateHandler { throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭或占用,无法转动"); } - if (aSwitch.isNormalPosition()) { + if (aSwitch.isPosN()) { throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔已经在定位,无需转动"); } @@ -73,7 +74,7 @@ public class SwitchOperateHandler { throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭或占用,无法转动"); } - if (aSwitch.isReversePosition()) { + if (aSwitch.isPosR()) { throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔已经在反位,无需转动"); } @@ -256,14 +257,17 @@ public class SwitchOperateHandler { @OperateHandlerMapping(type = Operation.Type.Switch_Hook_Lock) public void switchHookLock(Simulation simulation, String switchCode, Boolean normal) { VirtualRealitySwitch vrSwitch = simulation.getRepository().getVRByCode(switchCode, VirtualRealitySwitch.class); - vrSwitch.setNormal(normal); - vrSwitch.setReverse(!normal); + if (normal) { + vrSwitch.setP(SwitchIndication.N); + } else { + vrSwitch.setP(SwitchIndication.R); + } } /** 强行转岔 */ @OperateHandlerMapping(type = Operation.Type.Switch_Force_Turn) public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) { - ciApiService.switchForceTurn(simulation, switchCode, normal); + ciApiService.switchForceTurn(simulation, switchCode); } /** 挤岔恢复 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/service/StandFaultService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/service/StandFaultService.java index 93a03d061..51be9ecb6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/service/StandFaultService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/service/StandFaultService.java @@ -2,13 +2,11 @@ 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.ControllableDevice; -import club.joylink.rtss.simulation.cbtc.communication.vo.PsdSwitch; import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo; import club.joylink.rtss.simulation.cbtc.data.map.MayOutOfOrderDevice; import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; -import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceFaultOverEvent; import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceFaultSetEvent; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; @@ -24,6 +22,8 @@ public class StandFaultService implements DeviceFaultService { @Autowired private ApplicationContext applicationContext; + @Autowired + private VirtualRealityDeviceService virtualRealityDeviceService; @Override public void setFault(Simulation simulation, MayOutOfOrderDevice device, FaultParam param) { @@ -35,15 +35,11 @@ public class StandFaultService implements DeviceFaultService { VirtualRealityScreenDoor vrPsd = ((Stand) device).getPsd().getVirtualScreenDoor(); switch (fault) { case PSD_CANNOT_BE_CLOSED:{ - ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, true); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.K); break; } case PSD_CANNOT_BE_OPENED:{ - ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, false); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.G); break; } } @@ -59,15 +55,11 @@ public class StandFaultService implements DeviceFaultService { VirtualRealityScreenDoor vrPsd = ((Stand) device).getPsd().getVirtualScreenDoor(); switch (fault) { case PSD_CANNOT_BE_CLOSED:{ - ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, !vrPsd.isSettingClose()); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.G); break; } case PSD_CANNOT_BE_OPENED: { - ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, vrPsd.isSettingOpen()); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.K); break; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteService.java index a08fce7b9..ea5fb5efc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsRouteService.java @@ -3,7 +3,7 @@ package club.joylink.rtss.simulation.cbtc.ATS.service; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; -import club.joylink.rtss.simulation.cbtc.CI.service.RouteService; +import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.Cycle; @@ -29,7 +29,7 @@ import java.util.stream.Collectors; public class AtsRouteService { @Autowired - private RouteService routeService; + private CiRouteService routeService; @Autowired private CiApiService ciApiService; @@ -146,7 +146,7 @@ public class AtsRouteService { collect = fltRoutes; } Route route = collect.get(0); - Route.CheckFailMessage message = routeService.setting(simulation, route); + Route.CheckFailMessage message = routeService.setRoute(simulation, route); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNull(message, route.debugStr() + "无法办理"); route.setFleetMode(true); } @@ -167,7 +167,7 @@ public class AtsRouteService { } lockedRoute.setFleetMode(false); if (simulation.getRepository().getConfig().isCancelRouteWhenCancelFlt()) { - routeService.cancelWithoutCheck(simulation, lockedRoute); + routeService.unlockRoute(simulation, lockedRoute); } } @@ -261,9 +261,7 @@ public class AtsRouteService { * 总取消 */ public void totalCancel(Simulation simulation, String signalCode) { -// if (cycleCode != null) { //如果是取消自动折返 -// this.cancelAutoTurnBack(simulation, cycleCode); -// } else { + // todo 总取消操作有很多种操作方式,对应不同的按钮,此处都用信号机编号可能不妥 Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); Route lockedRoute = signal.getLockedRoute(); if (lockedRoute == null) { @@ -271,46 +269,26 @@ public class AtsRouteService { String.format("信号机[%s(%s)]没有已锁闭进路,无需取消进路", signal.getName(), signal.getCode())); } if (!signal.isApproachLock()) { //当接近区段未被占用 - if (signal.isGuideOpen()) { //如果引导信号开启中 - this.ciApiService.closeGuideSignal(simulation, signalCode); - } else { - this.cancelRoute(simulation, signalCode); -// this.ciApiService.cancelFleetRoute(simulation, signalCode); - } + this.cancelRoute(simulation, signalCode); } else { -// boolean trainStop = true; -// for (TrainStatus trainStatus : approachTrainList) { -// if (trainStatus.getSpeed() != 0) { -// trainStop = false; -// break; -// } -// } -// if (!trainStop) { //如果占用接近区段的列车没停稳 -// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, -// String.format("进路[%s(%s)]接近区段列车没停稳", lockedRoute.getName(), lockedRoute.getCode())); -// } - if (signal.isGuideOpen()) { //如果引导信号开启中 - this.ciApiService.closeGuideSignal(simulation, signalCode); - } else if (signal.isClose()) { //如果信号灯关了 - routeService.cancelWithoutCheck(simulation, lockedRoute); - this.ciApiService.cancelFleetRoute(simulation, lockedRoute.getCode()); - } else { - this.ciApiService.closeSignal(simulation, signalCode); - } + this.routeService.unlockRoute(simulation, lockedRoute); + this.ciApiService.cancelFleetRoute(simulation, lockedRoute.getCode()); +// if (signal.isGuideAspect()) { //如果引导信号开启中 +// this.ciApiService.closeGuideSignal(simulation, signalCode); +// } else if (signal.isClose()) { //如果信号灯关了 +// } else { +// this.ciApiService.closeSignal(simulation, signalCode); +// } } -// } - - } public void cancelRoute(Simulation simulation, String signalCode) { Route route = this.ciApiService.findLockedRouteByStartSignal(simulation, signalCode); if (Objects.nonNull(route)) { - SimulationDataRepository repository = simulation.getRepository(); BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotTrue( - routeService.isApproachLock(repository, route), "进路接近锁闭,无法取消"); + route.isApproachLock(), "进路接近锁闭,无法取消"); BusinessExceptionAssertEnum.OPERATION_FAIL.assertNotTrue( - route.getStart().isGuideOpen(), "引导进路,需要人解进路"); + route.getStart().isGuideAspect(), "引导进路,需要人解进路"); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFleetMode(), String.format("进路[%s]已开启自动通过进路,无法取消", route.debugStr())); this.ciApiService.unlockRoute(simulation, route.getCode()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java index 95766c069..fde15969d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java @@ -11,7 +11,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.status.StationStatus; import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption; import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; @@ -371,15 +370,16 @@ public class AtsStationService { List signalList = simulation.getRepository().getSignalList().stream() .filter(signal -> station.equals(signal.getInterlockStation())).collect(Collectors.toList()); BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(signalList, station.debugStr() + "下无信号机"); + // todo 信号显示变为aspect一个字段,此处逻辑不再适用 if (!signalList.get(0).isForcePhysical()) { - signalList.forEach(signal -> { - VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); - if (virtualSignal != null) { - virtualSignal.apply(signal.isGreenOpen(), signal.isYellowOpen(), signal.isRedOpen()); - } - signal.changeLightType(false); - signal.setForcePhysical(true); - }); +// signalList.forEach(signal -> { +// VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); +// if (virtualSignal != null) { +// virtualSignal.apply(signal.isGreenOpen(), signal.isYellowOpen(), signal.isRedOpen()); +// } +// signal.changeLightType(false); +// signal.setForcePhysical(true); +// }); } else { signalList.forEach(signal -> signal.setForcePhysical(false)); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java index a503f16aa..234f5079f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainLoadService.java @@ -2,8 +2,7 @@ package club.joylink.rtss.simulation.cbtc.ATS.service; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService; -import club.joylink.rtss.simulation.cbtc.CI.CILogicLoop; -import club.joylink.rtss.simulation.cbtc.CI.service.RouteService; +import club.joylink.rtss.simulation.cbtc.CI.CiLogic; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService; import club.joylink.rtss.simulation.cbtc.constant.RunLevel; @@ -51,14 +50,11 @@ public class AtsTrainLoadService { @Autowired private DeviceStatusModifyTool deviceStatusModifyTool; - @Autowired - private RouteService routeService; - @Autowired private VRDeviceLogicLoop vrDeviceLogicLoop; @Autowired - private CILogicLoop ciLogicLoop; + private CiLogic ciLogic; @Autowired private AtsTrainMonitorService atsTrainMonitorService; @Autowired @@ -409,12 +405,10 @@ public class AtsTrainLoadService { // this.updateTrainSpeed(simulation); // 更新列车占用计轴区段 this.vrDeviceLogicLoop.updateTrainOccupySection(simulation); - // 计轴占用处理 - this.ciLogicLoop.getStatusFromVRDevice(simulation); + // 联锁相关逻辑 + this.ciLogic.run(simulation); // ATS监控逻辑 this.atsTrainMonitorService.monitor(simulation); - // 进路解锁逻辑 - this.ciLogicLoop.routeLogic(simulation); MapConfig config = simulation.getRepository().getConfig(); if (RunLevel.ITC.equals(config.getRunMode())) { for (VirtualRealityTrain train : simulation.getRepository().getAllVrTrain()) { @@ -607,9 +601,9 @@ public class AtsTrainLoadService { // 排列好进路 this.deviceStatusModifyTool.openRouteDirect(simulation, route); // 进路设置为正常解锁 - this.routeService.normalUnlockStart(simulation, route); - // 根据列车位置直接进路正常解锁 - this.deviceStatusModifyTool.routeUnlockByEndSection(route, tailPosition.getSection()); + this.ciLogic.trainUnlockStart(simulation, route); +// // 根据列车位置直接进路正常解锁 +// this.deviceStatusModifyTool.routeUnlockByEndSection(route, tailPosition.getSection()); break; } } @@ -621,7 +615,7 @@ public class AtsTrainLoadService { SimulationDataRepository repository = simulation.getRepository(); int loadedNum = 0; for (TrainLoadParam2 trainLoadParam2 : trainLoadList) { - if (loadedNum > num) { + if (loadedNum == num) { break; } TripPlan tripPlan = trainLoadParam2.getTripPlan(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java index 81f0427b6..587e0738d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainMonitorService.java @@ -3,7 +3,6 @@ package club.joylink.rtss.simulation.cbtc.ATS.service; import club.joylink.rtss.simulation.cbtc.ATS.service.ars.AtsTriggerRouteService; import club.joylink.rtss.simulation.cbtc.ATS.service.stage.AtsRealRunRecordService; import club.joylink.rtss.simulation.cbtc.ATS.service.stage.AtsTrainStageHandler; -import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; @@ -41,8 +40,6 @@ public class AtsTrainMonitorService { private AtsStandService atsStandService; @Autowired private OnboardAtpApiService onboardAtpApiService; - @Autowired - private CiApiService ciApiService; /** * 列车监控逻辑 @@ -113,7 +110,6 @@ public class AtsTrainMonitorService { // 停车点停车 this.trainParking(simulation, trainInfo, headSection.getStation(), headSection); this.onboardAtpApiService.parkingInPlace(simulation, vrTrain, headSection); - this.ciApiService.handleTrainStopMessage(simulation, vrTrain); } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java index b40f715e8..bb37613c3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsTrainService.java @@ -419,11 +419,11 @@ public class AtsTrainService { } // 站台停靠 Signal tdSignal = headSection.getSignalOf(trainRight); // 列车方向信号机 - if (Objects.nonNull(tdSignal) && tdSignal.isNormalOpen()) { + if (Objects.nonNull(tdSignal) && tdSignal.isMainAspect()) { base = headSection.getNextRunningSectionOf(trainRight); } else { Signal trdSignal = headSection.getSignalOf(!trainRight); - if (Objects.nonNull(trdSignal) && trdSignal.isNormalOpen()) { + if (Objects.nonNull(trdSignal) && trdSignal.isMainAspect()) { right = !trainRight; base = headSection.getNextRunningSectionOf(right); } @@ -431,7 +431,7 @@ public class AtsTrainService { } else if (stop) { // 列车停车中 Signal trdSignal = headSection.getSignalOf(!trainRight); - if (Objects.nonNull(trdSignal) && trdSignal.isNormalOpen()) { + if (Objects.nonNull(trdSignal) && trdSignal.isMainAspect()) { right = !trainRight; } if (headSection.isNormalStandTrack() || headSection.isTransferTrack()) { @@ -449,7 +449,7 @@ public class AtsTrainService { break; } Signal signal = base.getSignalOf(right); - if (Objects.nonNull(signal) && !signal.isNormalOpen()) { + if (Objects.nonNull(signal) && !signal.isMainAspect()) { nextTarget = base; break; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsPlanTrainRouteSelectServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsPlanTrainRouteSelectServiceImpl.java index ee6f683cd..e7629a677 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsPlanTrainRouteSelectServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsPlanTrainRouteSelectServiceImpl.java @@ -4,17 +4,17 @@ import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; import club.joylink.rtss.simulation.cbtc.ATS.service.alarm.AtsAlarmService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; -import club.joylink.rtss.simulation.cbtc.data.map.*; +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.SwitchElement; import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan; import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; -import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; import java.time.LocalDateTime; import java.time.LocalTime; @@ -337,7 +337,7 @@ public class AtsPlanTrainRouteSelectServiceImpl extends AtsRouteSelectService { Map atsTriggerRouteMap = aheadTrain.getAtsTriggerRouteMap(); if (!atsTriggerRouteMap.isEmpty()) { for (Route triggerRoute : atsTriggerRouteMap.values()) { - if (triggerRoute.isConflictWith(route) && (triggerRoute.isSetting() || triggerRoute.isOpen())) { + if (triggerRoute.isConflictWith(route) && (triggerRoute.isSetting() || triggerRoute.isOpenMain())) { return false; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsRouteSelectService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsRouteSelectService.java index ce312d7d0..b81ebe977 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsRouteSelectService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsRouteSelectService.java @@ -1,7 +1,7 @@ package club.joylink.rtss.simulation.cbtc.ATS.service.ars; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.simulation.cbtc.CI.service.RouteService; +import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.*; @@ -144,7 +144,7 @@ public abstract class AtsRouteSelectService { } } if (route != null) { - Route.CheckFailMessage check = RouteService.check(simulation, route); + Route.CheckFailMessage check = CiRouteService.routeSetCheck(simulation, route); if (check != null) route = null; } @@ -188,7 +188,7 @@ public abstract class AtsRouteSelectService { } if (signal.hasCiAutoTriggerRoute() || signal.hasFleetModeRoute() || signal.hasNotAtsControlRoute()) { // 以此信号机为始端存在联锁自动进路或联锁自动触发进路或非ATS自动控制进路 // 如果信号机正常开放,且进路是路径方向上的进路,继续找,否则返回 - if (signal.isNormalOpen()) { + if (signal.isMainAspect()) { Route lockedRoute = signal.getLockedRoute(); if (routePath.isPathRoute(lockedRoute)) { continue; @@ -201,7 +201,7 @@ public abstract class AtsRouteSelectService { } if (this.isApproachSignal(repository, trainInfo, signal)) { // 是信号机接近区段 - if (signal.isNormalOpen()) { + if (signal.isMainAspect()) { if (routePath.isPathRoute(signal.getLockedRoute())) { continue; } else { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsTriggerRouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsTriggerRouteService.java index cb231a649..b8e17b2ce 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsTriggerRouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/ars/AtsTriggerRouteService.java @@ -72,7 +72,7 @@ public class AtsTriggerRouteService { return true; } if (route.getConflictAlarm() != null) { - if (route.isOpen()) { + if (route.isOpenMain()) { route.getConflictAlarm().recover(simulation.getCorrectSystemTime()); route.setConflictAlarm(null); continue; @@ -90,7 +90,7 @@ public class AtsTriggerRouteService { } } } - if (!route.isOpen()) { // 存在未开放的进路,直接返回 + if (!route.isOpenMain()) { // 存在未开放的进路,直接返回 if (!route.isSetting()) { // 进路未办理,继续尝试办理 this.trySetRoute(simulation, trainInfo, route); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsPlanTrainStageService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsPlanTrainStageService.java index bc783a457..f37467a5f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsPlanTrainStageService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/stage/AtsPlanTrainStageService.java @@ -125,7 +125,7 @@ public class AtsPlanTrainStageService implements AtsStageService { log.debug(String.format("列车[%s]折返初始化", trainInfo.getGroupNumber())); List routePaths = repository.getRoutePaths(parkSection, tripPlan.getEndSection()); Signal signal = parkSection.getSignalOf(routePaths.get(0).isRight()); - if (signal.isNormalOpen() || signal.isGuideOpen()) { + if (signal.isMainAspect() || signal.isGuideAspect()) { Route lockedRoute = signal.getLockedRoute(); if (lockedRoute != null && lockedRoute.getLastRouteSection().isTurnBackTrack()) { trainInfo.turnBackInit(lockedRoute.getLastRouteSection()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java index d5fb5b734..667fdacf1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CILogicLoop.java @@ -1,385 +1,385 @@ -package club.joylink.rtss.simulation.cbtc.CI; - -import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService; -import club.joylink.rtss.simulation.cbtc.ATS.AtsApiService; -import club.joylink.rtss.simulation.cbtc.CI.service.*; -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; -import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; -import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; -import club.joylink.rtss.simulation.cbtc.data.map.*; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.List; - -/** - * CI主线逻辑循环 - */ -@Slf4j -@Component -public class CILogicLoop { - - @Autowired - private RouteService routeService; - - @Autowired - private AutoSignalService autoSignalService; - - @Autowired - private SectionService sectionService; - - @Autowired - private SignalService signalService; - - @Autowired - private SwitchService switchService; - - @Autowired - private GroundAtpApiService groundAtpApiService; - - @Autowired - private AtsApiService atsApiService; - - public void run(Simulation simulation) { -// long start = System.currentTimeMillis(); - // 设备状态采集(从虚拟真实设备采集) - this.getStatusFromVRDevice(simulation); - // 进路逻辑 - this.routeLogic(simulation); - - // 自动信号逻辑 - this.autoSignalLogic(simulation); - - // 延时解锁设备逻辑 - this.deviceDelayUnlockLogic(simulation); - -// long end = System.currentTimeMillis(); -// System.out.println(String.format("------------CI逻辑耗时: %s ms", (end-start))); - } - - private void autoSignalLogic(Simulation simulation) { - List autoSignalList = simulation.getRepository().getAutoSignalList(); - if (!CollectionUtils.isEmpty(autoSignalList)) { - autoSignalList.forEach(autoSignal -> - this.autoSignalService.updateSignalDisplay(simulation, autoSignal)); - } - } - - private void deviceDelayUnlockLogic(Simulation simulation) { - SimulationDataRepository repository = simulation.getRepository(); - List
sectionList = repository.getSectionList(); - for (Section section : sectionList) { - this.sectionService.delayUnlock(simulation, section); - } - List switchList = repository.getSwitchList(); - for (Switch aSwitch : switchList) { - this.switchService.delayUnlock(simulation, aSwitch); - } - } - - /** - * 从虚拟真实设备采集状态 - * - * @param simulation - */ - public void getStatusFromVRDevice(Simulation simulation) { - SimulationDataRepository repository = simulation.getRepository(); - List signalList = getSignalsStatusFromVRDevice(simulation); - List switchList = getSwitchesStatusFromVRDevice(repository); - getSectionsStatusFromVRDevice(repository); - getPsdStatusFromVRDevice(repository); - // 道岔状态发送ATS - this.atsApiService.handleDeviceStatus(simulation, signalList); - this.atsApiService.handleDeviceStatus(simulation, switchList); - - // 计轴区段状态发送地面ATP - this.groundAtpApiService.receiveAndHandleAxleSectionStatus(simulation); - } - - - /** - * 进路相关逻辑 - */ - public void routeLogic(Simulation simulation) { - SimulationDataRepository repository = simulation.getRepository(); - List routeList = repository.getRouteList(); - for (Route route : routeList) { - //联锁机故障逻辑 - Station deviceStation = route.getStart().getDeviceStation(); - if (deviceStation != null) { - if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { - continue; - } - } -// Route.CheckFailMessage result = this.routeService.check(simulation, route); -// if (Objects.nonNull(result)) { -// route.setSettable(false); +//package club.joylink.rtss.simulation.cbtc.CI; +// +//import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService; +//import club.joylink.rtss.simulation.cbtc.ATS.AtsApiService; +//import club.joylink.rtss.simulation.cbtc.CI.service.*; +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; +//import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; +//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +//import club.joylink.rtss.simulation.cbtc.data.map.*; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import java.util.List; +// +///** +// * CI主线逻辑循环 +// */ +//@Slf4j +//@Component +//public class CILogicLoop { +// +// @Autowired +// private RouteService routeService; +// +// @Autowired +// private AutoSignalService autoSignalService; +// +// @Autowired +// private SectionService sectionService; +// +// @Autowired +// private SignalService signalService; +// +// @Autowired +// private SwitchService switchService; +// +// @Autowired +// private GroundAtpApiService groundAtpApiService; +// +// @Autowired +// private AtsApiService atsApiService; +// +// public void run(Simulation simulation) { +//// long start = System.currentTimeMillis(); +// // 设备状态采集(从虚拟真实设备采集) +// this.getStatusFromVRDevice(simulation); +// // 进路逻辑 +// this.routeLogic(simulation); +// +// // 自动信号逻辑 +// this.autoSignalLogic(simulation); +// +// // 延时解锁设备逻辑 +// this.deviceDelayUnlockLogic(simulation); +// +//// long end = System.currentTimeMillis(); +//// System.out.println(String.format("------------CI逻辑耗时: %s ms", (end-start))); +// } +// +// private void autoSignalLogic(Simulation simulation) { +// List autoSignalList = simulation.getRepository().getAutoSignalList(); +// if (!CollectionUtils.isEmpty(autoSignalList)) { +// autoSignalList.forEach(autoSignal -> +// this.autoSignalService.updateSignalDisplay(simulation, autoSignal)); +// } +// } +// +// private void deviceDelayUnlockLogic(Simulation simulation) { +// SimulationDataRepository repository = simulation.getRepository(); +// List
sectionList = repository.getSectionList(); +// for (Section section : sectionList) { +// this.sectionService.delayUnlock(simulation, section); +// } +// List switchList = repository.getSwitchList(); +// for (Switch aSwitch : switchList) { +// this.switchService.delayUnlock(simulation, aSwitch); +// } +// } +// +// /** +// * 从虚拟真实设备采集状态 +// * +// * @param simulation +// */ +// public void getStatusFromVRDevice(Simulation simulation) { +// SimulationDataRepository repository = simulation.getRepository(); +// List signalList = getSignalsStatusFromVRDevice(simulation); +// List switchList = getSwitchesStatusFromVRDevice(repository); +// getSectionsStatusFromVRDevice(repository); +// getPsdStatusFromVRDevice(repository); +// // 道岔状态发送ATS +// this.atsApiService.handleDeviceStatus(simulation, signalList); +// this.atsApiService.handleDeviceStatus(simulation, switchList); +// +// // 计轴区段状态发送地面ATP +// this.groundAtpApiService.receiveAndHandleAxleSectionStatus(simulation); +// } +// +// +// /** +// * 进路相关逻辑 +// */ +// public void routeLogic(Simulation simulation) { +// SimulationDataRepository repository = simulation.getRepository(); +// List routeList = repository.getRouteList(); +// for (Route route : routeList) { +// //联锁机故障逻辑 +// Station deviceStation = route.getStart().getDeviceStation(); +// if (deviceStation != null) { +// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { +// continue; +// } +// } +//// Route.CheckFailMessage result = this.routeService.check(simulation, route); +//// if (Objects.nonNull(result)) { +//// route.setSettable(false); +//// } else { +//// route.setSettable(true); +//// } +// // 联锁自动触发判断处理 +// if (route.isCiControl() && !repository.isSettingRoute(route) && +// !route.isNormalUnlock() && route.isCiTrigger()) { +// this.routeService.setting(simulation, route); +// } +// } +// List settingRoutes = repository.getSettingRoutes(); +// if (!CollectionUtils.isEmpty(settingRoutes)) { +// // 获取所有列车方向速度位置信息用以解锁进路 +// for (Route route : settingRoutes) { +// //联锁机故障逻辑 +// Station deviceStation = route.getStart().getDeviceStation(); +// if (deviceStation != null) { +// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { +// continue; +// } +// } +// +// if (route.isNormalUnlock()) { // 进路锁闭,若进路内存在列车,执行正常解锁 +// this.routeService.normalUnlock(simulation, route); +// } +// if (route.isSetting()) { // 进路排列过程 +// this.routeService.settingProgress(simulation, route); +// } +// if (route.isDelayUnlocking()) { // 进路延时解锁过程 +// this.routeService.humanCancelProgress(simulation, route); +// } +// if (route.isLock()) { // 进路信号开放,始终检查联锁条件是否满足 +// this.routeService.lockedRouteCheck(simulation, route); +// } +//// if (route.isLock()) { +// // 进路第一个区段是否占用 +//// Section firstRouteSection = route.getFirstRouteLogicSection(); +//// if (firstRouteSection.isRouteLock() && +//// firstRouteSection.isOccupied()) { +//// route.getStart().setReblockade(true); +//// log.debug(String.format("[%s]因[%s]第一个子区段[%s]进路锁闭且占用而重复封锁", +//// route.getStart().debugStr(), route.debugStr(), firstRouteSection.debugStr())); +//// } +//// if (route.isOpen() && !firstRouteSection.isOccupied()) { +//// route.getStart().setReblockade(false); +//// } +//// } +//// else if (route.isLock() && !route.isNormalUnlock() && !route.isOpen()) { +//// this.routeService.openedRouteCheck(simulation, route); +//// } +// } +// } +// // 延续保护进路解锁 +// List overlapList = repository.getListByType(MapElement.DeviceType.OVERLAP, RouteOverlap.class); +// for (RouteOverlap overlap : overlapList) { +// if (overlap.isLock()) {// 延续保护已锁闭 +// this.routeService.overlapUnlock(simulation, overlap); +// this.routeService.overlapCancelLock(overlap); // } else { -// route.setSettable(true); +// // 延续保护锁闭禁止条件释放 +// this.routeService.checkAndAllowOverlap(simulation, overlap); // } - // 联锁自动触发判断处理 - if (route.isCiControl() && !repository.isSettingRoute(route) && - !route.isNormalUnlock() && route.isCiTrigger()) { - this.routeService.setting(simulation, route); - } - } - List settingRoutes = repository.getSettingRoutes(); - if (!CollectionUtils.isEmpty(settingRoutes)) { - // 获取所有列车方向速度位置信息用以解锁进路 - for (Route route : settingRoutes) { - //联锁机故障逻辑 - Station deviceStation = route.getStart().getDeviceStation(); - if (deviceStation != null) { - if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { - continue; - } - } - - if (route.isNormalUnlock()) { // 进路锁闭,若进路内存在列车,执行正常解锁 - this.routeService.normalUnlock(simulation, route); - } - if (route.isSetting()) { // 进路排列过程 - this.routeService.settingProgress(simulation, route); - } - if (route.isDelayUnlocking()) { // 进路延时解锁过程 - this.routeService.humanCancelProgress(simulation, route); - } - if (route.isLock()) { // 进路信号开放,始终检查联锁条件是否满足 - this.routeService.lockedRouteCheck(simulation, route); - } -// if (route.isLock()) { - // 进路第一个区段是否占用 -// Section firstRouteSection = route.getFirstRouteLogicSection(); -// if (firstRouteSection.isRouteLock() && -// firstRouteSection.isOccupied()) { -// route.getStart().setReblockade(true); -// log.debug(String.format("[%s]因[%s]第一个子区段[%s]进路锁闭且占用而重复封锁", -// route.getStart().debugStr(), route.debugStr(), firstRouteSection.debugStr())); +// if (overlap.isSetting()) { // 延续保护办理中 +// this.routeService.overlapSettingProcess(simulation, overlap); +// } +// } +// // 延续保护触发 +// if (repository.getConfig().isOverlapSettingByTrigger()) { +// for (RouteOverlap overlap : overlapList) { +// this.routeService.checkLockOverlap(simulation, overlap); +// } +// } +// } +// +// /** +// * 从真实设置获取屏蔽门的状态 +// */ +// private void getPsdStatusFromVRDevice(SimulationDataRepository repository) { +// // 站台屏蔽门开关门等状态 +// List psdList = repository.getListByType(MapElement.DeviceType.PSD, PSD.class); +// psdList.forEach(psd -> { +// //联锁机故障 +// Stand stand = psd.getStand(); +// Station deviceStation = stand.getDeviceStation(); +// if (deviceStation != null) { +// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { +// stand.setNoStatus(true); +// psd.setNoStatus(true); +// return; +// } else { +// stand.setNoStatus(false); +// psd.setNoStatus(false); +// } +// if (deviceStation.isInterlockMachineStarting()) +// return; +// } else { +// stand.setNoStatus(false); +// psd.setNoStatus(false); +// } +// +// VirtualRealityScreenDoor vrScreenDoor = psd.getVirtualScreenDoor(); +// psd.apply(vrScreenDoor.isClose(), vrScreenDoor.isLock(), vrScreenDoor.isInterlockRelease()); +// }); +// } +// +// /** +// * 更新区段逻辑 +// */ +// private void getSectionsStatusFromVRDevice(SimulationDataRepository repository) { +// // 区段占用 +// List
axleSectionList = repository.getAxleSectionList(); +// axleSectionList.forEach(section -> { +// //联锁机故障 +// boolean interlockMachineFault = false; +// boolean interlockMachineStarting = false; +// Station deviceStation = section.getDeviceStation(); +// if (deviceStation != null) { +// if (deviceStation.isInterlockMachineStarting()) +// interlockMachineStarting = true; +// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) +// interlockMachineFault = true; +// } +// if (interlockMachineFault) { +// section.setNoStatus(true); +// if (section.isSwitchAxleCounterSection()) { +// section.getLogicList().forEach(switchSection -> switchSection.setNoStatus(true)); +// } +// } else { +// section.setNoStatus(false); +// if (section.isSwitchAxleCounterSection()) { +// section.getLogicList().forEach(switchSection -> switchSection.setNoStatus(false)); +// } +// } +// if (interlockMachineStarting) +// return; +//// if (section.isInvalid() && section.isFault()) { +//// section.setNctOccupied(false); +//// return; +//// } +//// if (section.isFault()) { +//// section.setNctOccupied(true); +//// return; +//// } +// if (Section.AxleFault.UNABLE_COLLECT_STATUS.equals(section.getFault())) +// return; +// VirtualRealitySectionAxleCounter virtualAxleCounter = section.getVirtualAxleCounter(); +// //更新区段故障状态 +// if (!VirtualRealitySectionAxleCounter.Fault.FAULT.equals(virtualAxleCounter.getFault())) { +// if (Section.AxleFault.FAULT.equals(section.getFault())){ +// section.setFault(null); +// } +// } +// //更新区段占用状态 +// if (virtualAxleCounter.isOccupy()) { +// section.axleCounterOccupy(virtualAxleCounter.isRight()); +// } else { +// section.clearOccupy(); +// section.judgeAsValid(); +// } +// //预复位 +// if (!virtualAxleCounter.isPreReset()) { +// List switchList = section.getRelSwitchList(); +// if (!CollectionUtils.isEmpty(switchList)) { +// switchList.forEach(aSwitch -> aSwitch.setPreReset(false)); +// } +// } +// }); +// } +// +// /** +// * 从真实设备获取道岔状态 +// */ +// private List getSwitchesStatusFromVRDevice(SimulationDataRepository repository) { +// // 道岔位置状态 +// List switchList = repository.getListByType(MapElement.DeviceType.SWITCH, Switch.class); +// switchList.forEach(aSwitch -> { +// //联锁机故障逻辑 +// Station deviceStation = aSwitch.getDeviceStation(); +// if (deviceStation != null) { +// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { +// aSwitch.setNoStatus(true); +// return; +// } else { +// aSwitch.setNoStatus(false); +// } +// if (deviceStation.isInterlockMachineStarting()) +// return; +// } else { +// aSwitch.setNoStatus(false); +// } +// +// Switch.SwitchFault fault = (Switch.SwitchFault) aSwitch.getFault(); +// if (fault != null) { +// switch (fault) { +// case SPLIT: +// case SQUEEZE: +// break; +// case NORMAL_SPLIT: { +// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); +// aSwitch.apply(false, virtualSwitch.isReverse()); +// break; // } -// if (route.isOpen() && !firstRouteSection.isOccupied()) { -// route.getStart().setReblockade(false); +// case REVERSE_SPLIT: { +// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); +// aSwitch.apply(virtualSwitch.isNormal(), false); +// break; // } // } -// else if (route.isLock() && !route.isNormalUnlock() && !route.isOpen()) { -// this.routeService.openedRouteCheck(simulation, route); +// } else { +// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); +// aSwitch.apply(virtualSwitch.isNormal(), virtualSwitch.isReverse()); +// } +// }); +// return switchList; +// } +// +// /** +// * 从真实设备获取信号机状态 +// */ +// private List getSignalsStatusFromVRDevice(Simulation simulation) { +// SimulationDataRepository repository = simulation.getRepository(); +// List signalList = repository.getSignalList(); +// for (Signal signal : signalList) { +// //联锁机故障逻辑 +// Station deviceStation = signal.getDeviceStation(); +// if (deviceStation != null) { +// if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { +// signal.setNoStatus(true); +// continue; +// } else { +// signal.setNoStatus(false); // } - } - } - // 延续保护进路解锁 - List overlapList = repository.getListByType(MapElement.DeviceType.OVERLAP, RouteOverlap.class); - for (RouteOverlap overlap : overlapList) { - if (overlap.isLock()) {// 延续保护已锁闭 - this.routeService.overlapUnlock(simulation, overlap); - this.routeService.overlapCancelLock(overlap); - } else { - // 延续保护锁闭禁止条件释放 - this.routeService.checkAndAllowOverlap(simulation, overlap); - } - if (overlap.isSetting()) { // 延续保护办理中 - this.routeService.overlapSettingProcess(simulation, overlap); - } - } - // 延续保护触发 - if (repository.getConfig().isOverlapSettingByTrigger()) { - for (RouteOverlap overlap : overlapList) { - this.routeService.checkLockOverlap(simulation, overlap); - } - } - } - - /** - * 从真实设置获取屏蔽门的状态 - */ - private void getPsdStatusFromVRDevice(SimulationDataRepository repository) { - // 站台屏蔽门开关门等状态 - List psdList = repository.getListByType(MapElement.DeviceType.PSD, PSD.class); - psdList.forEach(psd -> { - //联锁机故障 - Stand stand = psd.getStand(); - Station deviceStation = stand.getDeviceStation(); - if (deviceStation != null) { - if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { - stand.setNoStatus(true); - psd.setNoStatus(true); - return; - } else { - stand.setNoStatus(false); - psd.setNoStatus(false); - } - if (deviceStation.isInterlockMachineStarting()) - return; - } else { - stand.setNoStatus(false); - psd.setNoStatus(false); - } - - VirtualRealityScreenDoor vrScreenDoor = psd.getVirtualScreenDoor(); - psd.apply(vrScreenDoor.isClose(), vrScreenDoor.isLock(), vrScreenDoor.isInterlockRelease()); - }); - } - - /** - * 更新区段逻辑 - */ - private void getSectionsStatusFromVRDevice(SimulationDataRepository repository) { - // 区段占用 - List
axleSectionList = repository.getAxleSectionList(); - axleSectionList.forEach(section -> { - //联锁机故障 - boolean interlockMachineFault = false; - boolean interlockMachineStarting = false; - Station deviceStation = section.getDeviceStation(); - if (deviceStation != null) { - if (deviceStation.isInterlockMachineStarting()) - interlockMachineStarting = true; - if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) - interlockMachineFault = true; - } - if (interlockMachineFault) { - section.setNoStatus(true); - if (section.isSwitchAxleCounterSection()) { - section.getLogicList().forEach(switchSection -> switchSection.setNoStatus(true)); - } - } else { - section.setNoStatus(false); - if (section.isSwitchAxleCounterSection()) { - section.getLogicList().forEach(switchSection -> switchSection.setNoStatus(false)); - } - } - if (interlockMachineStarting) - return; -// if (section.isInvalid() && section.isFault()) { -// section.setNctOccupied(false); -// return; +// if (deviceStation.isInterlockMachineStarting()) +// continue; +// } else { +// signal.setNoStatus(false); // } -// if (section.isFault()) { -// section.setNctOccupied(true); -// return; +// +// if (signal.isLogicLight() || signal.isVirtual()) { +// continue; +// } else if (signal.isGuideOpen()) { +// int guideRemain = signal.getGuideRemain(); +// if (guideRemain != -1) { // 非无限开放 +// guideRemain -= SimulationModule.CI.getRateMs(); +// if (guideRemain <= 0) { +// // 关闭引导信号 +// this.signalService.close(simulation, signal); +// signal.updateGuideRemain(0); +// } else { +// signal.updateGuideRemain(guideRemain); +// } +// } // } - if (Section.AxleFault.UNABLE_COLLECT_STATUS.equals(section.getFault())) - return; - VirtualRealitySectionAxleCounter virtualAxleCounter = section.getVirtualAxleCounter(); - //更新区段故障状态 - if (!VirtualRealitySectionAxleCounter.Fault.FAULT.equals(virtualAxleCounter.getFault())) { - if (Section.AxleFault.FAULT.equals(section.getFault())){ - section.setFault(null); - } - } - //更新区段占用状态 - if (virtualAxleCounter.isOccupy()) { - section.axleCounterOccupy(virtualAxleCounter.isRight()); - } else { - section.clearOccupy(); - section.judgeAsValid(); - } - //预复位 - if (!virtualAxleCounter.isPreReset()) { - List switchList = section.getRelSwitchList(); - if (!CollectionUtils.isEmpty(switchList)) { - switchList.forEach(aSwitch -> aSwitch.setPreReset(false)); - } - } - }); - } - - /** - * 从真实设备获取道岔状态 - */ - private List getSwitchesStatusFromVRDevice(SimulationDataRepository repository) { - // 道岔位置状态 - List switchList = repository.getListByType(MapElement.DeviceType.SWITCH, Switch.class); - switchList.forEach(aSwitch -> { - //联锁机故障逻辑 - Station deviceStation = aSwitch.getDeviceStation(); - if (deviceStation != null) { - if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { - aSwitch.setNoStatus(true); - return; - } else { - aSwitch.setNoStatus(false); - } - if (deviceStation.isInterlockMachineStarting()) - return; - } else { - aSwitch.setNoStatus(false); - } - - Switch.SwitchFault fault = (Switch.SwitchFault) aSwitch.getFault(); - if (fault != null) { - switch (fault) { - case SPLIT: - case SQUEEZE: - break; - case NORMAL_SPLIT: { - VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); - aSwitch.apply(false, virtualSwitch.isReverse()); - break; - } - case REVERSE_SPLIT: { - VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); - aSwitch.apply(virtualSwitch.isNormal(), false); - break; - } - } - } else { - VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); - aSwitch.apply(virtualSwitch.isNormal(), virtualSwitch.isReverse()); - } - }); - return switchList; - } - - /** - * 从真实设备获取信号机状态 - */ - private List getSignalsStatusFromVRDevice(Simulation simulation) { - SimulationDataRepository repository = simulation.getRepository(); - List signalList = repository.getSignalList(); - for (Signal signal : signalList) { - //联锁机故障逻辑 - Station deviceStation = signal.getDeviceStation(); - if (deviceStation != null) { - if (Station.Fault.INTERLOCK_MACHINE_FAULT.equals(deviceStation.getFault())) { - signal.setNoStatus(true); - continue; - } else { - signal.setNoStatus(false); - } - if (deviceStation.isInterlockMachineStarting()) - continue; - } else { - signal.setNoStatus(false); - } - - if (signal.isLogicLight() || signal.isVirtual()) { - continue; - } else if (signal.isGuideOpen()) { - int guideRemain = signal.getGuideRemain(); - if (guideRemain != -1) { // 非无限开放 - guideRemain -= SimulationModule.CI.getRateMs(); - if (guideRemain <= 0) { - // 关闭引导信号 - this.signalService.close(simulation, signal); - signal.updateGuideRemain(0); - } else { - signal.updateGuideRemain(guideRemain); - } - } - } - VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); - signal.apply(virtualSignal.isGreenOpen(), virtualSignal.isYellowOpen(), virtualSignal.isRedOpen()); - } - return signalList; - } - - public void addJobs(Simulation simulation) { - simulation.addJob(SimulationModule.CI.name(), () -> this.run(simulation), SimulationConstants.CI_LOOP_RATE); - } -} +// VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); +// signal.apply(virtualSignal.isGreenOpen(), virtualSignal.isYellowOpen(), virtualSignal.isRedOpen()); +// } +// return signalList; +// } +// +// public void addJobs(Simulation simulation) { +// simulation.addJob(SimulationModule.CI.name(), () -> this.run(simulation), SimulationConstants.CI_LOOP_RATE); +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java index 501c63d06..838eb285f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiService.java @@ -5,10 +5,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.ESP; import club.joylink.rtss.simulation.cbtc.data.map.Route; import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.map.Station; -import club.joylink.rtss.simulation.cbtc.data.support.SignalApproachMessage; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; - -import java.util.List; /** * CI子系统接口 @@ -222,11 +218,6 @@ public interface CiApiService { */ void settingGuideRoute(Simulation simulation, String routeCode); - /** - * 关闭进路引导信号 - */ - void closeGuideSignal(Simulation simulation, String signalCode); - /** * 开站台屏蔽门 * @param simulation @@ -267,20 +258,6 @@ public interface CiApiService { void standHoldTrainCancelAll(Simulation simulation, String standCode); - /** - * 接收处理信号机接近消息 - * @param simulation - * @param approachMessageList - */ - void handleSignalApproachMessage(Simulation simulation, List approachMessageList); - - /** - * 接收处理列车停稳信息 - * @param simulation - * @param train - */ - void handleTrainStopMessage(Simulation simulation, VirtualRealityTrain train); - /** * 办理引导 * @param simulation @@ -289,13 +266,6 @@ public interface CiApiService { */ void setGuide(Simulation simulation, String signalCode, String routeCode); - /** - * 取消引导 - * @param simulation - * @param signalCode - */ - void cancelGuide(Simulation simulation, String signalCode); - void setEst(Simulation simulation, ESP esp); void cancelEst(Simulation simulation, ESP esp); @@ -328,7 +298,7 @@ public interface CiApiService { /** * 强扳道岔 */ - void switchForceTurn(Simulation simulation, String switchCode, Boolean normal); + void switchForceTurn(Simulation simulation, String switchCode); /** * 计轴预复位 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java index be42562fa..259a20b24 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl.java @@ -1,671 +1,672 @@ -package club.joylink.rtss.simulation.cbtc.CI; - -import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.simulation.cbtc.CI.service.*; -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; -import club.joylink.rtss.simulation.cbtc.data.map.*; -import club.joylink.rtss.simulation.cbtc.data.support.SignalApproachMessage; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; -import club.joylink.rtss.simulation.cbtc.exception.SimulationException; -import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - -import java.time.LocalTime; -import java.util.List; -import java.util.Objects; -import java.util.Optional; -import java.util.stream.Collectors; - -/** - * CI子系统 - */ -@Slf4j -@Component -public class CiApiServiceImpl implements CiApiService { - - @Autowired - private SignalService signalService; - - @Autowired - private SectionService sectionService; - - @Autowired - private SwitchService switchService; - - @Autowired - private RouteService routeService; - - @Autowired - private StandService standService; - - @Override - public void blockadeSection(Simulation simulation, String sectionCode) { - Section section = simulation.getRepository().getByCode(sectionCode, Section.class); - this.sectionService.blockade(section); - } - - @Override - public void unblockSection(Simulation simulation, String sectionCode) { - Section section = simulation.getRepository().getByCode(sectionCode, Section.class); - this.sectionService.unblock(section); - } - - @Override - public void blockadeSignal(Simulation simulation, String signalCode) { - Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); - this.signalService.blockade(simulation, signal); - } - - @Override - public void unblockSignal(Simulation simulation, String signalCode) { - Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); - this.signalService.unblock(signal); - } - - @Override - public void closeSignal(Simulation simulation, String signalCode) { - Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); - this.signalService.close(simulation, signal); - } - - @Override - public void reopenSignal(Simulation simulation, String signalCode) { - // 判断信号机是否是关闭状态、进路是否锁闭、联锁关系是否满足 - Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); - if (signal.isNormalOpen()) { - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, - "信号机已经开启,无需重开信号机"); - } - Optional routeOptional = simulation.getRepository().getSettingRoutes().stream() - .filter(route -> route.getStart().equals(signal)).limit(1).findAny(); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "信号机不是已排进路的始端信号机"); -// settingRoute(simulation, routeOptional.get().getCode()); - Route lockedRoute = signal.getLockedRoute(); - if (Objects.isNull(lockedRoute)) { - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, - "进路未锁闭,不能重开信号机"); - } - if (!this.routeService.isInterlocked(lockedRoute)) { - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, - String.format("进路[%s(%s)]联锁关系不满足,不能重开信号机", lockedRoute.getName(), lockedRoute.getCode())); - } - this.routeService.routeOpen(simulation, lockedRoute); - if (lockedRoute.isDelayUnlocking()) { - lockedRoute.cancelDelayUnlocking(); - } - } - - @Override - public void turn(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - boolean toNormal = aSwitch.judgeTurnToNormal(); - if (toNormal) { - if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) { - log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode())); - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操"); - } - } else { - if (!this.switchService.turn2ReversePosition(simulation, aSwitch)) { - log.info(String.format("道岔[%s(%s)]锁闭,不能进行反操", aSwitch.getName(), aSwitch.getCode())); - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行反操"); - } - } - } - - @Override - public void turn2NormalPosition(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) { - log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode())); - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操"); - } - } - - @Override - public void turn2ReversePosition(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - if (!this.switchService.turn2ReversePosition(simulation, aSwitch)) { - log.info(String.format("道岔[%s(%s)]锁闭,不能进行反操", aSwitch.getName(), aSwitch.getCode())); - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行反操"); - } - } - - @Override - public void singleLockSwitch(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - this.switchService.singleLock(aSwitch); - } - - @Override - public void singleUnlockSwitch(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - this.switchService.singleUnlock(aSwitch); - } - - @Override - public void blockadeSwitch(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - //条件检查 - MapConfig config = simulation.getRepository().getConfig(); - if (config.isBlockadeCommandOnlyValidInStandbyMode()) { - boolean standbyMode = simulation.getRepository().getRouteList() - .stream().filter(route -> route.isRouteSwitch(aSwitch)).anyMatch(route -> !route.isCbtcMode()); //包含该道岔的进路是否有处于后备模式的 - if (!standbyMode) { - return; - } - } -// if (config.isSomeCommandNeedInit()) { -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(aSwitch.isInit(), aSwitch.debugStr() + "未初始化"); +//package club.joylink.rtss.simulation.cbtc.CI; +// +//import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +//import club.joylink.rtss.simulation.cbtc.CI.service.*; +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +//import club.joylink.rtss.simulation.cbtc.data.map.*; +//import club.joylink.rtss.simulation.cbtc.data.support.SignalApproachMessage; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; +//import club.joylink.rtss.simulation.cbtc.exception.SimulationException; +//import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +//import org.springframework.util.StringUtils; +// +//import java.time.LocalTime; +//import java.util.List; +//import java.util.Objects; +//import java.util.Optional; +//import java.util.stream.Collectors; +// +///** +// * CI子系统 +// */ +//@Slf4j +//@Component +//public class CiApiServiceImpl implements CiApiService { +// +// @Autowired +// private SignalService signalService; +// +// @Autowired +// private SectionService sectionService; +// +// @Autowired +// private SwitchService switchService; +// +// @Autowired +// private RouteService routeService; +// +// @Autowired +// private StandService standService; +// +// @Override +// public void blockadeSection(Simulation simulation, String sectionCode) { +// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); +// this.sectionService.blockade(section); +// } +// +// @Override +// public void unblockSection(Simulation simulation, String sectionCode) { +// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); +// this.sectionService.unblock(section); +// } +// +// @Override +// public void blockadeSignal(Simulation simulation, String signalCode) { +// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); +// this.signalService.blockade(simulation, signal); +// } +// +// @Override +// public void unblockSignal(Simulation simulation, String signalCode) { +// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); +// this.signalService.unblock(signal); +// } +// +// @Override +// public void closeSignal(Simulation simulation, String signalCode) { +// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); +// this.signalService.close(simulation, signal); +// } +// +// @Override +// public void reopenSignal(Simulation simulation, String signalCode) { +// // 判断信号机是否是关闭状态、进路是否锁闭、联锁关系是否满足 +// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); +// if (signal.isMainAspect()) { +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, +// "信号机已经开启,无需重开信号机"); // } - - this.switchService.blockade(aSwitch); - } - - @Override - public void unblockSwitch(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - this.switchService.unblock(aSwitch); - } - - @Override - public void blockadeSwitchSection(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - this.switchService.blockade(aSwitch); - } - - @Override - public void unblockSwitchSection(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - this.switchService.unblock(aSwitch); - } - - @Override - public Route.CheckFailMessage routeSettingCheck(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - return this.routeService.check(simulation, route); - } - - @Override - public void settingRoute(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - this.routeService.setting(simulation, route); - } - - @Override - public void unlockRoute(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - if (simulation.getRepository().getConfig().isDelayWhenCancelRouteWithAbnormalInterlock()) { - if (!routeService.isInterlocked(route)) { - routeService.humanCancel(simulation, route); - return; - } - } - this.routeService.cancelNoApproachLock(simulation, route); - } - - @Override - public void forceUnlockRoute(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFleetMode(), - String.format("进路[%s]已开启自动通过进路,无法取消", route.debugStr())); - SimulationDataRepository repository = simulation.getRepository(); - if (routeService.isApproachLock(repository, route)) { - routeService.humanCancel(simulation, route); - } else { - unlockRoute(simulation, route.getCode()); - } - } - - @Override - public void humanCancel(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - this.routeService.humanCancel(simulation, route); - } - - @Override - public void sectionFaultUnlock(Simulation simulation, String sectionCode) { - Section section = simulation.getRepository().getByCode(sectionCode, Section.class); - if (section.isCross()) { - Optional
crossLockedSectionOptional = section.getLogicList().stream().filter(Section::isLocked).findAny(); - if (crossLockedSectionOptional.isEmpty()) { - return; - } -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(crossLockedSectionOptional.isPresent(), -// section.debugStr() + "未锁闭,无需解锁"); - section = crossLockedSectionOptional.get(); - } - if (!section.isLocked()) { - return; - } -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(section.isLocked(), -// section.debugStr() + "未锁闭,无需解锁"); - List lockedRouteList = simulation.getRepository().queryAllLockedRoute(); - Route lockedRoute = null; - if (section.isRouteLock()) { - lockedRoute = section.getRoute(); +// Optional routeOptional = simulation.getRepository().getSettingRoutes().stream() +// .filter(route -> route.getStart().equals(signal)).limit(1).findAny(); +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "信号机不是已排进路的始端信号机"); +//// settingRoute(simulation, routeOptional.get().getCode()); +// Route lockedRoute = signal.getLockedRoute(); +// if (Objects.isNull(lockedRoute)) { +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, +// "进路未锁闭,不能重开信号机"); +// } +// if (!this.routeService.isInterlocked(lockedRoute)) { +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, +// String.format("进路[%s(%s)]联锁关系不满足,不能重开信号机", lockedRoute.getName(), lockedRoute.getCode())); +// } +// this.routeService.routeOpen(simulation, lockedRoute); +// if (lockedRoute.isDelayUnlocking()) { +// lockedRoute.cancelDelayUnlocking(); +// } +// } +// +// @Override +// public void turn(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// boolean toNormal = aSwitch.judgeTurnToNormal(); +// aSwitch.setLastTurnToNormal(toNormal); +// if (toNormal) { +// if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) { +// log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode())); +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操"); +// } +// } else { +// if (!this.switchService.turn2ReversePosition(simulation, aSwitch)) { +// log.info(String.format("道岔[%s(%s)]锁闭,不能进行反操", aSwitch.getName(), aSwitch.getCode())); +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行反操"); +// } +// } +// } +// +// @Override +// public void turn2NormalPosition(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) { +// log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode())); +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操"); +// } +// } +// +// @Override +// public void turn2ReversePosition(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// if (!this.switchService.turn2ReversePosition(simulation, aSwitch)) { +// log.info(String.format("道岔[%s(%s)]锁闭,不能进行反操", aSwitch.getName(), aSwitch.getCode())); +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行反操"); +// } +// } +// +// @Override +// public void singleLockSwitch(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// this.switchService.singleLock(aSwitch); +// } +// +// @Override +// public void singleUnlockSwitch(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// this.switchService.singleUnlock(aSwitch); +// } +// +// @Override +// public void blockadeSwitch(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// //条件检查 +// MapConfig config = simulation.getRepository().getConfig(); +// if (config.isBlockadeCommandOnlyValidInStandbyMode()) { +// boolean standbyMode = simulation.getRepository().getRouteList() +// .stream().filter(route -> route.isRouteSwitch(aSwitch)).anyMatch(route -> !route.isCbtcMode()); //包含该道岔的进路是否有处于后备模式的 +// if (!standbyMode) { +// return; +// } +// } +//// if (config.isSomeCommandNeedInit()) { +//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(aSwitch.isInit(), aSwitch.debugStr() + "未初始化"); +//// } +// +// this.switchService.blockade(aSwitch); +// } +// +// @Override +// public void unblockSwitch(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// this.switchService.unblock(aSwitch); +// } +// +// @Override +// public void blockadeSwitchSection(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// this.switchService.blockade(aSwitch); +// } +// +// @Override +// public void unblockSwitchSection(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// this.switchService.unblock(aSwitch); +// } +// +// @Override +// public Route.CheckFailMessage routeSettingCheck(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// return this.routeService.check(simulation, route); +// } +// +// @Override +// public void settingRoute(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// this.routeService.setting(simulation, route); +// } +// +// @Override +// public void unlockRoute(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// if (simulation.getRepository().getConfig().isDelayWhenCancelRouteWithAbnormalInterlock()) { +// if (!routeService.isInterlocked(route)) { +// routeService.humanCancel(simulation, route); +// return; +// } +// } +// this.routeService.cancelNoApproachLock(simulation, route); +// } +// +// @Override +// public void forceUnlockRoute(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFleetMode(), +// String.format("进路[%s]已开启自动通过进路,无法取消", route.debugStr())); +// SimulationDataRepository repository = simulation.getRepository(); +// if (routeService.isApproachLock(repository, route)) { +// routeService.humanCancel(simulation, route); +// } else { +// unlockRoute(simulation, route.getCode()); +// } +// } +// +// @Override +// public void humanCancel(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// this.routeService.humanCancel(simulation, route); +// } +// +// @Override +// public void sectionFaultUnlock(Simulation simulation, String sectionCode) { +// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); +// if (section.isCross()) { +// Optional
crossLockedSectionOptional = section.getLogicList().stream().filter(Section::isLocked).findAny(); +// if (crossLockedSectionOptional.isEmpty()) { +// return; +// } +//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(crossLockedSectionOptional.isPresent(), +//// section.debugStr() + "未锁闭,无需解锁"); +// section = crossLockedSectionOptional.get(); +// } +// if (!section.isLocked()) { +// return; +// } +//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(section.isLocked(), +//// section.debugStr() + "未锁闭,无需解锁"); +// List lockedRouteList = simulation.getRepository().queryAllLockedRoute(); +// Route lockedRoute = null; +// if (section.isRouteLock()) { +// lockedRoute = section.getRoute(); +//// for (Route route : lockedRouteList) { +//// if (route.containSection(section)) { +//// lockedRoute = route; +//// break; +//// } +//// } +// } else if (section.isOverlapLock()) { // for (Route route : lockedRouteList) { -// if (route.containSection(section)) { +// if (route.overlapContainSection(section)) { // lockedRoute = route; // break; // } // } - } else if (section.isOverlapLock()) { - for (Route route : lockedRouteList) { - if (route.overlapContainSection(section)) { - lockedRoute = route; - break; - } - } - } - this.sectionService.sectionFaultUnlock(simulation, section, lockedRoute); - } - - @Override - public void switchSectionFaultUnlock(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - if (!aSwitch.isLocked()) - return; - List lockedRouteList = simulation.getRepository().queryAllLockedRoute(); - Route lockedRoute = null; - if (aSwitch.isRouteLock()) { - lockedRoute = aSwitch.getRoute(); +// } +// this.sectionService.sectionFaultUnlock(simulation, section, lockedRoute); +// } +// +// @Override +// public void switchSectionFaultUnlock(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// if (!aSwitch.isLocked()) +// return; +// List lockedRouteList = simulation.getRepository().queryAllLockedRoute(); +// Route lockedRoute = null; +// if (aSwitch.isRouteLock()) { +// lockedRoute = aSwitch.getRoute(); +//// for (Route route : lockedRouteList) { +//// if (route.isRouteSwitch(aSwitch)) { +//// lockedRoute = route; +//// break; +//// } +//// } +// } else if (aSwitch.isOverlapLock()) { // for (Route route : lockedRouteList) { -// if (route.isRouteSwitch(aSwitch)) { +// if (route.overlapContainSwitch(aSwitch)) { // lockedRoute = route; // break; // } // } - } else if (aSwitch.isOverlapLock()) { - for (Route route : lockedRouteList) { - if (route.overlapContainSwitch(aSwitch)) { - lockedRoute = route; - break; - } - } - } - this.switchService.switchFaultUnlock(simulation, aSwitch, lockedRoute); - } - - @Override - public void setFleetRoute(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - this.routeService.setFleet(route); - } - - @Override - public void cancelFleetRoute(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - this.routeService.cancelFleet(route); - } - - @Override - public void setCIAutoTriggerRoute(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - this.routeService.setCIAutoTrigger(route); - } - - @Override - public void cancelCIAutoTriggerRoute(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - this.routeService.cancelCIAutoTrigger(route); - } - - @Override - public Route findLockedRouteByStartSignal(Simulation simulation, String signalCode) { - Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); - return signal.getLockedRoute(); - } - - @Override - public Route findRouteByStartAndEndSignal(Simulation simulation, String startSignalCode, String endSignalCode) { - Signal start = simulation.getRepository().getByCode(startSignalCode, Signal.class); - List routeList = start.getRouteList(); - if (!CollectionUtils.isEmpty(routeList)) { - for (Route route : routeList) { - if (Objects.equals(route.getDestination().getCode(), endSignalCode)) { - return route; - } - } - } - return null; - } - - @Override - public void settingGuideRoute(Simulation simulation, String routeCode) { - Route route = simulation.getRepository().getByCode(routeCode, Route.class); - this.routeService.settingGuideRoute(simulation, route); - } - - @Override - public void closeGuideSignal(Simulation simulation, String signalCode) { - Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); - this.signalService.close(simulation, signal); - } - - @Override - public void openScreenDoor(Simulation simulation, String standCode) { - Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); - if (Objects.nonNull(stand.getPsd())) { - this.standService.openScreenDoor(simulation, stand.getPsd()); - } - } - - @Override - public void closeScreenDoor(Simulation simulation, String standCode) { - Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); - if (Objects.nonNull(stand.getPsd())) { - this.standService.closeScreenDoor(simulation, stand.getPsd()); - } - } - - @Override - public void standHoldTrain(Simulation simulation, String standCode, boolean center) { - Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); - this.standService.holdTrain(simulation, stand, center); - } - - @Override - public void sysHoldTrain(Simulation simulation, String standCode) { - Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); - this.standService.sysHoldTrain(simulation, stand); - } - - @Override - public void standHoldTrainCancel(Simulation simulation, String standCode, boolean center) { - Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); - this.standService.cancelHoldTrain(simulation, stand, center); - } - - @Override - public void sysHoldTrainCancel(Simulation simulation, String standCode) { - Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); - this.standService.cancelSysHoldTrain(simulation, stand); - } - - @Override - public void ibpHoldTrain(Simulation simulation, String standCode) { - Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); - this.standService.ibpHoldTrain(simulation, stand); - } - - @Override - public void ibpHoldTrainCancel(Simulation simulation, String standCode) { - Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); - this.standService.cancelIbpHoldTrain(simulation, stand); - } - - @Override - public void standHoldTrainCancelAll(Simulation simulation, String standCode) { - Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); - this.standService.cancelAllHoldTrain(simulation, stand); - } - - @Override - public void handleSignalApproachMessage(Simulation simulation, - List approachMessageList) { - approachMessageList.forEach(approachMessage -> { - Signal signal = simulation.getRepository().getByCode(approachMessage.getSignalCode(), Signal.class); - this.signalService.handleApproachMessage(simulation, signal, approachMessage); - }); - } - - @Override - public void handleTrainStopMessage(Simulation simulation, VirtualRealityTrain train) { - this.routeService.handleTrainStopMessage(simulation, train); - } - - /** - * 办理引导 - */ - @Override - public void setGuide(Simulation simulation, String signalCode, String routeCode) { - SimulationDataRepository repository = simulation.getRepository(); - MapConfig config = repository.getConfig(); - Signal signal; - Route route = null; - if (StringUtils.hasText(signalCode)) { - signal = repository.getByCode(signalCode, Signal.class); - } else if (StringUtils.hasText(routeCode)) { - route = repository.getByCode(routeCode, Route.class); - signal = route.getStart(); - } else { - throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空"); - } - //条件检查 - if (config.isGuideNeedRouteSettingFirst()) { - List routeList = signal.getRouteList(); - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, String.format("信号机[%s]非进路始端信号机", signal.getCode())); - if (route != null) { - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(route.isLock(), String.format("进路[%s]未办理", route.getCode())); - } else { - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(signal.getLockedRoute(), String.format("信号机[%s]无已办理进路", signal.getCode())); - } - } -// if (config.isSomeCommandNeedInit()) { -// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isInit(), signal.debugStr() + "未初始化"); // } - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isClose(), String.format("信号机[%s]需处于关闭状态", signal.getCode())); - boolean signalApproachOccupied = signal.getApproachPathList() - .stream().anyMatch(sectionPath -> sectionPath.getSectionList().stream().anyMatch(Section::isOccupied)); - if (config.isNeedApproachLockBeforeSetGuide()) { - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signalApproachOccupied, - String.format("对%s开放引导操作失败,接近区段没有列车占用", signal.getName())); - } - //办理引导进路或开放引导信号 - if (config.isGuideNeedRouteSettingFirst()) { - signalService.openGuideSignal(simulation, signal); - } else { - if (route != null) { - if (route.isLock()) { - signalService.openGuideSignal(simulation, route.getStart()); - } else { - routeService.settingGuideRoute(simulation, route); - } - } else { - if (signal.getLockedRoute() != null) { //如果有已锁闭进路 - signalService.openGuideSignal(simulation, signal); - } else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null,筛选最合适的进路(直线进路>分叉进路>折返进路) - List collect = signal.getRouteList().stream() - .filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList())) - .collect(Collectors.toList()); - if (CollectionUtils.isEmpty(collect)) { - collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList()); - } - if (CollectionUtils.isEmpty(collect)) { - collect = signal.getRouteList(); - } - route = collect.get(0); - routeService.settingGuideRoute(simulation, route); - } else { //如果信号机没有关联进路 - signalService.openGuideSignal(simulation, signal); - } - } - } - } - - /** - * 取消引导 - */ - @Override - public void cancelGuide(Simulation simulation, String signalCode) { - Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); - signalService.close(simulation, signal); - if (signal.getLockedRoute() != null) { - routeService.cancelGuideRoute(simulation, signal.getLockedRoute()); - } - } - - @Override - public void setEst(Simulation simulation, ESP esp) { - esp.update(true); - } - - @Override - public void cancelEst(Simulation simulation, ESP esp) { - esp.update(false); - } - - @Override - public void restart(Simulation simulation, Station station) { - Station deviceStation; - if (station.isCentralized()) { - deviceStation = station; - } else { - deviceStation = station.getDeviceStation(); - } - deviceStation.setInterlockMachineStarting(false); - } - - @Override - public void release(Simulation simulation, Station station) { - - } - - @Override - public void powerOnUnlock(Simulation simulation, Station station) { - if (!station.isCentralized()) { - station = station.getDeviceStation(); - } - Station deviceStation = station; - if (Objects.nonNull(deviceStation.getRestartTime()) - && deviceStation.getRestartTime().isBefore(LocalTime.now()) - && ((Simulation.FunctionalType.LESSON.equals(simulation.getBuildParams().getFunctionalType()) - || Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType())) - ? true : deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()))) { - List
sections = simulation.getRepository().getSectionList(); - sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock); - return; - } - throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无效操作或连锁机重启过8分钟需手动解锁"); - } - - @Override - public void standEC(Simulation simulation, Stand stand) { - if (stand.getEsp() == null) - return; - stand.getEsp().update(true); - } - - @Override - public void cancelStandEC(Simulation simulation, Stand stand) { - if (stand.getEsp() == null) - return; - stand.getEsp().update(false); - } - - @Override - public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertTrue(!aSwitch.isLocked() && aSwitch.isSectionOccupied(), - String.format("对%s强行转岔操作被联锁逻辑取消", aSwitch.getName())); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isLocked(), String.format("道岔[%s]锁闭,无法转动", aSwitch.getCode())); - if (normal == null) { - normal = aSwitch.judgeTurnToNormal(); - } - switchService.controlSwitch(simulation, aSwitch, normal); - } - - @Override - public void axlePreReset(Simulation simulation, String sectionCode) { - Section section = simulation.getRepository().getByCode(sectionCode, Section.class); - Section axleSection = section.findAxleCounterSection(); - //条件检查 - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), - section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); - VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); - if (!virtualAxleCounter.isOccupy()) - Section.AxleFault.ARB.apply(axleSection); - else - virtualAxleCounter.preReset(); - } - - @Override - public void switchAxlePreReset(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - aSwitch.setPreReset(true); - } - - @Override - public void switchSqueezeRecovery(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - Switch.SwitchFault.SQUEEZE.fix(aSwitch); - } - - @Override - public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - if (auto != null) { - aSwitch.setAuto(auto); - } else { - if (normal != null) { - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isAuto(), "道岔未处于人工模式"); - if (normal) { - switchService.turn2NormalPosition(simulation, aSwitch); - } else { - switchService.turn2ReversePosition(simulation, aSwitch); - } - } - } - if (reserve != null) { - aSwitch.setDispatcherReserve(reserve); - } - } - - @Override - public void initializeBlock(Simulation simulation, String switchCode) { - Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); - aSwitch.setInit(true); - } - - @Override - public void initializeGuide(Simulation simulation, String signalCode) { - Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); - signal.setInit(true); - } - - @Override - public void cancelGuideInitialization(Simulation simulation, String signalCode) { - Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); - signal.setInit(false); - } - - @Override - public void axleReset(Simulation simulation, String sectionCode) { - VirtualRealitySectionAxleCounter axle = getAxleCounterAndCheck4Reset(simulation, sectionCode); - if (!axle.isOccupy()) - return; - axle.axleReset(); - } - - @Override - public void setOverlap(Simulation simulation, String signalCode, String overlapCode) { - SimulationDataRepository repository = simulation.getRepository(); - Signal signal = repository.getByCode(signalCode, Signal.class); - RouteOverlap overlap = repository.getByCode(overlapCode, RouteOverlap.class); - this.routeService.setOverlap(simulation, signal, overlap); - } - - /** - * 获取计轴器并为预复位/复位操作检查设备状态 - */ - private VirtualRealitySectionAxleCounter getAxleCounterAndCheck4Reset(Simulation simulation, String sectionCode) { - Section section = simulation.getRepository().getByCode(sectionCode, Section.class); - Section axleSection = section.findAxleCounterSection(); - //条件检查 - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), - section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); - VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); - if (simulation.getRepository().getConfig().isStationPreResetBeforeAxlePreReset()) { - Station deviceStation = axleSection.getDeviceStation(); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(deviceStation, section.debugStr() + "没有所属集中站"); - BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(deviceStation.isPreReset(), deviceStation.debugStr() + "需处于预复位状态"); - } - return virtualAxleCounter; - } -} +// this.switchService.switchFaultUnlock(simulation, aSwitch, lockedRoute); +// } +// +// @Override +// public void setFleetRoute(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// this.routeService.setFleet(route); +// } +// +// @Override +// public void cancelFleetRoute(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// this.routeService.cancelFleet(route); +// } +// +// @Override +// public void setCIAutoTriggerRoute(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// this.routeService.setCIAutoTrigger(route); +// } +// +// @Override +// public void cancelCIAutoTriggerRoute(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// this.routeService.cancelCIAutoTrigger(route); +// } +// +// @Override +// public Route findLockedRouteByStartSignal(Simulation simulation, String signalCode) { +// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); +// return signal.getLockedRoute(); +// } +// +// @Override +// public Route findRouteByStartAndEndSignal(Simulation simulation, String startSignalCode, String endSignalCode) { +// Signal start = simulation.getRepository().getByCode(startSignalCode, Signal.class); +// List routeList = start.getRouteList(); +// if (!CollectionUtils.isEmpty(routeList)) { +// for (Route route : routeList) { +// if (Objects.equals(route.getDestination().getCode(), endSignalCode)) { +// return route; +// } +// } +// } +// return null; +// } +// +// @Override +// public void settingGuideRoute(Simulation simulation, String routeCode) { +// Route route = simulation.getRepository().getByCode(routeCode, Route.class); +// this.routeService.settingGuideRoute(simulation, route); +// } +// +// @Override +// public void closeGuideSignal(Simulation simulation, String signalCode) { +// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); +// this.signalService.close(simulation, signal); +// } +// +// @Override +// public void openScreenDoor(Simulation simulation, String standCode) { +// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); +// if (Objects.nonNull(stand.getPsd())) { +// this.standService.openScreenDoor(simulation, stand.getPsd()); +// } +// } +// +// @Override +// public void closeScreenDoor(Simulation simulation, String standCode) { +// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); +// if (Objects.nonNull(stand.getPsd())) { +// this.standService.closeScreenDoor(simulation, stand.getPsd()); +// } +// } +// +// @Override +// public void standHoldTrain(Simulation simulation, String standCode, boolean center) { +// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); +// this.standService.holdTrain(simulation, stand, center); +// } +// +// @Override +// public void sysHoldTrain(Simulation simulation, String standCode) { +// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); +// this.standService.sysHoldTrain(simulation, stand); +// } +// +// @Override +// public void standHoldTrainCancel(Simulation simulation, String standCode, boolean center) { +// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); +// this.standService.cancelHoldTrain(simulation, stand, center); +// } +// +// @Override +// public void sysHoldTrainCancel(Simulation simulation, String standCode) { +// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); +// this.standService.cancelSysHoldTrain(simulation, stand); +// } +// +// @Override +// public void ibpHoldTrain(Simulation simulation, String standCode) { +// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); +// this.standService.ibpHoldTrain(simulation, stand); +// } +// +// @Override +// public void ibpHoldTrainCancel(Simulation simulation, String standCode) { +// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); +// this.standService.cancelIbpHoldTrain(simulation, stand); +// } +// +// @Override +// public void standHoldTrainCancelAll(Simulation simulation, String standCode) { +// Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); +// this.standService.cancelAllHoldTrain(simulation, stand); +// } +// +// @Override +// public void handleSignalApproachMessage(Simulation simulation, +// List approachMessageList) { +// approachMessageList.forEach(approachMessage -> { +// Signal signal = simulation.getRepository().getByCode(approachMessage.getSignalCode(), Signal.class); +// this.signalService.handleApproachMessage(simulation, signal, approachMessage); +// }); +// } +// +// @Override +// public void handleTrainStopMessage(Simulation simulation, VirtualRealityTrain train) { +// this.routeService.handleTrainStopMessage(simulation, train); +// } +// +// /** +// * 办理引导 +// */ +// @Override +// public void setGuide(Simulation simulation, String signalCode, String routeCode) { +// SimulationDataRepository repository = simulation.getRepository(); +// MapConfig config = repository.getConfig(); +// Signal signal; +// Route route = null; +// if (StringUtils.hasText(signalCode)) { +// signal = repository.getByCode(signalCode, Signal.class); +// } else if (StringUtils.hasText(routeCode)) { +// route = repository.getByCode(routeCode, Route.class); +// signal = route.getStart(); +// } else { +// throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空"); +// } +// //条件检查 +// if (config.isGuideNeedRouteSettingFirst()) { +// List routeList = signal.getRouteList(); +// BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, String.format("信号机[%s]非进路始端信号机", signal.getCode())); +// if (route != null) { +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(route.isLock(), String.format("进路[%s]未办理", route.getCode())); +// } else { +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(signal.getLockedRoute(), String.format("信号机[%s]无已办理进路", signal.getCode())); +// } +// } +//// if (config.isSomeCommandNeedInit()) { +//// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isInit(), signal.debugStr() + "未初始化"); +//// } +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isClose(), String.format("信号机[%s]需处于关闭状态", signal.getCode())); +// boolean signalApproachOccupied = signal.getApproachPathList() +// .stream().anyMatch(sectionPath -> sectionPath.getSectionList().stream().anyMatch(Section::isOccupied)); +// if (config.isNeedApproachLockBeforeSetGuide()) { +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signalApproachOccupied, +// String.format("对%s开放引导操作失败,接近区段没有列车占用", signal.getName())); +// } +// //办理引导进路或开放引导信号 +// if (config.isGuideNeedRouteSettingFirst()) { +// signalService.openGuideSignal(simulation, signal); +// } else { +// if (route != null) { +// if (route.isLock()) { +// signalService.openGuideSignal(simulation, route.getStart()); +// } else { +// routeService.settingGuideRoute(simulation, route); +// } +// } else { +// if (signal.getLockedRoute() != null) { //如果有已锁闭进路 +// signalService.openGuideSignal(simulation, signal); +// } else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null,筛选最合适的进路(直线进路>分叉进路>折返进路) +// List collect = signal.getRouteList().stream() +// .filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList())) +// .collect(Collectors.toList()); +// if (CollectionUtils.isEmpty(collect)) { +// collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList()); +// } +// if (CollectionUtils.isEmpty(collect)) { +// collect = signal.getRouteList(); +// } +// route = collect.get(0); +// routeService.settingGuideRoute(simulation, route); +// } else { //如果信号机没有关联进路 +// signalService.openGuideSignal(simulation, signal); +// } +// } +// } +// } +// +// /** +// * 取消引导 +// */ +// @Override +// public void cancelGuide(Simulation simulation, String signalCode) { +// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); +// signalService.close(simulation, signal); +// if (signal.getLockedRoute() != null) { +// routeService.cancelGuideRoute(simulation, signal.getLockedRoute()); +// } +// } +// +// @Override +// public void setEst(Simulation simulation, ESP esp) { +// esp.update(true); +// } +// +// @Override +// public void cancelEst(Simulation simulation, ESP esp) { +// esp.update(false); +// } +// +// @Override +// public void restart(Simulation simulation, Station station) { +// Station deviceStation; +// if (station.isCentralized()) { +// deviceStation = station; +// } else { +// deviceStation = station.getDeviceStation(); +// } +// deviceStation.setInterlockMachineStarting(false); +// } +// +// @Override +// public void release(Simulation simulation, Station station) { +// +// } +// +// @Override +// public void powerOnUnlock(Simulation simulation, Station station) { +// if (!station.isCentralized()) { +// station = station.getDeviceStation(); +// } +// Station deviceStation = station; +// if (Objects.nonNull(deviceStation.getRestartTime()) +// && deviceStation.getRestartTime().isBefore(LocalTime.now()) +// && ((Simulation.FunctionalType.LESSON.equals(simulation.getBuildParams().getFunctionalType()) +// || Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType())) +// ? true : deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()))) { +// List
sections = simulation.getRepository().getSectionList(); +// sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock); +// return; +// } +// throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无效操作或连锁机重启过8分钟需手动解锁"); +// } +// +// @Override +// public void standEC(Simulation simulation, Stand stand) { +// if (stand.getEsp() == null) +// return; +// stand.getEsp().update(true); +// } +// +// @Override +// public void cancelStandEC(Simulation simulation, Stand stand) { +// if (stand.getEsp() == null) +// return; +// stand.getEsp().update(false); +// } +// +// @Override +// public void switchForceTurn(Simulation simulation, String switchCode, Boolean normal) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertTrue(!aSwitch.isLocked() && aSwitch.isSectionOccupied(), +// String.format("对%s强行转岔操作被联锁逻辑取消", aSwitch.getName())); +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isLocked(), String.format("道岔[%s]锁闭,无法转动", aSwitch.getCode())); +// if (normal == null) { +// normal = aSwitch.judgeTurnToNormal(); +// } +// switchService.controlSwitch(simulation, aSwitch, normal); +// } +// +// @Override +// public void axlePreReset(Simulation simulation, String sectionCode) { +// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); +// Section axleSection = section.findAxleCounterSection(); +// //条件检查 +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), +// section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); +// VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); +// if (!virtualAxleCounter.isOccupy()) +// Section.AxleFault.ARB.apply(axleSection); +// else +// virtualAxleCounter.preReset(); +// } +// +// @Override +// public void switchAxlePreReset(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// aSwitch.setPreReset(true); +// } +// +// @Override +// public void switchSqueezeRecovery(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// Switch.SwitchFault.SQUEEZE.fix(aSwitch); +// } +// +// @Override +// public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// if (auto != null) { +// aSwitch.setAuto(auto); +// } else { +// if (normal != null) { +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isAuto(), "道岔未处于人工模式"); +// if (normal) { +// switchService.turn2NormalPosition(simulation, aSwitch); +// } else { +// switchService.turn2ReversePosition(simulation, aSwitch); +// } +// } +// } +// if (reserve != null) { +// aSwitch.setDispatcherReserve(reserve); +// } +// } +// +// @Override +// public void initializeBlock(Simulation simulation, String switchCode) { +// Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); +// aSwitch.setInit(true); +// } +// +// @Override +// public void initializeGuide(Simulation simulation, String signalCode) { +// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); +// signal.setInit(true); +// } +// +// @Override +// public void cancelGuideInitialization(Simulation simulation, String signalCode) { +// Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); +// signal.setInit(false); +// } +// +// @Override +// public void axleReset(Simulation simulation, String sectionCode) { +// VirtualRealitySectionAxleCounter axle = getAxleCounterAndCheck4Reset(simulation, sectionCode); +// if (!axle.isOccupy()) +// return; +// axle.axleReset(); +// } +// +// @Override +// public void setOverlap(Simulation simulation, String signalCode, String overlapCode) { +// SimulationDataRepository repository = simulation.getRepository(); +// Signal signal = repository.getByCode(signalCode, Signal.class); +// RouteOverlap overlap = repository.getByCode(overlapCode, RouteOverlap.class); +// this.routeService.setOverlap(simulation, signal, overlap); +// } +// +// /** +// * 获取计轴器并为预复位/复位操作检查设备状态 +// */ +// private VirtualRealitySectionAxleCounter getAxleCounterAndCheck4Reset(Simulation simulation, String sectionCode) { +// Section section = simulation.getRepository().getByCode(sectionCode, Section.class); +// Section axleSection = section.findAxleCounterSection(); +// //条件检查 +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), +// section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); +// VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); +// if (simulation.getRepository().getConfig().isStationPreResetBeforeAxlePreReset()) { +// Station deviceStation = axleSection.getDeviceStation(); +// BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(deviceStation, section.debugStr() + "没有所属集中站"); +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(deviceStation.isPreReset(), deviceStation.debugStr() + "需处于预复位状态"); +// } +// return virtualAxleCounter; +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java new file mode 100644 index 000000000..d675116df --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiApiServiceImpl2.java @@ -0,0 +1,612 @@ +package club.joylink.rtss.simulation.cbtc.CI; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.CI.device.*; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.*; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; +import club.joylink.rtss.simulation.cbtc.exception.SimulationException; +import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.time.LocalTime; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * CI子系统 + */ +@Slf4j +@Component +public class CiApiServiceImpl2 implements CiApiService { + @Autowired + private CiSwitchControlService switchService; + @Autowired + private CiSectionService sectionService; + @Autowired + private CiSignalControlService signalService; + @Autowired + private CiRouteService routeService; + @Autowired + private CiService ciService; + @Autowired + private CiStandService standService; + + @Override + public void blockadeSection(Simulation simulation, String sectionCode) { + Section section = simulation.getRepository().getByCode(sectionCode, Section.class); + this.sectionService.blockade(section); + } + + @Override + public void unblockSection(Simulation simulation, String sectionCode) { + Section section = simulation.getRepository().getByCode(sectionCode, Section.class); + this.sectionService.unblock(section); + } + + @Override + public void blockadeSignal(Simulation simulation, String signalCode) { + Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); + this.signalService.blockade(simulation, signal); + } + + @Override + public void unblockSignal(Simulation simulation, String signalCode) { + Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); + this.signalService.unblock(signal); + } + + @Override + public void closeSignal(Simulation simulation, String signalCode) { + Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); + this.signalService.closeRoute(simulation, signal); + } + + @Override + public void reopenSignal(Simulation simulation, String signalCode) { + // 判断信号机是否是关闭状态、进路是否锁闭、联锁关系是否满足 + Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); + if (signal.isMainAspect()) { + throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, + "信号机已经开启,无需重开信号机"); + } + Optional routeOptional = simulation.getRepository().getSettingRoutes().stream() + .filter(route -> route.getStart().equals(signal)).limit(1).findAny(); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(routeOptional.isPresent(), "信号机不是已排进路的始端信号机"); +// settingRoute(simulation, routeOptional.get().getCode()); + Route lockedRoute = signal.getLockedRoute(); + if (Objects.isNull(lockedRoute)) { + throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, + "进路未锁闭,不能重开信号机"); + } + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!lockedRoute.isDelayUnlocking(), "进路延时解锁中,不能重开"); + this.routeService.routeReopen(simulation, lockedRoute); + } + + @Override + public void turn(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + if (!this.switchService.turn(simulation, aSwitch)) { + log.info(String.format("道岔[%s(%s)]锁闭,不能转动", aSwitch.getName(), aSwitch.getCode())); + throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操"); + } + } + + @Override + public void turn2NormalPosition(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + if (!this.switchService.turn2NormalPosition(simulation, aSwitch)) { + log.info(String.format("道岔[%s(%s)]锁闭,不能进行定操", aSwitch.getName(), aSwitch.getCode())); + throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行定操"); + } + } + + @Override + public void turn2ReversePosition(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + if (!this.switchService.turn2ReversePosition(simulation, aSwitch)) { + log.info(String.format("道岔[%s(%s)]锁闭,不能进行反操", aSwitch.getName(), aSwitch.getCode())); + throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "道岔锁闭,不能进行反操"); + } + } + + @Override + public void singleLockSwitch(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + this.switchService.singleLock(aSwitch); + } + + @Override + public void singleUnlockSwitch(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + this.switchService.singleUnlock(aSwitch); + } + + @Override + public void blockadeSwitch(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + //条件检查 + MapConfig config = simulation.getRepository().getConfig(); + if (config.isBlockadeCommandOnlyValidInStandbyMode()) { + boolean standbyMode = simulation.getRepository().getRouteList() + .stream().filter(route -> route.isRouteSwitch(aSwitch)) + .anyMatch(route -> !route.getStart().isCbtcMode()); //包含该道岔的进路是否有处于后备模式的 + if (!standbyMode) { + return; + } + } +// if (config.isSomeCommandNeedInit()) { +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(aSwitch.isInit(), aSwitch.debugStr() + "未初始化"); +// } + + this.switchService.blockade(aSwitch); + } + + @Override + public void unblockSwitch(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + this.switchService.unblock(aSwitch); + } + + @Override + public void blockadeSwitchSection(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + this.switchService.blockade(aSwitch); + } + + @Override + public void unblockSwitchSection(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + this.switchService.unblock(aSwitch); + } + + @Override + public Route.CheckFailMessage routeSettingCheck(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + return this.routeService.routeSetCheck(simulation, route); + } + + @Override + public void settingRoute(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + this.routeService.setRoute(simulation, route); + } + + @Override + public void unlockRoute(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + if (route.isTransferRoute() && simulation.getRepository().getConfig().isTransferRouteCanOnlyFaultUnlock()) { + throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("转换轨进路只能通过区故解取消"); + } + if (simulation.getRepository().getConfig().isDelayWhenCancelRouteWithAbnormalInterlock()) { + if (this.ciService.isRouteSwitchLost(simulation, route)) { + this.routeService.delayUnlockStart(simulation, route, route.getStart()); + return; + } + } + this.routeService.unlockRoute(simulation, route); + } + + @Override + public void forceUnlockRoute(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFleetMode(), + String.format("进路[%s]已开启自动通过进路,无法取消", route.debugStr())); + if (route.isApproachLock()) { + this.routeService.delayUnlockStart(simulation, route, route.getStart()); + } else { + this.routeService.unlockRoute(simulation, route); + } + } + + @Override + public void humanCancel(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + this.routeService.delayUnlockStart(simulation, route, route.getStart()); + } + + @Override + public void sectionFaultUnlock(Simulation simulation, String sectionCode) { + Section section = simulation.getRepository().getByCode(sectionCode, Section.class); + if (section.isCross()) { + Optional
crossLockedSectionOptional = section.getLogicList().stream().filter(Section::isLocked).findAny(); + if (crossLockedSectionOptional.isEmpty()) { + return; + } +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(crossLockedSectionOptional.isPresent(), +// section.debugStr() + "未锁闭,无需解锁"); + section = crossLockedSectionOptional.get(); + } + if (!section.isLocked()) { + return; + } +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(section.isLocked(), +// section.debugStr() + "未锁闭,无需解锁"); + List lockedRouteList = simulation.getRepository().queryAllLockedRoute(); + Route lockedRoute = null; + if (section.isRouteLock()) { + lockedRoute = section.getRoute(); + } else if (section.isOverlapLock()) { + for (Route route : lockedRouteList) { + if (route.overlapContainSection(section)) { + lockedRoute = route; + break; + } + } + } + if (lockedRoute != null && lockedRoute.isDelayUnlocking()) { + throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("进路延时解锁中,不能区故解"); + } + this.routeService.sectionFaultUnlock(simulation, section, lockedRoute); + } + + @Override + public void switchSectionFaultUnlock(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + if (!aSwitch.isLocked()) + return; + List lockedRouteList = simulation.getRepository().queryAllLockedRoute(); + Route lockedRoute = null; + if (aSwitch.isRouteLock()) { + lockedRoute = aSwitch.getRoute(); + } else if (aSwitch.isOverlapLock()) { + for (Route route : lockedRouteList) { + if (route.overlapContainSwitch(aSwitch)) { + lockedRoute = route; + break; + } + } + } + this.routeService.switchFaultUnlock(simulation, aSwitch, lockedRoute); + } + + @Override + public void setFleetRoute(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + this.routeService.setFleet(route); + } + + @Override + public void cancelFleetRoute(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + this.routeService.cancelFleet(route); + } + + @Override + public void setCIAutoTriggerRoute(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + this.routeService.setCIAutoTrigger(route); + } + + @Override + public void cancelCIAutoTriggerRoute(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + this.routeService.cancelCIAutoTrigger(route); + } + + @Override + public Route findLockedRouteByStartSignal(Simulation simulation, String signalCode) { + Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); + return signal.getLockedRoute(); + } + + @Override + public Route findRouteByStartAndEndSignal(Simulation simulation, String startSignalCode, String endSignalCode) { + Signal start = simulation.getRepository().getByCode(startSignalCode, Signal.class); + List routeList = start.getRouteList(); + if (!CollectionUtils.isEmpty(routeList)) { + for (Route route : routeList) { + if (Objects.equals(route.getDestination().getCode(), endSignalCode)) { + return route; + } + } + } + return null; + } + + @Override + public void settingGuideRoute(Simulation simulation, String routeCode) { + Route route = simulation.getRepository().getByCode(routeCode, Route.class); + this.routeService.setGuide(simulation, route); + } + + @Override + public void openScreenDoor(Simulation simulation, String standCode) { + Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); + if (Objects.nonNull(stand.getPsd())) { + this.standService.openScreenDoor(simulation, stand.getPsd()); + } + } + + @Override + public void closeScreenDoor(Simulation simulation, String standCode) { + Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); + if (Objects.nonNull(stand.getPsd())) { + this.standService.closeScreenDoor(simulation, stand.getPsd()); + } + } + + @Override + public void standHoldTrain(Simulation simulation, String standCode, boolean center) { + Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); + this.standService.holdTrain(simulation, stand, center); + } + + @Override + public void sysHoldTrain(Simulation simulation, String standCode) { + Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); + this.standService.sysHoldTrain(simulation, stand); + } + + @Override + public void standHoldTrainCancel(Simulation simulation, String standCode, boolean center) { + Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); + this.standService.cancelHoldTrain(simulation, stand, center); + } + + @Override + public void sysHoldTrainCancel(Simulation simulation, String standCode) { + Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); + this.standService.cancelSysHoldTrain(simulation, stand); + } + + @Override + public void ibpHoldTrain(Simulation simulation, String standCode) { + Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); + this.standService.ibpHoldTrain(simulation, stand); + } + + @Override + public void ibpHoldTrainCancel(Simulation simulation, String standCode) { + Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); + this.standService.cancelIbpHoldTrain(simulation, stand); + } + + @Override + public void standHoldTrainCancelAll(Simulation simulation, String standCode) { + Stand stand = simulation.getRepository().getByCode(standCode, Stand.class); + this.standService.cancelAllHoldTrain(simulation, stand); + } + + /** + * 办理引导 + */ + @Override + public void setGuide(Simulation simulation, String signalCode, String routeCode) { + SimulationDataRepository repository = simulation.getRepository(); + MapConfig config = repository.getConfig(); + Signal signal; + Route route = null; + if (StringUtils.hasText(signalCode)) { + signal = repository.getByCode(signalCode, Signal.class); + } else if (StringUtils.hasText(routeCode)) { + route = repository.getByCode(routeCode, Route.class); + signal = route.getStart(); + } else { + throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空"); + } + //条件检查 + if (config.isGuideNeedRouteSettingFirst()) { + List routeList = signal.getRouteList(); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(routeList, String.format("信号机[%s]非进路始端信号机", signal.getCode())); + if (route != null) { + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(route.isLock(), String.format("进路[%s]未办理", route.getCode())); + } else { + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotNull(signal.getLockedRoute(), String.format("信号机[%s]无已办理进路", signal.getCode())); + } + } +// if (config.isSomeCommandNeedInit()) { +// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isInit(), signal.debugStr() + "未初始化"); +// } + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signal.isForbidAspect(), + String.format("信号机[%s]需处于关闭状态", signal.getCode())); + boolean signalApproachOccupied = signal.getApproachPathList() + .stream().anyMatch(sectionPath -> sectionPath.getSectionList().stream().anyMatch(Section::isOccupied)); + if (config.isNeedApproachLockBeforeSetGuide()) { + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(signalApproachOccupied, + String.format("对%s开放引导操作失败,接近区段没有列车占用", signal.getName())); + } + //办理引导进路或开放引导信号 + if (config.isGuideNeedRouteSettingFirst()) { + this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getSignalModel().getGuideAspect()); + } else { + if (route != null) { + if (route.isLock()) { + this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getSignalModel().getGuideAspect()); + } else { + this.routeService.setGuide(simulation, route); + } + } else { + if (signal.getLockedRoute() != null) { //如果有已锁闭进路 + this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getSignalModel().getGuideAspect()); + } else if (!CollectionUtils.isEmpty(signal.getRouteList())) { //如果signal锁闭进路为null,筛选最合适的进路(直线进路>分叉进路>折返进路) + List collect = signal.getRouteList().stream() + .filter(r -> !r.isTurnBack() && CollectionUtils.isEmpty(r.getSwitchList())) + .collect(Collectors.toList()); + if (CollectionUtils.isEmpty(collect)) { + collect = signal.getRouteList().stream().filter(r -> !r.isTurnBack()).collect(Collectors.toList()); + } + if (CollectionUtils.isEmpty(collect)) { + collect = signal.getRouteList(); + } + route = collect.get(0); + this.routeService.setGuide(simulation, route); + } else { //如果信号机没有关联进路 + this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, signal.getSignalModel().getGuideAspect()); + } + } + } + } + + @Override + public void setEst(Simulation simulation, ESP esp) { + esp.update(true); + } + + @Override + public void cancelEst(Simulation simulation, ESP esp) { + esp.update(false); + } + + @Override + public void restart(Simulation simulation, Station station) { + Station deviceStation; + if (station.isCentralized()) { + deviceStation = station; + } else { + deviceStation = station.getDeviceStation(); + } + deviceStation.setInterlockMachineStarting(false); + } + + @Override + public void release(Simulation simulation, Station station) { + + } + + @Override + public void powerOnUnlock(Simulation simulation, Station station) { + if (!station.isCentralized()) { + station = station.getDeviceStation(); + } + Station deviceStation = station; + if (Objects.nonNull(deviceStation.getRestartTime()) + && deviceStation.getRestartTime().isBefore(LocalTime.now()) + && ((Simulation.FunctionalType.LESSON.equals(simulation.getBuildParams().getFunctionalType()) + || Simulation.FunctionalType.EXAM.equals(simulation.getBuildParams().getFunctionalType())) + ? true : deviceStation.getRestartTime().plusMinutes(8).isAfter(LocalTime.now()))) { + List
sections = simulation.getRepository().getSectionList(); + sections.stream().filter(section -> Objects.equals(section.getDeviceStation(), deviceStation)).forEach(Section::faultUnlock); + return; + } + throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("无效操作或连锁机重启过8分钟需手动解锁"); + } + + @Override + public void standEC(Simulation simulation, Stand stand) { + if (stand.getEsp() == null) + return; + stand.getEsp().update(true); + } + + @Override + public void cancelStandEC(Simulation simulation, Stand stand) { + if (stand.getEsp() == null) + return; + stand.getEsp().update(false); + } + + @Override + public void switchForceTurn(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + BusinessExceptionAssertEnum.SIMULATION_EXCEPTION_FOR_SHOW.assertTrue(!aSwitch.isLocked() && aSwitch.isSectionOccupied(), + String.format("对%s强行转岔操作被联锁逻辑取消", aSwitch.getName())); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isLocked(), String.format("道岔[%s]锁闭,无法转动", aSwitch.getCode())); + this.switchService.forceTurn(simulation, aSwitch); + } + + @Override + public void axlePreReset(Simulation simulation, String sectionCode) { + Section section = simulation.getRepository().getByCode(sectionCode, Section.class); + Section axleSection = section.findAxleCounterSection(); + //条件检查 + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), + section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); + VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); + if (!virtualAxleCounter.isOccupy()) + Section.AxleFault.ARB.apply(axleSection); + else + virtualAxleCounter.preReset(); + } + + @Override + public void switchAxlePreReset(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + aSwitch.setPreReset(true); + } + + @Override + public void switchSqueezeRecovery(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + Switch.SwitchFault.SQUEEZE.fix(aSwitch); + } + + @Override + public void switchCommand(Simulation simulation, String switchCode, Boolean auto, Boolean reserve, Boolean normal) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + if (auto != null) { + aSwitch.setAuto(auto); + } else { + if (normal != null) { + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(!aSwitch.isAuto(), "道岔未处于人工模式"); + if (normal) { + switchService.turn2NormalPosition(simulation, aSwitch); + } else { + switchService.turn2ReversePosition(simulation, aSwitch); + } + } + } + if (reserve != null) { + aSwitch.setDispatcherReserve(reserve); + } + } + + @Override + public void initializeBlock(Simulation simulation, String switchCode) { + Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); + aSwitch.setInit(true); + } + + @Override + public void initializeGuide(Simulation simulation, String signalCode) { + Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); + signal.setInit(true); + } + + @Override + public void cancelGuideInitialization(Simulation simulation, String signalCode) { + Signal signal = simulation.getRepository().getByCode(signalCode, Signal.class); + signal.setInit(false); + } + + @Override + public void axleReset(Simulation simulation, String sectionCode) { + VirtualRealitySectionAxleCounter axle = getAxleCounterAndCheck4Reset(simulation, sectionCode); + if (!axle.isOccupy()) + return; + axle.axleReset(); + } + + @Override + public void setOverlap(Simulation simulation, String signalCode, String overlapCode) { + SimulationDataRepository repository = simulation.getRepository(); + Signal signal = repository.getByCode(signalCode, Signal.class); + RouteOverlap overlap = repository.getByCode(overlapCode, RouteOverlap.class); + this.routeService.setOverlap(simulation, overlap); + } + + /** + * 获取计轴器并为预复位/复位操作检查设备状态 + */ + private VirtualRealitySectionAxleCounter getAxleCounterAndCheck4Reset(Simulation simulation, String sectionCode) { + Section section = simulation.getRepository().getByCode(sectionCode, Section.class); + Section axleSection = section.findAxleCounterSection(); + //条件检查 + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(axleSection != null && axleSection.isAxleCounter(), + section.debugStr() + "不是计轴区段也不归属于任何计轴区段"); + VirtualRealitySectionAxleCounter virtualAxleCounter = axleSection.getVirtualAxleCounter(); + if (simulation.getRepository().getConfig().isStationPreResetBeforeAxlePreReset()) { + Station deviceStation = axleSection.getDeviceStation(); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(deviceStation, section.debugStr() + "没有所属集中站"); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(deviceStation.isPreReset(), deviceStation.debugStr() + "需处于预复位状态"); + } + return virtualAxleCounter; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java new file mode 100644 index 000000000..8e3039c71 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/CiLogic.java @@ -0,0 +1,145 @@ +package club.joylink.rtss.simulation.cbtc.CI; + +import club.joylink.rtss.simulation.cbtc.CI.device.CiDeviceStatusCollector; +import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService; +import club.joylink.rtss.simulation.cbtc.CI.device.CiService; +import club.joylink.rtss.simulation.cbtc.CI.device.CiSignalControlService; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; +import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.MapConfig; +import club.joylink.rtss.simulation.cbtc.data.map.Route; +import club.joylink.rtss.simulation.cbtc.data.map.RouteOverlap; +import club.joylink.rtss.simulation.cbtc.data.map.Section; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; + +@Slf4j +@Component +public class CiLogic { + @Autowired + private CiDeviceStatusCollector deviceStatusCollector; + @Autowired + private CiRouteService routeService; + @Autowired + private CiSignalControlService signalControlService; + @Autowired + private CiService ciService; + + public void run(Simulation simulation) { + // 采集真实设备状态 + this.deviceStatusCollector.collect(simulation); + // 联锁监控逻辑 + SimulationDataRepository repository = simulation.getRepository(); + List routeList = repository.getRouteList(); + for (Route route : routeList) { + this.interlockMonitor(simulation, route); + } + List routeOverlapList = repository.getRouteOverlapList(); + for (RouteOverlap routeOverlap : routeOverlapList) { + this.overlapMonitor(simulation, routeOverlap); + } + } + + /** + * 进路监控 + * @param simulation + * @param route + */ + public void interlockMonitor(Simulation simulation, Route route) { + if (route.isCiControl()) { // 进路联锁自动触发 + if (!route.isLock() && !route.isSetting() && this.ciService.isCiRouteTrigger(simulation, route)) { + this.routeService.setRoute(simulation, route); + } + } else if (route.isFleetMode()) { // 联锁自动进路 + if (this.ciService.isCiRouteTrigger(simulation, route)) { + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getAspect()); + } + } + if (route.isSetting() || route.isLock() || route.isNormalUnlock()) { // 监控中的进路 + if (route.isDelayUnlocking()) { + this.routeService.delayUnlocking(simulation, route, route.getDelayUnlockDevice()); + } + if (route.isSetting()) { + this.routeService.routeSettingProcess(simulation, route); + } + if (route.isNormalUnlock()) { + this.routeService.trainUnlockRoute(simulation, route); + } + if (route.isOpenMain() || route.isOpenGuide()) { + // 进路首区段列车占用,进路开始解锁 + Section firstLogicSection = route.getFirstLogicSection(); + SimulationDataRepository repository = simulation.getRepository(); + if (repository.isTrainHeadOccupy(firstLogicSection)) { + this.trainUnlockStart(simulation, route); + } + } + if (route.isOpenMain()) { // 主信号开放 + this.ciService.interlockCheck(simulation, route); + SignalAspect aspect = this.ciService.getRouteCurrentMaxAspect(route); + if (!aspect.equals(route.getStart().getAspect())) {//与联锁显示不同,关闭信号 + log.info("进路[{}]联锁条件不满足,关闭信号", route.debugStr()); + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, + route.getStart(), route.getStart().getSignalModel().getDefaultAspect()); + } + } + // 进路延续保护办理判断 + if (route.isSettingOverlap()) { + this.ciService.checkAndTrySettingOverlap(simulation, route.getOverlap()); + } + } + } + + public void trainUnlockStart(Simulation simulation, Route route) { + route.startNormalUnlock(); + log.info("进路[{}]因列车进入,关闭信号", route.debugStr()); + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, + route.getStart(), route.getStart().getSignalModel().getDefaultAspect()); + } + + /** + * 延续保护进路监控 + * @param simulation + * @param overlap + */ + public void overlapMonitor(Simulation simulation, RouteOverlap overlap) { + MapConfig config = simulation.getRepository().getConfig(); + if (config.isOverlapSettingByTrigger() && overlap.isTriggerSectionOccupied()) { + this.ciService.checkAndTrySettingOverlap(simulation, overlap); + } + if (overlap.isSetting()) { + this.routeService.overlapSettingProcess(simulation, overlap); + } + if (overlap.isForbidden()) { + this.routeService.checkAndAllowOverlap(simulation, overlap); + } + if (overlap.isLock() && !this.ciService.interlockCheck(simulation, overlap)) { + overlap.setLock(false); + } + if (overlap.isSectionOverlapLocked()) { + if (simulation.getRepository().isTrainParking(overlap.getSection())) { + log.debug("列车停稳,延续保护[{}}],触发区段[{}}]立即解锁", + overlap.getName(), + overlap.getSection().debugStr()); + overlap.releaseImmediately(); + return; + } + if (overlap.isReleasing()) { + overlap.releaseProgress(); + } else if (!overlap.isReleasing() && simulation.getRepository().isTrainHeadOccupy(overlap.getSection())) { + // 进路首区段列车占用,进路开始解锁 + overlap.startReleasing(); + } + } + } + + public void addJobs(Simulation simulation) { + simulation.addJob(SimulationModule.CI.name(), () -> this.run(simulation), SimulationConstants.CI_LOOP_RATE); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiDeviceStatusCollector.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiDeviceStatusCollector.java new file mode 100644 index 000000000..2716f9a7e --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiDeviceStatusCollector.java @@ -0,0 +1,79 @@ +package club.joylink.rtss.simulation.cbtc.CI.device; + +import club.joylink.rtss.simulation.cbtc.ATP.ground.GroundAtpApiService; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.PSD; +import club.joylink.rtss.simulation.cbtc.data.map.Section; +import club.joylink.rtss.simulation.cbtc.data.map.Signal; +import club.joylink.rtss.simulation.cbtc.data.map.Switch; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class CiDeviceStatusCollector { + @Autowired + private GroundAtpApiService groundAtpApiService; + public void collect(Simulation simulation) { + SimulationDataRepository repository = simulation.getRepository(); + this.collectSection(repository, repository.getSectionList()); + this.collectSignal(repository, repository.getSignalList()); + this.collectSwitch(repository, repository.getSwitchList()); + this.collectPsd(repository, repository.getPSDList()); + this.groundAtpApiService.receiveAndHandleAxleSectionStatus(simulation); + } + + private void collectPsd(SimulationDataRepository repository, List psdList) { + for (PSD psd : psdList) { + VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor(); + if (vrPsd != null) { + psd.apply(vrPsd.isClose(), vrPsd.isLock(), vrPsd.isInterlockRelease()); + } + } + } + + private void collectSection(SimulationDataRepository repository, List
sectionList) { + for (Section section : sectionList) { + VirtualRealitySectionAxleCounter axle = section.getVirtualAxleCounter(); + if (axle != null) { + if (axle.isOccupy()) { + section.axleCounterOccupy(axle.isRight()); + } else { + section.axleCounterClear(); + } + } + } + } + + private void collectSwitch(SimulationDataRepository repository, List switchList) { + // 道岔位置状态 + switchList.forEach(aSwitch -> { + VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); + aSwitch.updatePos(vrSwitch.getP()); + }); + } + + private void collectSignal(SimulationDataRepository repository, List signalList) { + for (Signal signal : signalList) { + if (signal.isVirtual()) { + continue; + } + VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); + SignalAspect aspect = virtualSignal.getAspect(); + if (aspect.equals(SignalAspect.No)) { + signal.setLogicLight(true); + } else { + signal.setLogicLight(false); + signal.setAspect(aspect); + } + } + } + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java new file mode 100644 index 000000000..e5b5955d4 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiRouteService.java @@ -0,0 +1,660 @@ +package club.joylink.rtss.simulation.cbtc.CI.device; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; +import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.time.LocalDateTime; +import java.util.*; + +@Slf4j +@Component +public class CiRouteService { + @Autowired + private CiSwitchControlService switchControlService; + @Autowired + private CiSignalControlService signalControlService; + @Autowired + private CiService ciService; + + /** + * 进路排列检查 + * @param simulation + * @param route + * @return + */ + public static Route.CheckFailMessage routeSetCheck(Simulation simulation, Route route) { + MapConfig config = simulation.getRepository().getConfig(); + Signal start = route.getStart(); + if (!config.isSignalBlockRouteSettable()) { + // 信号封锁,不能办理 + if (start.isBlockade()) { + return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalBlockade, start); + } + } + // 进路中道岔没有被征用或锁定在相反位置 + Route.CheckFailMessage failMessage = setSwitchCheck(route.getSwitchList()); + if (failMessage != null) { + return failMessage; + } + // 进路中道岔是否存在和监控中进路延续保护冲突 + failMessage = monitorRouteOverlapConflictCheck(simulation, route); + if (failMessage != null) { + return failMessage; + } + // 进路内区段封锁/锁闭方向检查 + List
sectionList = route.getSectionList(); + for (Section section : sectionList) { + // 封锁状态 + if (section.isBlockade()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); + } else if (!CollectionUtils.isEmpty(section.getLogicList())) { + for (Section logicSection : section.getLogicList()) { + if (logicSection.isBlockade()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, logicSection); + } + } + } else if (section.getParent() != null) { + if (section.getParent().isCross() && section.getParent().isBlockade()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); + } + } + // 进路内区段锁闭方向不是此进路方向 + if ((section.isRouteLock() || section.isOverlapLock()) && + !Objects.equals(section.isLockRight(), start.isRight())) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionLockOppositeDirection, section); + } + // 故障占用 + for (int i = 0; i < 3; i++) { + if (section.getParent() == null || section.isAxleCounter()) + break; + section = section.getParent(); + } + if (Section.AxleFault.FAULT.equals(section.getFault())) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionFaultOccupied, section); + } + } + //敌对进路 + List conflictingRouteList = route.getConflictingRouteList(); + for (Route conflict : conflictingRouteList) { + if (conflict.isSetting() || conflict.isLock()) { + return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, conflict); + } + } + if (start.isCbtcMode()) { + // CBTC办理检查 + Section firstLogicSection = route.getFirstLogicSection(); + if (firstLogicSection.isOccupied()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, firstLogicSection); + } + } else { + // 后备办理检查 + // 区段占用 + for (Section section : sectionList) { + if (section.isOccupied()) { + return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); + } + } + // 延续保护检查 + RouteOverlap overlap = route.getOverlap(); + if (Objects.nonNull(overlap)) { + SectionPath sectionPath = overlap.selectPath(); + failMessage = setSwitchCheck(sectionPath.getSwitchList()); + } + } + return failMessage; + } + + private static Route.CheckFailMessage monitorRouteOverlapConflictCheck(Simulation simulation, Route route) { + SimulationDataRepository repository = simulation.getRepository(); + List settingRoutes = repository.getSettingRoutes(); + for (Route sr : settingRoutes) { + if (sr.isSettingOverlap() && !repository.isTrainParking(sr.getOverlap().getSection())) { + SectionPath sectionPath = sr.getOverlap().selectPath(); + for (SwitchElement switchElement : sectionPath.getSwitchList()) { + if (route.isConflictSwitch(switchElement)) { + return new Route.CheckFailMessage(Route.CheckFailReason.SwitchCiUseOnOppositePosition, + switchElement.getASwitch()); + } + } + } + } + return null; + } + + private static Route.CheckFailMessage setSwitchCheck(List switchList) { + if (switchList != null) { + for (SwitchElement switchElement : switchList) { + Switch aSwitch = switchElement.getASwitch(); + if (aSwitch.isBlockade()) { // 道岔封锁 + return new Route.CheckFailMessage(Route.CheckFailReason.SwitchBlockade, aSwitch); + } + if ((aSwitch.isLocked() || aSwitch.isSectionOccupied()) && + aSwitch.getPos().equals(SwitchIndication.of(!switchElement.isNormal()))) {//道岔锁闭或占用在相反位置 + return new Route.CheckFailMessage(Route.CheckFailReason.SwitchLockPositionError, aSwitch); + } + if (aSwitch.isCiUseOnOppositePosition(switchElement.isNormal())) { // 道岔征用在相反位置 + return new Route.CheckFailMessage(Route.CheckFailReason.SwitchCiUseOnOppositePosition, aSwitch); + } + } + } + return null; + } + + /** + * 排列引导进路 + * @param simulation + * @param route + */ + public void setGuide(Simulation simulation, Route route) { + // 引导进路开始办理 + LocalDateTime systemTime = simulation.getSystemTime(); + route.startGuideSetting(systemTime); + // 道岔征用 + for (SwitchElement switchElement : route.getSwitchList()) { + switchElement.getASwitch().ciUse(switchElement.isNormal()); + } + simulation.getRepository().addSettingRoute(route); + } + + /** + * 排列进路 + * @param simulation + * @param route + * @return + */ + public Route.CheckFailMessage setRoute(Simulation simulation, Route route) { + Route.CheckFailMessage failMessage = routeSetCheck(simulation, route); + if (failMessage == null) { + if (route.isLock() && !route.isFleetMode()) { + log.info("进路[{}]已经锁闭", route.debugStr()); + return null; + } + // 进路开始办理 + LocalDateTime systemTime = simulation.getSystemTime(); + route.startSetting(systemTime); + // 道岔征用 + for (SwitchElement switchElement : route.getSwitchList()) { + switchElement.getASwitch().ciUse(switchElement.isNormal()); + } + // 延续保护进路办理 + this.ciService.checkAndTrySettingOverlap(simulation, route.getOverlap()); + simulation.getRepository().addSettingRoute(route); + } + if (Objects.nonNull(failMessage)) { + log.info(String.format("进路[%s]排列检查失败,无法排列:%s", route.debugStr(), failMessage.debugStr())); + } + return failMessage; + } + + /** + * 排列进路过程控制 + * @param simulation + * @param route + */ + public void routeSettingProcess(Simulation simulation, Route route) { + if (route.isSetting()) { // 进路排列中 + MapConfig config = simulation.getRepository().getConfig(); + if (!config.isRouteSettingNoFail()) { + if (simulation.getSystemTime().isAfter(route.getSettingStartTime().plusSeconds(SimulationConstants.ROUTE_SETTING_TIMEOUT))) { + log.info("进路[{}]办理超时,取消办理2", route.debugStr()); + route.settingOver(); + route.setLock(false); + return; + } + } + // 道岔位置转换 + boolean mainRouteSwitchOnPos = this.switchControlService.batchTurnRouteSwitch(simulation, route.getSwitchList()); + // 预先锁闭 + if (mainRouteSwitchOnPos || config.isLockFirst()) { + // 进路排列区段预先锁闭 + this.checkAndLockRouteMain(route); + } + // 侧防办理 + this.flsSetting(simulation, route.getFlsList()); + // 检查信号开放条件,开信号 + this.ciService.interlockCheck(simulation, route); + if (!route.getStart().isBlockade()) { + if (route.isGuideSetting()) { + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getSignalModel().getGuideAspect()); + } else { + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getAspect()); + } + } + if ((route.getAspect().equals(route.getStart().getAspect())) || + (route.isGuideSetting() && route.getStart().getAspect().equals(route.getStart().getSignalModel().getGuideAspect()))) { + log.debug("进路[{}]信号开放,办理结束", route.debugStr()); + route.settingOver(); + } + } + } + + private void flsSetting(Simulation simulation, List flsList) { + // 侧防道岔转换 + if (!CollectionUtils.isEmpty(flsList)) { + for (RouteFls routeFls : flsList) { + List level1List = routeFls.getLevel1List(); + for (RouteFls.FlsElement flsElement : level1List) { + SwitchElement pSwitch = flsElement.getPSwitch(); + if (pSwitch != null) { + boolean onPos = this.switchControlService.turnRouteSwitch(simulation, pSwitch); + if (onPos) { + pSwitch.getASwitch().fpLock(); + } + } + } + } + } + } + + /** + * 检查并锁闭主进路(不包含侧防和延续保护) + * @param route + */ + private void checkAndLockRouteMain(Route route) { + boolean right = route.isRight(); + List
sectionList = route.getSectionList(); + List switchList = route.getSwitchList(); + for (SwitchElement switchElement : switchList) { + if (switchElement.isOnPosition()) { + switchElement.getASwitch().routeLock(route); + } + } + for (Section section : sectionList) { + if (section.isSwitchTrack()) { + Switch relSwitch = section.getRelSwitch(); + relSwitch.sectionRouteLocking(route, right); + } else { + section.routeLocking(route, right); + } + } + route.setLock(true); + } + + /** + * 解锁进路 + * @param simulation + * @param route + */ + public void unlockRoute(Simulation simulation, Route route) { + // 取消自动进路 + this.cancelFleet(route); + // 关闭始端信号机 + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, + route.getStart(), route.getStart().getSignalModel().getDefaultAspect()); + log.debug(String.format("取消进路,信号机[%s(%s)]关灯", + route.getStart().getName(), route.getStart().getCode())); + //进路解锁 + route.setLock(false); + route.setSetting(false); + route.setAtsControl(false); + // 始端信号机锁闭进路置为null + route.getStart().setLockedRoute(null); + route.getStart().setLevel(Signal.LEVEL_Close); + simulation.getRepository().removeSettingRoute(route); + // 进路区段取消锁闭 + List
sectionList = route.getSectionList(); + for (Section section : sectionList) { + if (section.isOccupied() && !section.isFaultOccupied()) { // 区段列车占用 + route.startNormalUnlock(); + route.updateUnlockedSection(section); + return; + } + if (section.isSwitchTrack()) { + Switch relSwitch = section.getRelSwitch(); + relSwitch.routeUnlock(); + RouteFls routeFls = route.queryRouteFlsOfSwitch(relSwitch); + if (routeFls != null) { + routeFls.unlock(); + } + } else { + section.routeUnlocking(route); + } + } + // 进路延续保护解锁 + RouteOverlap overlap = route.getOverlap(); + if (Objects.nonNull(overlap)) { + overlap.releaseImmediately(); + log.debug(overlap.debugStr() + "因取消进路解锁"); + } + } + + public void delayUnlockStart(Simulation simulation, Route route, DelayUnlockDevice device) { + device.delayUnlockStart(route); + route.setDelayUnlockDevice(device); + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getStart().getSignalModel().getDefaultAspect()); + } + + /** + * 延时解锁进路 + * @param simulation + * @param route + */ + public void delayUnlocking(Simulation simulation, Route route, DelayUnlockDevice device) { + if (device.countAndCheckFinish(SimulationModule.CI.getRateMs())) { + // 延时结束,执行解锁 + if (device instanceof Signal) { + // 解锁整条进路 + this.unlockRoute(simulation, route); + } else if (device instanceof Switch) { + Switch aSwitch = (Switch) device; + this.faultUnlock(simulation, route, aSwitch); + } else if (device instanceof Section) { + ((Section) device).faultUnlock(); + } + route.setLock(false); + route.setDelayUnlockDevice(null); + } + } + + private void faultUnlock(Simulation simulation, Route route, Switch aSwitch) { + aSwitch.faultUnlock(); + aSwitch.sectionFaultUnlock(); + if (route != null) { + route.unlockRouteFlsOfSwitch(aSwitch); //进路中该道岔对应的侧防解除锁闭 + RouteOverlap overlap = route.getOverlap(); + if (overlap != null) { + for (SectionPath sectionPath : overlap.getPathList()) { + overlap.unlockFlsOfSwitch(sectionPath.getFlsList(), aSwitch); //延续保护中该道岔的侧防解除锁闭 + } + } + } + } + + /** + * 道岔区段故障解锁 + * @param simulation + * @param aSwitch + * @param route + */ + public void switchFaultUnlock(Simulation simulation, Switch aSwitch, Route route) { + if (route != null) { + if (route.isApproachLock() || aSwitch.isOverlapLock()) { + // 延时解锁 + this.delayUnlockStart(simulation, route, aSwitch); + return; + } else { + route.setLock(false); + } + } + this.faultUnlock(simulation, route, aSwitch); + } + + /** + * 区故解 + */ + public void sectionFaultUnlock(Simulation simulation, Section section, Route route) { + if (route != null) { + if (route.getStart().isApproachLock() || section.isOverlapLock()) { + // 区段延时解锁 + this.delayUnlockStart(simulation, route, section); + return; + } else { + if (route.isOpenMain() || route.isOpenGuide()) { + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), + route.getStart().getSignalModel().getDefaultAspect()); + } + route.setLock(false); + } + } + section.faultUnlock(); + if (section.isShowLogic()) { + section.getLogicList().forEach(Section::faultUnlock); + } + } + + /** + * 列车逐段解锁进路 + * @param simulation + * @param route + */ + public void trainUnlockRoute(Simulation simulation, Route route) { + if (!route.isNormalUnlock()) { + return; + } + if (!route.isFleetMode()) { // 连续通过进路不解锁,非连续通过进路随最后一辆车的运行而解锁 + boolean right = route.getStart().isRight(); + // 区段是顺序的(否则会有问题) + boolean allUnlock = true; + if (Objects.isNull(route.getUnlockedSection())) { + log.error(String.format("进路[%s(%s)]正常解锁异常", route.getName(), route.getCode())); + return; + } + List
sectionList = route.getSectionList(); + for (int i = 0; i < sectionList.size(); i++) { + Section section = sectionList.get(i); + if (!Objects.equals(route.getUnlockedSection(), section)) { + continue; + } + Switch relSwitch = section.getRelSwitch(); + if (section.isOccupied()) { + // 区段逻辑占用,且有逻辑区段 + if (section.isOccupied() && !CollectionUtils.isEmpty(section.getLogicList())) { + // 逻辑区段占用,根据逻辑区段占用位置解锁 + List
logicList = section.getLogicList(); + if (!right) { // 向左,逻辑区段列表reverse + logicList = new ArrayList<>(section.getLogicList()); + Collections.reverse(logicList); + } + for (Section logic : logicList) { + if (!logic.isOccupied() && logic.isRouteLockOn(right)) { + logic.routeUnlocking(route); + logic.overlapUnlocking(); + } else if(logic.isOccupied()) { + break; + } + } + } + allUnlock = false; + break; + } else { + if (section.isSwitchTrack()) { // 如果是道岔区段,解锁道岔 + section.routeUnlocking(route); + if (section.getParent() != null && section.getParent().isCross()) { + section.getParent().routeUnlocking(route); + } + relSwitch.routeUnlock(); + relSwitch.overlapUnLock(); + // 侧防解锁 + route.unlockRouteFlsOfSwitch(relSwitch); + //检查道岔的联动道岔和计轴关联道岔是否可以解锁 + for (SwitchElement switchElement : route.getSwitchList()) { + if (switchElement.getASwitch().equals(relSwitch)) { + continue; + } + Switch aSwitch = switchElement.getASwitch(); + if (route.isRouteSection(aSwitch.getA())) { + continue; + } + if (relSwitch.isLinkedSwitch(aSwitch) || relSwitch.isBConnectTo(aSwitch)) { + if (!aSwitch.getA().isRouteLock()) { + aSwitch.routeUnlock(); + aSwitch.overlapUnLock(); + } + } + } + } else { + if (!CollectionUtils.isEmpty(section.getLogicList())) { + for (Section logic : section.getLogicList()) { + if (!logic.isOccupied() && logic.isRouteLockOn(right)) { + logic.routeUnlocking(route); + logic.overlapUnlocking(); + } + } + } + section.routeUnlocking(route); + section.overlapUnlocking(); + } + log.debug(section.debugStr() + "因正常解锁解锁"); + } + if (!section.isRouteLock() && (i + 1) < sectionList.size()) { + // 区段已经解锁,更新解锁区段 + route.updateUnlockedSection(sectionList.get(i + 1)); + } else if (section.isRouteLock() && (i + 1) >= sectionList.size()) { + allUnlock = true; + } + } + Section firstRouteSection = route.getFirstRouteSection(); + if (firstRouteSection.isFree()) { + route.getStart().setReblockade(false); + } + if (allUnlock) { // 进路所有区段都已经解锁,解锁完成 + route.normalUnlockOver(); + simulation.getRepository().removeSettingRoute(route); + log.debug(String.format("进路[%s(%s)-%s]解锁完毕,移除", route.getName(), route.getCode(), route.isTurnBack() ? "Z" : "B")); + } + } + } + + /** + * 延续保护办理 + * @param simulation + * @param overlap + */ + public void setOverlap(Simulation simulation, RouteOverlap overlap) { + if (overlap.isSetting()) { + // 已经在办理了 + return; + } + LocalDateTime systemTime = simulation.getSystemTime(); + overlap.startSetting(systemTime); + } + + public void checkAndAllowOverlap(Simulation simulation, RouteOverlap overlap) { + if (!overlap.getSection().isOccupied()) { + overlap.allow(); + return; + } + SectionPath sectionPath = overlap.selectPath(); + if (simulation.getRepository().isTrainHeadOccupy(sectionPath.getFirstSection())) { + overlap.allow(); + } + } + + /** + * 延续保护办理过程 + * @param simulation + * @param overlap + */ + public void overlapSettingProcess(Simulation simulation, RouteOverlap overlap) { + if (!overlap.isSetting()) { + return; + } + if (!overlap.getSection().isRouteLock()) { + return; + } + MapConfig config = simulation.getRepository().getConfig(); + if (!config.isRouteSettingNoFail()) { + if (simulation.getSystemTime().isAfter(overlap.getSettingStartTime().plusSeconds(SimulationConstants.ROUTE_SETTING_TIMEOUT))) { + log.info(String.format("进路延续保护[%s]办理失败", overlap.debugStr())); + overlap.settingOver(); + return; + } + } + SectionPath sectionPath = overlap.selectPath(); + for (SwitchElement switchElement : sectionPath.getSwitchList()) { + if (!switchElement.getASwitch().ciUse(switchElement.isNormal())) { + return; + } + } + // 延续保护位置转动 + boolean onPos = this.switchControlService.batchTurnRouteSwitch(simulation, sectionPath.getSwitchList()); + // 延续保护区段预先锁闭 + if (onPos || config.isLockFirst()) { + this.checkAndLockOverlap(simulation, overlap); + } + // 侧防办理 + this.flsSetting(simulation, sectionPath.getFlsList()); + if (this.ciService.interlockCheck(simulation, overlap)) { + log.debug(String.format("进路延续保护[%s]办理成功", overlap.debugStr())); + overlap.setLock(true); + overlap.settingOver(); + } + } + + private void checkAndLockOverlap(Simulation simulation, RouteOverlap overlap) { + SectionPath sectionPath = overlap.selectPath(); + boolean right = overlap.isRight(); + List
logicList = sectionPath.getLogicList(); + if (!CollectionUtils.isEmpty(logicList)) { + for (Section section : logicList) { + section.overlapLocking(right); + } + } else { + List
sectionList = sectionPath.getSectionList(); + for (Section section : sectionList) { + if (section.isSwitchTrack()) { + Switch relSwitch = section.getRelSwitch(); + relSwitch.sectionOverlapLocking(right); + } else { + section.overlapLocking(right); + } + } + } + } + + public void routeReopen(Simulation simulation, Route route) { + // 检查信号开放条件,开信号 + this.ciService.interlockCheck(simulation, route); + if (!route.getStart().isBlockade()) { + this.signalControlService.tryControlSignalAspectAccordingLevel(simulation, route.getStart(), route.getAspect()); + } + } + + /** + * 设置自动进路模式 + * + * @param route + */ + public void setFleet(Route route) { + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFlt(), + "不是自动进路,不能设置自动进路"); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isCiControl(), + "进路联锁自动触发,不能设置自动进路"); + if (!route.isFleetMode()) { + route.setFleetMode(true); + } + } + + /** + * 取消自动进路 + * @param route + */ + public void cancelFleet(Route route) { + if (route.isFleetMode()) { + route.setFleetMode(false); + } + } + + /** + * 设置联锁自动触发 + * @param route + */ + public void setCIAutoTrigger(Route route) { + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isFleetMode(), + "进路处于自动进路模式中,不能设置联锁自动触发"); + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(route.isArs(), + "进路不具有该功能,无法设置为联锁自动触发"); + if (!route.isCiControl()) { + route.setCiControl(true); + } + } + + /** + * 取消联锁自动触发 + * @param route + */ + public void cancelCIAutoTrigger(Route route) { + if (route.isCiControl()) { + route.setCiControl(false); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSectionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSectionService.java new file mode 100644 index 000000000..9df01ffb7 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSectionService.java @@ -0,0 +1,46 @@ +package club.joylink.rtss.simulation.cbtc.CI.device; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; +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.Signal; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.Objects; + +@Slf4j +@Component +public class CiSectionService { + @Autowired + private CiSignalControlService signalControlService; + /** + * 封锁(封锁后,包含区段的进路不能排列) + */ + public void blockade(Section section) { + if (!section.isBlockade()) { + section.setBlockade(true); + if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) { + section.getLogicList().forEach(logic -> logic.setBlockade(true)); + } + } + } + + /** + * 解封 + */ + public void unblock(Section section) { + if (section.isBlockade()) { + section.setBlockade(false); + if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) { + section.getLogicList().forEach(logic -> logic.setBlockade(false)); + } + } + } + + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java new file mode 100644 index 000000000..31abb2a4c --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiService.java @@ -0,0 +1,305 @@ +package club.joylink.rtss.simulation.cbtc.CI.device; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.data.map.*; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; + +import java.util.List; + +@Slf4j +@Component +public class CiService { + + public boolean isCiRouteTrigger(Simulation simulation, Route route) { + return route.isCiTrigger(); + } + + /** + * 检查延续保护是否需要办理,若需要,触发办理 + * @param simulation + * @param overlap + */ + public void checkAndTrySettingOverlap(Simulation simulation, RouteOverlap overlap) { + if (overlap != null && !overlap.isSetting() && !overlap.isLock() && + !overlap.isForbidden()) { + if (overlap.getSection().isRouteLock()) { + SectionPath sectionPath = overlap.selectPath(); + for (SwitchElement switchElement : sectionPath.getSwitchList()) { + if (switchElement.getASwitch().isLocked() && !switchElement.isOnPosition()) { + log.debug("延续保护进路[{}]道岔[{}]锁闭在相反位置,不触发办理", overlap.debugStr(), + switchElement.getASwitch().debugStr()); + return; + } + } + overlap.startSetting(simulation.getSystemTime()); + } + } + } + + /** + * 进路当前最高信号显示 + * + * @param route + * @return + */ + public SignalAspect getRouteCurrentMaxAspect(Route route) { + if (route.isNormalUnlock()) { + return route.getStart().getSignalModel().getDefaultAspect(); + } + return route.getStart().getMaxAspectByLevel(route.getAspect()); + } + + /** + * 延续保护检查 + * + * @param simulation + * @param overlap + * @return + */ + public boolean interlockCheck(Simulation simulation, RouteOverlap overlap) { + if (overlap != null) { + SectionPath sectionPath = overlap.selectPath(); + List
logicList = sectionPath.getLogicList(); + if (!CollectionUtils.isEmpty(logicList)) { + for (Section section : logicList) { + if (!section.isOverlapLockOn(overlap.isRight())) { + return false; + } + if (section.isOccupied()) { + return false; + } + } + } else { + List
sectionList = sectionPath.getSectionList(); + for (Section section : sectionList) { + if (!section.isOverlapLockOn(overlap.isRight())) { + return false; + } + if (section.isOccupied()) { + return false; + } + } + } + List switchList = sectionPath.getSwitchList(); + for (SwitchElement switchElement : switchList) { + if (!switchElement.isOnPosition()) { + return false; + } + } + List flsList = sectionPath.getFlsList(); + if (!this.interlockCheck(simulation, flsList)) { + return false; + } + } + return true; + } + + /** + * 侧防检查 + * + * @param simulation + * @param flsList + * @return + */ + private boolean interlockCheck(Simulation simulation, List flsList) { + if (CollectionUtils.isEmpty(flsList)) { + return true; + } + for (RouteFls routeFls : flsList) { + List level1List = routeFls.getLevel1List(); + for (RouteFls.FlsElement flsElement : level1List) { + SwitchElement pSwitch = flsElement.getPSwitch(); + if (pSwitch != null && !pSwitch.isOnPosition()) { + return false; + } else { + Signal pSignal = flsElement.getPSignal(); + if (pSignal != null && !pSignal.getSignalModel().getDefaultAspect().equals(pSignal.getAspect())) { + return false; + } + } + } + } + return true; + } + + public void interlockCheck(Simulation simulation, Route route) { + int level = this.checkRouteLevel(simulation, route); + route.getStart().setLevel(level); + } + + private int checkRouteLevel(Simulation simulation, Route route) { + int level = Signal.LEVEL_Close; + if (route.isNormalUnlock()) { + return level; + } + // 进路区段检查 + boolean right = route.isRight(); + List
sectionList = route.getSectionList(); + for (Section section : sectionList) { + if (!section.isRouteLock()) { +// log.debug("进路{}连锁条件检查失败:区段{}未锁闭", route.debugStr(), +// section.debugStr()); + return level; + } + if (!section.isRouteLockOn(right)) { +// log.debug("进路{}连锁条件检查失败:区段{}锁闭方向错误", route.debugStr(), +// section.debugStr()); + return level; + } + if (section.isNoStatus()) { +// log.debug("进路{}连锁条件检查失败:区段{}连锁无状态", route.debugStr(), +// section.debugStr()); + return level; + } + } + // 道岔位置一致检查 + for (SwitchElement element : route.getSwitchList()) { + if (!element.isOnPosition()) { +// log.debug("进路{}连锁条件检查失败:道岔{}位置{}", +// route.debugStr(), +// element.getASwitch().debugStr(), element.getASwitch().getPos()); + return level; + } + } + level = Signal.LEVEL_Guide; // 引导级 + // 进路侧防检查 + List flsList = route.getFlsList(); + if (!CollectionUtils.isEmpty(flsList)) { + for (RouteFls routeFls : flsList) { + List level1List = routeFls.getLevel1List(); + for (RouteFls.FlsElement flsElement : level1List) { + SwitchElement pSwitch = flsElement.getPSwitch(); + if (pSwitch != null && !pSwitch.isOnPosition()) { +// log.debug("进路{}连锁条件检查失败:侧防道岔{}位置不对", +// route.debugStr(), pSwitch.getASwitch().debugStr()); + return level; + } else { + SwitchElement fpae = flsElement.getFpae(); + Signal pSignal = flsElement.getPSignal(); + if (pSignal != null && !pSignal.getSignalModel().getDefaultAspect().equals(pSignal.getAspect())) { + if (fpae != null) { + if (fpae.isOnPosition()) { + return level; + } + } else { + return level; + } + } + } + } + } + } + //超限区段检查 + for (SwitchElement element : route.getSwitchList()) { + RouteOverrun overrun = route.findOverrunBySwitch(element.getASwitch()); + if (overrun != null) { + if (overrun.getSection() != null && overrun.getSection().hasNctOccupy()) { +// log.debug("进路{}连锁条件检查失败:超限区段{}被占用", +// route.debugStr(), overrun.getCode()); + return level; + } + SwitchElement overrunSE = overrun.getSwitchElement(); + if (overrunSE != null && overrunSE.isOnPosition()) { + if (overrunSE.getASwitch().getAllSections().stream().anyMatch(Section::hasNctOccupy)) { +// log.debug("进路{}连锁条件检查失败:超限区段{}被占用", +// route.debugStr(), overrun.getCode()); + return level; + } + } + } + } + + if (route.getStart().isCbtcMode()) { + level = Signal.LEVEL_Atp; // ATP级 + } + // 站台紧急停车 + if (!CollectionUtils.isEmpty(route.getEspList())) { + for (ESP esp : route.getEspList()) { + if (esp.isEffective()) { +// log.debug("进路{}连锁条件检查失败:站台紧急停车按钮{}按下", route.debugStr(), +// esp.debugStr()); + return level; + } + } + } + // 区段占用检查 + for (Section section : sectionList) { + if (section.isOccupied()) { +// log.debug("进路{}连锁条件检查:区段{}占用", +// route.debugStr(), section.debugStr()); + return level; + } + if (section.getSpeedUpLimit() != -1) { +// log.debug("进路{}连锁条件检查:区段{}限速", +// route.debugStr(), section.debugStr()); + return level; + } + if (!CollectionUtils.isEmpty(section.getLogicList())) { + for (Section logic : section.getLogicList()) { + if (logic.getSpeedUpLimit() != -1) { +// log.debug("进路{}连锁条件检查失败:区段{}限速", +// route.debugStr(), logic.debugStr()); + return level; + } + } + } + } + // 屏蔽门 + if (!CollectionUtils.isEmpty(route.getPsdList())) { + for (PSD psd : route.getPsdList()) { + if(Stand.Fault.PSD_CANNOT_BE_CLOSED.equals(psd.getStand().getFault()) && !psd.getStand().isInterlockRelease()) { + return Signal.LEVEL_Guide; + } + if (!psd.isCloseAndLock() && !psd.isInterlockRelease()) { +// log.debug("联锁网络检查:站台[{}({})]屏蔽门[{}({})]未关闭", +// psd.getStand().getName(), psd.getStand().getCode(), +// psd.getName(), psd.getCode()); + return level; + } + } + } + // 站台扣车 + if (!CollectionUtils.isEmpty(route.getStandHoldList())) { + for (Stand stand : route.getStandHoldList()) { + if (stand.isHoldTrain()) { +// log.debug("进路[{}]连锁条件检查:站台[{}({})]扣车", +// route.debugStr(), +// stand.getName(), stand.getCode()); + return level; + } + } + } + // 延续保护 + if (!this.interlockCheck(simulation, route.getOverlap())) { +// log.debug("进路[{}]连锁条件检查: 延续保护未锁闭", route.debugStr()); + return level; + } + return Signal.LEVEL_Main; // 主信号级 + } + + public boolean isRouteSwitchLost(Simulation simulation, Route route) { + for (SwitchElement switchElement : route.getSwitchList()) { + if (switchElement.getASwitch().isFaultOnPosition(switchElement.isNormal())) { + return true; + } + } + List flsList = route.getFlsList(); + if (flsList != null) { + for (RouteFls routeFls : flsList) { + for (RouteFls.FlsElement flsElement : routeFls.getLevel1List()) { + SwitchElement pSwitch = flsElement.getPSwitch(); + if (pSwitch != null) { + if (pSwitch.getASwitch().isFaultOnPosition(pSwitch.isNormal())) { + return true; + } + } + } + } + } + return false; + } + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSignalControlService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSignalControlService.java new file mode 100644 index 000000000..902e03aff --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSignalControlService.java @@ -0,0 +1,105 @@ +package club.joylink.rtss.simulation.cbtc.CI.device; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.data.map.Signal; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +public class CiSignalControlService { + @Autowired + private VirtualRealityDeviceService virtualRealityDeviceService; + + public void tryControlSignalAspectAccordingLevel(Simulation simulation, Signal signal, SignalAspect aspect) { + VirtualRealitySignal vrSignal = signal.getVirtualSignal(); + boolean cbtcMode = signal.isCbtcMode(); + if (cbtcMode) {//CBTC模式 + if (!signal.isLogicLight()) { + return; + } + if (vrSignal.getModel().getDefaultAspect().equals(aspect)) { + signal.setAspect(aspect); + } else if (aspect.equals(vrSignal.getModel().getGuideAspect()) && (signal.isGuideLevel() || signal.isAtpLevel() || signal.isMainLevel())) { + signal.setAspect(aspect); + } else if (signal.isAtpLevel() || signal.isMainLevel()) { + signal.setAspect(aspect); + } + } else { // 后备模式 + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(vrSignal); + if (signal.isLogicLight()) { + return; + } + if (vrSignal.getModel().getDefaultAspect().equals(aspect)) { + this.virtualRealityDeviceService.control(simulation, vrSignal, aspect); + } else if (aspect.equals(vrSignal.getModel().getGuideAspect())) { + if (signal.isGuideLevel() || signal.isAtpLevel() || signal.isMainLevel()) { + this.virtualRealityDeviceService.control(simulation, vrSignal, aspect); + } + } else { + if (signal.isMainLevel()) { + this.virtualRealityDeviceService.control(simulation, vrSignal, aspect); + } + } + } + } + + /** + * 根据信号机接近消息控制室外信号机点灯/关闭 + * @param simulation + * @param signal + */ + public void controlLightOfSignal(Simulation simulation, Signal signal) { + VirtualRealitySignal vrSignal = signal.getVirtualSignal(); + if (signal.isCbtcMode()) { + if (vrSignal != null && !signal.isLogicLight()) { + this.virtualRealityDeviceService.control(simulation, vrSignal, SignalAspect.No); + } + } else { + if (vrSignal != null && signal.isLogicLight()) { + if (signal.getLockedRoute() != null && signal.getLockedRoute().getAspect().equals(signal.getAspect())) { + signal.getLockedRoute().startSetting(simulation.getSystemTime()); + } + this.virtualRealityDeviceService.control(simulation, vrSignal, vrSignal.getModel().getDefaultAspect()); + } + } + } + + /** + * 封锁(封锁后,包含信号机的进路不能排列) + * @param signal + */ + public void blockade(Simulation simulation, Signal signal) { + if(!signal.isBlockade()) { + signal.setBlockade(true); + this.closeRoute(simulation, signal); + if (signal.getLockedRoute() != null) { + signal.setReblockade(true); + log.debug(signal.debugStr() + "因信号机封锁且有锁闭的进路而重复封锁"); + } + } + } + + /** + * 解封 + * @param signal + */ + public void unblock(Signal signal) { + if (signal.isBlockade()) { + signal.setBlockade(false); + } + } + + public void closeRoute(Simulation simulation, Signal signal) { + if (signal.isLogicLight()) { + signal.setAspect(signal.getSignalModel().getDefaultAspect()); + } else { + this.virtualRealityDeviceService.control(simulation, signal.getVirtualSignal(), signal.getSignalModel().getDefaultAspect()); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java new file mode 100644 index 000000000..e77fd5005 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiStandService.java @@ -0,0 +1,135 @@ +package club.joylink.rtss.simulation.cbtc.CI.device; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.map.PSD; +import club.joylink.rtss.simulation.cbtc.data.map.Route; +import club.joylink.rtss.simulation.cbtc.data.map.Signal; +import club.joylink.rtss.simulation.cbtc.data.map.Stand; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +@Slf4j +@Component +public class CiStandService { + @Autowired + private VirtualRealityDeviceService virtualRealityDeviceService; + @Autowired + private CiSignalControlService signalService; + /** + * 打开屏蔽门 + * + * @param simulation + * @param psd + */ + public void openScreenDoor(Simulation simulation, PSD psd) { + VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor(); + if (vrPsd.isPslControl()) { + return; + } + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.K); + } + + /** + * 关闭屏蔽门 + * + * @param simulation + * @param psd + */ + public void closeScreenDoor(Simulation simulation, PSD psd) { + VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor(); + if (vrPsd.isPslControl()) { + return; + } + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.G); + } + + /** + * 设置扣车 + * + * @param simulation + * @param stand + * @param center + */ + public void holdTrain(Simulation simulation, Stand stand, boolean center) { + if (center) { + stand.setCenterHoldTrain(true); + } else { + stand.setStationHoldTrain(true); + } + } + + /**系统扣车*/ + public void sysHoldTrain(Simulation simulation, Stand stand) { + stand.setSysHoldTrain(true); + } + + public void cancelSysHoldTrain(Simulation simulation, Stand stand) { + stand.setSysHoldTrain(false); + // 如果所有扣车都取消,开放出站信号机 + if (!stand.isHoldTrain()) { + this.reopenSignal(simulation, stand); + } + } + + public void ibpHoldTrain(Simulation simulation, Stand stand) { + stand.setIbpHoldTrain(true); + } + + public void cancelIbpHoldTrain(Simulation simulation, Stand stand) { + stand.setIbpHoldTrain(false); + // 如果所有扣车都取消,开放出站信号机 + if (!stand.isHoldTrain()) { + this.reopenSignal(simulation, stand); + } + } + + /** + * 取消扣车 + * + * @param simulation + * @param stand + * @param center + */ + public void cancelHoldTrain(Simulation simulation, Stand stand, boolean center) { + if (center) { + stand.setCenterHoldTrain(false); + } else { + stand.setStationHoldTrain(false); + } + // 如果所有扣车都取消,开放出站信号机 + if (!stand.isHoldTrain()) { + this.reopenSignal(simulation, stand); + } + } + + public void cancelAllHoldTrain(Simulation simulation, Stand stand) { + stand.setCenterHoldTrain(false); + stand.setStationHoldTrain(false); + this.reopenSignal(simulation, stand); + } + + private void reopenSignal(Simulation simulation, Stand stand) { + Signal signal = stand.getSection().getSignalOf(stand.isRight()); + if (Objects.nonNull(signal) && !signal.isMainAspect()) { + Route lockedRoute = signal.getLockedRoute(); + this.signalService.tryControlSignalAspectAccordingLevel(simulation, signal, lockedRoute.getAspect()); + } + } + + /** + * 设置或取消互锁解除 + * @param release 是否是设置 + */ + public void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release) { + stand.getPsd().getVirtualScreenDoor().updateIL(release); + stand.getPsd().setInterlockRelease(release); + if (release) { + this.reopenSignal(simulation, stand); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java new file mode 100644 index 000000000..569bd7adc --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/device/CiSwitchControlService.java @@ -0,0 +1,180 @@ +package club.joylink.rtss.simulation.cbtc.CI.device; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.map.*; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +public class CiSwitchControlService { + @Autowired + private VirtualRealityDeviceService virtualRealityDeviceService; + /** + * 道岔单锁 + * @param aSwitch + */ + public void singleLock(Switch aSwitch) { + if (!aSwitch.isSingleLock()) { + aSwitch.setSingleLock(true); + } + } + + /** + * 道岔单解 + * @param aSwitch + */ + public void singleUnlock(Switch aSwitch) { + if (aSwitch.isSingleLock()) { + aSwitch.setSingleLock(false); + } + } + + /** + * 封锁(封锁后,包含道岔的进路不能排列) + * @param aSwitch + */ + public void blockade(Switch aSwitch) { + if(!aSwitch.isBlockade()) { + aSwitch.setBlockade(true); + aSwitch.getA().setBlockade(true); + aSwitch.getB().setBlockade(true); + aSwitch.getC().setBlockade(true); + } + aSwitch.setInit(false); + } + + /** + * 解封 + * @param aSwitch + */ + public void unblock(Switch aSwitch) { + if(aSwitch.isBlockade()) { + aSwitch.setBlockade(false); + aSwitch.getA().setBlockade(false); + aSwitch.getB().setBlockade(false); + aSwitch.getC().setBlockade(false); + } + } + + /** + * 强转道岔 + * @param simulation + * @param aSwitch + * @return + */ + public boolean forceTurn(Simulation simulation, Switch aSwitch) { + if (!aSwitch.isSectionOccupied()) { + return false; + } + if (aSwitch.isLocked()) { + return false; + } + // 设置强扳授权 + aSwitch.setForceTurnRemain(120 * 1000); + this.turn(simulation, aSwitch); + // 手动释放强扳 + aSwitch.setForceTurnRemain(0); + return true; + } + + /** + * 道岔转动 + * @param simulation + * @param aSwitch + * @return + */ + public boolean turn(Simulation simulation, Switch aSwitch) { + VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); + if (vrSwitch.getCommand() != null) { + switch (vrSwitch.getCommand()) { + case NP: + return this.turn2ReversePosition(simulation, aSwitch); + case RP: + return this.turn2NormalPosition(simulation, aSwitch); + } + } else { + if (aSwitch.isPosN()) { + return this.turn2ReversePosition(simulation, aSwitch); + } else if (aSwitch.isPosR()) { + return this.turn2ReversePosition(simulation, aSwitch); + } + } + return this.turn2NormalPosition(simulation, aSwitch); + } + + /** + * 道岔定操 + * @param simulation + * @param aSwitch + */ + public boolean turn2NormalPosition(Simulation simulation, Switch aSwitch) { + if (!this.checkTurnCondition(aSwitch)) { + return false; + } + VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); + this.virtualRealityDeviceService.control(simulation, vrSwitch, VirtualRealitySwitch.Operation.NP); + return true; + } + + /** + * 道岔反操 + * @param simulation + * @param aSwitch + * @return + */ + public boolean turn2ReversePosition(Simulation simulation, Switch aSwitch) { + if (!this.checkTurnCondition(aSwitch)) { + return false; + } + VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); + this.virtualRealityDeviceService.control(simulation, vrSwitch, VirtualRealitySwitch.Operation.RP); + return true; + } + + /** + * 检查道岔转动条件 + * @param aSwitch + * @return + */ + private boolean checkTurnCondition(Switch aSwitch) { + // 道岔锁闭 或者 道岔占用且无强扳授权,则不能转动 + return !(aSwitch.isLocked() || (aSwitch.isSectionOccupied() && aSwitch.getForceTurnRemain() <= 0)); + } + + /** + * 批量转动道岔到指定位置 + * @param simulation + * @param list + */ + public boolean batchTurnRouteSwitch(Simulation simulation, List list) { + boolean allOn = true; + if (list == null) { + return true; + } + for (SwitchElement switchElement : list) { + boolean onPos = this.turnRouteSwitch(simulation, switchElement); + if (!onPos) { + allOn = false; + } + } + return allOn; + } + + public boolean turnRouteSwitch(Simulation simulation, SwitchElement switchElement) { + boolean onPos = true; + if (!switchElement.isOnPosition()) { + onPos = false; + if (switchElement.isNormal()) { + this.turn2NormalPosition(simulation, switchElement.getASwitch()); + } else { + this.turn2ReversePosition(simulation, switchElement.getASwitch()); + } + } + return onPos; + } + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/AutoSignalService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/AutoSignalService.java index 3244c15d2..b4d69e11c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/AutoSignalService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/AutoSignalService.java @@ -1,59 +1,59 @@ -package club.joylink.rtss.simulation.cbtc.CI.service; - -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.data.map.AutoSignal; -import club.joylink.rtss.simulation.cbtc.data.map.Section; -import club.joylink.rtss.simulation.cbtc.data.map.Signal; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * 自动信号服务 - */ -@Slf4j -@Component -public class AutoSignalService { - - @Autowired - private SignalService signalService; - - /** - * 根据连锁关系更新信号显示 - * @param simulation - * @param autoSignal - */ - public void updateSignalDisplay(Simulation simulation, AutoSignal autoSignal) { - Signal signal = autoSignal.getSignal(); - if (!signal.isLogicLight()) { - List
sectionList = autoSignal.getSectionList(); - boolean clear = true; // 所有区段是否出清 - for (Section section : sectionList) { - if (section.isOccupied()) { - clear = false; - break; - } - } - if (clear) { // 全部出清,开信号机 - this.signalService.openGreenSignal(simulation, signal); - } else { // 关信号机 - this.signalService.close(simulation, signal); - } - } else { - if (!signal.isNormalOpen()) { - this.signalService.openGreenSignal(simulation, signal); - } - } -// if (!clear) { // 信号机物理点红灯 -// if (signal.isLogicLight()) { -// signal.changeLightType(false); +//package club.joylink.rtss.simulation.cbtc.CI.service; +// +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.data.map.AutoSignal; +//import club.joylink.rtss.simulation.cbtc.data.map.Section; +//import club.joylink.rtss.simulation.cbtc.data.map.Signal; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +// +//import java.util.List; +// +///** +// * 自动信号服务 +// */ +//@Slf4j +//@Component +//public class AutoSignalService { +// +// @Autowired +// private SignalService signalService; +// +// /** +// * 根据连锁关系更新信号显示 +// * @param simulation +// * @param autoSignal +// */ +// public void updateSignalDisplay(Simulation simulation, AutoSignal autoSignal) { +// Signal signal = autoSignal.getSignal(); +// if (!signal.isLogicLight()) { +// List
sectionList = autoSignal.getSectionList(); +// boolean clear = true; // 所有区段是否出清 +// for (Section section : sectionList) { +// if (section.isOccupied()) { +// clear = false; +// break; +// } +// } +// if (clear) { // 全部出清,开信号机 +// this.signalService.openGreenSignal(simulation, signal); +// } else { // 关信号机 +// this.signalService.close(simulation, signal); +// } +// } else { +// if (!signal.isMainAspect()) { +// this.signalService.openGreenSignal(simulation, signal); // } -// this.signalService.close(simulation, signal); -// } else { // 信号机开灯 -// this.signalService.openGreenSignal(simulation, signal); // } - } - -} +//// if (!clear) { // 信号机物理点红灯 +//// if (signal.isLogicLight()) { +//// signal.changeLightType(false); +//// } +//// this.signalService.close(simulation, signal); +//// } else { // 信号机开灯 +//// this.signalService.openGreenSignal(simulation, signal); +//// } +// } +// +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java index 1d8f92bf5..c217e97bb 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/RouteService.java @@ -1,1618 +1,1618 @@ -package club.joylink.rtss.simulation.cbtc.CI.service; - -import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; -import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; -import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; -import club.joylink.rtss.simulation.cbtc.data.map.*; -import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; -import club.joylink.rtss.simulation.cbtc.exception.SimulationException; -import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.time.LocalDateTime; -import java.util.*; -import java.util.stream.Collectors; - -/** - * 进路操作服务 - */ -@Component -@Slf4j -public class RouteService { - - @Autowired - private SwitchService switchService; - - @Autowired - private SignalService signalService; - - /** - * 进路办理条件检查 - * - * @param simulation - * @param route - * @return - */ - public static Route.CheckFailMessage check(Simulation simulation, Route route) { - Route.CheckFailMessage failMessage = baseCheck(simulation, route); - if (Objects.nonNull(failMessage)) { - return failMessage; - } -// // 区间运行方向检查 -// failMessage = this.directionRodCheck(simulation, route); +//package club.joylink.rtss.simulation.cbtc.CI.service; +// +//import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; +//import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; +//import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +//import club.joylink.rtss.simulation.cbtc.data.map.*; +//import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; +//import club.joylink.rtss.simulation.cbtc.exception.SimulationException; +//import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import java.time.LocalDateTime; +//import java.util.*; +//import java.util.stream.Collectors; +// +///** +// * 进路操作服务 +// */ +//@Component +//@Slf4j +//public class RouteService { +// +// @Autowired +// private SwitchService switchService; +// +// @Autowired +// private SignalService signalService; +// +// /** +// * 进路办理条件检查 +// * +// * @param simulation +// * @param route +// * @return +// */ +// public static Route.CheckFailMessage check(Simulation simulation, Route route) { +// Route.CheckFailMessage failMessage = baseCheck(simulation, route); // if (Objects.nonNull(failMessage)) { // return failMessage; // } - // 共用道岔的冲突进路检查 - failMessage = switchUseCheck(simulation, route); - if (Objects.nonNull(failMessage)) { - return failMessage; - } - // 进路区段是否占用 - if (!route.isCbtcMode() || route.isGround() || route.isAtp()) { - failMessage = ciLevelCheck(route); - } - // 进路区段是否故障占用 - for (Section section : route.getSectionList()) { - for (int i = 0; i < 3; i++) { - if (section.getParent() == null || section.isAxleCounter()) - break; - section = section.getParent(); - } - if (Section.AxleFault.FAULT.equals(section.getFault())) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionFaultOccupied, section); - } - } - return failMessage; - } - - private Route.CheckFailMessage directionRodCheck(Simulation simulation, Route route) { - List directionRodList = simulation.getRepository() - .getListByType(MapElement.DeviceType.DIRECTION_ROD, DirectionRod.class); - if (!CollectionUtils.isEmpty(directionRodList)) { - for (DirectionRod directionRod : directionRodList) { - if (directionRod.getDeviceStationList().contains(route.getInterlockStation())) { - for (Section section : route.getSectionList()) { - if (directionRod.getSectionList().contains(section) - && directionRod.allowRight() != route.getStart().isRight()) { - return new Route.CheckFailMessage(Route.CheckFailReason.DirectionRodLimit, route); - } - } - } - } - } - return null; - } - - /** - * 共用道岔冲突进路检查 - * - * @param simulation - * @param route - * @return - */ - private static Route.CheckFailMessage switchUseCheck(Simulation simulation, Route route) { - List routeList = simulation.getRepository().getSettingRoutes(); - for (Route other : routeList) { -// if (Objects.equals(other, route) && !route.isCbtcMode()) { -// return new Route.CheckFailMessage(Route.CheckFailReason.RouteSetting, other); -// } - if ((Objects.nonNull(other.getOverlap()) && - (other.getOverlap().isSetting() || other.getOverlap().isLock())) || - checkCanOverlapSet(simulation, other)) { - SectionPath sectionPath = other.getOverlap().selectPath(); - if (Objects.nonNull(sectionPath)) { - if (route.containConflictSwitch(sectionPath.getSwitchList())) { - return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, other); - } - } - } - if (checkCanOverlapSet(simulation, route)) { - SectionPath sectionPath = route.getOverlap().selectPath(); - if (Objects.nonNull(sectionPath)) { - if (other.containConflictSwitch(sectionPath.getSwitchList())) { - for (SwitchElement switchElement : other.getSwitchList()) { - if (!switchElement.getASwitch().isRouteLock()) { - continue; - } - for (SwitchElement element : sectionPath.getSwitchList()) { - if (Objects.equals(element.getASwitch(), switchElement.getASwitch()) && - !Objects.equals(switchElement.isNormal(), element.isNormal())) { - return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, other); - } - } - } - } - } - } - if (other.isNormalUnlock()) { - continue; - } - if (route.containConflictSwitch(other.getSwitchList())) { - return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, other); - } else if (route.isOppositeTo(other) && - other.containSameSection(route.getSectionList())) { - return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, other); - } - } - return null; - } - - /** - * 进路CBTC/联锁办理条件公有检查 - * - * @param simulation - * @param route - * @return - */ - private static Route.CheckFailMessage baseCheck(Simulation simulation, Route route) { - MapConfig config = simulation.getRepository().getConfig(); - Signal start = route.getStart(); - if (!config.isSignalBlockRouteSettable()) { - // 信号封锁,不能办理 - if (start.isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalBlockade, start); - } - } - // 判断是否侧防锁闭 - if (start.isFpl()) { - return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalFlankProtectLock, start); - } -// else if (route.getDestination().isBlockade()) { -// return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalBlockade, route.getDestination()); +//// // 区间运行方向检查 +//// failMessage = this.directionRodCheck(simulation, route); +//// if (Objects.nonNull(failMessage)) { +//// return failMessage; +//// } +// // 共用道岔的冲突进路检查 +// failMessage = switchUseCheck(simulation, route); +// if (Objects.nonNull(failMessage)) { +// return failMessage; // } - // 进路内区段封锁/锁闭方向检查 - List
sectionList = route.getSectionList(); - for (Section section : sectionList) { - // 封锁状态 - if (section.isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); - } else if (!CollectionUtils.isEmpty(section.getLogicList())) { - for (Section logicSection : section.getLogicList()) { - if (logicSection.isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, logicSection); - } - } - } - if (section.getParent() != null) { - if (section.getParent().isCross() && section.getParent().isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); - } - } - // 进路内区段锁闭方向不是此进路方向 - if ((section.isRouteLock() || section.isOverlapLock()) && - !Objects.equals(section.isLockRight(), start.isRight())) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionLockOppositeDirection, section); - } - } - // 进路内道岔封锁/锁闭/占用位置检查 - List switchList = route.getSwitchList(); - for (SwitchElement element : switchList) { - Switch aSwitch = element.getASwitch(); - // 封锁中,不能排列 - if (aSwitch.isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SwitchBlockade, aSwitch); - } - // 是否被征用到相反位置 - if (aSwitch.isCiUseOnOppositePosition(element.isNormal())) { - return new Route.CheckFailMessage(Route.CheckFailReason.SwitchCiUseOnOppositePosition, aSwitch); - } - // 是否锁闭在另一方向 - if (aSwitch.isLocked() && !aSwitch.isOnPosition(element.isNormal())) { - return new Route.CheckFailMessage(Route.CheckFailReason.SwitchLockPositionError, aSwitch); - } - // 是否占用在另一个位置 - if (aSwitch.isSectionOccupied() && !aSwitch.isOnPosition(element.isNormal())) { - return new Route.CheckFailMessage(Route.CheckFailReason.SwitchOccupiedPositionError, aSwitch); - } +// // 进路区段是否占用 +// if (!route.isCbtcMode() || route.isGround() || route.isAtp()) { +// failMessage = ciLevelCheck(route); +// } +// // 进路区段是否故障占用 +// for (Section section : route.getSectionList()) { +// for (int i = 0; i < 3; i++) { +// if (section.getParent() == null || section.isAxleCounter()) +// break; +// section = section.getParent(); +// } +// if (Section.AxleFault.FAULT.equals(section.getFault())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionFaultOccupied, section); +// } +// } +// return failMessage; +// } +// +// private Route.CheckFailMessage directionRodCheck(Simulation simulation, Route route) { +// List directionRodList = simulation.getRepository() +// .getListByType(MapElement.DeviceType.DIRECTION_ROD, DirectionRod.class); +// if (!CollectionUtils.isEmpty(directionRodList)) { +// for (DirectionRod directionRod : directionRodList) { +// if (directionRod.getDeviceStationList().contains(route.getInterlockStation())) { +// for (Section section : route.getSectionList()) { +// if (directionRod.getSectionList().contains(section) +// && directionRod.allowRight() != route.getStart().isRight()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.DirectionRodLimit, route); +// } +// } +// } +// } +// } +// return null; +// } +// +// /** +// * 共用道岔冲突进路检查 +// * +// * @param simulation +// * @param route +// * @return +// */ +// private static Route.CheckFailMessage switchUseCheck(Simulation simulation, Route route) { +// List routeList = simulation.getRepository().getSettingRoutes(); +// for (Route other : routeList) { +//// if (Objects.equals(other, route) && !route.isCbtcMode()) { +//// return new Route.CheckFailMessage(Route.CheckFailReason.RouteSetting, other); +//// } +// if ((Objects.nonNull(other.getOverlap()) && +// (other.getOverlap().isSetting() || other.getOverlap().isLock())) || +// checkCanOverlapSet(simulation, other)) { +// SectionPath sectionPath = other.getOverlap().selectPath(); +// if (Objects.nonNull(sectionPath)) { +// if (route.containConflictSwitch(sectionPath.getSwitchList())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, other); +// } +// } +// } +// if (checkCanOverlapSet(simulation, route)) { +// SectionPath sectionPath = route.getOverlap().selectPath(); +// if (Objects.nonNull(sectionPath)) { +// if (other.containConflictSwitch(sectionPath.getSwitchList())) { +// for (SwitchElement switchElement : other.getSwitchList()) { +// if (!switchElement.getASwitch().isRouteLock()) { +// continue; +// } +// for (SwitchElement element : sectionPath.getSwitchList()) { +// if (Objects.equals(element.getASwitch(), switchElement.getASwitch()) && +// !Objects.equals(switchElement.isNormal(), element.isNormal())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, other); +// } +// } +// } +// } +// } +// } +// if (other.isNormalUnlock()) { +// continue; +// } +// if (route.containConflictSwitch(other.getSwitchList())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, other); +// } else if (route.isOppositeTo(other) && +// other.containSameSection(route.getSectionList())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, other); +// } +// } +// return null; +// } +// +// /** +// * 进路CBTC/联锁办理条件公有检查 +// * +// * @param simulation +// * @param route +// * @return +// */ +// private static Route.CheckFailMessage baseCheck(Simulation simulation, Route route) { +// MapConfig config = simulation.getRepository().getConfig(); +// Signal start = route.getStart(); +// if (!config.isSignalBlockRouteSettable()) { +// // 信号封锁,不能办理 +// if (start.isBlockade()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalBlockade, start); +// } +// } +// // 判断是否侧防锁闭 +// if (start.isFpl()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalFlankProtectLock, start); +// } +//// else if (route.getDestination().isBlockade()) { +//// return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalBlockade, route.getDestination()); +//// } +// // 进路内区段封锁/锁闭方向检查 +// List
sectionList = route.getSectionList(); +// for (Section section : sectionList) { +// // 封锁状态 +// if (section.isBlockade()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); +// } else if (!CollectionUtils.isEmpty(section.getLogicList())) { +// for (Section logicSection : section.getLogicList()) { +// if (logicSection.isBlockade()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, logicSection); +// } +// } +// } +// if (section.getParent() != null) { +// if (section.getParent().isCross() && section.getParent().isBlockade()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); +// } +// } +// // 进路内区段锁闭方向不是此进路方向 +// if ((section.isRouteLock() || section.isOverlapLock()) && +// !Objects.equals(section.isLockRight(), start.isRight())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionLockOppositeDirection, section); +// } +// } +// // 进路内道岔封锁/锁闭/占用位置检查 +// List switchList = route.getSwitchList(); +// for (SwitchElement element : switchList) { +// Switch aSwitch = element.getASwitch(); +// // 封锁中,不能排列 +// if (aSwitch.isBlockade()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SwitchBlockade, aSwitch); +// } +// // 是否被征用到相反位置 +// if (aSwitch.isCiUseOnOppositePosition(element.isNormal())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SwitchCiUseOnOppositePosition, aSwitch); +// } +// // 是否锁闭在另一方向 +// if (aSwitch.isLocked() && !aSwitch.isOnPosition(element.isNormal())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SwitchLockPositionError, aSwitch); +// } +// // 是否占用在另一个位置 +// if (aSwitch.isSectionOccupied() && !aSwitch.isOnPosition(element.isNormal())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SwitchOccupiedPositionError, aSwitch); +// } +//// // 道岔是否故障 +//// if (aSwitch.isFaultOnPosition(element.isNormal()) && aSwitch.isLoss()) { +//// return new Route.CheckFailMessage(Route.CheckFailReason.SwitchFault, aSwitch); +//// } +// } +// // 敌对进路办理中或已锁闭,不能办理 +// List conflictingRouteList = route.getConflictingRouteList(); +// for (Route conflict : conflictingRouteList) { +// if (conflict.isSetting() || conflict.isLock()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, conflict); +// } +// } +// return null; +// } +// +// /** +// * 进路CBTC/联锁办理条件公有检查 +// * +// * @param route +// * @return +// */ +// private Route.CheckFailMessage guideRouteCheck(Route route) { +// // 信号封锁,不能办理 +// if (route.getStart().isBlockade()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalBlockade, route.getStart()); +// } +// // 进路内区段封锁/锁闭方向检查 +// List
sectionList = route.getSectionList(); +// for (Section section : sectionList) { +// // 封锁状态 +// if (section.isBlockade()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); +// } +// // 进路内区段锁闭方向不是此进路方向 +// if ((section.isRouteLock() || section.isOverlapLock()) && +// !Objects.equals(section.isLockRight(), route.getStart().isRight())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionLockOppositeDirection, section); +// } +// } +// // 进路要经过的道岔的检测 +// List switchList = route.getSwitchList(); +// Set sectionRelSwitches = sectionList.stream().map(Section::getRelSwitch).collect(Collectors.toSet()); +// switchList = switchList.stream().filter(switchElement -> sectionRelSwitches.contains(switchElement.getASwitch())).collect(Collectors.toList()); +// for (SwitchElement element : switchList) { +// Switch aSwitch = element.getASwitch(); +// // 封锁中,不能排列 +// if (aSwitch.isBlockade()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SwitchBlockade, aSwitch); +// } +// // 是否锁闭在另一方向 +// if (aSwitch.isLocked() && !aSwitch.isOnPosition(element.isNormal())) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SwitchLockPositionError, aSwitch); +// } // // 道岔是否故障 // if (aSwitch.isFaultOnPosition(element.isNormal()) && aSwitch.isLoss()) { // return new Route.CheckFailMessage(Route.CheckFailReason.SwitchFault, aSwitch); // } - } - // 敌对进路办理中或已锁闭,不能办理 - List conflictingRouteList = route.getConflictingRouteList(); - for (Route conflict : conflictingRouteList) { - if (conflict.isSetting() || conflict.isLock()) { - return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, conflict); - } - } - return null; - } - - /** - * 进路CBTC/联锁办理条件公有检查 - * - * @param route - * @return - */ - private Route.CheckFailMessage guideRouteCheck(Route route) { - // 信号封锁,不能办理 - if (route.getStart().isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.StartSignalBlockade, route.getStart()); - } - // 进路内区段封锁/锁闭方向检查 - List
sectionList = route.getSectionList(); - for (Section section : sectionList) { - // 封锁状态 - if (section.isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionBlockade, section); - } - // 进路内区段锁闭方向不是此进路方向 - if ((section.isRouteLock() || section.isOverlapLock()) && - !Objects.equals(section.isLockRight(), route.getStart().isRight())) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionLockOppositeDirection, section); - } - } - // 进路要经过的道岔的检测 - List switchList = route.getSwitchList(); - Set sectionRelSwitches = sectionList.stream().map(Section::getRelSwitch).collect(Collectors.toSet()); - switchList = switchList.stream().filter(switchElement -> sectionRelSwitches.contains(switchElement.getASwitch())).collect(Collectors.toList()); - for (SwitchElement element : switchList) { - Switch aSwitch = element.getASwitch(); - // 封锁中,不能排列 - if (aSwitch.isBlockade()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SwitchBlockade, aSwitch); - } - // 是否锁闭在另一方向 - if (aSwitch.isLocked() && !aSwitch.isOnPosition(element.isNormal())) { - return new Route.CheckFailMessage(Route.CheckFailReason.SwitchLockPositionError, aSwitch); - } - // 道岔是否故障 - if (aSwitch.isFaultOnPosition(element.isNormal()) && aSwitch.isLoss()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SwitchFault, aSwitch); - } - } - // 敌对进路办理中或已锁闭,不能办理 - List conflictingRouteList = route.getConflictingRouteList(); - for (Route conflict : conflictingRouteList) { - if (conflict.isSetting() || conflict.isLock()) { - return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, conflict); - } - } - return null; - } - - /** - * 联锁级进路办理条件检查 - * - * @param route - * @return - */ - private static Route.CheckFailMessage ciLevelCheck(Route route) { - // 进路内区段占用检查 - List
sectionList = route.getSectionList(); - for (Section section : sectionList) { - if (section.isOccupied()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); - } -// if (section.isOccupied() && !section.isPreReset()) { -// if (section.isSwitchTrack()) { -// if (!section.getRelSwitch().isPreReset()) { -// return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); -// } -// } else { -// return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); -// } -// } - } - // 延续保护检查 - RouteOverlap overlap = route.getOverlap(); - if (Objects.nonNull(overlap)) { - SectionPath sectionPath = overlap.selectPath(); - List switchList = sectionPath.getSwitchList(); - if (!CollectionUtils.isEmpty(switchList)) { - for (SwitchElement element : switchList) { - if (!element.getASwitch().isOnPosition(element.isNormal()) && element.getASwitch().isLocked()) { - return new Route.CheckFailMessage(Route.CheckFailReason.SwitchLockPositionError, element.getASwitch()); - } - } - } - } - return null; - } - - /** - * 进路办理 - * - * @param simulation - * @param route - * @return - */ - public Route.CheckFailMessage setting(Simulation simulation, Route route) { - Route.CheckFailMessage check = this.check(simulation, route); - if (Objects.nonNull(check)) { - log.info(String.format("进路[%s]排列检查失败,无法排列:%s", route.debugStr(), check.debugStr())); - return check; - } - if (route.isLock() && !route.isFleetMode()) { - log.info(String.format("进路[%s]已经锁闭", route.debugStr())); - return null; - } - // 进路开始办理 - LocalDateTime systemTime = simulation.getSystemTime(); - route.startSetting(systemTime); - // 道岔征用 - for (SwitchElement switchElement : route.getSwitchList()) { - switchElement.getASwitch().ciUse(switchElement.isNormal()); - } - if (this.checkCanOverlapSet(simulation, route)) { - route.getOverlap().startSetting(systemTime); - SectionPath sectionPath = route.getOverlap().selectPath(); - for (SwitchElement switchElement : sectionPath.getSwitchList()) { - switchElement.getASwitch().ciUse(switchElement.isNormal()); - } - } - simulation.getRepository().addSettingRoute(route); - return null; - } - - public static boolean checkCanOverlapSet(Simulation simulation, Route route) { -// boolean overlapLock = false; - MapConfig config = simulation.getRepository().getConfig(); - RouteOverlap overlap = route.getOverlap(); - if (Objects.isNull(overlap)) return false; - if (Objects.nonNull(overlap)) { - if (route.isCbtcMode() && !route.isSetOverlapInCtc()) { - // CTC模式不办理判断 - return false; - } - if (overlap.isLock() || overlap.isSetting() || overlap.isForbidden()) { - return false; - } - Section section = overlap.getSection(); - if (section.isNormalStandTrack() && section.getStandList().get(0).isTrainParking()) { - // 列车停靠,不办理 - return false; - } - SectionPath sectionPath = overlap.selectPath(); - List switchList = sectionPath.getSwitchList(); - if (!CollectionUtils.isEmpty(switchList)) { - for (SwitchElement switchElement : switchList) { - if (switchElement.getASwitch().isFaultOnPosition(switchElement.isNormal()) && switchElement.getASwitch().isLoss()) { - // 道岔指定位置故障且失表,不再触发 - return false; - } else if (switchElement.getASwitch().isLocked() && !switchElement.getASwitch().isOnPosition(switchElement.isNormal())) { - return false; - } - } - } - } - return true; - } - - /** - * 进路办理过程 - * - * @param simulation - * @param route - */ - public void settingProgress(Simulation simulation, Route route) { - if (route.isSetting()) { // 进路排列中 - MapConfig config = simulation.getRepository().getConfig(); - if (!config.isRouteSettingNoFail()) { - if (Objects.isNull(route.getSettingStartTime())) {//旧数据兼容逻辑 - route.setSettingStartTime(simulation.getSystemTime()); - } - if (simulation.getSystemTime().isAfter(route.getSettingStartTime().plusSeconds(SimulationConstants.ROUTE_SETTING_TIMEOUT))) { - route.settingFailed(); -// simulation.getRepository().removeSettingRoute(route); - route.setLock(false); - log.info(String.format("进路[%s]办理失败,取消办理2", route.debugStr())); - return; - } - } - route.setLock(true); - route.getStart().setLockedRoute(route); - boolean right = route.getStart().isRight(); - // 预先锁闭 - if (config.isLockFirst()) { - // 进路排列区段预先锁闭 - List
sectionList = route.getSectionList(); - for (Section section : sectionList) { - if (section.isSwitchTrack()) { - Switch relSwitch = section.getRelSwitch(); - relSwitch.getA().routeLocking(route, right); - if (relSwitch.isNormalPosition()) { // 定位 - relSwitch.getB().routeLocking(route, right); - relSwitch.getC().routeUnlocking(route); - } else if (relSwitch.isReversePosition()) { // 反位 - relSwitch.getC().routeLocking(route, right); - relSwitch.getB().routeUnlocking(route); - } else { // 失表 - relSwitch.getB().routeLocking(route, right); - relSwitch.getC().routeLocking(route, right); - } - } else { - section.routeLocking(route, right); - } -// log.debug(section.debugStr() + "因<预先锁闭>锁闭"); - } - } - // 征用设备 - // 道岔位置转换 - List switchList = route.getSwitchList(); - this.routeSwitchTurn(simulation, switchList); - this.routeFlsControl(simulation, route.getFlsList()); - if (config.isLockFirst()) { - for (SwitchElement switchElement : switchList) { - switchElement.getASwitch().routeLock(route); - } - if (!CollectionUtils.isEmpty(route.getFlsList())) { - for (RouteFls routeFls : route.getFlsList()) { - routeFls.lock(); - } - } - } - // 设备已征用,检查进路条件 - boolean onPosition = this.checkSwitchPosition(simulation, route); - if (!onPosition) { // 还未转换到位置 - return; - } - - // 所有道岔已经到进路指定位值,执行区段锁闭 - this.sectionLock(simulation, route); - route.getStart().setLevel(Signal.LEVEL_2); - // 侧防检查 - boolean flsOnPosition = this.isFlsCheckPass(route.getFlsList()); - if (flsOnPosition) { - // 侧防锁闭 - this.routeFlsLock(route.getFlsList()); - } - if (simulation.getSystemTime().isAfter(route.getSettingStartTime().plusSeconds(SimulationConstants.ROUTE_SETTING_TIMEOUT))) { - route.settingFinish(); - log.info(String.format("进路[%s]办理超时,结束", route.debugStr())); - return; - } - // 联锁网络检查 - if (this.isInterlocked(route)) { - if (route.getStart().isBlockade()) { - route.settingFinish(); - return; - } - // 联锁检查通过,开放信号 - this.routeOpen(simulation, route); - if (route.getStart().isNormalOpen()) { - log.debug(String.format("进路[%s]锁闭,始端信号机已开放", route.debugStr())); - route.settingFinish(); - } - } - } - } - - private void routeFlsControl(Simulation simulation, List flsList) { - // 侧防道岔转换 - if (!CollectionUtils.isEmpty(flsList)) { - List switchElementList = new ArrayList<>(); - for (RouteFls routeFls : flsList) { - List level1List = routeFls.getLevel1List(); - for (RouteFls.FlsElement flsElement : level1List) { - SwitchElement pSwitch = flsElement.getPSwitch(); - if (pSwitch != null) { - switchElementList.add(pSwitch); - } -// else if (flsElement.getFpae() != null) { -// switchElementList.add(flsElement.getFpae()); -// } - } - } - this.routeSwitchTurn(simulation, switchElementList); - } - } - - private boolean checkSwitchPosition(Simulation simulation, Route route) { - Set sectionRelSwitches = route.getSectionList().stream().map(Section::getRelSwitch).collect(Collectors.toSet()); - List switchList; - if (route.isOpenGuide()) { - switchList = route.getSwitchList().stream().filter(element -> sectionRelSwitches.contains(element.getASwitch())).collect(Collectors.toList()); - } else { - switchList = route.getSwitchList(); - } - boolean onPosition = this.checkRouteSwitchPosition(switchList); - if (!onPosition) return false; -// if (!route.isCbtcMode()) { // 检查进路延续保护 -// RouteOverlap overlap = route.getOverlap(); -// if (Objects.nonNull(overlap) && !overlap.isLock()) { -// return false; +// } +// // 敌对进路办理中或已锁闭,不能办理 +// List conflictingRouteList = route.getConflictingRouteList(); +// for (Route conflict : conflictingRouteList) { +// if (conflict.isSetting() || conflict.isLock()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.ConflictingRouteSetting, conflict); // } // } - return true; - } - - /** - * 延续保护进路办理过程 - * - * @param simulation - * @param overlap - */ - public void overlapSettingProcess(Simulation simulation, RouteOverlap overlap) { - if (Objects.isNull(overlap) || !overlap.isSetting()) { - return; - } - SectionPath sectionPath = overlap.selectPath(); - List switchList = sectionPath.getSwitchList(); - if (!CollectionUtils.isEmpty(switchList)) { // 判断道岔是否此延续保护征用的位置,若不是,尝试征用 - for (SwitchElement switchElement : switchList) { - if (!switchElement.getASwitch().ciUse(switchElement.isNormal())) { // 未征用至指定位置,返回 - return; - } - } - } - MapConfig config = simulation.getRepository().getConfig(); - if (!config.isRouteSettingNoFail()) { - if (simulation.getSystemTime().isAfter(overlap.getSettingStartTime().plusSeconds(SimulationConstants.ROUTE_SETTING_TIMEOUT))) { - overlap.settingFailed(); - log.info(String.format("进路延续保护[%s]办理失败", overlap.debugStr())); - return; - } - } - boolean right = overlap.isRight(); - // 延续保护区段预先锁闭 - List
logicList = sectionPath.getLogicList(); - if (config.isLockFirst()) { - if (!CollectionUtils.isEmpty(logicList)) { - for (Section section : logicList) { - section.overlapLocking(right); - } - } else { - List
sectionList = sectionPath.getSectionList(); - for (Section section : sectionList) { - if (section.isSwitchTrack()) { - Switch relSwitch = section.getRelSwitch(); - relSwitch.getA().overlapLocking(right); - if (relSwitch.isNormalPosition()) { // 定位 - relSwitch.getB().overlapLocking(right); - relSwitch.getC().overlapUnlocking(); - } else if (relSwitch.isReversePosition()) { // 反位 - relSwitch.getC().overlapLocking(right); - relSwitch.getB().overlapUnlocking(); - } else { // 失表 - relSwitch.getB().overlapLocking(right); - relSwitch.getC().overlapLocking(right); - } - } else { - section.overlapLocking(right); - } - } - } - } - List flsList = sectionPath.getFlsList(); - // 延续保护位置转动 - this.routeSwitchTurn(simulation, switchList); - this.routeFlsControl(simulation, flsList); - if (config.isLockFirst()) { - for (SwitchElement switchElement : switchList) { - if (!switchElement.isOnPosition() && - (switchElement.getASwitch().isSectionOccupied() || switchElement.getASwitch().isLocked())) { - continue; - } - switchElement.getASwitch().overlapLock(); - } - if (!CollectionUtils.isEmpty(flsList)) { - for (RouteFls routeFls : flsList) { - routeFls.lock(); - } - } - } - // 道岔是否转换到位置 - boolean onPosition = this.checkRouteSwitchPosition(switchList) && this.isFlsCheckPass(flsList); - if (!onPosition) return; // 未到位,返回 - if (!overlap.getSection().isRouteLock()) { - return; - } - this.overlapLock(sectionPath, right); - overlap.settingFinish(); - log.debug(String.format("进路延续保护[%s]办理成功", overlap.debugStr())); - } - - /** - * 侧防检查是否通过 - */ - public boolean isFlsCheckPass(List flsList) { - if (!CollectionUtils.isEmpty(flsList)) { - for (RouteFls routeFls : flsList) { - List level1List = routeFls.getLevel1List(); - for (RouteFls.FlsElement flsElement : level1List) { - SwitchElement pSwitch = flsElement.getPSwitch(); - if (pSwitch != null && !pSwitch.getASwitch().isOnPosition(pSwitch.isNormal())) { - return false; - } - Signal pSignal = flsElement.getPSignal(); - if (pSignal != null && !pSignal.isClose()) { - SwitchElement fpae = flsElement.getFpae(); - if (fpae != null) { - if (fpae.getASwitch().isOnPosition(fpae.isNormal())) { - return false; - } - } else { - return false; - } - } -// else { +// return null; +// } +// +// /** +// * 联锁级进路办理条件检查 +// * +// * @param route +// * @return +// */ +// private static Route.CheckFailMessage ciLevelCheck(Route route) { +// // 进路内区段占用检查 +// List
sectionList = route.getSectionList(); +// for (Section section : sectionList) { +// if (section.isOccupied()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); +// } +//// if (section.isOccupied() && !section.isPreReset()) { +//// if (section.isSwitchTrack()) { +//// if (!section.getRelSwitch().isPreReset()) { +//// return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); +//// } +//// } else { +//// return new Route.CheckFailMessage(Route.CheckFailReason.SectionNotFree, section); +//// } +//// } +// } +// // 延续保护检查 +// RouteOverlap overlap = route.getOverlap(); +// if (Objects.nonNull(overlap)) { +// SectionPath sectionPath = overlap.selectPath(); +// List switchList = sectionPath.getSwitchList(); +// if (!CollectionUtils.isEmpty(switchList)) { +// for (SwitchElement element : switchList) { +// if (!element.getASwitch().isOnPosition(element.isNormal()) && element.getASwitch().isLocked()) { +// return new Route.CheckFailMessage(Route.CheckFailReason.SwitchLockPositionError, element.getASwitch()); +// } +// } +// } +// } +// return null; +// } +// +// /** +// * 进路办理 +// * +// * @param simulation +// * @param route +// * @return +// */ +// public Route.CheckFailMessage setting(Simulation simulation, Route route) { +// Route.CheckFailMessage check = this.check(simulation, route); +// if (Objects.nonNull(check)) { +// log.info(String.format("进路[%s]排列检查失败,无法排列:%s", route.debugStr(), check.debugStr())); +// return check; +// } +// if (route.isLock() && !route.isFleetMode()) { +// log.info(String.format("进路[%s]已经锁闭", route.debugStr())); +// return null; +// } +// // 进路开始办理 +// LocalDateTime systemTime = simulation.getSystemTime(); +// route.startSetting(systemTime); +// // 道岔征用 +// for (SwitchElement switchElement : route.getSwitchList()) { +// switchElement.getASwitch().ciUse(switchElement.isNormal()); +// } +// if (this.checkCanOverlapSet(simulation, route)) { +// route.getOverlap().startSetting(systemTime); +// SectionPath sectionPath = route.getOverlap().selectPath(); +// for (SwitchElement switchElement : sectionPath.getSwitchList()) { +// switchElement.getASwitch().ciUse(switchElement.isNormal()); +// } +// } +// simulation.getRepository().addSettingRoute(route); +// return null; +// } +// +// public static boolean checkCanOverlapSet(Simulation simulation, Route route) { +//// boolean overlapLock = false; +// MapConfig config = simulation.getRepository().getConfig(); +// RouteOverlap overlap = route.getOverlap(); +// if (Objects.isNull(overlap)) return false; +// if (Objects.nonNull(overlap)) { +// if (route.isCbtcMode() && !route.isSetOverlapInCtc()) { +// // CTC模式不办理判断 +// return false; +// } +// if (overlap.isLock() || overlap.isSetting() || overlap.isForbidden()) { +// return false; +// } +// Section section = overlap.getSection(); +// if (section.isNormalStandTrack() && section.getStandList().get(0).isTrainParking()) { +// // 列车停靠,不办理 +// return false; +// } +// SectionPath sectionPath = overlap.selectPath(); +// List switchList = sectionPath.getSwitchList(); +// if (!CollectionUtils.isEmpty(switchList)) { +// for (SwitchElement switchElement : switchList) { +// if (switchElement.getASwitch().isFaultOnPosition(switchElement.isNormal()) && switchElement.getASwitch().isLoss()) { +// // 道岔指定位置故障且失表,不再触发 +// return false; +// } else if (switchElement.getASwitch().isLocked() && !switchElement.getASwitch().isOnPosition(switchElement.isNormal())) { +// return false; +// } +// } +// } +// } +// return true; +// } +// +// /** +// * 进路办理过程 +// * +// * @param simulation +// * @param route +// */ +// public void settingProgress(Simulation simulation, Route route) { +// if (route.isSetting()) { // 进路排列中 +// MapConfig config = simulation.getRepository().getConfig(); +// if (!config.isRouteSettingNoFail()) { +// if (Objects.isNull(route.getSettingStartTime())) {//旧数据兼容逻辑 +// route.setSettingStartTime(simulation.getSystemTime()); +// } +// if (simulation.getSystemTime().isAfter(route.getSettingStartTime().plusSeconds(SimulationConstants.ROUTE_SETTING_TIMEOUT))) { +// route.settingFailed(); +//// simulation.getRepository().removeSettingRoute(route); +// route.setLock(false); +// log.info(String.format("进路[%s]办理失败,取消办理2", route.debugStr())); +// return; +// } +// } +// route.setLock(true); +// route.getStart().setLockedRoute(route); +// boolean right = route.getStart().isRight(); +// // 预先锁闭 +// if (config.isLockFirst()) { +// // 进路排列区段预先锁闭 +// List
sectionList = route.getSectionList(); +// for (Section section : sectionList) { +// if (section.isSwitchTrack()) { +// Switch relSwitch = section.getRelSwitch(); +// relSwitch.getA().routeLocking(route, right); +// if (relSwitch.isNormalPosition()) { // 定位 +// relSwitch.getB().routeLocking(route, right); +// relSwitch.getC().routeUnlocking(route); +// } else if (relSwitch.isReversePosition()) { // 反位 +// relSwitch.getC().routeLocking(route, right); +// relSwitch.getB().routeUnlocking(route); +// } else { // 失表 +// relSwitch.getB().routeLocking(route, right); +// relSwitch.getC().routeLocking(route, right); +// } +// } else { +// section.routeLocking(route, right); +// } +//// log.debug(section.debugStr() + "因<预先锁闭>锁闭"); +// } +// } +// // 征用设备 +// // 道岔位置转换 +// List switchList = route.getSwitchList(); +// this.routeSwitchTurn(simulation, switchList); +// this.routeFlsControl(simulation, route.getFlsList()); +// if (config.isLockFirst()) { +// for (SwitchElement switchElement : switchList) { +// switchElement.getASwitch().routeLock(route); +// } +// if (!CollectionUtils.isEmpty(route.getFlsList())) { +// for (RouteFls routeFls : route.getFlsList()) { +// routeFls.lock(); +// } +// } +// } +// // 设备已征用,检查进路条件 +// boolean onPosition = this.checkSwitchPosition(simulation, route); +// if (!onPosition) { // 还未转换到位置 +// return; +// } +// +// // 所有道岔已经到进路指定位值,执行区段锁闭 +// this.sectionLock(simulation, route); +// route.getStart().setLevel(Signal.LEVEL_Guide); +// // 侧防检查 +// boolean flsOnPosition = this.isFlsCheckPass(route.getFlsList()); +// if (flsOnPosition) { +// // 侧防锁闭 +// this.routeFlsLock(route.getFlsList()); +// } +// if (simulation.getSystemTime().isAfter(route.getSettingStartTime().plusSeconds(SimulationConstants.ROUTE_SETTING_TIMEOUT))) { +// route.settingFinish(); +// log.info(String.format("进路[%s]办理超时,结束", route.debugStr())); +// return; +// } +// // 联锁网络检查 +// if (this.isInterlocked(route)) { +// if (route.getStart().isBlockade()) { +// route.settingFinish(); +// return; +// } +// // 联锁检查通过,开放信号 +// this.routeOpen(simulation, route); +// if (route.getStart().isNormalOpen()) { +// log.debug(String.format("进路[%s]锁闭,始端信号机已开放", route.debugStr())); +// route.settingFinish(); +// } +// } +// } +// } +// +// private void routeFlsControl(Simulation simulation, List flsList) { +// // 侧防道岔转换 +// if (!CollectionUtils.isEmpty(flsList)) { +// List switchElementList = new ArrayList<>(); +// for (RouteFls routeFls : flsList) { +// List level1List = routeFls.getLevel1List(); +// for (RouteFls.FlsElement flsElement : level1List) { +// SwitchElement pSwitch = flsElement.getPSwitch(); +// if (pSwitch != null) { +// switchElementList.add(pSwitch); +// } +//// else if (flsElement.getFpae() != null) { +//// switchElementList.add(flsElement.getFpae()); +//// } +// } +// } +// this.routeSwitchTurn(simulation, switchElementList); +// } +// } +// +// private boolean checkSwitchPosition(Simulation simulation, Route route) { +// Set sectionRelSwitches = route.getSectionList().stream().map(Section::getRelSwitch).collect(Collectors.toSet()); +// List switchList; +// if (route.isOpenGuide()) { +// switchList = route.getSwitchList().stream().filter(element -> sectionRelSwitches.contains(element.getASwitch())).collect(Collectors.toList()); +// } else { +// switchList = route.getSwitchList(); +// } +// boolean onPosition = this.checkRouteSwitchPosition(switchList); +// if (!onPosition) return false; +//// if (!route.isCbtcMode()) { // 检查进路延续保护 +//// RouteOverlap overlap = route.getOverlap(); +//// if (Objects.nonNull(overlap) && !overlap.isLock()) { +//// return false; +//// } +//// } +// return true; +// } +// +// /** +// * 延续保护进路办理过程 +// * +// * @param simulation +// * @param overlap +// */ +// public void overlapSettingProcess(Simulation simulation, RouteOverlap overlap) { +// if (Objects.isNull(overlap) || !overlap.isSetting()) { +// return; +// } +// SectionPath sectionPath = overlap.selectPath(); +// List switchList = sectionPath.getSwitchList(); +// if (!CollectionUtils.isEmpty(switchList)) { // 判断道岔是否此延续保护征用的位置,若不是,尝试征用 +// for (SwitchElement switchElement : switchList) { +// if (!switchElement.getASwitch().ciUse(switchElement.isNormal())) { // 未征用至指定位置,返回 +// return; +// } +// } +// } +// MapConfig config = simulation.getRepository().getConfig(); +// if (!config.isRouteSettingNoFail()) { +// if (simulation.getSystemTime().isAfter(overlap.getSettingStartTime().plusSeconds(SimulationConstants.ROUTE_SETTING_TIMEOUT))) { +// overlap.settingFailed(); +// log.info(String.format("进路延续保护[%s]办理失败", overlap.debugStr())); +// return; +// } +// } +// boolean right = overlap.isRight(); +// // 延续保护区段预先锁闭 +// List
logicList = sectionPath.getLogicList(); +// if (config.isLockFirst()) { +// if (!CollectionUtils.isEmpty(logicList)) { +// for (Section section : logicList) { +// section.overlapLocking(right); +// } +// } else { +// List
sectionList = sectionPath.getSectionList(); +// for (Section section : sectionList) { +// if (section.isSwitchTrack()) { +// Switch relSwitch = section.getRelSwitch(); +// relSwitch.getA().overlapLocking(right); +// if (relSwitch.isNormalPosition()) { // 定位 +// relSwitch.getB().overlapLocking(right); +// relSwitch.getC().overlapUnlocking(); +// } else if (relSwitch.isReversePosition()) { // 反位 +// relSwitch.getC().overlapLocking(right); +// relSwitch.getB().overlapUnlocking(); +// } else { // 失表 +// relSwitch.getB().overlapLocking(right); +// relSwitch.getC().overlapLocking(right); +// } +// } else { +// section.overlapLocking(right); +// } +// } +// } +// } +// List flsList = sectionPath.getFlsList(); +// // 延续保护位置转动 +// this.routeSwitchTurn(simulation, switchList); +// this.routeFlsControl(simulation, flsList); +// if (config.isLockFirst()) { +// for (SwitchElement switchElement : switchList) { +// if (!switchElement.isOnPosition() && +// (switchElement.getASwitch().isSectionOccupied() || switchElement.getASwitch().isLocked())) { +// continue; +// } +// switchElement.getASwitch().overlapLock(); +// } +// if (!CollectionUtils.isEmpty(flsList)) { +// for (RouteFls routeFls : flsList) { +// routeFls.lock(); +// } +// } +// } +// // 道岔是否转换到位置 +// boolean onPosition = this.checkRouteSwitchPosition(switchList) && this.isFlsCheckPass(flsList); +// if (!onPosition) return; // 未到位,返回 +// if (!overlap.getSection().isRouteLock()) { +// return; +// } +// this.overlapLock(sectionPath, right); +// overlap.settingFinish(); +// log.debug(String.format("进路延续保护[%s]办理成功", overlap.debugStr())); +// } +// +// /** +// * 侧防检查是否通过 +// */ +// public boolean isFlsCheckPass(List flsList) { +// if (!CollectionUtils.isEmpty(flsList)) { +// for (RouteFls routeFls : flsList) { +// List level1List = routeFls.getLevel1List(); +// for (RouteFls.FlsElement flsElement : level1List) { +// SwitchElement pSwitch = flsElement.getPSwitch(); +// if (pSwitch != null && !pSwitch.getASwitch().isOnPosition(pSwitch.isNormal())) { +// return false; +// } +// Signal pSignal = flsElement.getPSignal(); +// if (pSignal != null && !pSignal.isClose()) { // SwitchElement fpae = flsElement.getFpae(); -// if (fpae != null && !fpae.getASwitch().isOnPosition(fpae.isNormal())) { +// if (fpae != null) { +// if (fpae.getASwitch().isOnPosition(fpae.isNormal())) { +// return false; +// } +// } else { // return false; // } // } - } - } - } - return true; - } - - public boolean checkRouteSwitchPosition(Collection switchList) { - if (!CollectionUtils.isEmpty(switchList)) { - for (SwitchElement switchElement : switchList) { - if (!switchElement.getASwitch().isOnPosition(switchElement.isNormal())) { - return false; - } - } - } - return true; - } - - /** - * 进路信号开放 - * - * @param simulation - * @param route - */ - public void routeOpen(Simulation simulation, Route route) { - if (route.isOpenGuide() || route.isGuide()) { - route.getStart().changeLightType(false); - this.signalService.openGuideSignal(simulation, route.getStart()); - log.debug(String.format("进路始端信号机[%s(%s)]开[引导信号]", - route.getStart().getName(), route.getStart().getCode())); - } else { - if (route.isCbtcMode() && !route.isGround()) { - // cbtc下,关灯 - route.getStart().changeLightType(true); - } else { - route.getStart().changeLightType(false); - } - if (route.isOpenGreen()) { - this.signalService.openGreenSignal(simulation, route.getStart()); - } else { - this.signalService.openYellowSignal(simulation, route.getStart()); - } - log.debug(String.format("进路始端信号机[%s(%s)]开[%s]", - route.getStart().getName(), route.getStart().getCode(), - route.isOpenGreen() ? "绿灯" : "黄灯")); - } - } - - /** - * 进路始端信号关闭 - * - * @param simulation - * @param route - */ - private void routeClose(Simulation simulation, Route route) { - this.signalService.close(simulation, route.getStart()); - } - - private void sectionLock(Simulation simulation, Route route) { - boolean right = route.getStart().isRight(); - // 进路区段锁闭 - for (Section section : route.getSectionList()) { - section.routeLocking(route, right); - if (section.isSwitchTrack()) { - // 道岔锁闭 - Switch relSwitch = section.getRelSwitch(); - if (relSwitch.isNormalPosition()) { - relSwitch.getC().routeUnlocking(route); - } else if (relSwitch.isReversePosition()) { - relSwitch.getB().routeUnlocking(route); - } - } -// log.debug(section.debugStr() + "在进路办理过程中锁闭"); - } - // 道岔锁闭 - for (SwitchElement element : route.getSwitchList()) { - Switch aSwitch = element.getASwitch(); - aSwitch.routeLock(route); - } - - // 延续保护 -// if (!route.isCbtcMode()) { -// RouteOverlap overlap = route.getOverlap(); -// if (Objects.nonNull(overlap) && overlap.isSetting()) { -// SectionPath sectionPath = overlap.selectPath(); -// for (Section section : sectionPath.getSectionList()) { -// section.overlapLocking(right); -// if (section.isSwitchTrack()) { -// Switch relSwitch = section.getRelSwitch(); -// relSwitch.overlapLock(); -// } +//// else { +//// SwitchElement fpae = flsElement.getFpae(); +//// if (fpae != null && !fpae.getASwitch().isOnPosition(fpae.isNormal())) { +//// return false; +//// } +//// } // } -// for (SwitchElement element : sectionPath.getSwitchList()) { -// element.getASwitch().overlapLock(); -// } -// overlap.settingFinish(); // } // } - } - - private void routeFlsLock(List flsList) { - if (!CollectionUtils.isEmpty(flsList)) { - for (RouteFls routeFls : flsList) { - routeFls.lock(); - } - } - } - - private boolean routeSwitchTurn(Simulation simulation, List routeSwitchList) { - boolean onPosition = true; - if (!CollectionUtils.isEmpty(routeSwitchList)) { - for (SwitchElement element : routeSwitchList) { - Switch aSwitch = element.getASwitch(); - if (!aSwitch.isOnPosition(element.isNormal())) { - // 道岔没有到达进路所需位置 - onPosition = false; - // 道岔需要转动 - if (element.isNormal()) { - this.switchService.turn2NormalPosition(simulation, aSwitch); - } else { - this.switchService.turn2ReversePosition(simulation, aSwitch); - } - } - } - } - return onPosition; - } - - /** - * 取消 - * - * @param simulation - * @param route - */ - public boolean cancelNoApproachLock(Simulation simulation, Route route) { - if (route.isTransferRoute() && simulation.getRepository().getConfig().isTransferRouteCanOnlyFaultUnlock()) { - throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("转换轨进路只能通过区故解取消"); - } - if (route.isLock()) { // 进路锁闭 - // 取消进路逻辑 - if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) { - route.getStart().getRouteList().forEach(aRoute -> { - aRoute.setAtsControl(false); - aRoute.setCiControl(false); - }); - } else { - route.setAtsControl(false); - } - if (!route.isDelayUnlocking()) { - this.cancelWithoutCheck(simulation, route); - } - } else { - log.info(String.format("进路[%s(%s)]未锁闭,不需要取消进路。", - route.getName(), route.getCode())); - return false; - } - return true; - } - - /** - * 解锁进路 - * - * @param simulation - * @param route - */ - public void cancelWithoutCheck(Simulation simulation, Route route) { - // 取消自动进路 - this.cancelFleet(route); - // 关闭始端信号机 - this.routeClose(simulation, route); - log.debug(String.format("取消进路,信号机[%s(%s)]关灯", - route.getStart().getName(), route.getStart().getCode())); - route.getStart().setLevel(Signal.LEVEL_1); - // 始端信号机锁闭进路置为null - route.getStart().setLockedRoute(null); - // 进路区段取消锁闭 - boolean right = route.getStart().isRight(); - List
sectionList = route.getSectionList(); - sectionList.forEach(section -> { - if (section.isSwitchTrack()) { - Switch relSwitch = section.getRelSwitch(); - relSwitch.getA().routeUnlocking(route); - relSwitch.getB().routeUnlocking(route); - relSwitch.getC().routeUnlocking(route); - } else { - section.routeUnlocking(route); - } - log.debug(section.debugStr() + "因取消进路解锁"); - }); - // 进路道岔取消锁闭 - List switchList = route.getSwitchList(); - if (!CollectionUtils.isEmpty(switchList)) { - switchList.forEach(switchElement -> { - Switch aSwitch = switchElement.getASwitch(); - aSwitch.routeUnlock(); - }); - } - // 进路侧防取消锁闭 - List flsList = route.getFlsList(); - if (!CollectionUtils.isEmpty(flsList)) { - for (RouteFls routeFls : flsList) { - routeFls.unlock(); - } - } - // 进路延续保护解锁 - RouteOverlap overlap = route.getOverlap(); - if (Objects.nonNull(overlap)) { - overlap.releaseImmediately(); - log.debug(overlap.debugStr() + "因取消进路解锁"); - } - //进路解锁 - route.setLock(false); - route.setSetting(false); - simulation.getRepository().removeSettingRoute(route); - } - - /** - * 人解 - * - * @param simulation - * @param route - */ - public boolean humanCancel(Simulation simulation, Route route) { - if (route.isTransferRoute() && simulation.getRepository().getConfig().isTransferRouteCanOnlyFaultUnlock()) { - throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("转换轨进路只能通过区故解取消"); - } - if (route.isGuideSignalOpen()) { //根据宁波一HMI教学视频添加该分支 - this.cancelGuideRoute(simulation, route); - } else { - if (route.isDelayUnlocking()) { // 已经在延时解锁中 - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, - String.format("正在延时解锁")); - } - if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) { - route.getStart().getRouteList().forEach(aRoute -> { - aRoute.setAtsControl(false); - aRoute.setCiControl(false); - }); - } else { - route.setAtsControl(false); - } - // 关闭始端信号 - this.routeClose(simulation, route); - log.debug(String.format("人解进路,信号机[%s(%s)]关灯", - route.getStart().getName(), route.getStart().getCode())); - // 设置延时 - route.getStart().setDelayTime(route.getDelayReleaseTime() * 1000); - route.setDelayUnlocking(true); - route.getLogicSections().forEach(section -> section.setDelayUnlock(true)); - } - return true; - } - - /** - * 人解进路执行进度 - * - * @param simulation - * @param route - */ - public void humanCancelProgress(Simulation simulation, Route route) { - if (route.isDelayUnlocking()) { // 进路延时解锁中 - Signal start = route.getStart(); - int delayTime = start.getDelayTime(); - delayTime -= SimulationModule.CI.getRateMs(); - if (delayTime <= 0) { // 延时完毕,执行解锁 - this.cancelWithoutCheck(simulation, route); - // 进路解锁完成 - route.setDelayUnlocking(false); - start.setDelayTime(0); - route.getLogicSections().forEach(section -> section.setDelayUnlock(false)); - } else { - start.setDelayTime(delayTime); - } - } - } - - /** - * 进路始端信号机开放的联锁条件是否满足 - * - * @param route - * @return - */ - public boolean isInterlocked(Route route) { -// Route.CheckFailMessage failMessage; -// if (route.isOpenGuide()) { -// failMessage = this.guideRouteCheck(route); -// } else { -// failMessage = this.baseCheck(route); +// return true; +// } +// +// public boolean checkRouteSwitchPosition(Collection switchList) { +// if (!CollectionUtils.isEmpty(switchList)) { +// for (SwitchElement switchElement : switchList) { +// if (!switchElement.getASwitch().isOnPosition(switchElement.isNormal())) { +// return false; +// } +// } // } -// if (Objects.nonNull(failMessage)) { -// log.debug(String.format("联锁网络检查失败:[%s]", failMessage.toJson())); +// return true; +// } +// +// /** +// * 进路信号开放 +// * +// * @param simulation +// * @param route +// */ +// public void routeOpen(Simulation simulation, Route route) { +// if (route.isOpenGuide() || route.isGuide()) { +// route.getStart().changeLightType(false); +// this.signalService.openGuideSignal(simulation, route.getStart()); +// log.debug(String.format("进路始端信号机[%s(%s)]开[引导信号]", +// route.getStart().getName(), route.getStart().getCode())); +// } else { +// if (route.isCbtcMode() && !route.isGround()) { +// // cbtc下,关灯 +// route.getStart().changeLightType(true); +// } else { +// route.getStart().changeLightType(false); +// } +// if (route.isOpenGreen()) { +// this.signalService.openGreenSignal(simulation, route.getStart()); +// } else { +// this.signalService.openYellowSignal(simulation, route.getStart()); +// } +// log.debug(String.format("进路始端信号机[%s(%s)]开[%s]", +// route.getStart().getName(), route.getStart().getCode(), +// route.isOpenGreen() ? "绿灯" : "黄灯")); +// } +// } +// +// /** +// * 进路始端信号关闭 +// * +// * @param simulation +// * @param route +// */ +// private void routeClose(Simulation simulation, Route route) { +// this.signalService.close(simulation, route.getStart()); +// } +// +// private void sectionLock(Simulation simulation, Route route) { +// boolean right = route.getStart().isRight(); +// // 进路区段锁闭 +// for (Section section : route.getSectionList()) { +// section.routeLocking(route, right); +// if (section.isSwitchTrack()) { +// // 道岔锁闭 +// Switch relSwitch = section.getRelSwitch(); +// if (relSwitch.isNormalPosition()) { +// relSwitch.getC().routeUnlocking(route); +// } else if (relSwitch.isReversePosition()) { +// relSwitch.getB().routeUnlocking(route); +// } +// } +//// log.debug(section.debugStr() + "在进路办理过程中锁闭"); +// } +// // 道岔锁闭 +// for (SwitchElement element : route.getSwitchList()) { +// Switch aSwitch = element.getASwitch(); +// aSwitch.routeLock(route); +// } +// +// // 延续保护 +//// if (!route.isCbtcMode()) { +//// RouteOverlap overlap = route.getOverlap(); +//// if (Objects.nonNull(overlap) && overlap.isSetting()) { +//// SectionPath sectionPath = overlap.selectPath(); +//// for (Section section : sectionPath.getSectionList()) { +//// section.overlapLocking(right); +//// if (section.isSwitchTrack()) { +//// Switch relSwitch = section.getRelSwitch(); +//// relSwitch.overlapLock(); +//// } +//// } +//// for (SwitchElement element : sectionPath.getSwitchList()) { +//// element.getASwitch().overlapLock(); +//// } +//// overlap.settingFinish(); +//// } +//// } +// } +// +// private void routeFlsLock(List flsList) { +// if (!CollectionUtils.isEmpty(flsList)) { +// for (RouteFls routeFls : flsList) { +// routeFls.lock(); +// } +// } +// } +// +// private boolean routeSwitchTurn(Simulation simulation, List routeSwitchList) { +// boolean onPosition = true; +// if (!CollectionUtils.isEmpty(routeSwitchList)) { +// for (SwitchElement element : routeSwitchList) { +// Switch aSwitch = element.getASwitch(); +// if (!aSwitch.isOnPosition(element.isNormal())) { +// // 道岔没有到达进路所需位置 +// onPosition = false; +// // 道岔需要转动 +// if (element.isNormal()) { +// this.switchService.turn2NormalPosition(simulation, aSwitch); +// } else { +// this.switchService.turn2ReversePosition(simulation, aSwitch); +// } +// } +// } +// } +// return onPosition; +// } +// +// /** +// * 取消 +// * +// * @param simulation +// * @param route +// */ +// public boolean cancelNoApproachLock(Simulation simulation, Route route) { +// if (route.isTransferRoute() && simulation.getRepository().getConfig().isTransferRouteCanOnlyFaultUnlock()) { +// throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("转换轨进路只能通过区故解取消"); +// } +// if (route.isLock()) { // 进路锁闭 +// // 取消进路逻辑 +// if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) { +// route.getStart().getRouteList().forEach(aRoute -> { +// aRoute.setAtsControl(false); +// aRoute.setCiControl(false); +// }); +// } else { +// route.setAtsControl(false); +// } +// if (!route.isDelayUnlocking()) { +// this.cancelWithoutCheck(simulation, route); +// } +// } else { +// log.info(String.format("进路[%s(%s)]未锁闭,不需要取消进路。", +// route.getName(), route.getCode())); // return false; // } - int level = checkRouteLevel(route); - route.getStart().setLevel(level); - if (level != Signal.LEVEL_3) { - - if (route.isOpen()) { - log.info(String.format("进路[%s]联锁检查等级为[%s]", route.debugStr(), level)); - } - return false; - } - return true; - } - - private int checkRouteLevel(Route route) { - int level = Signal.LEVEL_1; - if (route.isNormalUnlock()) { - return level; - } - // 屏蔽门检查 - Signal start = route.getStart(); - Section signalSection = start.getSection(); - if (signalSection.isNormalStandTrack()) { - Stand stand = signalSection.getStandList().get(0); - if (Stand.Fault.PSD_CANNOT_BE_CLOSED.equals(stand.getFault()) && !stand.isInterlockRelease()) { - return level; - } - } - // 进路区段检查 - boolean right = start.isRight(); - List
sectionList = route.getSectionList(); - for (Section section : sectionList) { - if (!section.isRouteLockOn(right)) { - log.info(String.format("进路[%s]连锁条件检查失败:区段[%s]锁闭方向错误", route.debugStr(), - section.debugStr())); - return level; - } - if (section.isNoStatus()) { - log.info(String.format("进路[%s]连锁条件检查失败:区段[%s]连锁无状态", route.debugStr(), - section.debugStr())); - return level; - } - } - // 道岔位置一致检查 - Set sectionRelSwitches = sectionList.stream().map(Section::getRelSwitch).collect(Collectors.toSet()); - for (SwitchElement element : route.getSwitchList()) { - if (route.isOpenGuide() && !sectionRelSwitches.contains(element.getASwitch())) { //引导进路只检查进路区段经过的道岔 - continue; - } - if (!element.getASwitch().isOnPosition(element.isNormal())) { - String p; - if (element.getASwitch().isNormalPosition()) { - p = "定位"; - } else if (element.getASwitch().isReversePosition()) { - p = "反位"; - } else { - p = "失表"; - } - log.info(String.format("进路[%s]连锁条件检查失败:道岔[%s(%s)]位置[%s]", - route.debugStr(), - element.getASwitch().getName(), element.getASwitch().getCode(), p)); - return level; - } - } - level = Signal.LEVEL_2; // 引导级 -// if (route.getStart().isBlockade()) { -// log.info(String.format("进路[%s]连锁条件检查失败:始端信号机封锁", route.debugStr())); +// return true; +// } +// +// /** +// * 解锁进路 +// * +// * @param simulation +// * @param route +// */ +// public void cancelWithoutCheck(Simulation simulation, Route route) { +// // 取消自动进路 +// this.cancelFleet(route); +// // 关闭始端信号机 +// this.routeClose(simulation, route); +// log.debug(String.format("取消进路,信号机[%s(%s)]关灯", +// route.getStart().getName(), route.getStart().getCode())); +// route.getStart().setLevel(Signal.LEVEL_Close); +// // 始端信号机锁闭进路置为null +// route.getStart().setLockedRoute(null); +// // 进路区段取消锁闭 +// boolean right = route.getStart().isRight(); +// List
sectionList = route.getSectionList(); +// sectionList.forEach(section -> { +// if (section.isSwitchTrack()) { +// Switch relSwitch = section.getRelSwitch(); +// relSwitch.getA().routeUnlocking(route); +// relSwitch.getB().routeUnlocking(route); +// relSwitch.getC().routeUnlocking(route); +// } else { +// section.routeUnlocking(route); +// } +// log.debug(section.debugStr() + "因取消进路解锁"); +// }); +// // 进路道岔取消锁闭 +// List switchList = route.getSwitchList(); +// if (!CollectionUtils.isEmpty(switchList)) { +// switchList.forEach(switchElement -> { +// Switch aSwitch = switchElement.getASwitch(); +// aSwitch.routeUnlock(); +// }); +// } +// // 进路侧防取消锁闭 +// List flsList = route.getFlsList(); +// if (!CollectionUtils.isEmpty(flsList)) { +// for (RouteFls routeFls : flsList) { +// routeFls.unlock(); +// } +// } +// // 进路延续保护解锁 +// RouteOverlap overlap = route.getOverlap(); +// if (Objects.nonNull(overlap)) { +// overlap.releaseImmediately(); +// log.debug(overlap.debugStr() + "因取消进路解锁"); +// } +// //进路解锁 +// route.setLock(false); +// route.setSetting(false); +// simulation.getRepository().removeSettingRoute(route); +// } +// +// /** +// * 人解 +// * +// * @param simulation +// * @param route +// */ +// public boolean humanCancel(Simulation simulation, Route route) { +// if (route.isTransferRoute() && simulation.getRepository().getConfig().isTransferRouteCanOnlyFaultUnlock()) { +// throw BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("转换轨进路只能通过区故解取消"); +// } +// if (route.isGuideSignalOpen()) { //根据宁波一HMI教学视频添加该分支 +// this.cancelGuideRoute(simulation, route); +// } else { +// if (route.isDelayUnlocking()) { // 已经在延时解锁中 +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, +// String.format("正在延时解锁")); +// } +// if (simulation.getRepository().getConfig().isCancelAtsControlOfAllRoutesWhenCancelRoute()) { +// route.getStart().getRouteList().forEach(aRoute -> { +// aRoute.setAtsControl(false); +// aRoute.setCiControl(false); +// }); +// } else { +// route.setAtsControl(false); +// } +// // 关闭始端信号 +// this.routeClose(simulation, route); +// log.debug(String.format("人解进路,信号机[%s(%s)]关灯", +// route.getStart().getName(), route.getStart().getCode())); +// // 设置延时 +// route.getStart().setDelayTime(route.getDelayReleaseTime() * 1000); +// route.setDelayUnlocking(true); +// route.getLogicSections().forEach(section -> section.setDelayUnlock(true)); +// } +// return true; +// } +// +// /** +// * 人解进路执行进度 +// * +// * @param simulation +// * @param route +// */ +// public void humanCancelProgress(Simulation simulation, Route route) { +// if (route.isDelayUnlocking()) { // 进路延时解锁中 +// Signal start = route.getStart(); +// int delayTime = start.getDelayTime(); +// delayTime -= SimulationModule.CI.getRateMs(); +// if (delayTime <= 0) { // 延时完毕,执行解锁 +// this.cancelWithoutCheck(simulation, route); +// // 进路解锁完成 +// route.setDelayUnlocking(false); +// start.setDelayTime(0); +// route.getLogicSections().forEach(section -> section.setDelayUnlock(false)); +// } else { +// start.setDelayTime(delayTime); +// } +// } +// } +// +// /** +// * 进路始端信号机开放的联锁条件是否满足 +// * +// * @param route +// * @return +// */ +// public boolean isInterlocked(Route route) { +//// Route.CheckFailMessage failMessage; +//// if (route.isOpenGuide()) { +//// failMessage = this.guideRouteCheck(route); +//// } else { +//// failMessage = this.baseCheck(route); +//// } +//// if (Objects.nonNull(failMessage)) { +//// log.debug(String.format("联锁网络检查失败:[%s]", failMessage.toJson())); +//// return false; +//// } +// int level = checkRouteLevel(route); +// route.getStart().setLevel(level); +// if (level != Signal.LEVEL_Main) { +// +// if (route.isOpen()) { +// log.info(String.format("进路[%s]联锁检查等级为[%s]", route.debugStr(), level)); +// } +// return false; +// } +// return true; +// } +// +// private int checkRouteLevel(Route route) { +// int level = Signal.LEVEL_Close; +// if (route.isNormalUnlock()) { // return level; // } - //超限区段检查 - for (SwitchElement element : route.getSwitchList()) { - if (route.isOpenGuide() && !sectionRelSwitches.contains(element.getASwitch())) { //引导进路只检查进路区段经过的道岔 - continue; - } - RouteOverrun overrun = route.findOverrunBySwitch(element.getASwitch()); - if (overrun != null) { - if (overrun.getSection() != null && overrun.getSection().hasNctOccupy()) { - log.info(String.format("进路[%s]连锁条件检查失败:超限区段[%s]被占用", - route.debugStr(), overrun.getCode())); - return level; - } - SwitchElement overrunSE = overrun.getSwitchElement(); - if (overrunSE != null && overrunSE.isOnPosition()) { - if (overrunSE.getASwitch().getAllSections().stream().anyMatch(Section::hasNctOccupy)) { - log.info(String.format("进路[%s]连锁条件检查失败:超限区段[%s]被占用", - route.debugStr(), overrun.getCode())); - return level; - } - } - } - } - // 进路侧防检查 - List flsList = route.getFlsList(); - if (!route.isOpenGuide() && !CollectionUtils.isEmpty(flsList)) { - boolean level1Result = true; - for (RouteFls routeFls : flsList) { - List level1List = routeFls.getLevel1List(); - for (RouteFls.FlsElement flsElement : level1List) { - SwitchElement pSwitch = flsElement.getPSwitch(); - if (pSwitch != null && !pSwitch.getASwitch().isOnPosition(pSwitch.isNormal())) { - level1Result = false; - break; - } else { - SwitchElement fpae = flsElement.getFpae(); - Signal pSignal = flsElement.getPSignal(); - if (pSignal != null && !pSignal.isClose()) { - if (fpae != null) { - if (fpae.getASwitch().isOnPosition(fpae.isNormal())) { - level1Result = false; - } - } else { - level1Result = false; - } - } -// if ((pSignal != null && !pSignal.isClose()) || -// (fpae != null && !fpae.getASwitch().isOnPosition(fpae.isNormal()))) { -// level1Result = false; -// break; -// } - } - } - } - if (!level1Result) { - log.info(String.format("进路[%s]连锁条件检查失败:侧防不满足", route.debugStr())); - return level; - } - } - // 站台紧急停车 - if (!CollectionUtils.isEmpty(route.getEspList())) { - for (ESP esp : route.getEspList()) { - if (esp.isEffective()) { - log.info(String.format("进路[%s]连锁条件检查失败:站台紧急停车按钮[%s]按下", route.debugStr(), - esp.debugStr())); - return level; - } - } - } - // 首区段检查 - Section firstRouteSection = route.getFirstRouteSection(); - if (route.isCbtcMode()) { // CTC模式检查 - // CTC模式检查进路首区段(可能是逻辑区段)是否占用 - if (!CollectionUtils.isEmpty(firstRouteSection.getLogicList())) { - ArrayList
logicList = new ArrayList<>(firstRouteSection.getLogicList()); - if (!right) { - Collections.reverse(logicList); - } - if (logicList.get(0).isOccupied()) { - log.info(String.format("进路[%s]连锁条件检查失败:CTC模式首个区段占用", route.debugStr())); - return level; - } - } else { - if (firstRouteSection.isOccupied()) { - log.info(String.format("进路[%s]连锁条件检查失败:CTC模式首个区段占用", route.debugStr())); - return level; - } - } - } else { // 后备模式检查 - // 区段占用检查 - Route.CheckFailMessage checkFailMessage = this.ciLevelCheck(route); - if (Objects.nonNull(checkFailMessage)) { - log.info(String.format("进路[%s]连锁条件检查失败:[%s]", - route.debugStr(), checkFailMessage.toJson())); - return level; - } - for (Section section : route.getSectionList()) { - if (section.getSpeedUpLimit() != -1) { - log.info(String.format("进路[%s]连锁条件检查失败:区段[%s]限速", - route.debugStr(), section.debugStr())); - return level; - } - if (!CollectionUtils.isEmpty(section.getLogicList())) { - for (Section logic : section.getLogicList()) { - if (logic.getSpeedUpLimit() != -1) { - log.info(String.format("进路[%s]连锁条件检查失败:区段[%s]限速", - route.debugStr(), logic.debugStr())); - return level; - } - } - } - } -// // 屏蔽门 -// if (!CollectionUtils.isEmpty(route.getPsdList())) { -// for (PSD psd : route.getPsdList()) { -// if (!psd.isCloseAndLock()) { -// log.debug(String.format("联锁网络检查失败:站台[%s(%s)]屏蔽门[%s(%s)]未关闭", -// psd.getStand().getName(), psd.getStand().getCode(), -// psd.getName(), psd.getCode())); +// // 屏蔽门检查 +// Signal start = route.getStart(); +// Section signalSection = start.getSection(); +// if (signalSection.isNormalStandTrack()) { +// Stand stand = signalSection.getStandList().get(0); +// if (Stand.Fault.PSD_CANNOT_BE_CLOSED.equals(stand.getFault()) && !stand.isInterlockRelease()) { +// return level; +// } +// } +// // 进路区段检查 +// boolean right = start.isRight(); +// List
sectionList = route.getSectionList(); +// for (Section section : sectionList) { +// if (!section.isRouteLockOn(right)) { +// log.info(String.format("进路[%s]连锁条件检查失败:区段[%s]锁闭方向错误", route.debugStr(), +// section.debugStr())); +// return level; +// } +// if (section.isNoStatus()) { +// log.info(String.format("进路[%s]连锁条件检查失败:区段[%s]连锁无状态", route.debugStr(), +// section.debugStr())); +// return level; +// } +// } +// // 道岔位置一致检查 +// Set sectionRelSwitches = sectionList.stream().map(Section::getRelSwitch).collect(Collectors.toSet()); +// for (SwitchElement element : route.getSwitchList()) { +// if (route.isOpenGuide() && !sectionRelSwitches.contains(element.getASwitch())) { //引导进路只检查进路区段经过的道岔 +// continue; +// } +// if (!element.getASwitch().isOnPosition(element.isNormal())) { +// String p; +// if (element.getASwitch().isNormalPosition()) { +// p = "定位"; +// } else if (element.getASwitch().isReversePosition()) { +// p = "反位"; +// } else { +// p = "失表"; +// } +// log.info(String.format("进路[%s]连锁条件检查失败:道岔[%s(%s)]位置[%s]", +// route.debugStr(), +// element.getASwitch().getName(), element.getASwitch().getCode(), p)); +// return level; +// } +// } +// level = Signal.LEVEL_Guide; // 引导级 +//// if (route.getStart().isBlockade()) { +//// log.info(String.format("进路[%s]连锁条件检查失败:始端信号机封锁", route.debugStr())); +//// return level; +//// } +// //超限区段检查 +// for (SwitchElement element : route.getSwitchList()) { +// if (route.isOpenGuide() && !sectionRelSwitches.contains(element.getASwitch())) { //引导进路只检查进路区段经过的道岔 +// continue; +// } +// RouteOverrun overrun = route.findOverrunBySwitch(element.getASwitch()); +// if (overrun != null) { +// if (overrun.getSection() != null && overrun.getSection().hasNctOccupy()) { +// log.info(String.format("进路[%s]连锁条件检查失败:超限区段[%s]被占用", +// route.debugStr(), overrun.getCode())); +// return level; +// } +// SwitchElement overrunSE = overrun.getSwitchElement(); +// if (overrunSE != null && overrunSE.isOnPosition()) { +// if (overrunSE.getASwitch().getAllSections().stream().anyMatch(Section::hasNctOccupy)) { +// log.info(String.format("进路[%s]连锁条件检查失败:超限区段[%s]被占用", +// route.debugStr(), overrun.getCode())); // return level; // } // } // } - // 站台扣车 - if (!CollectionUtils.isEmpty(route.getStandHoldList())) { - for (Stand stand : route.getStandHoldList()) { - if (stand.isHoldTrain()) { - log.info(String.format("进路[%s]连锁条件检查失败:站台[%s(%s)]扣车", - route.debugStr(), - stand.getName(), stand.getCode())); - return level; - } - } - } - // 延续保护 - RouteOverlap overlap = route.getOverlap(); - if (overlap != null && !overlap.isLock()) { - log.info(String.format("进路[%s]连锁条件检查失败: 延续保护未锁闭", route.debugStr())); - return level; - } - } - level = Signal.LEVEL_3; // 主信号级 - return level; - } - - /** - * 设置自动进路模式 - * - * @param route - */ - public void setFleet(Route route) { - if (route.isFlt()) { - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, - String.format("不是自动进路,不能设置自动进路")); - } - if (route.isCiControl()) { // 如果联锁自动控制 - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, - String.format("进路联锁自动触发模式中,不能设置自动进路")); - } - if (!route.isFleetMode()) { - route.setFleetMode(true); - } - } - - /** - * 取消自动进路模式 - * - * @param route - */ - public void cancelFleet(Route route) { - if (route.isFleetMode()) { - route.setFleetMode(false); - } - } - - /** - * 设置进路为CI自动触发 - * - * @param route - */ - public void setCIAutoTrigger(Route route) { - if (route.isFleetMode()) { - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, - String.format("进路处于自动进路模式中,不能设置联锁自动触发")); - } - if (route.isArs()) { - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, - String.format("进路不具有该功能,无法设置为联锁自动触发")); - } - if (!route.isCiControl()) { - route.setCiControl(true); - } - } - - /** - * 取消进路CI自动触发 - * - * @param route - */ - public void cancelCIAutoTrigger(Route route) { - if (route.isCiControl()) { - route.setCiControl(false); - } - } - - /** - * 引导进路办理 - * - * @param simulation - * @param route - */ - public void settingGuideRoute(Simulation simulation, Route route) { - // 进路排列条件校验 - Route.CheckFailMessage checkFailMessage = this.guideRouteCheck(route); - if (Objects.nonNull(checkFailMessage)) { - throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, checkFailMessage.toJson()); - } - // 办理引导进路开始 - route.startSetting(simulation.getSystemTime()); - route.setOpenGuide(true); - simulation.getRepository().addSettingRoute(route); - } - - /** - * 取消引导进路 - * - * @param simulation - * @param route - */ - public void cancelGuideRoute(Simulation simulation, Route route) { - route.setOpenGuide(false); - this.cancelNoApproachLock(simulation, route); - } - - /** - * 进路正常解锁逻辑 - * - * @param simulation - * @param route - */ - public void normalUnlock(Simulation simulation, Route route) { - if (!route.isNormalUnlock()) { - return; - } - if (!route.isFleetMode()) { // 连续通过进路不解锁,非连续通过进路随最后一辆车的运行而解锁 - boolean right = route.getStart().isRight(); - // 区段是顺序的(否则会有问题) - boolean allUnlock = true; - boolean overlapRelock = true; - if (Objects.isNull(route.getUnlockedSection())) { - log.error(String.format("进路[%s(%s)]正常解锁异常", route.getName(), route.getCode())); - return; - } - List
sectionList = route.getSectionList(); - for (int i = 0; i < sectionList.size(); i++) { - Section section = sectionList.get(i); - if (!Objects.equals(route.getUnlockedSection(), section)) { - continue; - } - if (route.isLastRouteSection(section)) { - overlapRelock = false; - } - Switch relSwitch = section.getRelSwitch(); - if (section.isOccupied()) { - // 区段逻辑占用,且有逻辑区段 - if (section.isOccupied() && !CollectionUtils.isEmpty(section.getLogicList())) { - // 逻辑区段占用,根据逻辑区段占用位置解锁 - List
logicList = section.getLogicList(); - if (!right) { // 向左,逻辑区段列表reverse - logicList = new ArrayList<>(section.getLogicList()); - Collections.reverse(logicList); - } - for (Section logic : logicList) { - if (!logic.isOccupied()) { - logic.routeUnlocking(route); - } else { - break; - } - } - } - allUnlock = false; - break; - } else { - if (section.isSwitchTrack()) { // 如果是道岔区段,解锁道岔 - section.routeUnlocking(route); - if (section.getParent() != null && section.getParent().isCross()) { - section.getParent().routeUnlocking(route); - } - relSwitch.routeUnlock(); - // 侧防解锁 - route.unlockRouteFlsOfSwitch(relSwitch); - //检查道岔的联动道岔和计轴关联道岔是否可以解锁 - for (SwitchElement switchElement : route.getSwitchList()) { - if (switchElement.getASwitch().equals(relSwitch)) { - continue; - } - Switch aSwitch = switchElement.getASwitch(); - if (route.isRouteSection(aSwitch.getA())) { - continue; - } - if (relSwitch.isLinkedSwitch(aSwitch) || relSwitch.isBConnectTo(aSwitch)) { - if (!aSwitch.getA().isRouteLock()) { - aSwitch.routeUnlock(); - } - } - } - } else { - section.routeUnlocking(route); - } - log.debug(section.debugStr() + "因正常解锁解锁"); - } - if (!section.isRouteLock() && (i + 1) < sectionList.size()) { - // 区段已经解锁,更新解锁区段 - route.updateUnlockedSection(sectionList.get(i + 1)); - } else if (section.isRouteLock() && (i + 1) >= sectionList.size()) { - allUnlock = true; - } - } - Section firstRouteSection = route.getFirstRouteLogicSection(); - if (firstRouteSection.isFree()) { - route.getStart().setReblockade(false); - } - if (allUnlock) { // 进路所有区段都已经解锁,解锁完成 - route.normalUnlockOver(); - simulation.getRepository().removeSettingRoute(route); - log.debug(String.format("进路[%s(%s)-%s]解锁完毕,移除", route.getName(), route.getCode(), route.isTurnBack() ? "Z" : "B")); - } - if (overlapRelock) { - // 延续保护重新锁闭 - this.checkAndSetLockedRouteOverlap(simulation, route); - } - } - } - - private void overlapLock(SectionPath sectionPath, boolean right) { - List
sectionList = sectionPath.getSectionList(); - if (!CollectionUtils.isEmpty(sectionPath.getLogicList())) { - sectionList = sectionPath.getLogicList(); - } - for (Section section : sectionList) { - if (section.isSwitchTrack()) { - Switch relSwitch = section.getRelSwitch(); - relSwitch.overlapLock(); - relSwitch.getA().overlapLocking(right); - if (relSwitch.isNormalPosition()) { - relSwitch.getB().overlapLocking(right); - relSwitch.getC().overlapUnlocking(); - } else { - relSwitch.getC().overlapLocking(right); - relSwitch.getB().overlapUnlocking(); - } - } else { - if (!section.isOverlapLock()) { - section.overlapLocking(right); - } - } - } - // 侧防锁闭 - this.routeFlsLock(sectionPath.getFlsList()); - } - - public void normalUnlockStart(Simulation simulation, Route lockedRoute) { - if (lockedRoute.isNormalUnlock()) { - return; - } - if (lockedRoute.isOpen()) { - // 关闭始端信号 - this.routeClose(simulation, lockedRoute); - lockedRoute.getStart().setLevel(Signal.LEVEL_1);// 关闭 - log.debug(String.format("正常解锁,信号机[%s(%s)]关灯", - lockedRoute.getStart().getName(), lockedRoute.getStart().getCode())); - } - if (lockedRoute.isFleetMode()) { // 进路车队模式,不解锁 - return; - } - // 进路解锁开始信号 - lockedRoute.setSetting(false); - lockedRoute.normalUnlockStart(); - lockedRoute.setLock(false); - } - - /** - * 进路开放后,持续检查联锁条件满足,若不满足,需关闭信号 - * - * @param simulation - * @param route - */ - public void lockedRouteCheck(Simulation simulation, Route route) { - // 区段锁闭在进路方向上 - boolean right = route.getStart().isRight(); - for (Section section : route.getSectionList()) { - if (!section.isRouteLock()) { - section.routeLocking(route, right); - } - } - // 判断是否列车进入正常解锁 - Section firstLogicSection = route.getFirstLogicSection(); - if (firstLogicSection.isCtOccupied() || firstLogicSection.isNctOccupied()) { - this.normalUnlockStart(simulation, route); - return; - } - if (route.isOpen()) { - boolean interlocked = this.isInterlocked(route); - if (!interlocked) { - // 进路信号开放,联锁逻辑不满足,需关闭信号 - if (route.getStart().getLevel() == Signal.LEVEL_2) { - route.getStart().setReblockade(true); - } - if (route.isOpen()) { - this.routeClose(simulation, route); - log.info(String.format("进路[%s]始端信号联锁条件不满足,信号机[%s(%s)]关灯", - route.debugStr(), route.getStart().getName(), route.getStart().getCode())); - } - } - } - RouteOverlap overlap = route.getOverlap(); - if (route.isOpen()) { - if (this.checkCanOverlapSet(simulation, route) && !overlap.isLock()) { - this.checkAndSetLockedRouteOverlap(simulation, route); - } - } - } - - /** - * 延续保护取消锁闭 - */ - public void overlapCancelLock(RouteOverlap overlap) { - SectionPath sectionPath = overlap.selectPath(); - List switchList = sectionPath.getSwitchList(); - List flsList = sectionPath.getFlsList(); - boolean onPosition = this.checkRouteSwitchPosition(switchList) && this.isFlsCheckPass(flsList); - if (!onPosition) { - overlap.setLock(false); - } - } - - public void checkAndSetLockedRouteOverlap(Simulation simulation, Route route) { - RouteOverlap overlap = route.getOverlap(); - if (route.isCbtcMode() && this.checkCanOverlapSet(simulation, route)) { - overlap.startSetting(simulation.getSystemTime()); - } - } - - public void overlapUnlock(Simulation simulation, RouteOverlap overlap) { - if (!overlap.isLock()) { - return; - } - SectionPath sectionPath = overlap.selectPath(); - if (Objects.nonNull(sectionPath)) { -// boolean routeLock = true; -// for (Section section : sectionPath.getSectionList()) { -// if (!section.isRouteLock()) { -// routeLock = false; -// break; +// } +// // 进路侧防检查 +// List flsList = route.getFlsList(); +// if (!route.isOpenGuide() && !CollectionUtils.isEmpty(flsList)) { +// boolean level1Result = true; +// for (RouteFls routeFls : flsList) { +// List level1List = routeFls.getLevel1List(); +// for (RouteFls.FlsElement flsElement : level1List) { +// SwitchElement pSwitch = flsElement.getPSwitch(); +// if (pSwitch != null && !pSwitch.getASwitch().isOnPosition(pSwitch.isNormal())) { +// level1Result = false; +// break; +// } else { +// SwitchElement fpae = flsElement.getFpae(); +// Signal pSignal = flsElement.getPSignal(); +// if (pSignal != null && !pSignal.isClose()) { +// if (fpae != null) { +// if (fpae.getASwitch().isOnPosition(fpae.isNormal())) { +// level1Result = false; +// } +// } else { +// level1Result = false; +// } +// } +//// if ((pSignal != null && !pSignal.isClose()) || +//// (fpae != null && !fpae.getASwitch().isOnPosition(fpae.isNormal()))) { +//// level1Result = false; +//// break; +//// } +// } // } // } -// if (routeLock) { // 延续保护区段进路锁闭,立即解锁 +// if (!level1Result) { +// log.info(String.format("进路[%s]连锁条件检查失败:侧防不满足", route.debugStr())); +// return level; +// } +// } +// // 站台紧急停车 +// if (!CollectionUtils.isEmpty(route.getEspList())) { +// for (ESP esp : route.getEspList()) { +// if (esp.isEffective()) { +// log.info(String.format("进路[%s]连锁条件检查失败:站台紧急停车按钮[%s]按下", route.debugStr(), +// esp.debugStr())); +// return level; +// } +// } +// } +// // 首区段检查 +// Section firstRouteSection = route.getFirstRouteSection(); +// if (route.isCbtcMode()) { // CTC模式检查 +// // CTC模式检查进路首区段(可能是逻辑区段)是否占用 +// if (!CollectionUtils.isEmpty(firstRouteSection.getLogicList())) { +// ArrayList
logicList = new ArrayList<>(firstRouteSection.getLogicList()); +// if (!right) { +// Collections.reverse(logicList); +// } +// if (logicList.get(0).isOccupied()) { +// log.info(String.format("进路[%s]连锁条件检查失败:CTC模式首个区段占用", route.debugStr())); +// return level; +// } +// } else { +// if (firstRouteSection.isOccupied()) { +// log.info(String.format("进路[%s]连锁条件检查失败:CTC模式首个区段占用", route.debugStr())); +// return level; +// } +// } +// } else { // 后备模式检查 +// // 区段占用检查 +// Route.CheckFailMessage checkFailMessage = this.ciLevelCheck(route); +// if (Objects.nonNull(checkFailMessage)) { +// log.info(String.format("进路[%s]连锁条件检查失败:[%s]", +// route.debugStr(), checkFailMessage.toJson())); +// return level; +// } +// for (Section section : route.getSectionList()) { +// if (section.getSpeedUpLimit() != -1) { +// log.info(String.format("进路[%s]连锁条件检查失败:区段[%s]限速", +// route.debugStr(), section.debugStr())); +// return level; +// } +// if (!CollectionUtils.isEmpty(section.getLogicList())) { +// for (Section logic : section.getLogicList()) { +// if (logic.getSpeedUpLimit() != -1) { +// log.info(String.format("进路[%s]连锁条件检查失败:区段[%s]限速", +// route.debugStr(), logic.debugStr())); +// return level; +// } +// } +// } +// } +//// // 屏蔽门 +//// if (!CollectionUtils.isEmpty(route.getPsdList())) { +//// for (PSD psd : route.getPsdList()) { +//// if (!psd.isCloseAndLock()) { +//// log.debug(String.format("联锁网络检查失败:站台[%s(%s)]屏蔽门[%s(%s)]未关闭", +//// psd.getStand().getName(), psd.getStand().getCode(), +//// psd.getName(), psd.getCode())); +//// return level; +//// } +//// } +//// } +// // 站台扣车 +// if (!CollectionUtils.isEmpty(route.getStandHoldList())) { +// for (Stand stand : route.getStandHoldList()) { +// if (stand.isHoldTrain()) { +// log.info(String.format("进路[%s]连锁条件检查失败:站台[%s(%s)]扣车", +// route.debugStr(), +// stand.getName(), stand.getCode())); +// return level; +// } +// } +// } +// // 延续保护 +// RouteOverlap overlap = route.getOverlap(); +// if (overlap != null && !overlap.isLock()) { +// log.info(String.format("进路[%s]连锁条件检查失败: 延续保护未锁闭", route.debugStr())); +// return level; +// } +// } +// level = Signal.LEVEL_Main; // 主信号级 +// return level; +// } +// +// /** +// * 设置自动进路模式 +// * +// * @param route +// */ +// public void setFleet(Route route) { +// if (route.isFlt()) { +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, +// String.format("不是自动进路,不能设置自动进路")); +// } +// if (route.isCiControl()) { // 如果联锁自动控制 +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, +// String.format("进路联锁自动触发模式中,不能设置自动进路")); +// } +// if (!route.isFleetMode()) { +// route.setFleetMode(true); +// } +// } +// +// /** +// * 取消自动进路模式 +// * +// * @param route +// */ +// public void cancelFleet(Route route) { +// if (route.isFleetMode()) { +// route.setFleetMode(false); +// } +// } +// +// /** +// * 设置进路为CI自动触发 +// * +// * @param route +// */ +// public void setCIAutoTrigger(Route route) { +// if (route.isFleetMode()) { +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, +// String.format("进路处于自动进路模式中,不能设置联锁自动触发")); +// } +// if (route.isArs()) { +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, +// String.format("进路不具有该功能,无法设置为联锁自动触发")); +// } +// if (!route.isCiControl()) { +// route.setCiControl(true); +// } +// } +// +// /** +// * 取消进路CI自动触发 +// * +// * @param route +// */ +// public void cancelCIAutoTrigger(Route route) { +// if (route.isCiControl()) { +// route.setCiControl(false); +// } +// } +// +// /** +// * 引导进路办理 +// * +// * @param simulation +// * @param route +// */ +// public void settingGuideRoute(Simulation simulation, Route route) { +// // 进路排列条件校验 +// Route.CheckFailMessage checkFailMessage = this.guideRouteCheck(route); +// if (Objects.nonNull(checkFailMessage)) { +// throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, checkFailMessage.toJson()); +// } +// // 办理引导进路开始 +// route.startSetting(simulation.getSystemTime()); +// route.setOpenGuide(true); +// simulation.getRepository().addSettingRoute(route); +// } +// +// /** +// * 取消引导进路 +// * +// * @param simulation +// * @param route +// */ +// public void cancelGuideRoute(Simulation simulation, Route route) { +// route.setOpenGuide(false); +// this.cancelNoApproachLock(simulation, route); +// } +// +// /** +// * 进路正常解锁逻辑 +// * +// * @param simulation +// * @param route +// */ +// public void normalUnlock(Simulation simulation, Route route) { +// if (!route.isNormalUnlock()) { +// return; +// } +// if (!route.isFleetMode()) { // 连续通过进路不解锁,非连续通过进路随最后一辆车的运行而解锁 +// boolean right = route.getStart().isRight(); +// // 区段是顺序的(否则会有问题) +// boolean allUnlock = true; +// boolean overlapRelock = true; +// if (Objects.isNull(route.getUnlockedSection())) { +// log.error(String.format("进路[%s(%s)]正常解锁异常", route.getName(), route.getCode())); +// return; +// } +// List
sectionList = route.getSectionList(); +// for (int i = 0; i < sectionList.size(); i++) { +// Section section = sectionList.get(i); +// if (!Objects.equals(route.getUnlockedSection(), section)) { +// continue; +// } +// if (route.isLastRouteSection(section)) { +// overlapRelock = false; +// } +// Switch relSwitch = section.getRelSwitch(); +// if (section.isOccupied()) { +// // 区段逻辑占用,且有逻辑区段 +// if (section.isOccupied() && !CollectionUtils.isEmpty(section.getLogicList())) { +// // 逻辑区段占用,根据逻辑区段占用位置解锁 +// List
logicList = section.getLogicList(); +// if (!right) { // 向左,逻辑区段列表reverse +// logicList = new ArrayList<>(section.getLogicList()); +// Collections.reverse(logicList); +// } +// for (Section logic : logicList) { +// if (!logic.isOccupied()) { +// logic.routeUnlocking(route); +// } else { +// break; +// } +// } +// } +// allUnlock = false; +// break; +// } else { +// if (section.isSwitchTrack()) { // 如果是道岔区段,解锁道岔 +// section.routeUnlocking(route); +// if (section.getParent() != null && section.getParent().isCross()) { +// section.getParent().routeUnlocking(route); +// } +// relSwitch.routeUnlock(); +// // 侧防解锁 +// route.unlockRouteFlsOfSwitch(relSwitch); +// //检查道岔的联动道岔和计轴关联道岔是否可以解锁 +// for (SwitchElement switchElement : route.getSwitchList()) { +// if (switchElement.getASwitch().equals(relSwitch)) { +// continue; +// } +// Switch aSwitch = switchElement.getASwitch(); +// if (route.isRouteSection(aSwitch.getA())) { +// continue; +// } +// if (relSwitch.isLinkedSwitch(aSwitch) || relSwitch.isBConnectTo(aSwitch)) { +// if (!aSwitch.getA().isRouteLock()) { +// aSwitch.routeUnlock(); +// } +// } +// } +// } else { +// section.routeUnlocking(route); +// } +// log.debug(section.debugStr() + "因正常解锁解锁"); +// } +// if (!section.isRouteLock() && (i + 1) < sectionList.size()) { +// // 区段已经解锁,更新解锁区段 +// route.updateUnlockedSection(sectionList.get(i + 1)); +// } else if (section.isRouteLock() && (i + 1) >= sectionList.size()) { +// allUnlock = true; +// } +// } +// Section firstRouteSection = route.getFirstRouteSection(); +// if (firstRouteSection.isFree()) { +// route.getStart().setReblockade(false); +// } +// if (allUnlock) { // 进路所有区段都已经解锁,解锁完成 +// route.normalUnlockOver(); +// simulation.getRepository().removeSettingRoute(route); +// log.debug(String.format("进路[%s(%s)-%s]解锁完毕,移除", route.getName(), route.getCode(), route.isTurnBack() ? "Z" : "B")); +// } +// if (overlapRelock) { +// // 延续保护重新锁闭 +// this.checkAndSetLockedRouteOverlap(simulation, route); +// } +// } +// } +// +// private void overlapLock(SectionPath sectionPath, boolean right) { +// List
sectionList = sectionPath.getSectionList(); +// if (!CollectionUtils.isEmpty(sectionPath.getLogicList())) { +// sectionList = sectionPath.getLogicList(); +// } +// for (Section section : sectionList) { +// if (section.isSwitchTrack()) { +// Switch relSwitch = section.getRelSwitch(); +// relSwitch.overlapLock(); +// relSwitch.getA().overlapLocking(right); +// if (relSwitch.isNormalPosition()) { +// relSwitch.getB().overlapLocking(right); +// relSwitch.getC().overlapUnlocking(); +// } else { +// relSwitch.getC().overlapLocking(right); +// relSwitch.getB().overlapUnlocking(); +// } +// } else { +// if (!section.isOverlapLock()) { +// section.overlapLocking(right); +// } +// } +// } +// // 侧防锁闭 +// this.routeFlsLock(sectionPath.getFlsList()); +// } +// +// public void normalUnlockStart(Simulation simulation, Route lockedRoute) { +// if (lockedRoute.isNormalUnlock()) { +// return; +// } +// if (lockedRoute.isOpen()) { +// // 关闭始端信号 +// this.routeClose(simulation, lockedRoute); +// lockedRoute.getStart().setLevel(Signal.LEVEL_Close);// 关闭 +// log.debug(String.format("正常解锁,信号机[%s(%s)]关灯", +// lockedRoute.getStart().getName(), lockedRoute.getStart().getCode())); +// } +// if (lockedRoute.isFleetMode()) { // 进路车队模式,不解锁 +// return; +// } +// // 进路解锁开始信号 +// lockedRoute.setSetting(false); +// lockedRoute.normalUnlockStart(); +// lockedRoute.setLock(false); +// } +// +// /** +// * 进路开放后,持续检查联锁条件满足,若不满足,需关闭信号 +// * +// * @param simulation +// * @param route +// */ +// public void lockedRouteCheck(Simulation simulation, Route route) { +// // 区段锁闭在进路方向上 +// boolean right = route.getStart().isRight(); +// for (Section section : route.getSectionList()) { +// if (!section.isRouteLock()) { +// section.routeLocking(route, right); +// } +// } +// // 判断是否列车进入正常解锁 +// Section firstLogicSection = route.getFirstLogicSection(); +// if (firstLogicSection.isCtOccupied() || firstLogicSection.isNctOccupied()) { +// this.normalUnlockStart(simulation, route); +// return; +// } +// if (route.isOpen()) { +// boolean interlocked = this.isInterlocked(route); +// if (!interlocked) { +// // 进路信号开放,联锁逻辑不满足,需关闭信号 +// if (route.getStart().getLevel() == Signal.LEVEL_Guide) { +// route.getStart().setReblockade(true); +// } +// if (route.isOpen()) { +// this.routeClose(simulation, route); +// log.info(String.format("进路[%s]始端信号联锁条件不满足,信号机[%s(%s)]关灯", +// route.debugStr(), route.getStart().getName(), route.getStart().getCode())); +// } +// } +// } +// RouteOverlap overlap = route.getOverlap(); +// if (route.isOpen()) { +// if (this.checkCanOverlapSet(simulation, route) && !overlap.isLock()) { +// this.checkAndSetLockedRouteOverlap(simulation, route); +// } +// } +// } +// +// /** +// * 延续保护取消锁闭 +// */ +// public void overlapCancelLock(RouteOverlap overlap) { +// SectionPath sectionPath = overlap.selectPath(); +// List switchList = sectionPath.getSwitchList(); +// List flsList = sectionPath.getFlsList(); +// boolean onPosition = this.checkRouteSwitchPosition(switchList) && this.isFlsCheckPass(flsList); +// if (!onPosition) { +// overlap.setLock(false); +// } +// } +// +// public void checkAndSetLockedRouteOverlap(Simulation simulation, Route route) { +// RouteOverlap overlap = route.getOverlap(); +// if (route.isCbtcMode() && this.checkCanOverlapSet(simulation, route)) { +// overlap.startSetting(simulation.getSystemTime()); +// } +// } +// +// public void overlapUnlock(Simulation simulation, RouteOverlap overlap) { +// if (!overlap.isLock()) { +// return; +// } +// SectionPath sectionPath = overlap.selectPath(); +// if (Objects.nonNull(sectionPath)) { +//// boolean routeLock = true; +//// for (Section section : sectionPath.getSectionList()) { +//// if (!section.isRouteLock()) { +//// routeLock = false; +//// break; +//// } +//// } +//// if (routeLock) { // 延续保护区段进路锁闭,立即解锁 +//// overlap.releaseImmediately(); +//// } else +// if (overlap.getSection().isRouteLock() && +// overlap.getSection().isOccupied()) { // 前方进路最后子进路占用,触发/解锁执行 +// if (!overlap.isReleasing()) { +// log.debug(String.format("[%s]延续保护[%s],触发区段[%s(%s)]触发开始解锁", +// overlap.isRight() ? "右向" : "左向", overlap.getName(), +// overlap.getSection().getName(), overlap.getSection().getCode())); +// overlap.startReleasing(); +// } else { +// overlap.releaseProgress(); +// } +// } else if (!overlap.getSection().isRouteLock()) { +// // 最后子进路解锁,则延续保护解锁 // overlap.releaseImmediately(); -// } else - if (overlap.getSection().isRouteLock() && - overlap.getSection().isOccupied()) { // 前方进路最后子进路占用,触发/解锁执行 - if (!overlap.isReleasing()) { - log.debug(String.format("[%s]延续保护[%s],触发区段[%s(%s)]触发开始解锁", - overlap.isRight() ? "右向" : "左向", overlap.getName(), - overlap.getSection().getName(), overlap.getSection().getCode())); - overlap.startReleasing(); - } else { - overlap.releaseProgress(); - } - } else if (!overlap.getSection().isRouteLock()) { - // 最后子进路解锁,则延续保护解锁 - overlap.releaseImmediately(); - log.debug(overlap.debugStr() + "因前方进路最后子进路解锁而解锁"); - } else { - boolean allUnlock = true; - - List
logicList = sectionPath.getLogicList(); - if (!CollectionUtils.isEmpty(logicList)) { - for (Section section : logicList) { - if (section.isOverlapLock()) { - allUnlock = false; - break; - } - } - } else { - for (Section section : sectionPath.getSectionList()) { - if (section.isOverlapLock()) { - allUnlock = false; - break; - } - } - } - if (allUnlock) { - overlap.releaseImmediately(); - log.debug(overlap.debugStr() + "因关联区段全部非延续保护锁闭,故解锁"); - } - } - } - } - - public void checkLockOverlap(Simulation simulation, RouteOverlap overlap) { - if (!overlap.isLock()) { - boolean right = overlap.isRight(); - // 延续保护前方进路最后子进路锁闭,且无占用,延续保护触发区段占用,则尝试触发设置 - if (overlap.getSection().isRouteLockOn(right) && - !overlap.getSection().isOccupied() && - overlap.isTriggerSectionOccupied()) { - // 查找延续保护道岔位置正确的路径,进行延续保护设置 - List pathList = overlap.getPathList(); - SectionPath settingPath = null; - for (SectionPath path : pathList) { - boolean setting = true; - List switchList = path.getSwitchList(); - for (SwitchElement element : switchList) { - if (!element.getASwitch().isOnPosition(element.isNormal())) { - setting = false; - break; - } - } - List
logicList = path.getLogicList(); - if (!CollectionUtils.isEmpty(logicList)) { - for (Section section : logicList) { - if (section.isLockedOn(!right)) { - // 区段锁闭在相反方向 - setting = false; - break; - } - } - } else { - List
sectionList = path.getSectionList(); - for (Section section : sectionList) { - if (section.isLockedOn(!right)) { - // 区段锁闭在相反方向 - setting = false; - break; - } - } - } - if (setting) { - settingPath = path; - break; - } - } - if (Objects.nonNull(settingPath)) { - for (SwitchElement element : settingPath.getSwitchList()) { - element.getASwitch().overlapLock(); - } - List
logicList = settingPath.getLogicList(); - if (!CollectionUtils.isEmpty(logicList)) { - for (Section section : logicList) { - section.overlapLocking(right); - } - } else { - for (Section section : settingPath.getSectionList()) { - section.overlapLocking(right); - } - } - overlap.setLock(true); - } - } - } - } - - public void handleTrainStopMessage(Simulation simulation, VirtualRealityTrain train) { - // 进路最后一个区段通信车停车,进路延续保护立即解锁 - Section section = train.getHeadPosition().getSection(); - if (!section.isRouteLock()) - return; - if (!train.isParkingAt()) - return; - List overlapList = simulation.getRepository() - .getListByType(MapElement.DeviceType.OVERLAP, RouteOverlap.class); - for (RouteOverlap routeOverlap : overlapList) { - if (routeOverlap.allSectionsOl() && - section.isRouteLockOn(routeOverlap.isRight()) && routeOverlap.isRouteLastSection(section)) { - // 是此延续保护的解锁区段,立即解锁 - routeOverlap.releaseImmediately(); - log.debug(String.format("收到列车[%s]停稳消息,[%s]延续保护[%s],触发区段[%s(%s)]立即解锁", - train.getGroupNumber(), - routeOverlap.isRight() ? "右向" : "左向", routeOverlap.getName(), - routeOverlap.getSection().getName(), routeOverlap.getSection().getCode())); - break; - } - } - } - - public void checkAndAllowOverlap(Simulation simulation, RouteOverlap overlap) { - if (overlap.isForbidden()) { - if (!overlap.getSection().isOccupied()) { - overlap.allowLock(); - } else { - SectionPath sectionPath = overlap.selectPath(); - if (Objects.nonNull(sectionPath)) { - for (Section section : sectionPath.getSectionList()) { - if (section.isOccupied()) { - overlap.allowLock(); - break; - } - } - } - } - } - } - - public void setOverlap(Simulation simulation, Signal signal, RouteOverlap overlap) { - overlap.startSetting(simulation.getSystemTime()); - } - - public boolean isApproachLock(SimulationDataRepository repository, Route route) { - TrainInfo firstTrain = repository.querySignalApproachedFirstTrain(route.getStart()); - if (route.getStart().isApproachLock()) { // 接近锁闭,总人解 - if (firstTrain == null || !firstTrain.isStop()) { - return true; - } - } - return false; - } -} +// log.debug(overlap.debugStr() + "因前方进路最后子进路解锁而解锁"); +// } else { +// boolean allUnlock = true; +// +// List
logicList = sectionPath.getLogicList(); +// if (!CollectionUtils.isEmpty(logicList)) { +// for (Section section : logicList) { +// if (section.isOverlapLock()) { +// allUnlock = false; +// break; +// } +// } +// } else { +// for (Section section : sectionPath.getSectionList()) { +// if (section.isOverlapLock()) { +// allUnlock = false; +// break; +// } +// } +// } +// if (allUnlock) { +// overlap.releaseImmediately(); +// log.debug(overlap.debugStr() + "因关联区段全部非延续保护锁闭,故解锁"); +// } +// } +// } +// } +// +// public void checkLockOverlap(Simulation simulation, RouteOverlap overlap) { +// if (!overlap.isLock()) { +// boolean right = overlap.isRight(); +// // 延续保护前方进路最后子进路锁闭,且无占用,延续保护触发区段占用,则尝试触发设置 +// if (overlap.getSection().isRouteLockOn(right) && +// !overlap.getSection().isOccupied() && +// overlap.isTriggerSectionOccupied()) { +// // 查找延续保护道岔位置正确的路径,进行延续保护设置 +// List pathList = overlap.getPathList(); +// SectionPath settingPath = null; +// for (SectionPath path : pathList) { +// boolean setting = true; +// List switchList = path.getSwitchList(); +// for (SwitchElement element : switchList) { +// if (!element.getASwitch().isOnPosition(element.isNormal())) { +// setting = false; +// break; +// } +// } +// List
logicList = path.getLogicList(); +// if (!CollectionUtils.isEmpty(logicList)) { +// for (Section section : logicList) { +// if (section.isLockedOn(!right)) { +// // 区段锁闭在相反方向 +// setting = false; +// break; +// } +// } +// } else { +// List
sectionList = path.getSectionList(); +// for (Section section : sectionList) { +// if (section.isLockedOn(!right)) { +// // 区段锁闭在相反方向 +// setting = false; +// break; +// } +// } +// } +// if (setting) { +// settingPath = path; +// break; +// } +// } +// if (Objects.nonNull(settingPath)) { +// for (SwitchElement element : settingPath.getSwitchList()) { +// element.getASwitch().overlapLock(); +// } +// List
logicList = settingPath.getLogicList(); +// if (!CollectionUtils.isEmpty(logicList)) { +// for (Section section : logicList) { +// section.overlapLocking(right); +// } +// } else { +// for (Section section : settingPath.getSectionList()) { +// section.overlapLocking(right); +// } +// } +// overlap.setLock(true); +// } +// } +// } +// } +// +// public void handleTrainStopMessage(Simulation simulation, VirtualRealityTrain train) { +// // 进路最后一个区段通信车停车,进路延续保护立即解锁 +// Section section = train.getHeadPosition().getSection(); +// if (!section.isRouteLock()) +// return; +// if (!train.isParkingAt()) +// return; +// List overlapList = simulation.getRepository() +// .getListByType(MapElement.DeviceType.OVERLAP, RouteOverlap.class); +// for (RouteOverlap routeOverlap : overlapList) { +// if (routeOverlap.allSectionsOl() && +// section.isRouteLockOn(routeOverlap.isRight()) && routeOverlap.isRouteLastSection(section)) { +// // 是此延续保护的解锁区段,立即解锁 +// routeOverlap.releaseImmediately(); +// log.debug(String.format("收到列车[%s]停稳消息,[%s]延续保护[%s],触发区段[%s(%s)]立即解锁", +// train.getGroupNumber(), +// routeOverlap.isRight() ? "右向" : "左向", routeOverlap.getName(), +// routeOverlap.getSection().getName(), routeOverlap.getSection().getCode())); +// break; +// } +// } +// } +// +// public void checkAndAllowOverlap(Simulation simulation, RouteOverlap overlap) { +// if (overlap.isForbidden()) { +// if (!overlap.getSection().isOccupied()) { +// overlap.allowLock(); +// } else { +// SectionPath sectionPath = overlap.selectPath(); +// if (Objects.nonNull(sectionPath)) { +// for (Section section : sectionPath.getSectionList()) { +// if (section.isOccupied()) { +// overlap.allowLock(); +// break; +// } +// } +// } +// } +// } +// } +// +// public void setOverlap(Simulation simulation, Signal signal, RouteOverlap overlap) { +// overlap.startSetting(simulation.getSystemTime()); +// } +// +// public boolean isApproachLock(SimulationDataRepository repository, Route route) { +// TrainInfo firstTrain = repository.querySignalApproachedFirstTrain(route.getStart()); +// if (route.getStart().isApproachLock()) { // 接近锁闭,总人解 +// if (firstTrain == null || !firstTrain.isStop()) { +// return true; +// } +// } +// return false; +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SectionService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SectionService.java index ab630f882..50028bbdc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SectionService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SectionService.java @@ -1,122 +1,120 @@ -package club.joylink.rtss.simulation.cbtc.CI.service; - -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; -import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; -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.Signal; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Repository; -import org.springframework.util.CollectionUtils; - -import java.util.List; -import java.util.Objects; - -/** - * 区段服务 - */ -@Component -@Slf4j -public class SectionService { - - @Autowired - private SignalService signalService; - @Autowired - private RouteService routeService; - - /** - * 封锁(封锁后,包含区段的进路不能排列) - */ - public void blockade(Section section) { -// if(section.isRouteLock() || section.isOverlapLock()) { -// log.info(String.format("区段[%s(%s)]进路锁闭,不能封锁", section.getName(), section.getCode())); -// return; +//package club.joylink.rtss.simulation.cbtc.CI.service; +// +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; +//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.Signal; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import java.util.List; +//import java.util.Objects; +// +///** +// * 区段服务 +// */ +//@Component +//@Slf4j +//public class SectionService { +// +// @Autowired +// private SignalService signalService; +// @Autowired +// private RouteService routeService; +// +// /** +// * 封锁(封锁后,包含区段的进路不能排列) +// */ +// public void blockade(Section section) { +//// if(section.isRouteLock() || section.isOverlapLock()) { +//// log.info(String.format("区段[%s(%s)]进路锁闭,不能封锁", section.getName(), section.getCode())); +//// return; +//// } +// if (!section.isBlockade()) { +// section.setBlockade(true); +// if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) { +// section.getLogicList().forEach(logic -> logic.setBlockade(true)); +// } // } - if (!section.isBlockade()) { - section.setBlockade(true); - if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) { - section.getLogicList().forEach(logic -> logic.setBlockade(true)); - } - } - } - - /** - * 解封 - */ - public void unblock(Section section) { - if (section.isBlockade()) { - section.setBlockade(false); - if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) { - section.getLogicList().forEach(logic -> logic.setBlockade(false)); - } - } - } - - /** - * 区故解 - */ - public void sectionFaultUnlock(Simulation simulation, Section section, Route route) { - if (route != null) { - if (route.isOpen()) { - signalService.close(simulation, route.getStart()); - } - if (routeService.isApproachLock(simulation.getRepository(), route) || section.isOverlapLock()) { - // 区段延时解锁 - int delayTime = route.getDelayReleaseTime() * 1000; - section.delayUnlock(delayTime); - if (section.isShowLogic()) { - section.getLogicList().forEach(ls -> ls.delayUnlock(delayTime)); - } - return; - } else { - route.setLock(false); - Signal start = route.getStart(); - if (start.getLockedRoute() == route) { - start.setLockedRoute(null); - } - } - } - section.faultUnlock(); - if (section.isShowLogic()) { - section.getLogicList().forEach(Section::faultUnlock); - } - } - - /** - * 区段延时区故解 - * - * @param simulation - * @param section - */ - public void delayUnlock(Simulation simulation, Section section) { - int remainTime = section.getDelayTime(); - if (remainTime > 0) { - remainTime -= SimulationConstants.CI_LOOP_RATE; - if (remainTime <= 0) { - List routeList = simulation.getRepository().queryAllLockedRoute(); - Route lockedRoute = null; - for (Route route : routeList) { - if (route.containSection(section)) { - lockedRoute = route; - break; - } - } - if (Objects.nonNull(lockedRoute)) { - lockedRoute.setLock(false); - Signal start = lockedRoute.getStart(); - this.signalService.close(simulation, start); - if (start.getLockedRoute() == lockedRoute) { - start.setLockedRoute(null); - } - } - section.faultUnlock(); - section.setDelayTime(0); - } else { - section.setDelayTime(remainTime); - } - } - } -} +// } +// +// /** +// * 解封 +// */ +// public void unblock(Section section) { +// if (section.isBlockade()) { +// section.setBlockade(false); +// if (!section.isCross() && !CollectionUtils.isEmpty(section.getLogicList())) { +// section.getLogicList().forEach(logic -> logic.setBlockade(false)); +// } +// } +// } +// +// /** +// * 区故解 +// */ +// public void sectionFaultUnlock(Simulation simulation, Section section, Route route) { +// if (route != null) { +// if (route.isOpenMain()) { +// signalService.close(simulation, route.getStart()); +// } +// if (routeService.isApproachLock(simulation.getRepository(), route) || section.isOverlapLock()) { +// // 区段延时解锁 +// int delayTime = route.getDelayReleaseTime() * 1000; +// section.delayUnlock(delayTime); +// if (section.isShowLogic()) { +// section.getLogicList().forEach(ls -> ls.delayUnlock(delayTime)); +// } +// return; +// } else { +// route.setLock(false); +// Signal start = route.getStart(); +// if (start.getLockedRoute() == route) { +// start.setLockedRoute(null); +// } +// } +// } +// section.faultUnlock(); +// if (section.isShowLogic()) { +// section.getLogicList().forEach(Section::faultUnlock); +// } +// } +// +// /** +// * 区段延时区故解 +// * +// * @param simulation +// * @param section +// */ +// public void delayUnlock(Simulation simulation, Section section) { +// int remainTime = section.getDelayTime(); +// if (remainTime > 0) { +// remainTime -= SimulationConstants.CI_LOOP_RATE; +// if (remainTime <= 0) { +// List routeList = simulation.getRepository().queryAllLockedRoute(); +// Route lockedRoute = null; +// for (Route route : routeList) { +// if (route.containSection(section)) { +// lockedRoute = route; +// break; +// } +// } +// if (Objects.nonNull(lockedRoute)) { +// lockedRoute.setLock(false); +// Signal start = lockedRoute.getStart(); +// this.signalService.close(simulation, start); +// if (start.getLockedRoute() == lockedRoute) { +// start.setLockedRoute(null); +// } +// } +// section.faultUnlock(); +// section.setDelayTime(0); +// } else { +// section.setDelayTime(remainTime); +// } +// } +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SignalService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SignalService.java index 1c1326664..935ec154a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SignalService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SignalService.java @@ -1,180 +1,180 @@ -package club.joylink.rtss.simulation.cbtc.CI.service; - -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.data.map.Route; -import club.joylink.rtss.simulation.cbtc.data.map.Signal; -import club.joylink.rtss.simulation.cbtc.data.support.SignalApproachMessage; -import club.joylink.rtss.simulation.cbtc.event.RouteModeChangeEvent; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.List; -import java.util.Objects; - -/** - * 信号机服务 - */ -@Component -@Slf4j -public class SignalService { - - @Autowired - private VrSignalControlService vrSignalControlService; - - @Autowired - private ApplicationContext applicationContext; - - /** - * 封锁(封锁后,包含信号机的进路不能排列) - * @param signal - */ - public void blockade(Simulation simulation, Signal signal) { - if(!signal.isBlockade()) { - signal.setBlockade(true); - this.close(simulation, signal); - if (signal.getLockedRoute() != null) { - signal.setReblockade(true); - log.debug(signal.debugStr() + "因信号机封锁且有锁闭的进路而重复封锁"); - } - } - } - - /** - * 解封 - * @param signal - */ - public void unblock(Signal signal) { - if (signal.isBlockade()) { - signal.setBlockade(false); - } - } - - /** - * 信号关闭 - * @param simulation - * @param signal - */ - public void close(Simulation simulation, Signal signal) { - if (signal.isLogicLight()) { - signal.apply(false, false, true); - if (!signal.isVirtual()) { - this.vrSignalControlService.close(simulation, signal.getVirtualSignal()); - } - } else { - if (!signal.isVirtual()) { - this.vrSignalControlService.openRedSignal(simulation, signal.getVirtualSignal()); - } - } - } - - /** - * 控制室外信号机点绿灯 - * @param simulation - * @param signal - */ - public void openGreenSignal(Simulation simulation, Signal signal) { - if (signal.isLogicLight()) { - signal.apply(true, false, false); - if (!signal.isVirtual()) { - this.vrSignalControlService.close(simulation, signal.getVirtualSignal()); - } - } else { - if (!signal.isVirtual()) { - this.vrSignalControlService.openGreenSignal(simulation, signal.getVirtualSignal()); - } - } - } - - /** - * 控制室外信号机点黄灯 - * @param simulation - * @param signal - */ - public void openYellowSignal(Simulation simulation, Signal signal) { - if (signal.isLogicLight()) { - signal.apply(false, true, false); - if (!signal.isVirtual()) { - this.vrSignalControlService.close(simulation, signal.getVirtualSignal()); - } - } else { - this.vrSignalControlService.openYellowSignal(simulation, signal.getVirtualSignal()); - } - } - - /** - * 控制室外信号机点黄红灯 - * @param simulation - * @param signal - */ - public void openGuideSignal(Simulation simulation, Signal signal) { - signal.changeLightType(false); - this.vrSignalControlService.openGuideSignal(simulation, signal.getVirtualSignal()); - signal.apply(false, true, true); - int guideRemain = signal.getGuideRemain(); - if (guideRemain > 0) { - signal.guideInfinite(); - } else { - signal.guideStart(); - } - signal.setInit(false); - if (signal.isReblockade()) { - signal.setReblockade(false); - } - } - - /** - * 处理信号机接近消息 - * @param simulation - * @param signal - * @param approachMessage - */ - public void handleApproachMessage(Simulation simulation, Signal signal, SignalApproachMessage approachMessage) { - if (Objects.equals(signal.getApproachMsg(), approachMessage.getApproachMsg())) { - return; - } - signal.setApproachMsg(approachMessage.getApproachMsg()); - if (signal.isNctApproach()) { // 接近区段非通信车占用 - this.changeRoutesCBTCMode(simulation, signal, false); - if (signal.isLogicLight()) { // 非通信车占用,改为物理点灯 - this.changeSignalLightType(simulation, signal, false); - } - } else if (signal.isCbtcApproach()) { // 接近区段通信车占用 - this.changeRoutesCBTCMode(simulation, signal, true); - if (!signal.isLogicLight()) { - this.changeSignalLightType(simulation, signal, true); - } - } - } - - private void changeSignalLightType(Simulation simulation, Signal signal, boolean logic) { - if (!Objects.equals(signal.isLogicLight(), logic)) { - signal.changeLightType(logic); - if (!signal.isLogicLight()) { - if (!signal.isVirtual()) { - if (signal.isGreenOpen()) { - this.vrSignalControlService.openGreenSignal(simulation, signal.getVirtualSignal()); - } else if (signal.isYellowOpen()) { - this.vrSignalControlService.openYellowSignal(simulation, signal.getVirtualSignal()); - } else { - this.vrSignalControlService.openRedSignal(simulation, signal.getVirtualSignal()); - } - } - } else { - if (!signal.isVirtual()) { - this.vrSignalControlService.close(simulation, signal.getVirtualSignal()); - } - } - } - } - - private void changeRoutesCBTCMode(Simulation simulation, Signal signal, boolean cbtc) { - List routeList = signal.getRouteList(); - if (!CollectionUtils.isEmpty(routeList)) { - routeList.forEach(route -> route.setCbtcMode(cbtc)); - applicationContext.publishEvent(new RouteModeChangeEvent(this, simulation, routeList)); - } - } -} +//package club.joylink.rtss.simulation.cbtc.CI.service; +// +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.data.map.Route; +//import club.joylink.rtss.simulation.cbtc.data.map.Signal; +//import club.joylink.rtss.simulation.cbtc.data.support.SignalApproachMessage; +//import club.joylink.rtss.simulation.cbtc.event.RouteModeChangeEvent; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.context.ApplicationContext; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import java.util.List; +//import java.util.Objects; +// +///** +// * 信号机服务 +// */ +//@Component +//@Slf4j +//public class SignalService { +// +// @Autowired +// private VrSignalControlService vrSignalControlService; +// +// @Autowired +// private ApplicationContext applicationContext; +// +// /** +// * 封锁(封锁后,包含信号机的进路不能排列) +// * @param signal +// */ +// public void blockade(Simulation simulation, Signal signal) { +// if(!signal.isBlockade()) { +// signal.setBlockade(true); +// this.close(simulation, signal); +// if (signal.getLockedRoute() != null) { +// signal.setReblockade(true); +// log.debug(signal.debugStr() + "因信号机封锁且有锁闭的进路而重复封锁"); +// } +// } +// } +// +// /** +// * 解封 +// * @param signal +// */ +// public void unblock(Signal signal) { +// if (signal.isBlockade()) { +// signal.setBlockade(false); +// } +// } +// +// /** +// * 信号关闭 +// * @param simulation +// * @param signal +// */ +// public void close(Simulation simulation, Signal signal) { +// if (signal.isLogicLight()) { +// signal.apply(false, false, true); +// if (!signal.isVirtual()) { +// this.vrSignalControlService.close(simulation, signal.getVirtualSignal()); +// } +// } else { +// if (!signal.isVirtual()) { +// this.vrSignalControlService.openRedSignal(simulation, signal.getVirtualSignal()); +// } +// } +// } +// +// /** +// * 控制室外信号机点绿灯 +// * @param simulation +// * @param signal +// */ +// public void openGreenSignal(Simulation simulation, Signal signal) { +// if (signal.isLogicLight()) { +// signal.apply(true, false, false); +// if (!signal.isVirtual()) { +// this.vrSignalControlService.close(simulation, signal.getVirtualSignal()); +// } +// } else { +// if (!signal.isVirtual()) { +// this.vrSignalControlService.openGreenSignal(simulation, signal.getVirtualSignal()); +// } +// } +// } +// +// /** +// * 控制室外信号机点黄灯 +// * @param simulation +// * @param signal +// */ +// public void openYellowSignal(Simulation simulation, Signal signal) { +// if (signal.isLogicLight()) { +// signal.apply(false, true, false); +// if (!signal.isVirtual()) { +// this.vrSignalControlService.close(simulation, signal.getVirtualSignal()); +// } +// } else { +// this.vrSignalControlService.openYellowSignal(simulation, signal.getVirtualSignal()); +// } +// } +// +// /** +// * 控制室外信号机点黄红灯 +// * @param simulation +// * @param signal +// */ +// public void openGuideSignal(Simulation simulation, Signal signal) { +// signal.changeLightType(false); +// this.vrSignalControlService.openGuideSignal(simulation, signal.getVirtualSignal()); +// signal.apply(false, true, true); +// int guideRemain = signal.getGuideRemain(); +// if (guideRemain > 0) { +// signal.guideInfinite(); +// } else { +// signal.guideStart(); +// } +// signal.setInit(false); +// if (signal.isReblockade()) { +// signal.setReblockade(false); +// } +// } +// +// /** +// * 处理信号机接近消息 +// * @param simulation +// * @param signal +// * @param approachMessage +// */ +// public void handleApproachMessage(Simulation simulation, Signal signal, SignalApproachMessage approachMessage) { +// if (Objects.equals(signal.getApproachMsg(), approachMessage.getApproachMsg())) { +// return; +// } +// signal.setApproachMsg(approachMessage.getApproachMsg()); +// if (signal.isNctApproach()) { // 接近区段非通信车占用 +// this.changeRoutesCBTCMode(simulation, signal, false); +// if (signal.isLogicLight()) { // 非通信车占用,改为物理点灯 +// this.changeSignalLightType(simulation, signal, false); +// } +// } else if (signal.isCbtcApproach()) { // 接近区段通信车占用 +// this.changeRoutesCBTCMode(simulation, signal, true); +// if (!signal.isLogicLight()) { +// this.changeSignalLightType(simulation, signal, true); +// } +// } +// } +// +// private void changeSignalLightType(Simulation simulation, Signal signal, boolean logic) { +// if (!Objects.equals(signal.isLogicLight(), logic)) { +// signal.changeLightType(logic); +// if (!signal.isLogicLight()) { +// if (!signal.isVirtual()) { +// if (signal.isGreenOpen()) { +// this.vrSignalControlService.openGreenSignal(simulation, signal.getVirtualSignal()); +// } else if (signal.isYellowOpen()) { +// this.vrSignalControlService.openYellowSignal(simulation, signal.getVirtualSignal()); +// } else { +// this.vrSignalControlService.openRedSignal(simulation, signal.getVirtualSignal()); +// } +// } +// } else { +// if (!signal.isVirtual()) { +// this.vrSignalControlService.close(simulation, signal.getVirtualSignal()); +// } +// } +// } +// } +// +// private void changeRoutesCBTCMode(Simulation simulation, Signal signal, boolean cbtc) { +// List routeList = signal.getRouteList(); +// if (!CollectionUtils.isEmpty(routeList)) { +// routeList.forEach(route -> route.setCbtcMode(cbtc)); +// applicationContext.publishEvent(new RouteModeChangeEvent(this, simulation, routeList)); +// } +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/StandService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/StandService.java index e8322fa0e..e59fd1097 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/StandService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/StandService.java @@ -1,185 +1,185 @@ -package club.joylink.rtss.simulation.cbtc.CI.service; - -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice; -import club.joylink.rtss.simulation.cbtc.communication.vo.PsdSwitch; -import club.joylink.rtss.simulation.cbtc.data.map.*; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; -import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -import java.util.Objects; - -/** - * 屏蔽门服务 - */ -@Component -@Slf4j -public class StandService { - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - private SignalService signalService; - - @Autowired - private RouteService routeService; - - /** - * 控制室外屏蔽门开关 - */ - public void controlVrPSD(Simulation simulation, VirtualRealityScreenDoor vrPsd, boolean open) { - if ((open && (vrPsd.isSettingOpen() || vrPsd.isOpen2End())) || - (!open && (vrPsd.isSettingClose() || vrPsd.isLockAndClose()))) { -// log.debug(String.format("屏蔽门[%s(%s)]已经在对应状态,不需要再控制", vrPsd.getName(), vrPsd.getCode())); - return; - } - vrPsd.startSetting(open); - ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, open); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); - } - - /** - * 打开屏蔽门 - * - * @param simulation - * @param psd - */ - public void openScreenDoor(Simulation simulation, PSD psd) { - VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor(); - if (vrPsd.isPslControl()) { - return; - } - this.controlVrPSD(simulation, vrPsd, true); - } - - /** - * 关闭屏蔽门 - * - * @param simulation - * @param psd - */ - public void closeScreenDoor(Simulation simulation, PSD psd) { - VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor(); - if (vrPsd.isPslControl()) { - return; - } - this.controlVrPSD(simulation, vrPsd, false); - } - - /** - * 设置扣车 - * - * @param simulation - * @param stand - * @param center - */ - public void holdTrain(Simulation simulation, Stand stand, boolean center) { - if (center) { - stand.setCenterHoldTrain(true); - } else { - stand.setStationHoldTrain(true); - } - // 关闭出站信号机 - Signal signal = stand.getSection().getSignalOf(stand.isRight()); - if (Objects.nonNull(signal)) { - MapConfig config = simulation.getRepository().getConfig(); - if (config.isStandHoldCloseLogicLight()/* || !signal.isLogicLight()*/) { - this.signalService.close(simulation, signal); - } - } - } - - /**系统扣车*/ - public void sysHoldTrain(Simulation simulation, Stand stand) { - stand.setSysHoldTrain(true); - // 关闭出站信号机 - Signal signal = stand.getSection().getSignalOf(stand.isRight()); - if (Objects.nonNull(signal)) { - MapConfig config = simulation.getRepository().getConfig(); - if (config.isStandHoldCloseLogicLight() || !signal.isLogicLight()) { - this.signalService.close(simulation, signal); - } - } - } - - public void cancelSysHoldTrain(Simulation simulation, Stand stand) { - stand.setSysHoldTrain(false); - // 如果所有扣车都取消,开放出站信号机 - if (!stand.isHoldTrain()) { - this.reopenSignal(simulation, stand); - } - } - - public void ibpHoldTrain(Simulation simulation, Stand stand) { - stand.setIbpHoldTrain(true); - // 关闭出站信号机 - Signal signal = stand.getSection().getSignalOf(stand.isRight()); - if (Objects.nonNull(signal)) { - MapConfig config = simulation.getRepository().getConfig(); - if (config.isStandHoldCloseLogicLight() || !signal.isLogicLight()) { - this.signalService.close(simulation, signal); - } - } - } - - public void cancelIbpHoldTrain(Simulation simulation, Stand stand) { - stand.setIbpHoldTrain(false); - // 如果所有扣车都取消,开放出站信号机 - if (!stand.isHoldTrain()) { - this.reopenSignal(simulation, stand); - } - } - - /** - * 取消扣车 - * - * @param simulation - * @param stand - * @param center - */ - public void cancelHoldTrain(Simulation simulation, Stand stand, boolean center) { - if (center) { - stand.setCenterHoldTrain(false); - } else { - stand.setStationHoldTrain(false); - } - // 如果所有扣车都取消,开放出站信号机 - if (!stand.isHoldTrain()) { - this.reopenSignal(simulation, stand); - } - } - - public void cancelAllHoldTrain(Simulation simulation, Stand stand) { - stand.setCenterHoldTrain(false); - stand.setStationHoldTrain(false); - this.reopenSignal(simulation, stand); - } - - private void reopenSignal(Simulation simulation, Stand stand) { - Signal signal = stand.getSection().getSignalOf(stand.isRight()); - if (Objects.nonNull(signal) && !signal.isNormalOpen()) { - Route lockedRoute = signal.getLockedRoute(); - if (Objects.nonNull(lockedRoute) && this.routeService.isInterlocked(lockedRoute)) { // 锁闭进路存在,开信号机 - this.routeService.routeOpen(simulation, lockedRoute); - } - } - } - - /** - * 设置或取消互锁解除 - * @param release 是否是设置 - */ - public void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release) { - stand.getPsd().getVirtualScreenDoor().updateIL(release); - stand.getPsd().setInterlockRelease(release); - if (release) { - this.reopenSignal(simulation, stand); - } - } -} +//package club.joylink.rtss.simulation.cbtc.CI.service; +// +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice; +//import club.joylink.rtss.simulation.cbtc.communication.vo.PsdSwitch; +//import club.joylink.rtss.simulation.cbtc.data.map.*; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; +//import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.context.ApplicationContext; +//import org.springframework.stereotype.Component; +// +//import java.util.Objects; +// +///** +// * 屏蔽门服务 +// */ +//@Component +//@Slf4j +//public class StandService { +// +// @Autowired +// private ApplicationContext applicationContext; +// +// @Autowired +// private SignalService signalService; +// +// @Autowired +// private RouteService routeService; +// +// /** +// * 控制室外屏蔽门开关 +// */ +// public void controlVrPSD(Simulation simulation, VirtualRealityScreenDoor vrPsd, boolean open) { +// if ((open && (vrPsd.isSettingOpen() || vrPsd.isOpen2End())) || +// (!open && (vrPsd.isSettingClose() || vrPsd.isLockAndClose()))) { +//// log.debug(String.format("屏蔽门[%s(%s)]已经在对应状态,不需要再控制", vrPsd.getName(), vrPsd.getCode())); +// return; +// } +// vrPsd.startSetting(open); +// ControllableDevice ctrlMsg = new PsdSwitch(vrPsd, open); +// SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); +// this.applicationContext.publishEvent(event); +// } +// +// /** +// * 打开屏蔽门 +// * +// * @param simulation +// * @param psd +// */ +// public void openScreenDoor(Simulation simulation, PSD psd) { +// VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor(); +// if (vrPsd.isPslControl()) { +// return; +// } +// this.controlVrPSD(simulation, vrPsd, true); +// } +// +// /** +// * 关闭屏蔽门 +// * +// * @param simulation +// * @param psd +// */ +// public void closeScreenDoor(Simulation simulation, PSD psd) { +// VirtualRealityScreenDoor vrPsd = psd.getVirtualScreenDoor(); +// if (vrPsd.isPslControl()) { +// return; +// } +// this.controlVrPSD(simulation, vrPsd, false); +// } +// +// /** +// * 设置扣车 +// * +// * @param simulation +// * @param stand +// * @param center +// */ +// public void holdTrain(Simulation simulation, Stand stand, boolean center) { +// if (center) { +// stand.setCenterHoldTrain(true); +// } else { +// stand.setStationHoldTrain(true); +// } +// // 关闭出站信号机 +// Signal signal = stand.getSection().getSignalOf(stand.isRight()); +// if (Objects.nonNull(signal)) { +// MapConfig config = simulation.getRepository().getConfig(); +// if (config.isStandHoldCloseLogicLight()/* || !signal.isLogicLight()*/) { +// this.signalService.close(simulation, signal); +// } +// } +// } +// +// /**系统扣车*/ +// public void sysHoldTrain(Simulation simulation, Stand stand) { +// stand.setSysHoldTrain(true); +// // 关闭出站信号机 +// Signal signal = stand.getSection().getSignalOf(stand.isRight()); +// if (Objects.nonNull(signal)) { +// MapConfig config = simulation.getRepository().getConfig(); +// if (config.isStandHoldCloseLogicLight() || !signal.isLogicLight()) { +// this.signalService.close(simulation, signal); +// } +// } +// } +// +// public void cancelSysHoldTrain(Simulation simulation, Stand stand) { +// stand.setSysHoldTrain(false); +// // 如果所有扣车都取消,开放出站信号机 +// if (!stand.isHoldTrain()) { +// this.reopenSignal(simulation, stand); +// } +// } +// +// public void ibpHoldTrain(Simulation simulation, Stand stand) { +// stand.setIbpHoldTrain(true); +// // 关闭出站信号机 +// Signal signal = stand.getSection().getSignalOf(stand.isRight()); +// if (Objects.nonNull(signal)) { +// MapConfig config = simulation.getRepository().getConfig(); +// if (config.isStandHoldCloseLogicLight() || !signal.isLogicLight()) { +// this.signalService.close(simulation, signal); +// } +// } +// } +// +// public void cancelIbpHoldTrain(Simulation simulation, Stand stand) { +// stand.setIbpHoldTrain(false); +// // 如果所有扣车都取消,开放出站信号机 +// if (!stand.isHoldTrain()) { +// this.reopenSignal(simulation, stand); +// } +// } +// +// /** +// * 取消扣车 +// * +// * @param simulation +// * @param stand +// * @param center +// */ +// public void cancelHoldTrain(Simulation simulation, Stand stand, boolean center) { +// if (center) { +// stand.setCenterHoldTrain(false); +// } else { +// stand.setStationHoldTrain(false); +// } +// // 如果所有扣车都取消,开放出站信号机 +// if (!stand.isHoldTrain()) { +// this.reopenSignal(simulation, stand); +// } +// } +// +// public void cancelAllHoldTrain(Simulation simulation, Stand stand) { +// stand.setCenterHoldTrain(false); +// stand.setStationHoldTrain(false); +// this.reopenSignal(simulation, stand); +// } +// +// private void reopenSignal(Simulation simulation, Stand stand) { +// Signal signal = stand.getSection().getSignalOf(stand.isRight()); +// if (Objects.nonNull(signal) && !signal.isMainAspect()) { +// Route lockedRoute = signal.getLockedRoute(); +// if (Objects.nonNull(lockedRoute) && this.routeService.isInterlocked(lockedRoute)) { // 锁闭进路存在,开信号机 +// this.routeService.routeOpen(simulation, lockedRoute); +// } +// } +// } +// +// /** +// * 设置或取消互锁解除 +// * @param release 是否是设置 +// */ +// public void setOrCancelInterlockRelease(Simulation simulation, Stand stand, boolean release) { +// stand.getPsd().getVirtualScreenDoor().updateIL(release); +// stand.getPsd().setInterlockRelease(release); +// if (release) { +// this.reopenSignal(simulation, stand); +// } +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SwitchService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SwitchService.java index 8ecd0b884..6f5cb2aa4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SwitchService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/SwitchService.java @@ -1,264 +1,263 @@ -package club.joylink.rtss.simulation.cbtc.CI.service; - -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice; -import club.joylink.rtss.simulation.cbtc.communication.vo.SwitchTurn; -import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; -import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; -import club.joylink.rtss.simulation.cbtc.data.map.*; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; -import club.joylink.rtss.simulation.cbtc.event.RouteModeChangeEvent; -import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.context.event.EventListener; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.List; -import java.util.Objects; -import java.util.Random; -import java.util.stream.Collectors; - -/** - * 道岔服务 - */ -@Component -@Slf4j -public class SwitchService { - - @Autowired - private ApplicationContext applicationContext; - - @Autowired - private SignalService signalService; - - @Autowired - private RouteService routeService; - - @Autowired - private SectionService sectionService; - - /** - * 控制室外道岔转动(道岔转动指令下达) - * @param simulation - * @param aSwitch - * @param toNormal - */ - public void controlSwitch(Simulation simulation, Switch aSwitch, boolean toNormal) { - if (simulation.getRepository().getConfig().isSwitchTurnOperationCanRecoverSplitFault()) { - if (new Random().nextInt(3) == 0) { - Switch.SwitchFault.SPLIT.fix(aSwitch); - Switch.SwitchFault.NORMAL_SPLIT.fix(aSwitch); - Switch.SwitchFault.REVERSE_SPLIT.fix(aSwitch); - } - } - VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); - if ((virtualSwitch.isNormal() && toNormal) || - (virtualSwitch.isReverse() && !toNormal)) { - log.debug(String.format("道岔[%s]已经在指定位置[%s],无需转动", aSwitch.debugStr(), virtualSwitch.isNormal()?"N":"R")); - return; - } - if (virtualSwitch.isSettingTo(toNormal)) { - return; - } - // 向虚拟室外设备发送转换指令 - virtualSwitch.startSetting(toNormal); - ControllableDevice ctrlMsg = new SwitchTurn(virtualSwitch, toNormal); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); - } - - /** - * 道岔定操 - * @param simulation - * @param aSwitch - */ - public boolean turn2NormalPosition(Simulation simulation, Switch aSwitch) { - if(aSwitch.isLocked() || aSwitch.isSectionOccupied()) { - return false; - } - this.controlSwitch(simulation, aSwitch, true); - return true; - } - - /** - * 道岔反操 - * @param simulation - * @param aSwitch - * @return - */ - public boolean turn2ReversePosition(Simulation simulation, Switch aSwitch) { - if(aSwitch.isLocked() || aSwitch.isSectionOccupied()) { - return false; - } - this.controlSwitch(simulation, aSwitch, false); - return true; - } - - /** - * 道岔单锁 - * @param aSwitch - */ - public void singleLock(Switch aSwitch) { - if (!aSwitch.isSingleLock()) { - aSwitch.setSingleLock(true); - } - } - - /** - * 道岔单解 - * @param aSwitch - */ - public void singleUnlock(Switch aSwitch) { - if (aSwitch.isSingleLock()) { - aSwitch.setSingleLock(false); - } - } - - /** - * 封锁(封锁后,包含道岔的进路不能排列) - * @param aSwitch - */ - public void blockade(Switch aSwitch) { - if(!aSwitch.isBlockade()) { - aSwitch.setBlockade(true); - aSwitch.getA().setBlockade(true); - aSwitch.getB().setBlockade(true); - aSwitch.getC().setBlockade(true); - } - aSwitch.setInit(false); - } - - /** - * 解封 - * @param aSwitch - */ - public void unblock(Switch aSwitch) { - if(aSwitch.isBlockade()) { - aSwitch.setBlockade(false); - aSwitch.getA().setBlockade(false); - aSwitch.getB().setBlockade(false); - aSwitch.getC().setBlockade(false); - } - } - - /** - * 道岔区段故障解锁 - * @param simulation - * @param aSwitch - * @param route - */ - public void switchFaultUnlock(Simulation simulation, Switch aSwitch, Route route) { - if (route != null) { - if (route.isOpen()) { - signalService.close(simulation, route.getStart()); - } - if (routeService.isApproachLock(simulation.getRepository(), route) || aSwitch.isOverlapLock()) { - // 延时解锁 - aSwitch.setDelayTime(route.getDelayReleaseTime() * 1000); - aSwitch.getAllSections().forEach(section -> { - if (section.isLocked()) - sectionService.sectionFaultUnlock(simulation, section, route); - }); - return; - } else { - route.setLock(false); - Signal start = route.getStart(); - if (start.getLockedRoute() == route) { - start.setLockedRoute(null); - } - } - } - this.faultUnlock(aSwitch, route); - } - - public void faultUnlock(Switch aSwitch, Route route) { - aSwitch.faultUnlock(); - aSwitch.sectionFaultUnlock(); - if (route != null) { - route.unlockRouteFlsOfSwitch(aSwitch); //进路中该道岔对应的侧防解除锁闭 - RouteOverlap overlap = route.getOverlap(); - if (overlap != null) { - for (SectionPath sectionPath : overlap.getPathList()) { - overlap.unlockFlsOfSwitch(sectionPath.getFlsList(), aSwitch); //延续保护中该道岔的侧防解除锁闭 - } - } - } - } - - public void delayUnlock(Simulation simulation, Switch aSwitch) { - int remainTime = aSwitch.getDelayTime(); - if (remainTime > 0) { - remainTime -= SimulationConstants.CI_LOOP_RATE; - if (remainTime <= 0) { - List routeList = simulation.getRepository().queryAllLockedRoute(); - Route lockedRoute = null; - if (aSwitch.isRouteLock()) { - lockedRoute = aSwitch.getRoute(); - } else { - for (Route route : routeList) { - if (route.overlapContainSwitch(aSwitch)) { - lockedRoute = route; - break; - } - } - } - if (Objects.nonNull(lockedRoute)) { - lockedRoute.setLock(false); - Signal start = lockedRoute.getStart(); - if (start.getLockedRoute() == lockedRoute) { - start.setLockedRoute(null); - } - } - this.faultUnlock(aSwitch, lockedRoute); - aSwitch.setDelayTime(0); - } else { - aSwitch.setDelayTime(remainTime); - } - } - } - - @EventListener - public void handle(RouteModeChangeEvent event) { - this.switchStatusUpdate(event.getSimulation(), event.getRoutes()); - } - - /** - * 道岔的封锁失效状态更新 - */ - private void switchStatusUpdate(Simulation simulation, List routes) { - if (!simulation.getRepository().getConfig().isBlockadeCommandOnlyValidInStandbyMode()) { - return; - } - if (!CollectionUtils.isEmpty(routes)) { - if (!routes.get(0).isCbtcMode()) { //进路的状态被设为非cbtc - routes.forEach(route -> { - route.getSwitchList().forEach(switchElement -> { - Switch aSwitch = switchElement.getASwitch(); - if (aSwitch.isBlockade()) { - aSwitch.setBlockadeInvalid(false); - } - }); - }); - } else { - List switches = routes.stream() - .flatMap(route -> route.getSwitchList() - .stream() - .map(SwitchElement::getASwitch) - .filter(aSwitch -> aSwitch.isBlockade() && !aSwitch.isBlockadeInvalid())) - .collect(Collectors.toList()); //进路下所有处于封锁且封锁有效状态的道岔 - for (Route route : simulation.getRepository().getRouteList()) { - if (!route.isCbtcMode()) { - switches.removeIf(route::isRouteSwitch); - if (switches.isEmpty()) { - break; - } - } - } - switches.forEach(aSwitch -> aSwitch.setBlockadeInvalid(true)); - } - } - } -} +//package club.joylink.rtss.simulation.cbtc.CI.service; +// +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice; +//import club.joylink.rtss.simulation.cbtc.communication.vo.SwitchTurn; +//import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; +//import club.joylink.rtss.simulation.cbtc.data.map.*; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +//import club.joylink.rtss.simulation.cbtc.event.RouteModeChangeEvent; +//import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.context.ApplicationContext; +//import org.springframework.context.event.EventListener; +//import org.springframework.stereotype.Component; +//import org.springframework.util.CollectionUtils; +// +//import java.util.List; +//import java.util.Objects; +//import java.util.Random; +//import java.util.stream.Collectors; +// +///** +// * 道岔服务 +// */ +//@Component +//@Slf4j +//public class SwitchService { +// +// @Autowired +// private ApplicationContext applicationContext; +// +// @Autowired +// private SignalService signalService; +// +// @Autowired +// private RouteService routeService; +// +// @Autowired +// private SectionService sectionService; +// +// /** +// * 控制室外道岔转动(道岔转动指令下达) +// * @param simulation +// * @param aSwitch +// * @param toNormal +// */ +// public void controlSwitch(Simulation simulation, Switch aSwitch, boolean toNormal) { +// if (simulation.getRepository().getConfig().isSwitchTurnOperationCanRecoverSplitFault()) { +// if (new Random().nextInt(3) == 0) { +// Switch.SwitchFault.SPLIT.fix(aSwitch); +// Switch.SwitchFault.NORMAL_SPLIT.fix(aSwitch); +// Switch.SwitchFault.REVERSE_SPLIT.fix(aSwitch); +// } +// } +// VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); +// if ((virtualSwitch.isNormal() && toNormal) || +// (virtualSwitch.isReverse() && !toNormal)) { +// log.debug(String.format("道岔[%s]已经在指定位置[%s],无需转动", aSwitch.debugStr(), virtualSwitch.isNormal()?"N":"R")); +// return; +// } +// if (virtualSwitch.isSettingTo(toNormal)) { +// return; +// } +// // 向虚拟室外设备发送转换指令 +// virtualSwitch.startSetting(toNormal); +// ControllableDevice ctrlMsg = new SwitchTurn(virtualSwitch, toNormal); +// SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); +// this.applicationContext.publishEvent(event); +// } +// +// /** +// * 道岔定操 +// * @param simulation +// * @param aSwitch +// */ +// public boolean turn2NormalPosition(Simulation simulation, Switch aSwitch) { +// if(aSwitch.isLocked() || aSwitch.isSectionOccupied()) { +// return false; +// } +// this.controlSwitch(simulation, aSwitch, true); +// return true; +// } +// +// /** +// * 道岔反操 +// * @param simulation +// * @param aSwitch +// * @return +// */ +// public boolean turn2ReversePosition(Simulation simulation, Switch aSwitch) { +// if(aSwitch.isLocked() || aSwitch.isSectionOccupied()) { +// return false; +// } +// this.controlSwitch(simulation, aSwitch, false); +// return true; +// } +// +// /** +// * 道岔单锁 +// * @param aSwitch +// */ +// public void singleLock(Switch aSwitch) { +// if (!aSwitch.isSingleLock()) { +// aSwitch.setSingleLock(true); +// } +// } +// +// /** +// * 道岔单解 +// * @param aSwitch +// */ +// public void singleUnlock(Switch aSwitch) { +// if (aSwitch.isSingleLock()) { +// aSwitch.setSingleLock(false); +// } +// } +// +// /** +// * 封锁(封锁后,包含道岔的进路不能排列) +// * @param aSwitch +// */ +// public void blockade(Switch aSwitch) { +// if(!aSwitch.isBlockade()) { +// aSwitch.setBlockade(true); +// aSwitch.getA().setBlockade(true); +// aSwitch.getB().setBlockade(true); +// aSwitch.getC().setBlockade(true); +// } +// aSwitch.setInit(false); +// } +// +// /** +// * 解封 +// * @param aSwitch +// */ +// public void unblock(Switch aSwitch) { +// if(aSwitch.isBlockade()) { +// aSwitch.setBlockade(false); +// aSwitch.getA().setBlockade(false); +// aSwitch.getB().setBlockade(false); +// aSwitch.getC().setBlockade(false); +// } +// } +// +// /** +// * 道岔区段故障解锁 +// * @param simulation +// * @param aSwitch +// * @param route +// */ +// public void switchFaultUnlock(Simulation simulation, Switch aSwitch, Route route) { +// if (route != null) { +// if (route.isOpenMain()) { +// signalService.close(simulation, route.getStart()); +// } +// if (routeService.isApproachLock(simulation.getRepository(), route) || aSwitch.isOverlapLock()) { +// // 延时解锁 +// aSwitch.setDelayTime(route.getDelayReleaseTime() * 1000); +// aSwitch.getAllSections().forEach(section -> { +// if (section.isLocked()) +// sectionService.sectionFaultUnlock(simulation, section, route); +// }); +// return; +// } else { +// route.setLock(false); +// Signal start = route.getStart(); +// if (start.getLockedRoute() == route) { +// start.setLockedRoute(null); +// } +// } +// } +// this.faultUnlock(aSwitch, route); +// } +// +// public void faultUnlock(Switch aSwitch, Route route) { +// aSwitch.faultUnlock(); +// aSwitch.sectionFaultUnlock(); +// if (route != null) { +// route.unlockRouteFlsOfSwitch(aSwitch); //进路中该道岔对应的侧防解除锁闭 +// RouteOverlap overlap = route.getOverlap(); +// if (overlap != null) { +// for (SectionPath sectionPath : overlap.getPathList()) { +// overlap.unlockFlsOfSwitch(sectionPath.getFlsList(), aSwitch); //延续保护中该道岔的侧防解除锁闭 +// } +// } +// } +// } +// +// public void delayUnlock(Simulation simulation, Switch aSwitch) { +// int remainTime = aSwitch.getDelayTime(); +// if (remainTime > 0) { +// remainTime -= SimulationConstants.CI_LOOP_RATE; +// if (remainTime <= 0) { +// List routeList = simulation.getRepository().queryAllLockedRoute(); +// Route lockedRoute = null; +// if (aSwitch.isRouteLock()) { +// lockedRoute = aSwitch.getRoute(); +// } else { +// for (Route route : routeList) { +// if (route.overlapContainSwitch(aSwitch)) { +// lockedRoute = route; +// break; +// } +// } +// } +// if (Objects.nonNull(lockedRoute)) { +// lockedRoute.setLock(false); +// Signal start = lockedRoute.getStart(); +// if (start.getLockedRoute() == lockedRoute) { +// start.setLockedRoute(null); +// } +// } +// this.faultUnlock(aSwitch, lockedRoute); +// aSwitch.setDelayTime(0); +// } else { +// aSwitch.setDelayTime(remainTime); +// } +// } +// } +// +// @EventListener +// public void handle(RouteModeChangeEvent event) { +// this.switchStatusUpdate(event.getSimulation(), event.getRoutes()); +// } +// +// /** +// * 道岔的封锁失效状态更新 +// */ +// private void switchStatusUpdate(Simulation simulation, List routes) { +// if (!simulation.getRepository().getConfig().isBlockadeCommandOnlyValidInStandbyMode()) { +// return; +// } +// if (!CollectionUtils.isEmpty(routes)) { +// if (!routes.get(0).isCbtcMode()) { //进路的状态被设为非cbtc +// routes.forEach(route -> { +// route.getSwitchList().forEach(switchElement -> { +// Switch aSwitch = switchElement.getASwitch(); +// if (aSwitch.isBlockade()) { +// aSwitch.setBlockadeInvalid(false); +// } +// }); +// }); +// } else { +// List switches = routes.stream() +// .flatMap(route -> route.getSwitchList() +// .stream() +// .map(SwitchElement::getASwitch) +// .filter(aSwitch -> aSwitch.isBlockade() && !aSwitch.isBlockadeInvalid())) +// .collect(Collectors.toList()); //进路下所有处于封锁且封锁有效状态的道岔 +// for (Route route : simulation.getRepository().getRouteList()) { +// if (!route.isCbtcMode()) { +// switches.removeIf(route::isRouteSwitch); +// if (switches.isEmpty()) { +// break; +// } +// } +// } +// switches.forEach(aSwitch -> aSwitch.setBlockadeInvalid(true)); +// } +// } +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/VrPsdService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/VrPsdService.java new file mode 100644 index 000000000..ebfc92d88 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/VrPsdService.java @@ -0,0 +1,47 @@ +package club.joylink.rtss.simulation.cbtc.CI.service; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +@Slf4j +public class VrPsdService { + @Autowired + private VirtualRealityDeviceService virtualRealityDeviceService; + + /** + * 控制室外屏蔽门开关 + */ + public void controlVrPSD(Simulation simulation, VirtualRealityScreenDoor vrPsd, boolean open, CommandSource source) { + if ((open && (vrPsd.isSettingOpen() || vrPsd.isOpen2End())) || + (!open && (vrPsd.isSettingClose() || vrPsd.isLockAndClose()))) { + return; + } + switch (source) { + case SIG: { + if (vrPsd.isPslControl() || vrPsd.isIbpControl()) + return; + break; + } + case PSL: + break; + case IBP: { + if (vrPsd.isPslControl()) + return; + break; + } + } + this.virtualRealityDeviceService.control(simulation, vrPsd, + open ? VirtualRealityScreenDoor.Operation.K : VirtualRealityScreenDoor.Operation.G); + } + + public enum CommandSource{ + SIG, + PSL, + IBP + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/VrSignalControlService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/VrSignalControlService.java index 24156d827..7af5bf51a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/VrSignalControlService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/service/VrSignalControlService.java @@ -1,100 +1,100 @@ -package club.joylink.rtss.simulation.cbtc.CI.service; - -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice; -import club.joylink.rtss.simulation.cbtc.communication.vo.SignalLight; -import club.joylink.rtss.simulation.cbtc.data.map.Signal; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; -import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.stereotype.Component; - -import java.util.Objects; - -/** - * 信号机服务 - */ -@Component -@Slf4j -public class VrSignalControlService { - - @Autowired - private ApplicationContext applicationContext; - - /** - * 控制室外信号机灭灯 - * @param simulation - * @param vrSignal - */ - public void close(Simulation simulation, VirtualRealitySignal vrSignal) { - if (!vrSignal.isBlack()) { - this.controlRealSignal(simulation, vrSignal, false, false, false); - } - } - - /** - * 控制室外信号机点绿灯 - * @param simulation - * @param vrSignal - */ - public void openGreenSignal(Simulation simulation, VirtualRealitySignal vrSignal) { - controlRealSignal(simulation, vrSignal, true, false, false); - } - - /** - * 控制室外信号机点黄灯 - * @param simulation - * @param vrSignal - */ - public void openYellowSignal(Simulation simulation, VirtualRealitySignal vrSignal) { - controlRealSignal(simulation, vrSignal, false, true, false); - } - - /** - * 控制室外信号机点红灯 - * @param simulation - * @param vrSignal - */ - public void openRedSignal(Simulation simulation, VirtualRealitySignal vrSignal) { - controlRealSignal(simulation, vrSignal, false, false, true); - } - - /** - * 控制室外信号机点黄红灯 - * @param simulation - * @param vrSignal - */ - public void openGuideSignal(Simulation simulation, VirtualRealitySignal vrSignal) { - this.controlRealSignal(simulation, vrSignal, false, true, true); - } - - /** - * 控制室外信号灯显示 - * @param simulation - * @param vrSignal - * @param greenOpen - * @param yellowOpen - * @param redOpen - */ - private void controlRealSignal(Simulation simulation, VirtualRealitySignal vrSignal, - boolean greenOpen, boolean yellowOpen, boolean redOpen) { - // 根据点灯类型,和要开放信号,下达信号机控制指令 - if(Objects.isNull(vrSignal)){ - return; - } - if (!vrSignal.isSame(greenOpen, yellowOpen, redOpen)) { - Signal signal = simulation.getRepository().getByCode(vrSignal.getCode(), Signal.class); - if (signal.isFault()) { - vrSignal.apply(false, false, true); - } else { - vrSignal.apply(greenOpen, yellowOpen, redOpen); - } - ControllableDevice ctrlMsg = new SignalLight(vrSignal); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); - } - } - -} +//package club.joylink.rtss.simulation.cbtc.CI.service; +// +//import club.joylink.rtss.simulation.cbtc.Simulation; +//import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice; +//import club.joylink.rtss.simulation.cbtc.communication.vo.SignalLight; +//import club.joylink.rtss.simulation.cbtc.data.map.Signal; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; +//import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent; +//import lombok.extern.slf4j.Slf4j; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.context.ApplicationContext; +//import org.springframework.stereotype.Component; +// +//import java.util.Objects; +// +///** +// * 信号机服务 +// */ +//@Component +//@Slf4j +//public class VrSignalControlService { +// +// @Autowired +// private ApplicationContext applicationContext; +// +// /** +// * 控制室外信号机灭灯 +// * @param simulation +// * @param vrSignal +// */ +// public void close(Simulation simulation, VirtualRealitySignal vrSignal) { +// if (!vrSignal.isBlack()) { +// this.controlRealSignal(simulation, vrSignal, false, false, false); +// } +// } +// +// /** +// * 控制室外信号机点绿灯 +// * @param simulation +// * @param vrSignal +// */ +// public void openGreenSignal(Simulation simulation, VirtualRealitySignal vrSignal) { +// controlRealSignal(simulation, vrSignal, true, false, false); +// } +// +// /** +// * 控制室外信号机点黄灯 +// * @param simulation +// * @param vrSignal +// */ +// public void openYellowSignal(Simulation simulation, VirtualRealitySignal vrSignal) { +// controlRealSignal(simulation, vrSignal, false, true, false); +// } +// +// /** +// * 控制室外信号机点红灯 +// * @param simulation +// * @param vrSignal +// */ +// public void openRedSignal(Simulation simulation, VirtualRealitySignal vrSignal) { +// controlRealSignal(simulation, vrSignal, false, false, true); +// } +// +// /** +// * 控制室外信号机点黄红灯 +// * @param simulation +// * @param vrSignal +// */ +// public void openGuideSignal(Simulation simulation, VirtualRealitySignal vrSignal) { +// this.controlRealSignal(simulation, vrSignal, false, true, true); +// } +// +// /** +// * 控制室外信号灯显示 +// * @param simulation +// * @param vrSignal +// * @param greenOpen +// * @param yellowOpen +// * @param redOpen +// */ +// private void controlRealSignal(Simulation simulation, VirtualRealitySignal vrSignal, +// boolean greenOpen, boolean yellowOpen, boolean redOpen) { +// // 根据点灯类型,和要开放信号,下达信号机控制指令 +// if(Objects.isNull(vrSignal)){ +// return; +// } +// if (!vrSignal.isSame(greenOpen, yellowOpen, redOpen)) { +// Signal signal = simulation.getRepository().getByCode(vrSignal.getCode(), Signal.class); +// if (signal.isFault()) { +// vrSignal.apply(false, false, true); +// } else { +// vrSignal.apply(greenOpen, yellowOpen, redOpen); +// } +// ControllableDevice ctrlMsg = new SignalLight(vrSignal); +// SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); +// this.applicationContext.publishEvent(event); +// } +// } +// +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/DeviceStatusServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/DeviceStatusServiceImpl.java index 9998d7ffc..f37ec3adb 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/DeviceStatusServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/DeviceStatusServiceImpl.java @@ -45,7 +45,8 @@ public class DeviceStatusServiceImpl implements DeviceStatusService { for (Signal signal : signalList) { if (!signal.isCtc()) { VirtualRealitySignal vrSignal = repository.getVRByCode(signal.getCode(), VirtualRealitySignal.class); - vrSignal.apply(false, false, true); + vrSignal.control(vrSignal.getModel().getDefaultAspect()); + vrSignal.finish(); } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java index 88433c80e..b43b49420 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationService.java @@ -19,7 +19,7 @@ import club.joylink.rtss.vo.client.runplan.PlanTripNumberVO; import club.joylink.rtss.vo.client.runplan.RunPlanEChartsDataVO; import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.simulationv1.*; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import club.joylink.rtss.vo.map.MapVO; import java.time.LocalDateTime; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java index fc8f4656d..fac88bdba 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/GroupSimulationServiceImpl.java @@ -62,7 +62,7 @@ import club.joylink.rtss.vo.client.script.ScriptVO; import club.joylink.rtss.vo.client.simulationv1.*; import club.joylink.rtss.vo.client.training.TrainingNewVO; import club.joylink.rtss.vo.client.userPermission.UserPermissionVO; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.websocket.StompMessageService; import lombok.extern.slf4j.Slf4j; @@ -881,7 +881,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService { List realDeviceList = simulation.getRealDeviceList(); if (!CollectionUtils.isEmpty(realDeviceList)) { Set displayDeviceTypes = - new HashSet<>(List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, ProjectDeviceType.PLC_GATEWAY)); + new HashSet<>(List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, ProjectDeviceType.PLC_GATEWAY, ProjectDeviceType.IBP)); realDeviceList = realDeviceList .stream().filter(device -> displayDeviceTypes.contains(device.getDeviceType())).collect(Collectors.toList()); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java index c66dff905..efe75c1f8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ProjectJointSimulationServiceImpl.java @@ -14,6 +14,8 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDevice import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1IbpConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PscConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PslConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorIbpConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorPsdConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig; import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent; import club.joylink.rtss.simulation.cbtc.member.MemberManager; @@ -135,6 +137,12 @@ public class ProjectJointSimulationServiceImpl implements ProjectJointSimulation return ((XtyPsdConfig) config).getConfig().getPsdCode(); } } + case RICHOR_JOINT: { + switch (config.getDeviceType()) { + case IBP: + return ((RichorIbpConfig) config).getConfigVO().getStationCode(); + } + } } return null; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java index 5f2053d09..14b256745 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java @@ -11,6 +11,7 @@ import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.conversation.Conversation; import club.joylink.rtss.simulation.cbtc.conversation.ConversationMember; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.vo.OldSimulationInfoVO; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.DeviceQueryFuture; @@ -24,6 +25,7 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationUser; import club.joylink.rtss.simulation.cbtc.script.ScriptBO; +import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; import club.joylink.rtss.simulation.vo.SimulationInfoVO; import club.joylink.rtss.vo.AccountVO; import club.joylink.rtss.vo.client.fault.FaultRuleVO; @@ -68,6 +70,8 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation(); this.faultRules = new HashSet<>(); this.repository = new SimulationDataRepository(); + this.iscsRepository = new SimulationIscsDataRepository(); this.idGenerator = new SimulationIdGenerator(); } @@ -538,6 +543,7 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation member.setCommand(null)); this.planRunning = false; if (!CollectionUtils.isEmpty(simulationConversationMap)) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java index e4b8fc66f..1855bc25f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationLifeCycleServiceImpl.java @@ -6,7 +6,7 @@ import club.joylink.rtss.services.psl.IVirtualRealityPslService; import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.cbtc.ATS.ATSLogicLoop; import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher; -import club.joylink.rtss.simulation.cbtc.CI.CILogicLoop; +import club.joylink.rtss.simulation.cbtc.CI.CiLogic; import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams; import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; import club.joylink.rtss.simulation.cbtc.command.VoiceCommandBO; @@ -25,6 +25,7 @@ import club.joylink.rtss.simulation.cbtc.member.MemberManager; import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop; import club.joylink.rtss.simulation.cbtc.onboard.TrainTargetUpdateService; import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop; +import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; import lombok.extern.slf4j.Slf4j; @@ -60,9 +61,8 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic @Autowired private VRTrainRunningService vrTrainRunningService; - @Autowired - private CILogicLoop ciLogicLoop; + private CiLogic ciLogic; @Autowired private VRDeviceLogicLoop vrDeviceLogicLoop; @@ -105,6 +105,8 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic Simulation simulation = SimulationBuilder.build(group, params); // 缓存 simulationManager.save(simulation); + // TODO: 2021/9/10 暂时放在这里 + simulation.addMessagePublisher(new IscsStatusPublisher(simulation)); // 初始化设备状态 this.deviceStatusService.init(simulation); // 初始化成员 @@ -123,7 +125,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic atpLogicLoop.addJobs(simulation); trainTargetUpdateService.addJobs(simulation); vrTrainRunningService.addJobs(simulation); - ciLogicLoop.addJobs(simulation); + this.ciLogic.addJobs(simulation); vrDeviceLogicLoop.addJobs(simulation); // zcLogicLoop.addJobs(simulation); atsMessageCollectAndDispatcher.addJobs(simulation); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java index 38c869e78..943ac7766 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationMainThread.java @@ -1,17 +1,7 @@ package club.joylink.rtss.simulation.cbtc; import club.joylink.rtss.event.OrderPaySuccessEvent; -import club.joylink.rtss.services.IVirtualRealityIbpService; -import club.joylink.rtss.services.completition.ICompetitionPracticalService; -import club.joylink.rtss.simulation.cbtc.ATP.ground.ZCLogicLoop; -import club.joylink.rtss.simulation.cbtc.ATS.ATSLogicLoop; -import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher; import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; -import club.joylink.rtss.simulation.cbtc.CI.CILogicLoop; -import club.joylink.rtss.simulation.cbtc.command.CommandExecuteService; -import club.joylink.rtss.simulation.cbtc.communication.Joylink3DMessageService; -import club.joylink.rtss.simulation.cbtc.competition.CompetitionAndScriptManager; -import club.joylink.rtss.simulation.cbtc.competition.ScriptExecuteService; import club.joylink.rtss.simulation.cbtc.conversation.Conversation; import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage; import club.joylink.rtss.simulation.cbtc.data.plan.RealRun; @@ -22,14 +12,9 @@ import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO; import club.joylink.rtss.simulation.cbtc.data.vo.TrainIsAbout2ArriveVO; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.SimulationRealDeviceConnectManager; -import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop; -import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService; import club.joylink.rtss.simulation.cbtc.event.*; -import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationUser; -import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop; -import club.joylink.rtss.simulation.cbtc.robot.RobotLogicLoop; import club.joylink.rtss.simulation.cbtc.script.ScriptActionBO; import club.joylink.rtss.vo.client.SocketMessageVO; import club.joylink.rtss.vo.client.WebSocketMessageType; @@ -63,66 +48,13 @@ import java.util.Set; @Slf4j public class SimulationMainThread { - @Autowired - private SimulationLifeCycleService simulationLifeCycleService; - @Autowired private GroupSimulationCache groupSimulationCache; - - @Autowired - private ATSLogicLoop atsLogicLoop; - - @Autowired - private ATPLogicLoop atpLogicLoop; - - @Autowired - private VRTrainRunningService vrTrainRunningService; - - @Autowired - private CILogicLoop ciLogicLoop; - - @Autowired - private VRDeviceLogicLoop vrDeviceLogicLoop; - - @Autowired - private ZCLogicLoop zcLogicLoop; - - @Autowired - private ATSMessageCollectAndDispatcher atsMessageCollectAndDispatcher; - @Autowired private StompMessageService stompMessageService; - - @Autowired - private Joylink3DMessageService joylink3DMessageService; - - @Autowired - private ScriptExecuteService scriptExecuteService; - - @Autowired - private ICompetitionPracticalService iCompetitionPracticalService; - - @Autowired - private RobotLogicLoop robotLogicLoop; - - @Autowired - private FaultGenerator faultGenerator; - - @Autowired - private CommandExecuteService commandExecuteService; - @Autowired private SimulationRealDeviceConnectManager simulationRealDeviceConnectManager; - @Autowired - private IVirtualRealityIbpService iVirtualRealityIbpService; - - @Autowired - private CompetitionAndScriptManager competitionAndScriptManager; - - @Autowired - private PowerSupplyService powerSupplyService; - @Scheduled(fixedRate = 1000) public void updatePlcGatewayOnlineStatus() { Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); @@ -130,336 +62,6 @@ public class SimulationMainThread { this.simulationRealDeviceConnectManager.updatePlcGatewayOnlineStatus(simulation); } } -// -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.ATS_LOOP_RATE) -// public void ats() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.ATS, group, simulation)); -// } -// } -// -//// @Async("nsExecutor") -//// @Scheduled(fixedRate = SimulationConstants.TL_LOOP_RATE) -//// public void tl() { -//// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -//// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -//// groupSimulationMap.forEach((group, simulation) -> -//// this.run(SimulationModule.TL, group, simulation)); -//// } -//// } -// -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.ATP_LOOP_RATE) -// public void atp() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.ATP, group, simulation)); -// } -// } -// -// /** -// * 机器人司机驾驶逻辑 -// */ -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.ATO_LOOP_RATE) -// public void driver() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> this.run(SimulationModule.ROBOT, group, simulation)); -// } -// } -//// @Async("nsExecutor") -//// @Scheduled(fixedRate = SimulationConstants.ATO_LOOP_RATE) -//// public void ato() { -//// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -//// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -//// groupSimulationMap.forEach((group, simulation) -> { -//// this.run(SimulationModule.ATO, group, simulation); -//// }); -//// } -// -//// } -// -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.TRAIN_RUNNING_RATE) -// public void tr() { -//// long start = System.currentTimeMillis(); -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.TR, group, simulation)); -//// long end = System.currentTimeMillis(); -//// System.out.println("列车运行耗时: " + (end-start) + "ms"); -// } -// -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.CI_LOOP_RATE) -// public void ci() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.CI, group, simulation)); -// } -// } -// -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.VRD_LOOP_RATE) -// public void vrd() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.VRD, group, simulation)); -// } -// } -// -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.GROUND_ATP_LOOP_RATE) -// public void groundAtp() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.GROUND_ATP, group, simulation)); -// } -// } -// -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.ZC_LOOP_RATE) -// public void zc() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.ZC, group, simulation)); -// } -// } -// -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.TIME_LOOP_RATE) -// public void ts() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.TIME, group, simulation)); -// } -// } -// -// @Async("nsExecutor") -// @Scheduled(fixedRate = SimulationConstants.SYNC_TIME_RATE) -// public void syncTime() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.SYNC_TIME, group, simulation)); -// } -// -// @Scheduled(fixedRate = SimulationConstants.SCRIPT_LOOP_RATE) -// public void scriptRun() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> { -// competitionAndScriptManager.run(simulation); -//// ScriptBO script = simulation.getScript(); -//// if (Objects.nonNull(script) && script.isStarted()) { -//// this.scriptExecuteService.run(simulation); -//// } -// }); -// } -// } -// -// @Scheduled(fixedRate = SimulationConstants.SCRIPT_LOOP_RATE) -// public void competitionMonitor() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// if (!CollectionUtils.isEmpty(groupSimulationMap)) { -// groupSimulationMap.forEach((group, simulation) -> { -// competitionAndScriptManager.monitor(simulation); -// }); -// } -// } -// -// /** -// * 推送仿真状态到客户端 -// */ -// @Scheduled(fixedRate = SimulationConstants.SEND_CLIENT_RATE) -// public void push2Client() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.MESSAGE, group, simulation)); -// } -// -// @Scheduled(fixedRate = SimulationConstants.TRAIN_SPEED_PUSH_RATE) -// public void trainSpeedPush() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.TRAIN_SPEED, group, simulation)); -// } -// -// @Scheduled(fixedRate = SimulationConstants.SEND_CLIENT_RATE) -// public void push3DMessage() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.MESSAGE_3D, group, simulation)); -// } -// -// @Scheduled(fixedRate = SimulationConstants.TRAIN_DRIVE_POSITION_SYNC_RATE) -// public void sync3DDrivePositionInfo() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.DRIVE_POSITION, group, simulation)); -// } -// -// @Scheduled(fixedRate = SimulationConstants.FAULT_GENERATE_RATE) -// public void faultGenerate() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.FAULT, group, simulation)); -// } -// -// @Scheduled(fixedRate = SimulationConstants.COMMAND_EXECUTE_RATE) -// public void commandExecute() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.commandExecuteService.run(simulation)); -// } -// -// @Scheduled(fixedRate = SimulationConstants.TRAIN_POSITION_RATE) -// public void trainPositionSend() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.TRAIN_POSITION_3D, group, simulation)); -// } -// -// @Scheduled(fixedRate = SimulationConstants.IBP_STATUS_COLLECT_RATE) -// public void collectIbpStatus() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.IBP_STATUS, group, simulation)); -// } -// -// @Scheduled(fixedRate = SimulationConstants.POWER_SUPPLY_STATUS_UPDATE_RATE) -// public void powerSupplyStatusUpdate() { -// Map groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap(); -// groupSimulationMap.forEach((group, simulation) -> -// this.run(SimulationModule.CATENARY, group, simulation)); -// } -// -// /** -// * 仿真模块运行 -// * -// * @param module -// * @param group -// * @param simulation -// */ -// private void run(SimulationModule module, String group, Simulation simulation) { -// try { -// if (!simulation.isError() && !simulation.isPause()) { // 判断仿真系统正常运行 -// simulation.runAdd(); -// switch (module) { -// case ATS: { -// this.atsLogicLoop.run(simulation); -// break; -// } -//// case TL: { -//// this.tlLogicLoop.run(simulation); -//// break; -//// } -// case ATP: { -// this.atpLogicLoop.run(simulation); -// break; -// } -//// case ATO: { -//// this.atoLogicLoop.run(simulation); -//// break; -//// } -// case TR: { -// this.vrTrainRunningService.trainRunning(simulation); -// break; -// } -// case TL: -// break; -// case CI: { -// this.ciLogicLoop.run(simulation); -// break; -// } -// case RSC: -// break; -// case VRD: { -// this.vrDeviceLogicLoop.run(simulation); -// break; -// } -// case GROUND_ATP: { -//// this.atpSectionService.run(simulation); -// break; -// } -// case ZC: { -// this.zcLogicLoop.run(simulation); -// break; -// } -// case TIME: { -// simulation.updateSystemTime(module.getRateMs()); -// break; -// } -// case SYNC_TIME: { -// this.atsMessageCollectAndDispatcher.syncTime(simulation); -// break; -// } -// case MESSAGE: { -// this.atsMessageCollectAndDispatcher.run(simulation); -// break; -// } -// case TRAIN_SPEED: { -// this.joylink3DMessageService.collectAndSendTrainSpeedMessage(simulation); -// break; -// } -// case MESSAGE_3D: { -// this.joylink3DMessageService.collectAndSendTrainHmiDisplayMessage(simulation); -// this.joylink3DMessageService.tdtStatusCollectAndSend(simulation); -// break; -// } -// case TRAIN_POSITION_3D: { -// this.joylink3DMessageService.collectAndSendTrainPositionMessage(simulation); -// break; -// } -// case DRIVE_POSITION: { -// this.joylink3DMessageService.syncTrainDrivePosition(simulation); -// break; -// } -//// case SCRIPT: { -//// System.out.println("Script_Loop_Rate"); -//// -//// -//// break; -//// } -// case FAULT: { -// this.faultGenerator.simulationFaultGenerate(simulation); -// break; -// } -// case IBP_STATUS: { -// this.iVirtualRealityIbpService.collectAndDispatcher(simulation); -// break; -// } -// case CATENARY: { -// powerSupplyService.run(simulation); -// break; -// } -// case ROBOT: { -// robotLogicLoop.run(simulation); -// break; -// } -// default: { -// throw new SimulationException(SimulationExceptionType.System_Fault, -// String.format("仿真模块[%s]不存在", module)); -// } -// } -// simulation.runOver(); -// } -// } catch (Exception e) { -// simulation.runOver(); -// log.error(String.format("[%s]的仿真主线程出现异常:%s", group, e.getMessage()), e); -// this.simulationLifeCycleService.error(simulation, e); -// } -// -// } @Async("nsExecutor") @EventListener @@ -623,7 +225,7 @@ public class SimulationMainThread { simulation.getId(), conversation.getId())); SocketMessageVO message = SocketMessageFactory .buildSimulationConversationChatMessage(simulation, conversation, conversationMessage); - if(conversation.hasOtherMemberConnect()){ + if (conversation.hasOtherMemberConnect()) { Set userIds = simulation.getSimulationUserIds(); this.stompMessageService.sendToUser(userIds, message); return; @@ -721,7 +323,7 @@ public class SimulationMainThread { @EventListener public void simulationError(SimulationErrorEvent event) { Simulation simulation = event.getSimulation(); - log.info(String.format("仿真[%s]运行异常, 时间 [%s]", simulation.getId(),simulation.getCorrectSystemTime().format(DateTimeFormatter.ofPattern("yyyy-mm-dd hh:mm:ss")))); + log.info(String.format("仿真[%s]运行异常, 时间 [%s]", simulation.getId(), simulation.getCorrectSystemTime().format(DateTimeFormatter.ofPattern("yyyy-mm-dd hh:mm:ss")))); Set users = simulation.getSimulationUserIds(); SocketMessageVO message = SocketMessageFactory.build(WebSocketMessageType.Simulation_Error, simulation.getId(), ""); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java index 96d04c255..67f8febd4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/InterlockBuilder2.java @@ -6,8 +6,11 @@ import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.data.support.RouteUnit; -import club.joylink.rtss.simulation.rt.CIL.bo.CilSwitch; -import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.MapCISwitchVO; +import club.joylink.rtss.vo.map.MapLogicDataNewVO; +import club.joylink.rtss.vo.map.MapRoutingSectionNewVO; +import club.joylink.rtss.vo.map.MapSectionPathVO; +import club.joylink.rtss.vo.map.logic.*; import lombok.extern.slf4j.Slf4j; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -288,7 +291,7 @@ public class InterlockBuilder2 { startSignal.getRouteList().add(route); } Signal endSignal = (Signal) elementMap.get(mapRouteVO.getEndSignalCode()); - if (Objects.isNull(endSignal)) { + if (Objects.isNull(endSignal) && station != null && !station.isDepot()) { errMsgList.add(String.format("进路[%s(%s)]终端信号机未设置或不存在", route.getName(), route.getCode())); } else { route.setDestination(endSignal); @@ -308,7 +311,7 @@ public class InterlockBuilder2 { route.setGuide(mapRouteVO.isGuide()); route.setFlt(mapRouteVO.isFlt()); route.setArs(mapRouteVO.isArc()); - route.setOpenGreen(mapRouteVO.isGreenOpen()); + route.setAspect(mapRouteVO.getAspect()); MapSectionPathVO sectionPathVO = new MapSectionPathVO(route.getStart().isRight(), mapRouteVO.getRouteSectionList(), mapRouteVO.getRouteSwitchList()); List errorList = new ArrayList<>(); SectionPath sectionPath = checkAndBuildSectionPath(sectionPathVO, elementMap, errorList); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java index 2da9f5556..05040f36a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/MapDeviceBuilder.java @@ -2,11 +2,13 @@ package club.joylink.rtss.simulation.cbtc.build; import club.joylink.rtss.constants.BusinessConsts; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.constant.SignalModel; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption; import club.joylink.rtss.simulation.cbtc.data.vr.*; -import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.MapGraphDataNewVO; +import club.joylink.rtss.vo.map.graph.*; import lombok.extern.slf4j.Slf4j; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -89,10 +91,9 @@ public class MapDeviceBuilder { aSwitch.setDeviceStation(deviceStation); } // 创建虚拟真实道岔 - VirtualRealitySwitch virtualRealitySwitch = new VirtualRealitySwitch(aSwitch.getCode(), aSwitch.getName()); + VirtualRealitySwitch virtualRealitySwitch = new VirtualRealitySwitch(aSwitch.getCode(), aSwitch.getName(), switchVO.getTurnTime()); aSwitch.setVirtualSwitch(virtualRealitySwitch); deviceMap.put(virtualRealitySwitch.getCode(), virtualRealitySwitch); - virtualRealitySwitch.setSettingTime(switchVO.getTurnTime()); }); // 区段关系 sectionList.forEach(sectionVO -> { @@ -413,7 +414,10 @@ public class MapDeviceBuilder { } } //站台默认折返策略 - Stand.TurnBackType defaultStrategy = standVO.getDefaultReentryStrategy(); + Stand.TurnBackType defaultStrategy = null; + if (StringUtils.hasText(standVO.getDefaultReentryStrategy())) { + defaultStrategy = Stand.TurnBackType.valueOf(standVO.getDefaultReentryStrategy()); + } if (defaultStrategy == null) { stand.setDefaultTypeStrategy(Stand.TurnBackType.DEFAULT); } else { @@ -549,13 +553,13 @@ public class MapDeviceBuilder { continue; } Map strategyOptionMap = new HashMap<>(); - List optionList = strategyVO.getOptionList(); + List optionList = strategyVO.getOptionList(); if (CollectionUtils.isEmpty(optionList)) { errMsgList.add(String.format("折返策略[%s(%s)]没有选项", strategyVO.getName(), strategyVO.getCode())); } else { Integer defaultStrategyId = strategyVO.getInitId(); - for (MapTurnBackStrategyOptionVO optionVO : optionList) { + for (MapTurnBackStrategyVO.MapTurnBackStrategyOptionVO optionVO : optionList) { StationTurnBackStrategyOption option = strategyOptionMap.get(optionVO.getId()); if (Objects.nonNull(option)) { errMsgList.add(String.format("折返策略[%s(%s)]选项重复,id[%s]", @@ -1072,16 +1076,35 @@ public class MapDeviceBuilder { } signal.setInterlockStation(interlockStation); } + // 信号机型号 + if (StringUtils.hasText(signalVO.getSignalModel())) { + signal.setSignalModel(SignalModel.valueOf(signalVO.getSignalModel())); + } // 信号机类型 if (Objects.isNull(signalVO.getType())) { errMsgList.add(String.format("信号机[%s(%s)]类型未设置", signal.getName(), signal.getCode())); } else { signal.setType(signalVO.getType()); + switch (signalVO.getType()) { + case PROTECTION: + case PASSING: + case ARRIVAL: + case EXIT: + signal.setSignalModel(SignalModel.RGY); + break; + case BLOCKING: + signal.setSignalModel(SignalModel.R); + break; + case SHUNTING: + signal.setSignalModel(SignalModel.BW); + break; + } } signal.setRouteEnd(signalVO.isRouteEnd()); signal.setIgnoreRouteEnd(signalVO.getIgnoreRouteEnd()); signal.setNoRoute(signalVO.isNoRoute()); signal.setCtc(signalVO.isCtc()); + signal.setCtcSetOverlap(signalVO.isCtcSetOverlap()); signal.setCallOn(signalVO.isCallOn()); signal.setTurnBack(signalVO.isTurnBack()); // 关联区段及偏移量 @@ -1121,9 +1144,13 @@ public class MapDeviceBuilder { // 创建虚拟真实信号机 if (!signal.isVirtual()) { // 是真实存在的虚拟机才创建 - VirtualRealitySignal virtualRealitySignal = new VirtualRealitySignal(signal.getCode(), signal.getName()); - signal.setVirtualSignal(virtualRealitySignal); - deviceMap.put(virtualRealitySignal.getCode(), virtualRealitySignal); + if (signal.getSignalModel() == null) { + errMsgList.add(String.format("信号机[%s(%s)]不是虚拟信号机,没有设置信号机型号", signalVO.getName(), signalVO.getCode())); + } else { + VirtualRealitySignal virtualRealitySignal = new VirtualRealitySignal(signal.getCode(), signal.getName(), signal.getSignalModel()); + signal.setVirtualSignal(virtualRealitySignal); + deviceMap.put(virtualRealitySignal.getCode(), virtualRealitySignal); + } } }); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java index 93fe8eabe..2f49c9a10 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/SimulationBuilder.java @@ -10,7 +10,7 @@ import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; -import club.joylink.rtss.vo.map.MapStationParkingTimeVO; +import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.RealLineConfigVO; import lombok.Getter; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/build/UserConfigDataBuilder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/build/UserConfigDataBuilder.java index 8ab0f91ca..6d562693f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/build/UserConfigDataBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/build/UserConfigDataBuilder.java @@ -7,8 +7,8 @@ import club.joylink.rtss.simulation.cbtc.data.map.StationParkTime; import club.joylink.rtss.simulation.cbtc.data.map.StationRunLevel; import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO; import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; -import club.joylink.rtss.vo.map.MapStationParkingTimeVO; -import club.joylink.rtss.vo.map.MapStationRunLevelVO; +import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import club.joylink.rtss.vo.map.MapVO; import org.springframework.util.CollectionUtils; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/command/CommandBO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/command/CommandBO.java index 357a3fb59..f6890c4f7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/command/CommandBO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/command/CommandBO.java @@ -258,7 +258,7 @@ public class CommandBO { String switchCode = (String) command.getParams().get(ParamName.switchCode.name()); Switch aSwitch = simulation.getRepository().getByCode(switchCode, Switch.class); boolean normal = (boolean) command.getParams().get(ParamName.normal.name()); - if (aSwitch.getVirtualSwitch().isNormal() != normal) { + if (aSwitch.getVirtualSwitch().isPosN() != normal) { List steps = command.getStepByType(Step.StepType.OPERATION); return steps.get(0); } else { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java index df141eaaf..98cacc5ee 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/Joylink3DMessageService.java @@ -12,9 +12,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.status.TrainStatus; import club.joylink.rtss.simulation.cbtc.data.vo.TdtStatusVO; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +import club.joylink.rtss.simulation.cbtc.data.vr.ControllableVrDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.event.*; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; @@ -23,7 +21,6 @@ import club.joylink.rtss.vo.client.WebSocketMessageType; import club.joylink.rtss.vo.client.factory.SocketMessageFactory; import club.joylink.rtss.websocket.StompMessageService; import lombok.extern.slf4j.Slf4j; -import org.aspectj.runtime.internal.cflowstack.ThreadStackImpl11; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; @@ -155,24 +152,30 @@ public class Joylink3DMessageService { */ private List collectTrainInitData(VirtualRealityTrain train) { List list = new ArrayList<>(); - boolean door1Open; - if (train.getDoor1().isTurning()) { - door1Open = train.getDoor1().isCommandOpen(); - } else if (train.getDoor1().isOpen()) { - door1Open = true; - } else { - door1Open = false; + if (train.getDoor1().getCommand() != null) { + list.add(new TrainDoorSwitch(train, train.getDoor1())); } - list.add(new TrainDoorSwitch(train, train.getDoor1(), door1Open)); - boolean door2Open; - if (train.getDoor2().isTurning()) { - door2Open = train.getDoor2().isCommandOpen(); - } else if (train.getDoor2().isOpen()) { - door2Open = true; - } else { - door2Open = false; + if (train.getDoor2().getCommand() != null) { + list.add(new TrainDoorSwitch(train, train.getDoor2())); } - list.add(new TrainDoorSwitch(train, train.getDoor2(), door2Open)); +// boolean door1Open; +// if (train.getDoor1().isTurning()) { +// door1Open = train.getDoor1().isCommandOpen(); +// } else if (train.getDoor1().isOpen()) { +// door1Open = true; +// } else { +// door1Open = false; +// } +// list.add(new TrainDoorSwitch(train, train.getDoor1(), door1Open)); +// boolean door2Open; +// if (train.getDoor2().isTurning()) { +// door2Open = train.getDoor2().isCommandOpen(); +// } else if (train.getDoor2().isOpen()) { +// door2Open = true; +// } else { +// door2Open = false; +// } +// list.add(new TrainDoorSwitch(train, train.getDoor2(), door2Open)); list.add(new TrainLoadDestroy(train)); return list; } @@ -218,37 +221,40 @@ public class Joylink3DMessageService { * @return */ private void collectAndSend3DInitDeviceList(Simulation simulation, Collection userList) { - List initDeviceList = new ArrayList<>(); SimulationDataRepository repository = simulation.getRepository(); - // 信号机 - List vrSignalList = repository.getVrListByType(MapElement.DeviceType.SIGNAL, VirtualRealitySignal.class); - vrSignalList.forEach(signal -> initDeviceList.add(new SignalLight(signal))); - // 道岔 - List vrSwitchList = repository.getVrListByType(MapElement.DeviceType.SWITCH, VirtualRealitySwitch.class); - vrSwitchList.forEach(vrSwitch -> { - boolean normal; - if (vrSwitch.isSetting()) { - normal = vrSwitch.isToNormal(); - } else if (vrSwitch.isNormal()) { - normal = true; - } else { - normal = false; - } - initDeviceList.add(new SwitchTurn(vrSwitch, normal)); - }); - // 屏蔽门 - List vrPsdList = repository.getVrListByType(MapElement.DeviceType.PSD, VirtualRealityScreenDoor.class); - vrPsdList.forEach(vrPsd -> { - boolean open; - if (vrPsd.isSetting()) { - open = vrPsd.isCommandOpen(); - } else if (vrPsd.isClose()) { - open = false; - } else { - open = true; - } - initDeviceList.add(new PsdSwitch(vrPsd, open)); - }); + List initDeviceList = repository.getAllControllableVrDevice().stream() + .filter(vrDevice -> vrDevice.getCommand() != null) + .map(vrDevice -> new ControllableDevice(vrDevice)) + .collect(Collectors.toList()); +// // 信号机 +// List vrSignalList = repository.getVrListByType(MapElement.DeviceType.SIGNAL, VirtualRealitySignal.class); +// vrSignalList.forEach(signal -> initDeviceList.add(new SignalLight(signal))); +// // 道岔 +// List vrSwitchList = repository.getVrListByType(MapElement.DeviceType.SWITCH, VirtualRealitySwitch.class); +// vrSwitchList.forEach(vrSwitch -> { +// boolean normal; +// if (vrSwitch.isTurning()) { +// normal = vrSwitch.getCommand().equals(VirtualRealitySwitch.Operation.NP); +// } else if (vrSwitch.isPosN()) { +// normal = true; +// } else { +// normal = false; +// } +// initDeviceList.add(new SwitchTurn(vrSwitch, normal)); +// }); +// // 屏蔽门 +// List vrPsdList = repository.getVrListByType(MapElement.DeviceType.PSD, VirtualRealityScreenDoor.class); +// vrPsdList.forEach(vrPsd -> { +// boolean open; +// if (vrPsd.isTurning()) { +// open = vrPsd.getCommand().equals(VirtualRealityScreenDoor.Operation.K); +// } else if (vrPsd.isClose()) { +// open = false; +// } else { +// open = true; +// } +// initDeviceList.add(new PsdSwitch(vrPsd, open)); +// }); // 列车 List onlineTrainList = repository.getOnlineTrainList(); onlineTrainList.forEach(train -> initDeviceList.addAll(this.collectTrainInitData(train))); @@ -273,10 +279,17 @@ public class Joylink3DMessageService { @EventListener public void handleDeviceControlEvent(SimulationDeviceControlEvent event) { Simulation simulation = event.getSimulation(); - ControllableDevice ctrlMsg = event.getCtrlMsg(); + ControllableVrDevice device = event.getDevice(); + ControllableDevice cd; + if (device instanceof VirtualRealityTrain.Door) { + VirtualRealityTrain.Door door = (VirtualRealityTrain.Door) device; + cd = new TrainDoorSwitch(door.getTrain(), door); + } else { + cd = new ControllableDevice(device); + } SocketMessageVO message = SocketMessageFactory .build(WebSocketMessageType.DeviceCtrl_3D, - simulation.getId(), ctrlMsg); + simulation.getId(), cd); this.stompMessageService.sendToUser(simulation.getSimulationUserIds(), message); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/ControllableDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/ControllableDevice.java index 5ca23bcb5..463db6f9c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/ControllableDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/ControllableDevice.java @@ -1,10 +1,11 @@ package club.joylink.rtss.simulation.cbtc.communication.vo; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; +import club.joylink.rtss.simulation.cbtc.data.vr.ControllableVrDevice; import lombok.Getter; @Getter -public abstract class ControllableDevice { +public class ControllableDevice { /** 设备code */ private String code; @@ -12,8 +13,16 @@ public abstract class ControllableDevice { /** 设备类型 */ private MapElement.DeviceType type; + private String command; + protected ControllableDevice(String code, MapElement.DeviceType type) { this.code = code; this.type = type; } + + public ControllableDevice(ControllableVrDevice vrDevice) { + this.code = vrDevice.getCode(); + this.type = vrDevice.getDeviceType(); + this.command = vrDevice.getCommand().toString(); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/PsdSwitch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/PsdSwitch.java index 878be6e5f..d3f6ec7f4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/PsdSwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/PsdSwitch.java @@ -1,22 +1,22 @@ -package club.joylink.rtss.simulation.cbtc.communication.vo; - -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; -import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; -import lombok.Getter; - -/** - * 站台屏蔽门开/关门控制消息 - */ -@Getter -public class PsdSwitch extends ControllableDevice { - - /** true-开门 false-关门 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private boolean open; - - public PsdSwitch(VirtualRealityScreenDoor psd, boolean open) { - super(psd.getCode(), psd.getDeviceType()); - this.open = open; - } -} +//package club.joylink.rtss.simulation.cbtc.communication.vo; +// +//import com.fasterxml.jackson.databind.annotation.JsonSerialize; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; +//import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; +//import lombok.Getter; +// +///** +// * 站台屏蔽门开/关门控制消息 +// */ +//@Getter +//public class PsdSwitch extends ControllableDevice { +// +// /** true-开门 false-关门 */ +// @JsonSerialize(using = Boolean2NumSerializer.class) +// private boolean open; +// +// public PsdSwitch(VirtualRealityScreenDoor psd, boolean open) { +// super(psd.getCode(), psd.getDeviceType()); +// this.open = open; +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/SignalLight.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/SignalLight.java index 9f074d892..4af3767b0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/SignalLight.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/SignalLight.java @@ -1,32 +1,25 @@ -package club.joylink.rtss.simulation.cbtc.communication.vo; - -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; -import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; -import lombok.Getter; - -/** - * 信号机点灯状态 - */ -@Getter -public class SignalLight extends ControllableDevice { - - /** 红灯是否点亮 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private boolean red; - - /** 黄灯是否点亮 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private boolean yellow; - - /** 绿灯是否点亮 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private boolean green; - - public SignalLight(VirtualRealitySignal signal) { - super(signal.getCode(), signal.getDeviceType()); - this.red = signal.isRedOpen(); - this.green = signal.isGreenOpen(); - this.yellow = signal.isYellowOpen(); - } -} +//package club.joylink.rtss.simulation.cbtc.communication.vo; +// +//import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; +//import lombok.Getter; +// +///** +// * 信号机点灯状态 +// */ +//@Getter +//public class SignalLight extends ControllableDevice { +// /** +// * 信号显示 +// */ +// private SignalAspect aspect; +// +// public SignalLight(VirtualRealitySignal signal) { +// super(signal.getCode(), signal.getDeviceType()); +// if (signal.getCommand() != null) { +// this.aspect = signal.getCommand(); +// } else { +// this.aspect = signal.getAspect(); +// } +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/SwitchTurn.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/SwitchTurn.java index 3124b74c6..ab17efe37 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/SwitchTurn.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/SwitchTurn.java @@ -1,22 +1,22 @@ -package club.joylink.rtss.simulation.cbtc.communication.vo; - -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; -import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; -import lombok.Getter; - -/** - * 道岔开始转动消息 - */ -@Getter -public class SwitchTurn extends ControllableDevice { - - /** true-转到定位 false-转到反位 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private boolean normal; - - public SwitchTurn(VirtualRealitySwitch vrSwitch, boolean normal) { - super(vrSwitch.getCode(), vrSwitch.getDeviceType()); - this.normal = normal; - } -} +//package club.joylink.rtss.simulation.cbtc.communication.vo; +// +//import com.fasterxml.jackson.databind.annotation.JsonSerialize; +//import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +//import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; +//import lombok.Getter; +// +///** +// * 道岔开始转动消息 +// */ +//@Getter +//public class SwitchTurn extends ControllableDevice { +// +// /** true-转到定位 false-转到反位 */ +// @JsonSerialize(using = Boolean2NumSerializer.class) +// private boolean normal; +// +// public SwitchTurn(VirtualRealitySwitch vrSwitch, boolean normal) { +// super(vrSwitch.getCode(), vrSwitch.getDeviceType()); +// this.normal = normal; +// } +//} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainDoorSwitch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainDoorSwitch.java index 98f111f74..04907cb14 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainDoorSwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainDoorSwitch.java @@ -1,23 +1,15 @@ package club.joylink.rtss.simulation.cbtc.communication.vo; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; -import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; import lombok.Getter; @Getter public class TrainDoorSwitch extends ControllableDevice { - private String doorCode; + private String trainCode; - /** true-开门 false-关门 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private boolean open; - - public TrainDoorSwitch(VirtualRealityTrain train, VirtualRealityTrain.Door door, boolean open) { - super(train.getCode(), MapElement.DeviceType.TRAIN_DOOR); - this.doorCode = door.getCode(); - this.open = open; + public TrainDoorSwitch(VirtualRealityTrain train, VirtualRealityTrain.Door door) { + super(door); + this.trainCode = train.getCode(); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java index ecf76a436..36640ea07 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/communication/vo/TrainHmiDisplay.java @@ -163,6 +163,16 @@ public class TrainHmiDisplay { /** 牵引、制动力百分比 */ private int forcePercent; + /** + * 门模式 + */ + private String doorMode; + + /** + * 门选择 + */ + private String doorSelection; + public TrainHmiDisplay(VirtualRealityTrain train) { this.code = train.getCode(); this.groupNumber = train.getGroupNumber(); @@ -217,6 +227,8 @@ public class TrainHmiDisplay { this.inTheStandArea = train.isInTheStandArea(); this.tow = getTow(train); this.forcePercent = getForcePercent(train); + this.doorMode = train.getDoorMode().toString(); + this.doorSelection = train.getDoorSelection().toString(); } private int getForcePercent(VirtualRealityTrain train) { @@ -392,6 +404,14 @@ public class TrainHmiDisplay { this.forcePercent = forcePercent; map.put("forcePercent", forcePercent); } + if (!Objects.equals(this.doorMode, train.getDoorMode().toString())) { + this.doorMode = train.getDoorMode().toString(); + map.put("doorMode", this.doorMode); + } + if (!Objects.equals(this.doorSelection, train.getDoorSelection().toString())) { + this.doorSelection = train.getDoorSelection().toString(); + map.put("doorSelection", this.doorSelection); + } if (map.size() > 0) { map.put("code", this.code); return map; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SignalAspect.java b/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SignalAspect.java new file mode 100644 index 000000000..68abfeb6b --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SignalAspect.java @@ -0,0 +1,37 @@ +package club.joylink.rtss.simulation.cbtc.constant; + +/** + * 信号显示 + */ +public enum SignalAspect { + /** 无显示,灭灯 */ + No, + /** 红 */ + R, + /** 绿 */ + G, + /** 黄 */ + Y, + /** 月白 */ + W, + /** 蓝 */ + B, + /** 红黄 */ + RY, + /** 红白 */ + RW, + /** 绿绿 */ + GG, + /** 绿黄 */ + GY, + /** 黄黄 */ + YY, + /** 红闪(flashing) */ + RF, + /** 黄闪(flashing) */ + YF, + /** 绿闪(flashing) */ + GF, + /** 白闪(flashing) */ + WF, +} \ No newline at end of file diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SignalModel.java b/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SignalModel.java new file mode 100644 index 000000000..3ec17dc42 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SignalModel.java @@ -0,0 +1,50 @@ +package club.joylink.rtss.simulation.cbtc.constant; + +import lombok.Getter; + +import java.util.Arrays; +import java.util.List; + +@Getter +public enum SignalModel { + /** + * 红绿黄三灯信号机 + */ + RGY(SignalAspect.R, Arrays.asList(SignalAspect.G, SignalAspect.Y), SignalAspect.RY), + /** + * 单红灯信号机 + */ + R(SignalAspect.R, null, null), + /** + * 蓝白调车信号机 + */ + BW(SignalAspect.B, Arrays.asList(SignalAspect.W), null), + /** + * 黄绿红黄白(大铁进站信号机) + */ + YGRYW(SignalAspect.R, Arrays.asList(SignalAspect.G, SignalAspect.Y), SignalAspect.RW), + /** + * 黄绿红绿白(出站兼调车信号机) + */ + YGRGW(SignalAspect.R, Arrays.asList(SignalAspect.G, SignalAspect.Y), SignalAspect.RW), + ; + /** + * 信号机开启后默认显示(即禁止信号) + */ + private SignalAspect defaultAspect; + /** + * 主信号显示 + */ + private List mainAspects; + /** + * 信号机引导信号显示 + */ + private SignalAspect guideAspect; + + SignalModel(SignalAspect defaultAspect, List mainAspects, SignalAspect guideAspect) { + this.defaultAspect = defaultAspect; + this.mainAspects = mainAspects; + this.guideAspect = guideAspect; + } + +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SwitchIndication.java b/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SwitchIndication.java new file mode 100644 index 000000000..cde11e9ec --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SwitchIndication.java @@ -0,0 +1,24 @@ +package club.joylink.rtss.simulation.cbtc.constant; + +/** + * 道岔位置表示 + */ +public enum SwitchIndication { + /** 定位 */ + N, + /** 反位 */ + R, + /** 无(失表) */ + NO, + /** 挤叉 */ + EX, + ; + + public static SwitchIndication of(boolean normal) { + if (normal) { + return N; + } else { + return R; + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java index a1a0e0d08..bcfce55ff 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java @@ -16,6 +16,7 @@ import club.joylink.rtss.simulation.cbtc.data.support.RoutePath; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.vo.TdtStatusVO; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; +import club.joylink.rtss.simulation.cbtc.data.vr.ControllableVrDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; @@ -217,7 +218,9 @@ public class SimulationDataRepository { */ private final Map deviationInfoMap = new ConcurrentHashMap<>(); - /** 加线、抽线的计划 */ + /** + * 加线、抽线的计划 + */ private List changeTrips = new CopyOnWriteArrayList<>(); public void addChangeTrips(Collection trips) { @@ -732,6 +735,13 @@ public class SimulationDataRepository { } } + public void vrDeviceReset() { + // 虚拟真实设备状态重置 + for (VirtualRealityDevice vrDevice : this.vrDeviceMap.values()) { + vrDevice.reset(); + } + } + /** * 查询所有锁闭的进路 * @@ -744,45 +754,6 @@ public class SimulationDataRepository { .collect(Collectors.toList()); } - /** - * 获取下一发车计划 - * - * @param serviceNumber - * @param tripNumber - * @return - */ - public TripPlan queryTurnBackNextTrip(String serviceNumber, String tripNumber) { - // 获取服务下趟车次 - TripPlan next = this.queryServiceNextTripPlan(serviceNumber, tripNumber); - if (Objects.isNull(next)) { - throw new SimulationException(SimulationExceptionType.Simulation_Plan_Data_Error); - } - if (next.isInvalid()) - return null; - TripPlan prePlan = this.getTripPlan(serviceNumber, tripNumber); - if (!next.isDeparture()) { - return next; - } else { - // 取此折返轨上下一车次计划 - List allTripPlanList = this.getAllTripPlanList(); - List endDeparturePlanList = allTripPlanList.stream() - .filter(tripPlan -> Objects.equals(prePlan.getEndSection(), tripPlan.getStartSection()) && - !tripPlan.isOutbound() && - !tripPlan.isDeparture()) - .sorted(Comparator.comparing(TripPlan::getStartTime)) - .collect(Collectors.toList()); - if (!CollectionUtils.isEmpty(endDeparturePlanList)) { - return endDeparturePlanList.get(0); - } -// else { -// throw new SimulationException(SimulationExceptionType.System_Fault, -// String.format("获取计划车次[%s]下一发车计划异常,未找到区段[%s]下一即将发车计划", -// prePlan.debugStr(), prePlan.getEndSection().debugStr())); -// } - } - return null; - } - public TripPlan queryServiceNextTripPlan(String serviceNumber, String tripNumber) { // 获取服务下趟车次 List tripPlans = this.serviceTripsMap.get(serviceNumber); @@ -823,67 +794,8 @@ public class SimulationDataRepository { return next; } - /** - * 获取下一发车计划 - * - * @param station - * @param serviceNumber - * @return - */ - public TripPlan getNextTripPlan(Station station, String serviceNumber) { - List allTripPlanList = this.getAllTripPlanList(); - List endDeparturePlanList = allTripPlanList.stream() - .filter(tripPlan -> Objects.equals(station, tripPlan.getFirstStationPlan().getStation()) && - Objects.equals(tripPlan.getServiceNumber(), serviceNumber)) - .collect(Collectors.toList()); - TripPlan next = null; - for (int i = 0; i < endDeparturePlanList.size(); i++) { - TripPlan tripPlan = endDeparturePlanList.get(i); - if (!tripPlan.isDeparture()) { - next = tripPlan; - break; - } - } - if (Objects.nonNull(next)) { - return next; - } else { - throw new SimulationException(SimulationExceptionType.System_Fault, - String.format("车站[%s(%s)]获取服务[%s]下一发车计划异常", - station.getName(), - station.getCode(), - serviceNumber)); - } - } - - /** - * 备用车获取获取下一发车计划 - * - * @param station - * @param serviceNumber - * @return - */ - public TripPlan getBackUpNextTripPlan(Station station, String serviceNumber) { - List allTripPlanList = this.getAllTripPlanList(); - List endDeparturePlanList = allTripPlanList.stream() - .filter(tripPlan -> Objects.equals(station, tripPlan.getFirstStationPlan().getStation()) && - Objects.equals(tripPlan.getServiceNumber(), serviceNumber)) - .collect(Collectors.toList()); - TripPlan next = null; - for (int i = 0; i < endDeparturePlanList.size(); i++) { - TripPlan tripPlan = endDeparturePlanList.get(i); - if (!tripPlan.isDeparture()) { - next = tripPlan; - break; - } - } - if (next != null && next.isInvalid()) - return null; - return next; - } - /** * 此方法只能用于计划车次号唯一的线路(比如西门子风格的运行计划) - * * @param tripNumber * @return */ @@ -906,38 +818,6 @@ public class SimulationDataRepository { String.format("服务车次号[%s]未找到车次计划", stNumber)); } - public TrainInfo querySignalApproachedFirstTrain(Signal signal) { - List approachedTrainList = new ArrayList<>(); - for (TrainInfo train : this.getSuperviseTrainList()) { - if (!train.hasPositionAndDirection()) { - continue; - } - if (signal.isApproachSection(train.getPhysicalSection())) { - approachedTrainList.add(train); - } - } - if (!CollectionUtils.isEmpty(approachedTrainList)) { - if (approachedTrainList.size() == 1) { - return approachedTrainList.get(0); - } else { - // 信号机接近列车多于一个,根据列车位置判断 - boolean right = signal.isRight(); - TrainInfo front = approachedTrainList.get(0); - for (int i = 1; i < approachedTrainList.size(); i++) { - TrainInfo b = approachedTrainList.get(i); - SectionPosition aHead = this.buildHeadPositionOfTrainInfo(front); - SectionPosition bHead = this.buildHeadPositionOfTrainInfo(b); - if (bHead.isAheadOf(aHead, right)) { - front = b; - } - } - return front; - } - } else { - return null; - } - } - public SectionPosition buildHeadPositionOfTrainInfo(TrainInfo train) { if (!train.hasPositionAndDirection()) { throw new SimulationException(SimulationExceptionType.System_Fault, @@ -1084,23 +964,6 @@ public class SimulationDataRepository { return null; } - public RoutePath selectFirstChoiceRoutePath(List routePaths) { - if (!CollectionUtils.isEmpty(routePaths)) { - if (routePaths.size() == 1) { - return routePaths.get(0); - } - // 经过道岔反位最少 - RoutePath firstChoicePath = routePaths.get(0); - for (RoutePath routePath : routePaths) { - if (routePath.getReverseSwitchQuantity() < firstChoicePath.getReverseSwitchQuantity()) { - firstChoicePath = routePath; - } - } - return firstChoicePath; - } - return null; - } - public DestinationCodeDefinition getDestinationCodeDefinition(String code) { DestinationCodeDefinition destinationCodeDefinition = destinationMap.get(code); BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(destinationCodeDefinition, String.format("目的地码[%s]不存在", code)); @@ -1111,10 +974,6 @@ public class SimulationDataRepository { return destinationMap.get(code); } - public List getOutboundTripPlan() { - return getAllTripPlanList().stream().filter(TripPlan::isOutbound).collect(Collectors.toList()); - } - /** * 根据设备集中站找所属车站(包括集中站本身) */ @@ -1139,48 +998,6 @@ public class SimulationDataRepository { return new HashSet<>(this.usedTrainMap.values()); } - public List queryRouteOverlapBy(Section section, boolean right) { - List list = new ArrayList<>(); - List routeOverlapList = this.getRouteOverlapList(); - for (RouteOverlap routeOverlap : routeOverlapList) { - if (Objects.equals(routeOverlap.getSection(), section) && Objects.equals(right, routeOverlap.isRight())) { - list.add(routeOverlap); - } - } - return list; - } - - public boolean isOverlapNeedSetting(Route route) { - Objects.requireNonNull(route); - RouteOverlap overlap = route.getOverlap(); - if (Objects.isNull(overlap)) { - return false; - } - if (route.isCbtcMode() && !route.isSetOverlapInCtc()) { - // CTC模式不办理判断 - return false; - } - return true; - } - - /** - * 查询指定时间范围内的出库计划 - * - * @param start - * @param end - * @return - */ - public List queryOutBoundTripPlanBetween(LocalTime start, LocalTime end) { - List list = new ArrayList<>(); - List allTripPlanList = this.getAllTripPlanList(); - for (TripPlan tripPlan : allTripPlanList) { - if (tripPlan.isOutbound() && start.isBefore(tripPlan.getStartTime()) && end.isAfter(tripPlan.getStartTime())) { - list.add(tripPlan); - } - } - return list; - } - public RealRun queryLastRealRun(String groupNumber) { for (int i = this.realRunRecordList.size() - 1; i >= 0; i--) { RealRun realRun = this.realRunRecordList.get(i); @@ -1206,19 +1023,6 @@ public class SimulationDataRepository { .collect(Collectors.toList()); } - public StationPlan queryStationPlanBetween(Station station, LocalTime start, LocalTime end) { - for (TripPlan tripPlan : this.getAllTripPlanList()) { - if (tripPlan.getStartTime().isAfter(end) || tripPlan.getEndTime().isBefore(start)) - continue; - for (StationPlan stationPlan : tripPlan.getPlanList()) { - if (stationPlan.getStation().equals(station) && start.isBefore(stationPlan.getArriveTime()) && end.isAfter(stationPlan.getArriveTime())) { - return stationPlan; - } - } - } - return null; - } - /** * 查询以{end}为终点,并包含{section}的进路路径 */ @@ -1283,19 +1087,6 @@ public class SimulationDataRepository { return this.endTripMap.get(section.getCode()); } - public RealRun queryRealRunOf(TripPlan tripPlan, Section section) { - List realRuns = this.tripRealRunMap.get(tripPlan.getStNumber()); - if (realRuns == null) { - return null; - } - for (RealRun realRun : realRuns) { - if (realRun.getSectionCode().equals(section.getCode())) { - return realRun; - } - } - return null; - } - public TrainInfo queryAtsTrainInfoOfTripPlan(TripPlan tripPlan) { for (TrainInfo trainInfo : this.trainInfoMap.values()) { if (trainInfo.isPlanTrain() && trainInfo.getServiceNumber().equals(tripPlan.getServiceNumber()) && @@ -1306,19 +1097,6 @@ public class SimulationDataRepository { return null; } - public TripPlan queryPreviousTripPlanOfStand(Section section, TripPlan tripPlan) { - List standTripPlanList = this.getTripPlanListOfStand(section); - TripPlan previous = null; - for (TripPlan plan : standTripPlanList) { - if (tripPlan.equals(plan)) { - break; - } else { - previous = plan; - } - } - return previous; - } - public void addAtsAlarm(AtsAlarm alarm) { this.alarmMap.put(alarm.getCode(), alarm); } @@ -1337,4 +1115,40 @@ public class SimulationDataRepository { String key = start.getCode() + "-" + end.getCode(); return this.runLevelMap.get(key); } + + public List getAllControllableVrDevice() { + List controllableList = this.vrDeviceMap.values().stream() + .filter(vrDevice -> vrDevice instanceof ControllableVrDevice) + .map(vrDevice -> ((ControllableVrDevice) vrDevice)) + .collect(Collectors.toList()); + return controllableList; + } + + public boolean isTrainHeadOccupy(Section section) { + if (section.isOccupied()) { + for (TrainInfo trainInfo : this.getSuperviseTrainList()) { + if (trainInfo.hasPositionAndDirection()) { + Section head = this.getByCode(trainInfo.getPhysicalSection(), Section.class); + if (head.isSameAxle(section.getCode())) { + return true; + } + } + } + } + return false; + } + + public boolean isTrainParking(Section section) { + if (section.isOccupied()) { + for (TrainInfo trainInfo : this.getSuperviseTrainList()) { + if (trainInfo.hasPositionAndDirection() && trainInfo.isParking()) { + Section head = this.getByCode(trainInfo.getPhysicalSection(), Section.class); + if (head.isSameAxle(section.getCode())) { + return true; + } + } + } + } + return false; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java new file mode 100644 index 000000000..31f8a189f --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java @@ -0,0 +1,27 @@ +package club.joylink.rtss.simulation.cbtc.data; + +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; +import lombok.NoArgsConstructor; + +import java.util.*; + +@NoArgsConstructor +public class SimulationIscsDataRepository { + private final Map statusVOMap = new HashMap<>(); + + public IscsStatusVO findStatus(String iscsCode) { + return statusVOMap.get(iscsCode); + } + + public void addStatus(IscsStatusVO iscsStatusVO) { + statusVOMap.put(iscsStatusVO.getCode(), iscsStatusVO); + } + + public Collection getAllStatus() { + return statusVOMap.values(); + } + + public void reset() { + this.statusVOMap.clear(); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DelayUnlockDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DelayUnlockDevice.java new file mode 100644 index 000000000..4db6a1c66 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/DelayUnlockDevice.java @@ -0,0 +1,38 @@ +package club.joylink.rtss.simulation.cbtc.data.map; + +import lombok.Getter; + +@Getter +public abstract class DelayUnlockDevice extends MayOutOfOrderDevice { + private int remain; + + protected DelayUnlockDevice(String code, String name, DeviceType deviceType) { + super(code, name, deviceType); + } + + public void delayUnlockStart(Route route) { + this.remain = route.getDelayReleaseTime() * 1000; + } + + public void reset() { + super.reset(); + this.remain = 0; + } + + /** + * + * @param interval 单位:ms + */ + public boolean countAndCheckFinish(int interval) { + this.remain -= interval; + if (this.remain <= 0) { + this.remain = 0; + return true; + } + return false; + } + + public void recover(int remain) { + this.remain = remain; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Responder.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Responder.java index 3d640a3be..e2dffcc8d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Responder.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Responder.java @@ -97,7 +97,7 @@ public class Responder extends MapNamedElement { public boolean isTrigger(VirtualRealityTrain train, SectionPosition headPosition, SectionPosition headPositionNew) { if (this.isVB()) { - if (signal.isNormalOpen() && this.getSignal().isRight() == train.isRight()) { + if (signal.isMainAspect() && this.getSignal().isRight() == train.isRight()) { return this.position.isBetween(headPosition, headPositionNew); } else { return false; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java index 7923d2723..4300909e3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.cbtc.data.map; import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; @@ -22,7 +23,6 @@ public class Route extends MapNamedElement { public Route(String code, String name) { super(code, name, DeviceType.ROUTE); this.atsControl = true; - this.cbtcMode = true; this.conflictingRouteList = new ArrayList<>(); this.switchList = new ArrayList<>(); } @@ -58,8 +58,8 @@ public class Route extends MapNamedElement { /** 终端信号机 */ private Signal destination; - /** 信号开放绿灯(否则黄灯) */ - private boolean openGreen; + /** 信号显示 */ + private SignalAspect aspect; /** 进路区段 */ private List
sectionList; @@ -80,6 +80,7 @@ public class Route extends MapNamedElement { private List standHoldList; /** CTC模式下需要办理延续保护 */ + @Deprecated private boolean setOverlapInCtc = true; /** 进路延续保护 */ @@ -95,10 +96,6 @@ public class Route extends MapNamedElement { private Signal destinationButtonSignal; // ------------------状态属性--------------------- - - /** 是否CBTC模式 */ - private boolean cbtcMode; - /** ats自动控制 */ private boolean atsControl; @@ -117,17 +114,14 @@ public class Route extends MapNamedElement { /** 进路开始排列时间 */ private LocalDateTime settingStartTime; - /** 设备是否已被征用 */ - private boolean requisition; - /** 是否引导进路排列中 */ - private boolean openGuide; + private boolean guideSetting; /** 进路是否锁闭 */ private boolean lock; - /** 进路是否延时解锁中 */ - private boolean delayUnlocking; + /** 进路延时解锁设备 */ + private DelayUnlockDevice delayUnlockDevice; /** 是否正常解锁中 */ private boolean normalUnlock; @@ -136,6 +130,7 @@ public class Route extends MapNamedElement { private Section unlockedSection; /** 进路将要或上一次为哪辆列车排列 */ + @Deprecated private TrainInfo train; /** 检查冲突功能是否开启 */ private boolean checkConflict; @@ -148,16 +143,14 @@ public class Route extends MapNamedElement { @Override public void reset() { - this.cbtcMode = true; this.atsControl = true; this.fleetMode = false; this.ciControl = false; this.settable = false; this.setting = false; - this.requisition = false; - this.openGuide = false; + this.guideSetting = false; this.lock = false; - this.delayUnlocking = false; + this.delayUnlockDevice = null; this.normalUnlock = false; this.unlockedSection = null; this.train = null; @@ -168,25 +161,22 @@ public class Route extends MapNamedElement { * 进路是否开放(进路是否锁闭,并开放指定信号灯) * @return */ - public boolean isOpen() { - return this.isLock() && !this.start.isRedOpen() && - ((this.isOpenGreen() && this.start.isGreenOpen()) || - (!this.isOpenGreen() && this.start.isYellowOpen())); - } - - public void setAtsControl(boolean atsControl) { - this.atsControl = atsControl; - if (!atsControl) - this.checkConflict = false; + public boolean isOpenMain() { + return this.lock && this.aspect.equals(this.start.getAspect()); } /** * 进路是否开放引导信号 * @return */ - public boolean isGuideSignalOpen() { - return this.isLock() && - (this.start.isYellowOpen() && this.start.isRedOpen()); + public boolean isOpenGuide() { + return this.lock && (this.start.isGuideAspect()); + } + + public void setAtsControl(boolean atsControl) { + this.atsControl = atsControl; + if (!atsControl) + this.checkConflict = false; } /** @@ -204,19 +194,6 @@ public class Route extends MapNamedElement { return this.sectionList.get(0); } - public Section getFirstRouteLogicSection() { - Section section = this.sectionList.get(0); - List
logicList = section.getLogicList(); - boolean right = this.getStart().isRight(); - if (!CollectionUtils.isEmpty(logicList)) { - if (!right) { - return logicList.get(logicList.size() - 1); - } - return logicList.get(0); - } - return section; - } - /** * 获取第一个逻辑区段 */ @@ -303,7 +280,7 @@ public class Route extends MapNamedElement { } public boolean isApproachLock() { - return this.isOpen() && this.getStart().isNctApproach() || this.getStart().isCbtcApproach(); + return this.isOpenMain() && this.getStart().isApproachLock(); } public boolean isAnySectionOccupied() { @@ -423,29 +400,6 @@ public class Route extends MapNamedElement { return false; } - public void settingFinish() { - this.lock = true; - this.setting = false; - } - - public boolean isOppositeTo(Route other) { - return !Objects.equals(this.getStart().isRight(), other.getStart().isRight()); - } - - /** - * 排列失败 - */ - public void settingFailed() { -// this.lock = false; -// if (Objects.equals(this.start.getLockedRoute(), this)) { -// this.start.setLockedRoute(null); -// } - this.setting = false; - if (Objects.nonNull(this.overlap)) { - this.overlap.settingFailed(); - } - } - /** * 存在反位道岔 * @return @@ -459,27 +413,51 @@ public class Route extends MapNamedElement { return false; } - public synchronized void normalUnlockStart() { - this.normalUnlock = true; + public void startNormalUnlock() { + this.setSetting(false); this.unlockedSection = this.sectionList.get(0); + // 进路解锁开始信号 + this.normalUnlock = true; + this.setLock(false); } - public synchronized void updateUnlockedSection(Section section) { + public void updateUnlockedSection(Section section) { this.unlockedSection = section; } - public synchronized void normalUnlockOver() { + public void normalUnlockOver() { this.normalUnlock = false; this.unlockedSection = null; } - public synchronized void startSetting(LocalDateTime systemTime) { + public void startSetting(LocalDateTime systemTime) { + this.normalUnlock = false; this.setSetting(true); this.settingStartTime = systemTime; - this.requisition = false; - this.setOpenGuide(false); - this.setNormalUnlock(false); - this.unlockedSection = null; + this.setGuideSetting(false); + } + + public void startGuideSetting(LocalDateTime systemTime) { + this.normalUnlock = false; + this.setSetting(true); + this.settingStartTime = systemTime; + this.setGuideSetting(true); + } + + public void settingOver() { + this.setSetting(false); + if (this.overlap != null) { + this.overlap.settingOver(); + } + } + + public void setLock(boolean lock) { + this.lock = lock; + if (lock) { + this.start.setLockedRoute(this); + } else if(this == this.start.getLockedRoute()) { + this.start.setLockedRoute(null); + } } public int getReverseSwitchQuantity() { @@ -526,14 +504,14 @@ public class Route extends MapNamedElement { return false; } - public boolean hasSwitchFault() { + public boolean containsRoutePosFaultSwitch() { if (!CollectionUtils.isEmpty(this.switchList)) { for (SwitchElement element : this.switchList) { Switch aSwitch = element.getASwitch(); if (aSwitch.isFault() && (Switch.SwitchFault.SPLIT.equals(aSwitch.getFault()) || - (element.isNormal() && !aSwitch.isReversePosition() && Switch.SwitchFault.NORMAL_SPLIT.equals(aSwitch.getFault())) || - (!element.isNormal() && !aSwitch.isNormalPosition() && Switch.SwitchFault.REVERSE_SPLIT.equals(aSwitch.getFault())))) { + (element.isNormal() && Switch.SwitchFault.NORMAL_SPLIT.equals(aSwitch.getFault())) || + (!element.isNormal() && Switch.SwitchFault.REVERSE_SPLIT.equals(aSwitch.getFault())))) { return true; } } @@ -541,15 +519,11 @@ public class Route extends MapNamedElement { return false; } - public synchronized void updateRequisition(boolean requisition) { - this.requisition = requisition; - } - public boolean isLastRouteSection(Section section) { return Objects.equals(this.getLastRouteSection(), section); } - public RouteFls getRouteFlsOfSwitch(Switch aSwitch) { + public RouteFls queryRouteFlsOfSwitch(Switch aSwitch) { if (!CollectionUtils.isEmpty(this.flsList)) { for (RouteFls routeFls : flsList) { if (Objects.equals(routeFls.getBase().getASwitch(), aSwitch)) { @@ -577,7 +551,6 @@ public class Route extends MapNamedElement { } return false; } - /** * 获取进路的所有子区段 */ @@ -595,14 +568,6 @@ public class Route extends MapNamedElement { public boolean routeLastSection(Section section) { return Objects.equals(this.sectionList.get(sectionList.size()-1),section); } - /** - * 取消延时解锁 - */ - public void cancelDelayUnlocking() { - this.delayUnlocking = false; - this.start.setDelayTime(0); - getLogicSections().forEach(section -> section.setDelayUnlock(false)); - } public boolean isTransferRoute() { return this.sectionList.stream().anyMatch(Section::isTransferTrack); @@ -632,7 +597,7 @@ public class Route extends MapNamedElement { } public void unlockRouteFlsOfSwitch(Switch relSwitch) { - RouteFls routeFls = this.getRouteFlsOfSwitch(relSwitch); + RouteFls routeFls = this.queryRouteFlsOfSwitch(relSwitch); if (routeFls != null && !routeFls.getBase().getASwitch().isRouteLock() && !routeFls.getBase().getASwitch().isOverlapLock()) { routeFls.unlock(); } @@ -655,6 +620,29 @@ public class Route extends MapNamedElement { return overlap.containSection(section); } + public boolean isSettingOverlap() { + if (this.overlap != null) { + if (this.getStart().isCbtcMode() && this.getDestination().isCbtcMode()) { + return this.getDestination().isCtcSetOverlap(); + } + return true; + } + return false; + } + + public boolean isDelayUnlocking() { + return this.delayUnlockDevice != null; + } + + public boolean isConflictSwitch(SwitchElement switchElement) { + for (SwitchElement element : this.switchList) { + if (element.isConflict(switchElement)) { + return true; + } + } + return false; + } + /** * 进路检查失败原因 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlap.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlap.java index 640452515..8b53084e8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlap.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlap.java @@ -23,65 +23,95 @@ public class RouteOverlap extends MapNamedElement { // ------------固有属性/关联关系----------- List pathList; - /** 进路的最后子进路 */ + /** + * 进路的最后子进路 + */ private Section section; - /** 延续保护方向 */ + /** + * 延续保护方向 + */ private boolean right; - /** 延续保护起始信号机 */ + /** + * 延续保护起始信号机 + */ private Signal signal; - /** 触发区段路径 */ + /** + * 触发区段路径 + */ private List triggerPathList; - /** 延时解锁时间 */ + /** + * 延时解锁时间 + */ private int delayReleaseTime; // --------------状态属性------------- - - /** 办理中 */ + /** + * 办理中 + */ private boolean setting; - /** 办理开始时间 */ + /** + * 办理开始时间 + */ private LocalDateTime settingStartTime; - /** 设备是否已被征用 */ - private boolean requisition; - - /** 是否锁闭 */ + /** + * 是否锁闭 + */ private boolean lock; - - /** 是否暂时禁止锁闭 */ - private boolean forbidden; - - /** 是否正在解锁 */ + /** + * 是否正在解锁 + */ private boolean releasing; - - /** 剩余时间 */ + /** + * 禁止办理 + */ + private boolean forbidden; + /** + * 剩余时间 + */ private int remainTime; @Override public void reset() { this.setting = false; this.settingStartTime = null; - this.requisition = false; this.lock = false; - this.forbidden = false; this.releasing = false; + this.forbidden = false; this.remainTime = 0; } - public synchronized void startSetting(LocalDateTime systemTime) { + public void startSetting(LocalDateTime systemTime) { this.setLock(false); + this.releasing = false; this.settingStartTime = systemTime; - this.requisition = false; this.setting = true; } - public void settingFinish() { - this.setLock(true); + public void settingOver() { this.setting = false; this.settingStartTime = null; - this.requisition = false; + } + + public boolean isSectionOverlapLocked() { + SectionPath sectionPath = this.selectPath(); + if (!CollectionUtils.isEmpty(sectionPath.getLogicList())) { + for (Section logic : sectionPath.getLogicList()) { + if (!logic.isOverlapLockOn(this.isRight())) { + return false; + } + } + } else { + for (Section section1 : sectionPath.getSectionList()) { + if (!section1.isOverlapLockOn(this.isRight())) { + return false; + } + } + } + return true; } /** @@ -92,29 +122,38 @@ public class RouteOverlap extends MapNamedElement { this.releasing = true; } + public void allow() { + this.forbidden = false; + } + /** * 立即解锁 */ public void releaseImmediately() { - if (!CollectionUtils.isEmpty(this.pathList)) { - for (SectionPath path : this.pathList) { - // 先解锁区段,后解锁道岔 - for (Section section1 : path.getSectionList()) { - section1.overlapUnlocking(); - } - List flsList = path.getFlsList(); - for (SwitchElement element : path.getSwitchList()) { - Switch aSwitch = element.getASwitch(); - aSwitch.overlapUnLock(); - unlockFlsOfSwitch(flsList, aSwitch); + this.setting = false; + this.releasing = false; + this.forbidden = true; + this.remainTime = 0; + this.setLock(false); + SectionPath sectionPath = this.selectPath(); + // 先解锁区段,后解锁道岔 + for (Section logic : sectionPath.getLogicList()) { + logic.overlapUnlocking(); + } + for (Section section1 : sectionPath.getSectionList()) { + section1.overlapUnlocking(); + if (section1.getLogicList() != null) { + for (Section logic : section1.getLogicList()) { + logic.overlapUnlocking(); } } } - this.setting = false; - this.forbidden = true; - this.setLock(false); - this.remainTime = 0; - this.releasing = false; + List flsList = sectionPath.getFlsList(); + for (SwitchElement element : sectionPath.getSwitchList()) { + Switch aSwitch = element.getASwitch(); + aSwitch.overlapUnLock(); + unlockFlsOfSwitch(flsList, aSwitch); + } } public void unlockFlsOfSwitch(List flsList, Switch aSwitch) { @@ -132,7 +171,7 @@ public class RouteOverlap extends MapNamedElement { * 延时解锁 */ public void releaseProgress() { - if(this.releasing) { // 解锁中 + if (this.releasing) { // 解锁中 this.remainTime -= SimulationModule.CI.getRateMs(); if (this.remainTime <= 0) { this.releaseImmediately(); @@ -142,6 +181,7 @@ public class RouteOverlap extends MapNamedElement { /** * 包含直向路径 + * * @return */ public boolean hasStraightPath() { @@ -178,7 +218,7 @@ public class RouteOverlap extends MapNamedElement { } public SectionPath selectPath() { - if(!CollectionUtils.isEmpty(this.pathList) && !this.isOnlyOnePath()) { + if (!CollectionUtils.isEmpty(this.pathList) && !this.isOnlyOnePath()) { for (SectionPath sectionPath : this.pathList) { if (!CollectionUtils.isEmpty(sectionPath.getSwitchList())) { boolean onPosition = true; @@ -187,7 +227,7 @@ public class RouteOverlap extends MapNamedElement { onPosition = false; break; } - if (!element.getASwitch().isOnPosition(element.isNormal())) { + if (!element.isOnPosition()) { onPosition = false; break; } @@ -215,63 +255,6 @@ public class RouteOverlap extends MapNamedElement { return false; } - public boolean isRouteLastSection(Section section) { - return this.section.isSamePhysical(section.getCode()); - } - - public void allowLock() { - this.forbidden = false; - } - - /** - * 是否折返车站处,且路径中包含道岔的延续保护 - * @return - */ - public boolean isTurnBackStationHasSwitch() { - return this.getSection().isNormalStandTrack() && - this.getSection().getStation().isTurnBack() && - this.isPathContainSwitch(); - } - - private boolean isPathContainSwitch() { - return !CollectionUtils.isEmpty(this.pathList.get(0).getSwitchList()); - } - - public void settingFailed() { -// this.lock = false; - this.setting = false; - this.settingStartTime = null; - } - - public void updateRequisition(boolean requisition) { - this.requisition = requisition; - } - - /** - * 有延续保护的元素处于锁闭状态 - */ - public boolean allSectionsOl() { - if (!CollectionUtils.isEmpty(this.pathList)) { - for (SectionPath path : this.pathList) { - List
logicList = path.getLogicList(); - if (!CollectionUtils.isEmpty(logicList)) { - for (Section logic : logicList) { - if (!logic.isOverlapLock()) { - return false; - } - } - } else { - for (Section s : path.getSectionList()) { - if (!s.isOverlapLock()) { - return false; - } - } - } - } - } - return true; - } - public void setLock(boolean lock) { this.signal.setOverlapLock(lock); this.lock = lock; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlapElement.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlapElement.java index 0447acb31..46f396fa4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlapElement.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/RouteOverlapElement.java @@ -23,24 +23,6 @@ public class RouteOverlapElement { /** 延续保护道岔 */ private List switchElementList; - /** - * 是否所有延续道岔都在定义的位置 - * @return - */ - public boolean isAllSwitchRouteLockOnPosition() { - boolean lockOnPosition = true; - if (!CollectionUtils.isEmpty(this.switchElementList)) { - for (SwitchElement switchElement : this.switchElementList) { - if(!(switchElement.getASwitch().isOnPosition(switchElement.isNormal()) && - switchElement.getASwitch().isRouteLock())) { - lockOnPosition = false; - break; - } - } - } - return lockOnPosition; - } - /** * 直向延续保护 * @return diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java index 25792c5e6..5461909e5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java @@ -20,7 +20,7 @@ import java.util.Objects; */ @Getter @Setter -public class Section extends MayOutOfOrderDevice { +public class Section extends DelayUnlockDevice { public Section(String code, String name) { super(code, name, DeviceType.SECTION); @@ -222,11 +222,6 @@ public class Section extends MayOutOfOrderDevice { */ private int speedUpLimit = -1; - /** - * 区故解第一根延时解锁剩余时间,单位ms - */ - private int delayTime; - /** * 无状态(哈尔滨灰显) */ @@ -266,7 +261,6 @@ public class Section extends MayOutOfOrderDevice { this.invalid = false; this.faultLock = false; this.speedUpLimit = -1; - this.delayTime = 0; this.noStatus = false; this.delayUnlock = false; this.closeInit = false; @@ -364,9 +358,9 @@ public class Section extends MayOutOfOrderDevice { if (relSwitch.isA(this)) { if ((right && a.getLeftSection() != null) || (!right && a.getRightSection() != null)) { - if (relSwitch.isNormalPosition()) { + if (relSwitch.isPosN()) { return relSwitch.getB(); - } else if (relSwitch.isReversePosition()) { + } else if (relSwitch.isPosR()) { return relSwitch.getC(); } } else { @@ -377,8 +371,8 @@ public class Section extends MayOutOfOrderDevice { return this.rightSection; } else if(!right && a.getRightSection() != null) { return this.leftSection; - } else if ((relSwitch.isNormalPosition() && relSwitch.isB(this)) || - (relSwitch.isReversePosition() && relSwitch.isC(this))) { + } else if ((relSwitch.isPosN() && relSwitch.isB(this)) || + (relSwitch.isPosR() && relSwitch.isC(this))) { return a; } } @@ -615,9 +609,9 @@ public class Section extends MayOutOfOrderDevice { List relSwitchList = this.getRelSwitchList(); relSwitchList.forEach(aSwitch -> { atpSectionList.add(aSwitch.getA()); - if (aSwitch.isNormalPosition()) { + if (aSwitch.isPosN()) { atpSectionList.add(aSwitch.getB()); - } else if (aSwitch.isReversePosition()) { + } else if (aSwitch.isPosR()) { atpSectionList.add(aSwitch.getC()); } }); @@ -702,9 +696,9 @@ public class Section extends MayOutOfOrderDevice { */ public void overlapUnlocking() { this.overlapLock = false; - if (!CollectionUtils.isEmpty(this.logicList)) { - this.logicList.forEach(logic -> logic.overlapUnlocking()); - } +// if (!CollectionUtils.isEmpty(this.logicList)) { +// this.logicList.forEach(logic -> logic.overlapUnlocking()); +// } } public boolean isSamePhysical(String sectionCode) { @@ -793,9 +787,9 @@ public class Section extends MayOutOfOrderDevice { List
atpSectionList = new ArrayList<>(); Switch relSwitch = this.getRelSwitch(); atpSectionList.add(relSwitch.getA()); - if (relSwitch.isNormalPosition()) { + if (relSwitch.isPosN()) { atpSectionList.add(relSwitch.getB()); - } else if (relSwitch.isReversePosition()) { + } else if (relSwitch.isPosR()) { atpSectionList.add(relSwitch.getC()); } return atpSectionList; @@ -807,9 +801,9 @@ public class Section extends MayOutOfOrderDevice { List relSwitchList = parent.getRelSwitchList(); relSwitchList.forEach(relSwitch -> { atpSectionList.add(relSwitch.getA()); - if (relSwitch.isNormalPosition()) { + if (relSwitch.isPosN()) { atpSectionList.add(relSwitch.getB()); - } else if (relSwitch.isReversePosition()) { + } else if (relSwitch.isPosR()) { atpSectionList.add(relSwitch.getC()); } }); @@ -828,10 +822,10 @@ public class Section extends MayOutOfOrderDevice { List relSwitchList = this.getRelSwitchList(); for (Switch aSwitch : relSwitchList) { aSwitch.getA().setNctOccupied(true); - if (aSwitch.isNormalPosition()) { + if (aSwitch.isPosN()) { aSwitch.getB().setNctOccupied(true); aSwitch.getC().setNctOccupied(false); - } else if (aSwitch.isReversePosition()) { + } else if (aSwitch.isPosR()) { aSwitch.getC().setNctOccupied(true); aSwitch.getB().setNctOccupied(false); } else { @@ -877,9 +871,9 @@ public class Section extends MayOutOfOrderDevice { List relSwitchList = this.getRelSwitchList(); for (Switch aSwitch : relSwitchList) { aSwitch.getA().setInvalid(false); - if (aSwitch.isNormalPosition()) { + if (aSwitch.isPosN()) { aSwitch.getB().setInvalid(false); - } else if (aSwitch.isReversePosition()) { + } else if (aSwitch.isPosR()) { aSwitch.getC().setInvalid(false); } else { aSwitch.getB().setInvalid(false); @@ -916,7 +910,6 @@ public class Section extends MayOutOfOrderDevice { } public void delayUnlock(int delayTime) { - setDelayTime(delayTime); setDelayUnlock(true); } @@ -937,6 +930,10 @@ public class Section extends MayOutOfOrderDevice { return this.routeLock && Objects.equals(this.lockRight, right); } + public boolean isOverlapLockOn(boolean right) { + return this.overlapLock && this.lockRight == right; + } + /** * 获取道岔计轴区段关联的道岔区段中,道岔区段对应方向有连接区段(且此连接区段不是此道岔计轴区段的一员)的道岔区段 * @@ -974,7 +971,7 @@ public class Section extends MayOutOfOrderDevice { public Float getNeedLimitSpeed() { if (this.getSpeedUpLimit() >= 0) { return this.getSpeedUpLimit() / 3.6f; - } else if (this.isSwitchTrack() && this.getRelSwitch().isReversePosition()) { + } else if (this.isSwitchTrack() && this.getRelSwitch().isPosR()) { return 30 / 3.6f; } else if (this.isStandTrack() || isLogicStandTrack()) { //站台逻辑区段默认限速 return 45 / 3.6f; @@ -1126,10 +1123,10 @@ public class Section extends MayOutOfOrderDevice { List relSwitchList = this.getRelSwitchList(); for (Switch aSwitch : relSwitchList) { aSwitch.getA().setInvalid(true); - if (aSwitch.isNormalPosition()) { + if (aSwitch.isPosN()) { aSwitch.getB().setInvalid(true); aSwitch.getC().setInvalid(false); - } else if (aSwitch.isReversePosition()) { + } else if (aSwitch.isPosR()) { aSwitch.getC().setInvalid(true); aSwitch.getB().setInvalid(false); } else { @@ -1148,6 +1145,29 @@ public class Section extends MayOutOfOrderDevice { return !this.isNormalStandTrack() && this.isTurnBackTrack(); } + public boolean isLogicOverlapLock() { + if (!CollectionUtils.isEmpty(this.logicList)) { + for (Section section : this.logicList) { + if (section.isOverlapLock()) { + return true; + } + } + } + return false; + } + + public boolean isFaultOccupied() { + if (this.isOccupied() && + this.getVirtualAxleCounter() != null && + this.getFault() != null && + (AxleFault.FAULT.equals(this.getFault()) || AxleFault.CBTC_OCCUPIED_FAULT.equals(this.getFault()))) { + return true; + } else if (this.getParent() != null) { + return this.getParent().isFaultOccupied(); + } + return false; + } + public enum SectionRoadType { /** * 左行线 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/SectionPath.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/SectionPath.java index 8e22d5417..25b53d4f4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/SectionPath.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/SectionPath.java @@ -165,4 +165,12 @@ public class SectionPath { public boolean containSwitch(Switch aSwitch) { return this.switchList.stream().anyMatch(se -> Objects.equals(se.getASwitch(), aSwitch)); } + + public Section getFirstSection() { + if (!CollectionUtils.isEmpty(this.getLogicList())) { + return this.getLogicList().get(0); + } else { + return this.getSectionList().get(0); + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java index b4183db3c..eeefd6584 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java @@ -1,7 +1,8 @@ package club.joylink.rtss.simulation.cbtc.data.map; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.constant.SignalModel; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; -import club.joylink.rtss.simulation.cbtc.data.support.SignalApproachMessage; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; import lombok.Getter; import lombok.Setter; @@ -19,11 +20,10 @@ import java.util.stream.Collectors; */ @Getter @Setter -public class Signal extends MayOutOfOrderDevice { +public class Signal extends DelayUnlockDevice { public Signal(String code, String name) { super(code, name, DeviceType.SIGNAL); - this.redOpen = true; this.routeList = new ArrayList<>(); this.overlapList = new ArrayList<>(); } @@ -31,7 +31,10 @@ public class Signal extends MayOutOfOrderDevice { // ------------------固有属性/关联关系--------------------- private String showName; - + /** + * 信号机灯位类型 + */ + private SignalModel signalModel; /** * 设备集中站 */ @@ -107,6 +110,9 @@ public class Signal extends MayOutOfOrderDevice { */ private boolean ctc; + /** CTC级别是否办理延续保护 */ + private boolean ctcSetOverlap; + /** * 虚拟真实室外信号机 */ @@ -143,6 +149,10 @@ public class Signal extends MayOutOfOrderDevice { // ------------------状态属性--------------------- + private int mode; + public static final int Mode_BM = 0;//后备模式 + public static final int Mode_CBTC = 1;//CBTC模式 + /** * 当前锁闭的进路 */ @@ -152,10 +162,10 @@ public class Signal extends MayOutOfOrderDevice { * 信号级别:0-不可用;1-关闭;2-引导级;3-主信号级 */ private int level; - public static final int LEVEL_0 = 0; //不可用 - public static final int LEVEL_1 = 1; //关闭 - public static final int LEVEL_2 = 2; //引导级 - public static final int LEVEL_3 = 3; //主信号级 + public static final int LEVEL_Close = 0; //关闭 + public static final int LEVEL_Guide = 1; //引导级 + public static final int LEVEL_Atp = 2; //ATP级 + public static final int LEVEL_Main = 3; //主信号级 /** * 是否封锁 @@ -177,35 +187,15 @@ public class Signal extends MayOutOfOrderDevice { private boolean logicLight; /** - * 绿灯开放 + * 当前信号显示 */ - private boolean greenOpen; - - /** - * 黄灯开放 - */ - private boolean yellowOpen; - - /** - * 红灯开放 - */ - private boolean redOpen; - - /** - * 信号机延时解锁倒计时,单位ms - */ - private int delayTime; + private SignalAspect aspect; /** * 引导信号开放剩余时间,单位ms */ private int guideRemain; - /** - * 列车接近信息:0-无接近列车;1-接近为通信车;2-接近为非通信车 - */ - private SignalApproachMessage.ApproachMessage approachMsg; - /** * 强制物理点灯 */ @@ -237,18 +227,15 @@ public class Signal extends MayOutOfOrderDevice { @Override public void reset() { super.reset(); + this.changeToCbtcMode(); this.lockedRoute = null; - this.level = 1; + this.level = LEVEL_Close; this.blockade = false; this.reblockade = false; this.fpl = false; this.logicLight = this.isCtc(); - this.greenOpen = false; - this.yellowOpen = false; - this.redOpen = true; - this.delayTime = 0; + this.aspect = this.signalModel.getDefaultAspect(); this.guideRemain = 0; - this.approachMsg = SignalApproachMessage.ApproachMessage.NULL; this.forcePhysical = false; this.noStatus = false; this.init = false; @@ -261,6 +248,40 @@ public class Signal extends MayOutOfOrderDevice { return Objects.hash(getCode()); } + public boolean isCbtcMode() { + return this.mode == Mode_CBTC; + } + + /** + * 切换为CBTC模式 + * @return + */ + public boolean changeToCbtcMode() { + if (!this.isCtc()) { + return false; + } + if (this.mode != Mode_CBTC) { + this.mode = Mode_CBTC; + return true; + } + return false; + } + + /** + * 切换为后备模式 + * @return + */ + public boolean changeToBackupMode() { + if (this.getVirtualSignal() == null) { + return false; + } + if (this.mode != Mode_BM) { + this.mode = Mode_BM; + return true; + } + return false; + } + public void changeLightType(boolean logic) { if (SignalFault.MAIN_FILAMENT_BROKEN.equals(getFault()) && logic) { return; @@ -279,25 +300,22 @@ public class Signal extends MayOutOfOrderDevice { } } - /** - * 信号是否关闭 - * - * @return - */ - public boolean isClose() { - return this.redOpen && !this.greenOpen && !this.yellowOpen; - } - /** * 是否开启引导信号 */ - public boolean isGuideOpen() { - return !isGreenOpen() && isYellowOpen() && this.isRedOpen(); + public boolean isGuideAspect() { + return this.aspect != null && this.aspect.equals(this.signalModel.getGuideAspect()); + } + /** + * 是否禁止信号 + * @return + */ + public boolean isForbidAspect() { + return this.aspect != null && this.aspect.equals(this.signalModel.getDefaultAspect()); } - public boolean isNormalOpen() { - return !this.redOpen && - ((this.greenOpen && !this.yellowOpen) || (!this.greenOpen && this.yellowOpen)); + public boolean isMainAspect() { + return this.signalModel.getMainAspects() != null && this.signalModel.getMainAspects().contains(this.aspect); } public boolean isCtcApproachSection(String sectionCode) { @@ -313,7 +331,7 @@ public class Signal extends MayOutOfOrderDevice { if (logic.isSwitchTrack()) { Switch relSwitch = logic.getRelSwitch(); SwitchElement switchElement = elementMap.get(relSwitch.getCode()); - if (!relSwitch.isOnPosition(switchElement.isNormal())) { + if (!switchElement.isOnPosition()) { break; } } @@ -326,7 +344,7 @@ public class Signal extends MayOutOfOrderDevice { if (approach.isSwitchTrack()) { Switch relSwitch = approach.getRelSwitch(); SwitchElement element = elementMap.get(relSwitch.getCode()); - if (!relSwitch.isOnPosition(element.isNormal())) { + if (!element.isOnPosition()) { break; } } @@ -353,7 +371,7 @@ public class Signal extends MayOutOfOrderDevice { } else if (approach.isSwitchTrack()) { Switch relSwitch = approach.getRelSwitch(); SwitchElement element = elementMap.get(relSwitch.getCode()); - if (relSwitch.isOnPosition(element.isNormal())) { + if (element.isOnPosition()) { continue; } else { break; @@ -369,14 +387,6 @@ public class Signal extends MayOutOfOrderDevice { return Objects.nonNull(this.getLockedRoute()) ? this.lockedRoute.getCode() : null; } - public boolean isNctApproach() { - return Objects.equals(this.approachMsg, SignalApproachMessage.ApproachMessage.NCT); - } - - public boolean isCbtcApproach() { - return Objects.equals(this.approachMsg, SignalApproachMessage.ApproachMessage.CBTC); - } - public void updateApproachLock() { if (CollectionUtils.isEmpty(approachPathList)) return; @@ -441,6 +451,11 @@ public class Signal extends MayOutOfOrderDevice { return SignalType.TRANSMISSION.equals(this.type); } + public boolean isDepotSameSignal(Signal signal) { + return this.type.equals(signal.getType()) + || (this.type.equals(SignalType.SHUNTING2) && signal.getType().equals(SignalType.SHUNTING)); + } + /** * 是否与轨道常规运行方向相反 * @@ -459,12 +474,6 @@ public class Signal extends MayOutOfOrderDevice { || (!this.isRight() && Objects.equals(this.section.getRoadType(), Section.SectionRoadType.LEFT)); } - public void apply(boolean greenOpen, boolean yellowOpen, boolean redOpen) { - this.greenOpen = greenOpen; - this.yellowOpen = yellowOpen; - this.redOpen = redOpen; - } - public void guideStart() { this.guideRemain = 30 * 1000; } @@ -550,6 +559,43 @@ public class Signal extends MayOutOfOrderDevice { return itcMaCalPosition; } + /** + * 引导信号控制级别 + * @return + */ + public boolean isGuideLevel() { + return this.level == LEVEL_Guide; + } + + /** + * ATP 移动闭塞信号控制级别 + * @return + */ + public boolean isAtpLevel() { + return this.level == LEVEL_Atp; + } + + /** + * 主信号控制级别 + * @return + */ + public boolean isMainLevel() { + return this.level == LEVEL_Main; + } + + public SignalAspect getMaxAspectByLevel(SignalAspect aspect) { + switch (this.level) { + case LEVEL_Close: + return this.signalModel.getDefaultAspect(); + case LEVEL_Guide: + return this.signalModel.getGuideAspect() != null ? signalModel.getGuideAspect() : signalModel.getDefaultAspect(); + case LEVEL_Atp: + case LEVEL_Main: + return aspect; + } + return this.signalModel.getDefaultAspect(); + } + public enum LightColor { RED, YELLOW, @@ -597,6 +643,10 @@ public class Signal extends MayOutOfOrderDevice { * 出站信号机 */ EXIT, + /** + * 列车兼调车信号机 + */ + SHUNTING2, } public enum SignalFault implements DeviceFault { @@ -606,19 +656,20 @@ public class Signal extends MayOutOfOrderDevice { MAIN_FILAMENT_BROKEN { @Override public boolean apply(MayOutOfOrderDevice device) { - if (Objects.equals(device.getFault(), this)) { - return false; - } - Signal signal = (Signal) device; - if (signal.isVirtual()) - return false; - device.setFault(this); - signal.changeLightType(false); //改为物理点灯 - signal.apply(false, false, true); - VirtualRealitySignal realSignal = signal.getVirtualSignal(); - if (realSignal != null) { - VirtualRealitySignal.Fault.MAIN_FILAMENT_BROKEN.apply(realSignal); - } + // todo 信号机故障逻辑 +// if (Objects.equals(device.getFault(), this)) { +// return false; +// } +// Signal signal = (Signal) device; +// if (signal.isVirtual()) +// return false; +// device.setFault(this); +// signal.changeLightType(false); //改为物理点灯 +// signal.apply(false, false, true); +// VirtualRealitySignal realSignal = signal.getVirtualSignal(); +// if (realSignal != null) { +// VirtualRealitySignal.Fault.MAIN_FILAMENT_BROKEN.apply(realSignal); +// } // if (!signal.isLogicLight()) { //如果是物理点灯 // VirtualRealitySignal realSignal = signal.getVirtualSignal(); // realSignal.apply(false, false, true); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java index fb7f32637..82c097dd4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java @@ -453,7 +453,7 @@ public class Stand extends MayOutOfOrderDevice { VirtualRealityScreenDoor vrPSD = psd.getVirtualScreenDoor(); vrPSD.getFault().fix(vrPSD); if (!stand.isTrainParking()) - vrPSD.startSetting(false); + vrPSD.control(VirtualRealityScreenDoor.Operation.G); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java index e5bba1c03..89b71a48d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java @@ -1,10 +1,10 @@ package club.joylink.rtss.simulation.cbtc.data.map; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; import lombok.Getter; import lombok.Setter; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -15,12 +15,9 @@ import java.util.stream.Collectors; */ @Getter @Setter -public class Switch extends MayOutOfOrderDevice { +public class Switch extends DelayUnlockDevice { public Switch(String code, String name) { super(code, name, DeviceType.SWITCH); - // 初始化为定位 - this.normalPosition = true; - this.reversePosition = false; } // ------------------固有属性/关联关系--------------------- @@ -93,21 +90,10 @@ public class Switch extends MayOutOfOrderDevice { * 是否引导总锁 */ private boolean masterGuideLock; - /** - * 是否定位 + * 道岔位置表示 */ - private boolean normalPosition; - - /** - * 是否反位 - */ - private boolean reversePosition; - - /** - * 延时区段故障解锁剩余时间,单位ms - */ - private int delayTime; + private SwitchIndication pos; /** * 无状态 @@ -143,6 +129,15 @@ public class Switch extends MayOutOfOrderDevice { * 初始化 */ private boolean init; + /** + * 道岔强扳授权剩余时间,单位ms + */ + private int forceTurnRemain; + + /** + * 上一次是否是将道岔转向定位 + */ + private Boolean lastTurnToNormal; @Override public void reset() { @@ -155,9 +150,7 @@ public class Switch extends MayOutOfOrderDevice { this.fpLock = false; this.overlapLock = false; this.masterGuideLock = false; - this.normalPosition = true; - this.reversePosition = false; - this.delayTime = 0; + this.pos = SwitchIndication.N; this.noStatus = false; this.preReset = false; this.auto = true; @@ -165,6 +158,8 @@ public class Switch extends MayOutOfOrderDevice { this.interlockReserve = false; this.blockadeInvalid = false; this.init = false; + this.lastTurnToNormal = null; + this.forceTurnRemain = 0; } /** @@ -181,13 +176,6 @@ public class Switch extends MayOutOfOrderDevice { return this.a.isOccupied() && !this.a.isInvalid(); } - /** - * 道岔是否在定/反位上 - */ - public boolean isOnPosition(boolean normal) { - return (this.normalPosition && normal) || (!normal && this.reversePosition); - } - /** * 是否道岔关联的区段 */ @@ -197,13 +185,6 @@ public class Switch extends MayOutOfOrderDevice { Objects.equals(this.c.getCode(), section.getCode()); } - public Section getNextSectionOnBaseSection(Section section) { - if (!this.getVirtualSwitch().isNormal() && !this.getVirtualSwitch().isReverse()) { // 失表 - return null; - } - return this.getNextSectionOnBaseSectionAndPosition(section, this.getVirtualSwitch().isNormal()); - } - public Section getNextSectionOnBaseSectionAndPosition(Section section, boolean normal) { if (normal) { if (Objects.equals(this.a.getCode(), section.getCode())) { @@ -230,34 +211,15 @@ public class Switch extends MayOutOfOrderDevice { return !this.isLocked() && !this.isSectionOccupied(); } - /** - * 采集应用虚拟真实设备状态 - * - * @param normal - * @param reverse - */ - public void apply(boolean normal, boolean reverse) { - /*this.normalPosition = normal; - this.reversePosition = reverse; - if (normal || reverse) { - this.split = false; - }*/ - - this.normalPosition = normal; - this.reversePosition = reverse; -// if (!normal && !reverse) { -// this.setFault(SwitchFault.SPLIT); -// } else { -// this.setFault(null); -// } - } - public void routeLock(Route route) { this.routeLock = true; this.route = route; } public void routeUnlock() { + this.a.routeUnlocking(this.route); + this.b.routeUnlocking(this.route); + this.c.routeUnlocking(this.route); this.routeLock = false; this.route = null; this.checkAndResetUsePosition(); @@ -285,6 +247,9 @@ public class Switch extends MayOutOfOrderDevice { } public void overlapUnLock() { + this.a.overlapUnlocking(); + this.b.overlapUnlocking(); + this.c.overlapUnlocking(); this.overlapLock = false; this.checkAndResetUsePosition(); } @@ -354,14 +319,6 @@ public class Switch extends MayOutOfOrderDevice { return null; } - public boolean isSectionRouteLock() { - return this.getA().isRouteLock(); - } - - public boolean isTurning() { - return !this.isNormalPosition() && !this.isReversePosition(); - } - public boolean isBConnectTo(Switch otherSwitch) { Section leftSection = this.getB().getLeftSection(); Section rightSection = this.getB().getRightSection(); @@ -377,18 +334,14 @@ public class Switch extends MayOutOfOrderDevice { return false; } - public boolean isRouteLockOn(boolean normal) { - return this.isRouteLock() && this.isOnPosition(normal); - } - public Section getNextSectionBaseRealSwitch(Section section) { - if (this.virtualSwitch.isNormal()) { + if (this.virtualSwitch.isPosN()) { if (Objects.equals(this.a.getCode(), section.getCode())) { return this.b; } else if (Objects.equals(this.b.getCode(), section.getCode())) { return this.a; } - } else if (this.virtualSwitch.isReverse()) { + } else if (this.virtualSwitch.isPosR()) { if (Objects.equals(this.a.getCode(), section.getCode())) { return this.c; } else if (Objects.equals(this.c.getCode(), section.getCode())) { @@ -423,23 +376,8 @@ public class Switch extends MayOutOfOrderDevice { * 是否失表 */ public boolean isLoss() { - return !this.isNormalPosition() && !this.isReversePosition(); - } - - /** - * 判断道岔转动的方向 - */ - public boolean judgeTurnToNormal() { - boolean toNormal; - if (this.reversePosition) { - toNormal = true; - } else if (this.normalPosition) { - toNormal = false; - } else { - VirtualRealitySwitch virtualSwitch = this.virtualSwitch; - return !virtualSwitch.isToNormal(); - } - return toNormal; + return SwitchIndication.NO.equals(this.pos) || + SwitchIndication.EX.equals(this.pos); } /** @@ -455,10 +393,9 @@ public class Switch extends MayOutOfOrderDevice { } public void faultUnlock() { - setRouteLock(false); - setOverlapLock(false); - setFpLock(false); - setRoute(null); + this.routeUnlock(); + this.overlapUnLock(); + this.fpUnlock(); } /** @@ -507,11 +444,11 @@ public class Switch extends MayOutOfOrderDevice { } public void ctcOccupy() { - if (this.isNormalPosition()) { + if (this.isPosN()) { this.getA().setCtOccupied(true); this.getB().setCtOccupied(true); this.getC().setCtOccupied(false); - } else if (this.isReversePosition()) { + } else if (this.isPosR()) { this.getA().setCtOccupied(true); this.getB().setCtOccupied(false); this.getC().setCtOccupied(true); @@ -539,6 +476,74 @@ public class Switch extends MayOutOfOrderDevice { return false; } + public boolean isPosN() { + return SwitchIndication.N.equals(this.pos); + } + + public boolean isPosR() { + return SwitchIndication.R.equals(this.pos); + } + + public void updatePos(SwitchIndication pos) { + Switch.SwitchFault fault = (Switch.SwitchFault) this.getFault(); + if (fault != null) { + switch (fault) { + case SPLIT: + this.pos = SwitchIndication.NO; + break; + case SQUEEZE: + this.pos = SwitchIndication.EX; + break; + case NORMAL_SPLIT: { + if (pos.equals(SwitchIndication.N)) { + this.pos = SwitchIndication.NO; + } else { + this.pos = pos; + } + break; + } + case REVERSE_SPLIT: { + if (pos.equals(SwitchIndication.R)) { + this.pos = SwitchIndication.NO; + } else { + this.pos = pos; + } + break; + } + } + } else { + this.pos = pos; + } + } + + public void sectionOverlapLocking(boolean right) { + this.a.overlapLocking(right); + if (this.isPosN()) { // 定位 + this.b.overlapLocking(right); + this.c.overlapUnlocking(); + } else if (this.isPosR()) { // 反位 + this.c.overlapLocking(right); + this.b.overlapUnlocking(); + } else { // 失表 + this.b.overlapLocking(right); + this.c.overlapLocking(right); + } + } + + public void sectionRouteLocking(Route route, boolean right) { + this.a.routeLocking(route, right); + if (this.isPosN()) { // 定位 + this.b.routeLocking(route, right); + this.c.routeUnlocking(route); + } else if (this.isPosR()) { // 反位 + this.c.routeLocking(route, right); + this.b.routeUnlocking(route); + } else { // 失表 + this.b.routeLocking(route, right); + this.c.routeLocking(route, right); + } + } + public enum SwitchFault implements DeviceFault { /** * 道岔失表 @@ -551,8 +556,7 @@ public class Switch extends MayOutOfOrderDevice { return false; } aSwitch.setFault(this); - aSwitch.setNormalPosition(false); - aSwitch.setReversePosition(false); + aSwitch.setPos(SwitchIndication.NO); return true; } }, @@ -568,7 +572,9 @@ public class Switch extends MayOutOfOrderDevice { return false; } aSwitch.setFault(this); - aSwitch.setNormalPosition(false); + if (aSwitch.isPosN()) { + aSwitch.setPos(SwitchIndication.NO); + } return true; } }, @@ -584,7 +590,9 @@ public class Switch extends MayOutOfOrderDevice { return false; } aSwitch.setFault(this); - aSwitch.setReversePosition(false); + if (aSwitch.isPosR()) { + aSwitch.setPos(SwitchIndication.NO); + } return true; } }, @@ -599,8 +607,7 @@ public class Switch extends MayOutOfOrderDevice { VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); if (VirtualRealitySwitch.Fault.SQUEEZE.apply(vrSwitch)) { aSwitch.setFault(this); - aSwitch.setNormalPosition(false); - aSwitch.setReversePosition(false); + aSwitch.setPos(SwitchIndication.EX); return true; } return false; @@ -612,7 +619,7 @@ public class Switch extends MayOutOfOrderDevice { Switch aSwitch = (Switch) device; VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); VirtualRealitySwitch.Fault.SQUEEZE.fix(vrSwitch); - vrSwitch.startSetting(true); + vrSwitch.control(VirtualRealitySwitch.Operation.NP); } }, diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/SwitchElement.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/SwitchElement.java index 4633548ec..54fc8f164 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/SwitchElement.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/SwitchElement.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data.map; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; import lombok.Getter; import java.util.Objects; @@ -36,6 +37,11 @@ public class SwitchElement { } public boolean isOnPosition() { - return this.aSwitch.isOnPosition(this.isNormal()); +// return this.aSwitch.isOnPosition(this.isNormal()); + return this.aSwitch.getPos().equals(SwitchIndication.of(this.isNormal())); + } + + public boolean isConflict(SwitchElement switchElement) { + return this.getASwitch().equals(switchElement.getASwitch()) && this.isNormal() != switchElement.isNormal(); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/RouteStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/RouteStatus.java index 8f837b685..7d3601fd7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/RouteStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/RouteStatus.java @@ -18,11 +18,6 @@ import java.util.Objects; @Getter public class RouteStatus extends DeviceStatus { - /** 是否CBTC模式 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private boolean cbtcMode; - /** ats自动控制 */ @JsonSerialize(using = Boolean2NumSerializer.class) @JsonDeserialize(using = Boolean2NumDeserializer.class) @@ -75,13 +70,12 @@ public class RouteStatus extends DeviceStatus { public RouteStatus(Route route) { super(route.getCode(), route.getDeviceType()); - this.cbtcMode = route.isCbtcMode(); this.atsControl = route.isAtsControl(); this.fleetMode = route.isFleetMode(); this.ciControl = route.isCiControl(); this.settable = route.isSettable(); this.setting = route.isSetting(); - this.settingGuide = route.isOpenGuide(); + this.settingGuide = route.isGuideSetting(); this.lock = route.isLock(); this.canceling = route.isDelayUnlocking(); this.normalUnlock = route.isNormalUnlock(); @@ -91,7 +85,6 @@ public class RouteStatus extends DeviceStatus { @Override public DeviceStatusVO convert2VO(MapElement device) { RouteStatusVO statusVO = new RouteStatusVO((Route) device); - statusVO.setCbtcMode(cbtcMode); statusVO.setAtsControl(atsControl); statusVO.setFleetMode(fleetMode); statusVO.setCiControl(ciControl); @@ -110,11 +103,6 @@ public class RouteStatus extends DeviceStatus { Route route = (Route) device; RouteStatusVO status = (RouteStatusVO) statusVO; boolean change = false; - if (!Objects.equals(this.cbtcMode, route.isCbtcMode())) { - this.cbtcMode = route.isCbtcMode(); - status.setCbtcMode(this.cbtcMode); - change = true; - } if (!Objects.equals(this.atsControl, route.isAtsControl())) { this.atsControl = route.isAtsControl(); status.setAtsControl(this.atsControl); @@ -140,8 +128,8 @@ public class RouteStatus extends DeviceStatus { status.setSetting(this.setting); change = true; } - if (!Objects.equals(this.settingGuide, route.isOpenGuide())) { - this.settingGuide = route.isOpenGuide(); + if (!Objects.equals(this.settingGuide, route.isGuideSetting())) { + this.settingGuide = route.isGuideSetting(); status.setSettingGuide(this.settingGuide); change = true; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SignalStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SignalStatus.java index 413c8c3e5..5b231f085 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SignalStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SignalStatus.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data.status; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; 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.Signal; @@ -11,8 +12,6 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import lombok.Getter; -import java.time.DayOfWeek; -import java.time.LocalDateTime; import java.util.Objects; /** @@ -45,20 +44,10 @@ public class SignalStatus extends DeviceStatus { @JsonDeserialize(using = Boolean2NumDeserializer.class) private boolean logicLight; - /** 绿灯开放 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private boolean greenOpen; - - /** 黄灯开放 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private boolean yellowOpen; - - /** 红灯开放 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private boolean redOpen; + /** + * 当前信号显示 + */ + private SignalAspect aspect; /** 信号机延时解锁倒计时 */ private Integer remainTime; @@ -82,10 +71,8 @@ public class SignalStatus extends DeviceStatus { this.reblockade = signal.isReblockade(); this.level = signal.getLevel(); this.logicLight = signal.isLogicLight(); - this.greenOpen = signal.isGreenOpen(); - this.yellowOpen = signal.isYellowOpen(); - this.redOpen = signal.isRedOpen(); - this.remainTime = signal.getDelayTime(); + this.aspect = signal.getAspect(); + this.remainTime = signal.getRemain(); this.noStatus = signal.isNoStatus(); this.approachLock = signal.isApproachLock(); this.overlapLock = signal.isOverlapLock(); @@ -122,27 +109,17 @@ public class SignalStatus extends DeviceStatus { status.setLogicLight(this.logicLight); change = true; } - if (!Objects.equals(this.greenOpen, signal.isGreenOpen())) { - this.greenOpen = signal.isGreenOpen(); - status.setGreenOpen(this.greenOpen); + if (!Objects.equals(this.aspect, signal.getAspect())) { + this.aspect = signal.getAspect(); + status.setAspect(this.aspect); change = true; } - if (!Objects.equals(this.yellowOpen, signal.isYellowOpen())) { - this.yellowOpen = signal.isYellowOpen(); - status.setYellowOpen(this.yellowOpen); - change = true; - } - if (!Objects.equals(this.redOpen, signal.isRedOpen())) { - this.redOpen = signal.isRedOpen(); - status.setRedOpen(this.redOpen); - change = true; - } - int delayTime = signal.getDelayTime() / 1000; + int delayTime = signal.getRemain() / 1000; if (this.remainTime != delayTime) { this.remainTime = delayTime; change = true; } - if (signal.getDelayTime() > 0) { + if (signal.getRemain() > 0) { status.setRemainTime(delayTime); } else { status.setRemainTime(null); @@ -179,9 +156,7 @@ public class SignalStatus extends DeviceStatus { public DeviceStatusVO convert2VO(MapElement device) { SignalStatusVO statusVO = new SignalStatusVO((Signal) device); statusVO.setRemainTime(remainTime); - statusVO.setRedOpen(redOpen); - statusVO.setYellowOpen(yellowOpen); - statusVO.setGreenOpen(greenOpen); + statusVO.setAspect(this.aspect); statusVO.setLogicLight(logicLight); statusVO.setBlockade(blockade); statusVO.setLevel(this.level); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SwitchStatus.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SwitchStatus.java index 579c1c3c5..72c53914b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SwitchStatus.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/status/SwitchStatus.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data.status; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.vo.DeviceStatusVO; @@ -45,15 +46,10 @@ public class SwitchStatus extends DeviceStatus { @JsonDeserialize(using = Boolean2NumDeserializer.class) private boolean overlapLock; - /** 是否定位 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private boolean normalPosition; - - /** 是否反位 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private boolean reversePosition; + /** + * 道岔位置表示 + */ + private SwitchIndication pos; /** * 延时区段故障解锁剩余时间,单位s @@ -98,9 +94,8 @@ public class SwitchStatus extends DeviceStatus { this.routeLock = aSwitch.isRouteLock(); this.fpLock = aSwitch.isFpLock(); this.overlapLock = aSwitch.isOverlapLock(); - this.normalPosition = aSwitch.isNormalPosition(); - this.reversePosition = aSwitch.isReversePosition(); - this.delayTime = aSwitch.getDelayTime() / 1000; + this.pos = aSwitch.getPos(); + this.delayTime = aSwitch.getRemain() / 1000; this.noStatus = aSwitch.isNoStatus(); this.preReset = aSwitch.isPreReset(); this.auto = aSwitch.isAuto(); @@ -139,17 +134,12 @@ public class SwitchStatus extends DeviceStatus { status.setOverlapLock(this.overlapLock); change = true; } - if (!Objects.equals(this.normalPosition, aSwitch.isNormalPosition())) { - this.normalPosition = aSwitch.isNormalPosition(); - status.setNormalPosition(this.normalPosition); + if (!Objects.equals(this.pos, aSwitch.getPos())) { + this.pos = aSwitch.getPos(); + status.setPos(this.pos); change = true; } - if (!Objects.equals(this.reversePosition, aSwitch.isReversePosition())) { - this.reversePosition = aSwitch.isReversePosition(); - status.setReversePosition(this.reversePosition); - change = true; - } - int dt = aSwitch.getDelayTime() / 1000; + int dt = aSwitch.getRemain() / 1000; if (dt != this.delayTime) { this.delayTime = dt; status.setDelayTime(dt); @@ -196,8 +186,7 @@ public class SwitchStatus extends DeviceStatus { @Override public DeviceStatusVO convert2VO(MapElement device) { SwitchStatusVO statusVO = new SwitchStatusVO((Switch) device); - statusVO.setReversePosition(reversePosition); - statusVO.setNormalPosition(normalPosition); + statusVO.setPos(this.pos); statusVO.setOverlapLock(overlapLock); statusVO.setRouteLock(routeLock); statusVO.setFpLock(fpLock); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDelayUnlockDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDelayUnlockDevice.java new file mode 100644 index 000000000..9c47486b5 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageDelayUnlockDevice.java @@ -0,0 +1,27 @@ +package club.joylink.rtss.simulation.cbtc.data.storage.device; + +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 lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public class StorageDelayUnlockDevice extends StorageMayOutOfOrderDevice { + private int remain; + + public StorageDelayUnlockDevice(String code, MayOutOfOrderDevice.DeviceFault fault) { + super(code, fault); + } + + public void saveFrom(DelayUnlockDevice device) { + this.remain = device.getRemain(); + } + + protected void recoverTo(DelayUnlockDevice device, SimulationDataRepository repository) { + device.recover(this.remain); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRoute.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRoute.java index 9f7022d65..a9d41058a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRoute.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRoute.java @@ -1,14 +1,15 @@ 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.DelayUnlockDevice; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.Route; import club.joylink.rtss.simulation.cbtc.data.map.Section; 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; @@ -72,12 +73,8 @@ public class StorageRoute extends StorageDevice { @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean lock; - /** - * 进路是否人解中 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean canceling; + /** 进路延时解锁设备 */ + private String delayUnlockDevice; /** * 是否正常解锁中 @@ -109,10 +106,6 @@ public class StorageRoute extends StorageDevice { public static StorageRoute convert2Storage(Route route) { boolean change = false; StorageRoute storageRoute = new StorageRoute(route.getCode()); - if (!route.isCbtcMode()) { - change = true; - storageRoute.setCbtcMode(route.isCbtcMode()); - } if (!route.isAtsControl()) { change = true; storageRoute.setAtsControl(route.isAtsControl()); @@ -130,17 +123,17 @@ public class StorageRoute extends StorageDevice { storageRoute.setSetting(route.isSetting()); storageRoute.setSettingStartTime(route.getSettingStartTime()); } - if (route.isOpenGuide()) { + if (route.isGuideSetting()) { change = true; - storageRoute.setSettingGuide(route.isOpenGuide()); + storageRoute.setSettingGuide(route.isGuideSetting()); } if (route.isLock()) { change = true; storageRoute.setLock(route.isLock()); } - if (route.isDelayUnlocking()) { + if (route.getDelayUnlockDevice() != null) { change = true; - storageRoute.setCanceling(route.isDelayUnlocking()); + storageRoute.setDelayUnlockDevice(route.getDelayUnlockDevice().getCode()); } if (route.isNormalUnlock()) { change = true; @@ -160,15 +153,16 @@ public class StorageRoute extends StorageDevice { @Override public void recover2Simulation(MapElement element, Simulation simulation, SimulationDataRepository repository) { Route route = (Route) element; - route.setCbtcMode(cbtcMode != null ? cbtcMode : true); route.setAtsControl(atsControl != null ? atsControl : true); route.setFleetMode(fleetMode != null ? fleetMode : false); route.setCiControl(ciControl != null ? ciControl : false); route.setSetting(setting != null? setting : false); route.setSettingStartTime(this.settingStartTime); - route.setOpenGuide(settingGuide != null? settingGuide : false); + route.setGuideSetting(settingGuide != null? settingGuide : false); route.setLock(lock != null ? lock : false); - route.setDelayUnlocking(canceling != null ? canceling : false); + if (this.delayUnlockDevice != null) { + route.setDelayUnlockDevice((DelayUnlockDevice) repository.getByCode(this.delayUnlockDevice)); + } route.setNormalUnlock(normalUnlock != null ? normalUnlock : false); if (Objects.nonNull(this.unlockedSection)) { route.setUnlockedSection(repository.getByCode(this.unlockedSection, Section.class)); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRouteOverlap.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRouteOverlap.java index 543300cd0..1d7d12acd 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRouteOverlap.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageRouteOverlap.java @@ -38,31 +38,16 @@ public class StorageRouteOverlap extends StorageDevice { /** 办理开始时间 */ private LocalDateTime settingStartTime; - /** 设备是否已被征用 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean requisition; /** 是否锁闭 */ @JsonSerialize(using = Boolean2NumSerializer.class) @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean lock; - /** 是否暂时禁止锁闭 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean forbidden; - public StorageRouteOverlap(String code) { super(code); } -// public StorageRouteOverlap(RouteOverlap overlap) { -// super(overlap.getCode()); -// this.releasing = overlap.isReleasing(); -// this.remainTime = overlap.getRemainTime(); -// } - public static StorageRouteOverlap convert2Storage(RouteOverlap overlap) { boolean change = false; StorageRouteOverlap storageOverlap = new StorageRouteOverlap(overlap.getCode()); @@ -74,18 +59,10 @@ public class StorageRouteOverlap extends StorageDevice { change = true; storageOverlap.setSetting(overlap.isSetting()); } - if (overlap.isRequisition()) { - change = true; - storageOverlap.setRequisition(overlap.isRequisition()); - } if (overlap.isLock()) { change = true; storageOverlap.setLock(overlap.isLock()); } - if (overlap.isForbidden()) { - change = true; - storageOverlap.setForbidden(overlap.isForbidden()); - } if (overlap.getRemainTime() > 0) { change = true; storageOverlap.setRemainTime(overlap.getRemainTime()); @@ -108,9 +85,7 @@ public class StorageRouteOverlap extends StorageDevice { overlap.setReleasing(releasing != null ? releasing : false); overlap.setRemainTime(remainTime != null ? remainTime : 0); overlap.setSetting(setting != null ? setting : false); - overlap.setRequisition(requisition != null ? requisition : false); overlap.setLock(lock != null ? lock : false); - overlap.setForbidden(forbidden != null ? forbidden : false); overlap.setSettingStartTime(settingStartTime != null ? settingStartTime : null); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSection.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSection.java index c12b39fe5..592baf67f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSection.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSection.java @@ -18,7 +18,7 @@ import java.util.Objects; @Getter @Setter @NoArgsConstructor -public class StorageSection extends StorageMayOutOfOrderDevice { +public class StorageSection extends StorageDelayUnlockDevice { /** * 是否封锁 @@ -161,9 +161,9 @@ public class StorageSection extends StorageMayOutOfOrderDevice { change = true; storageSection.setSpeedUpLimit(section.getSpeedUpLimit()); } - if (!Objects.equals(section.getDelayTime(), 0)) { + if (section.getRemain() > 0) { change = true; - storageSection.setDelayTime(section.getDelayTime()); + storageSection.saveFrom(section); } if (section.isNoStatus()) { change = true; @@ -193,7 +193,9 @@ public class StorageSection extends StorageMayOutOfOrderDevice { section.setInvalid(invalid != null? invalid : false); section.setFaultLock(faultLock != null ? faultLock : false); section.setSpeedUpLimit(speedUpLimit != null? speedUpLimit : -1); - section.setDelayTime(delayTime != null ? delayTime : 0); + if (this.getRemain() > 0) { + this.recoverTo(section, repository); + } section.setNoStatus(noStatus != null ? noStatus : false); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSignal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSignal.java index 3fc9eb57c..a0a0ca8ca 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSignal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSignal.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.cbtc.data.storage.device; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; 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.MayOutOfOrderDevice; @@ -17,7 +18,7 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -public class StorageSignal extends StorageMayOutOfOrderDevice { +public class StorageSignal extends StorageDelayUnlockDevice { /** * 当前锁闭的进路 @@ -53,6 +54,8 @@ public class StorageSignal extends StorageMayOutOfOrderDevice { @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean logicLight; + private SignalAspect aspect; + /** * 绿灯开放 */ @@ -74,11 +77,6 @@ public class StorageSignal extends StorageMayOutOfOrderDevice { @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean redOpen; - /** - * 信号机延时解锁倒计时 - */ - private Integer delayTime; - /** * 无状态 */ @@ -120,21 +118,13 @@ public class StorageSignal extends StorageMayOutOfOrderDevice { change = true; storageSignal.setLogicLight(signal.isLogicLight()); } - if (signal.isGreenOpen()) { + if (!signal.getSignalModel().getDefaultAspect().equals(signal.getAspect())) { change = true; - storageSignal.setGreenOpen(signal.isGreenOpen()); + storageSignal.setAspect(signal.getAspect()); } - if (signal.isYellowOpen()) { + if (signal.getRemain() > 0) { change = true; - storageSignal.setYellowOpen(signal.isYellowOpen()); - } - if (!signal.isRedOpen()) { - change = true; - storageSignal.setRedOpen(signal.isRedOpen()); - } - if (signal.getDelayTime() > 0) { - change = true; - storageSignal.setDelayTime(signal.getDelayTime()); + storageSignal.saveFrom(signal); } if (signal.isNoStatus()) { change = true; @@ -161,10 +151,12 @@ public class StorageSignal extends StorageMayOutOfOrderDevice { signal.setReblockade(this.reblockade != null ? this.reblockade : false); signal.setFpl(this.fpl != null ? this.fpl : false); signal.setLogicLight(logicLight != null ? logicLight : true); - signal.setGreenOpen(greenOpen != null ? greenOpen : false); - signal.setYellowOpen(yellowOpen != null ? yellowOpen : false); - signal.setRedOpen(redOpen != null ? redOpen : true); - signal.setDelayTime(delayTime != null ? delayTime : 0); + if (aspect != null) { + signal.setAspect(aspect); + } + if (this.getRemain() > 0) { + this.recoverTo(signal, repository); + } signal.setNoStatus(noStatus != null ? noStatus : false); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSwitch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSwitch.java index c64217e46..72f403945 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/device/StorageSwitch.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.cbtc.data.storage.device; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; 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.MayOutOfOrderDevice; @@ -16,7 +17,7 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -public class StorageSwitch extends StorageMayOutOfOrderDevice { +public class StorageSwitch extends StorageDelayUnlockDevice { /** * 是否单锁 @@ -61,23 +62,9 @@ public class StorageSwitch extends StorageMayOutOfOrderDevice { private Boolean masterGuideLock; /** - * 是否定位 + * 道岔位置表示 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean normalPosition; - - /** - * 是否反位 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean reversePosition; - - /** - * 延时区段故障解锁剩余时间 - */ - private Integer delayTime; + private SwitchIndication pos; @JsonSerialize(using = Boolean2NumSerializer.class) @JsonDeserialize(using = Boolean2NumDeserializer.class) @@ -117,17 +104,13 @@ public class StorageSwitch extends StorageMayOutOfOrderDevice { change = true; storageSwitch.setMasterGuideLock(s.isMasterGuideLock()); } - if (!s.isNormalPosition()) { + if (!SwitchIndication.N.equals(s.getPos())) { change = true; - storageSwitch.setNormalPosition(s.isNormalPosition()); + storageSwitch.setPos(s.getPos()); } - if (s.isReversePosition()) { + if (s.getRemain() > 0) { change = true; - storageSwitch.setReversePosition(s.isReversePosition()); - } - if (s.getDelayTime() > 0) { - change = true; - storageSwitch.setDelayTime(s.getDelayTime()); + storageSwitch.saveFrom(s); } if (s.isNoStatus()) { change = true; @@ -152,9 +135,12 @@ public class StorageSwitch extends StorageMayOutOfOrderDevice { s.setRouteLock(routeLock != null ? routeLock : false); s.setOverlapLock(overlapLock != null ? overlapLock : false); s.setMasterGuideLock(masterGuideLock != null ? masterGuideLock : false); - s.setNormalPosition(normalPosition != null ? normalPosition : true); - s.setReversePosition(reversePosition != null ? reversePosition : false); - s.setDelayTime(delayTime != null ? delayTime : 0); + if (pos != null) { + s.setPos(pos); + } + if (this.getRemain() > 0) { + this.recoverTo(s, repository); + } s.setNoStatus(noStatus != null ? noStatus : false); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageControllableVrDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageControllableVrDevice.java new file mode 100644 index 000000000..cabddccfe --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageControllableVrDevice.java @@ -0,0 +1,32 @@ +package club.joylink.rtss.simulation.cbtc.data.storage.vr; + +import club.joylink.rtss.simulation.cbtc.data.vr.ControllableVrDevice; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@NoArgsConstructor +public abstract class StorageControllableVrDevice extends StorageVirtualRealityDeviceStatus { + /** + * 控制指令 + */ + private C command; + /** + * 剩余时间 + */ + private int remain; + + public StorageControllableVrDevice(VirtualRealityDevice device) { + super(device); + } + + public void saveFrom(ControllableVrDevice device) { + this.command = (C) device.getCommand(); + this.remain = device.getRemain(); + } + + public void recoverTo(ControllableVrDevice device) { + device.recover(this.command, this.remain); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageTrainDoor.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageTrainDoor.java index 3e22e2e63..efb0f57dc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageTrainDoor.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageTrainDoor.java @@ -1,10 +1,12 @@ package club.joylink.rtss.simulation.cbtc.data.storage.vr; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; 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; @@ -14,7 +16,7 @@ import java.util.Objects; @Getter @Setter @NoArgsConstructor -public class StorageTrainDoor { +public class StorageTrainDoor extends StorageControllableVrDevice { private String code; @JsonSerialize(using = Boolean2NumSerializer.class) @@ -25,30 +27,13 @@ public class StorageTrainDoor { @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean lock; - /** 是否开/关门过程中 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean turning; - - /** - * 命令:true-开门命令,false-关门命令 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean commandOpen; - - /** - * 过程剩余时间 - */ - private float remainTime; - public StorageTrainDoor(VirtualRealityTrain.Door door) { this.code = door.getCode(); this.close = door.isClose(); this.lock = door.isLock(); - this.turning = door.isTurning(); - this.commandOpen = door.isCommandOpen(); - this.remainTime = door.getRemainTime(); + if (door.isTurning()) { + this.saveFrom(door); + } } public void recover2Simulation(VirtualRealityTrain.Door door) { @@ -58,14 +43,13 @@ public class StorageTrainDoor { if (Objects.nonNull(this.lock)) { door.setLock(lock); } - if (Objects.nonNull(this.turning)) { - door.setTurning(turning); - } - if (Objects.nonNull(this.commandOpen)) { - door.setCommandOpen(commandOpen); - } - if (Objects.nonNull(this.remainTime)) { - door.setRemainTime(remainTime); + if (this.getRemain() > 0) { + this.recoverTo(door); } } + + @Override + public void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository) { + + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityScreenDoor.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityScreenDoor.java index aab483c89..e32f7a222 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityScreenDoor.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealityScreenDoor.java @@ -1,22 +1,20 @@ package club.joylink.rtss.simulation.cbtc.data.storage.vr; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; 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; -import java.util.Objects; - @Getter @Setter @NoArgsConstructor -public class StorageVirtualRealityScreenDoor extends StorageVirtualRealityDeviceStatus { +public class StorageVirtualRealityScreenDoor extends StorageControllableVrDevice { /** * 是否关闭 @@ -43,25 +41,6 @@ public class StorageVirtualRealityScreenDoor extends StorageVirtualRealityDevice @JsonDeserialize(using = Boolean2NumDeserializer.class) private Boolean interlockRelease; - /** - * 是否开门/关门过程 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean setting; - - /** - * 开门/关门剩余时间 - */ - private Float remainTime; - - /** - * 开/关门指令:true:开门指令,false:关门指令 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean commandOpen; - private VirtualRealityScreenDoor.Fault fault; public StorageVirtualRealityScreenDoor(VirtualRealityScreenDoor door) { @@ -97,17 +76,9 @@ public class StorageVirtualRealityScreenDoor extends StorageVirtualRealityDevice change = true; screenDoor.setInterlockRelease(door.isInterlockRelease()); } - if (door.isSetting()) { + if (door.isTurning()) { change = true; - screenDoor.setSetting(door.isSetting()); - } - if (Objects.nonNull(door.getRemainTime())) { - change = true; - screenDoor.setRemainTime(door.getRemainTime()); - } - if (door.isCommandOpen()) { - change = true; - screenDoor.setCommandOpen(door.isCommandOpen()); + screenDoor.saveFrom(door); } if (door.getFault() != null) { change = true; @@ -127,9 +98,9 @@ public class StorageVirtualRealityScreenDoor extends StorageVirtualRealityDevice door.setOpen2End(open2End != null ? open2End : false); door.setLock(lock != null ? lock : true); door.setInterlockRelease(interlockRelease != null ? interlockRelease : false); - door.setSetting(setting != null ? setting : false); - door.setRemainTime(remainTime); - door.setCommandOpen(commandOpen != null ? commandOpen : false); + if (this.getRemain() > 0) { + this.recoverTo(door); + } door.setFault(fault); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySignal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySignal.java index e07f40253..7aeeaa223 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySignal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySignal.java @@ -1,12 +1,9 @@ package club.joylink.rtss.simulation.cbtc.data.storage.vr; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; -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; @@ -14,19 +11,9 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -public class StorageVirtualRealitySignal extends StorageVirtualRealityDeviceStatus { +public class StorageVirtualRealitySignal extends StorageControllableVrDevice { - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean greenOpen; - - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean yellowOpen; - - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean redOpen; + private SignalAspect aspect; private VirtualRealitySignal.Fault fault; @@ -37,23 +24,18 @@ public class StorageVirtualRealitySignal extends StorageVirtualRealityDeviceStat public static StorageVirtualRealitySignal convert2Storage(VirtualRealitySignal signal) { boolean change = false; StorageVirtualRealitySignal storageSignal = new StorageVirtualRealitySignal(signal); - if (signal.isGreenOpen()) { + if (!signal.getModel().getDefaultAspect().equals(signal.getAspect())) { change = true; - storageSignal.setGreenOpen(signal.isGreenOpen()); + storageSignal.setAspect(signal.getAspect()); } - if (signal.isYellowOpen()) { + if (signal.isTurning()) { change = true; - storageSignal.setYellowOpen(signal.isYellowOpen()); - } - if (signal.isRedOpen()) { - change = true; - storageSignal.setRedOpen(signal.isRedOpen()); + storageSignal.saveFrom(signal); } if (signal.getFault() != null) { change = true; storageSignal.setFault(signal.getFault()); } - if (change) { return storageSignal; } @@ -63,9 +45,12 @@ public class StorageVirtualRealitySignal extends StorageVirtualRealityDeviceStat @Override public void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository) { VirtualRealitySignal signal = (VirtualRealitySignal) vrDevice; - signal.setGreenOpen(greenOpen != null ? greenOpen : false); - signal.setYellowOpen(yellowOpen != null ? yellowOpen : false); - signal.setRedOpen(redOpen != null ? redOpen : false); + if (this.aspect != null) { + signal.setAspect(this.aspect); + } + if (this.getRemain() > 0) { + this.recoverTo(signal); + } signal.setFault(fault); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySwitch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySwitch.java index 98e8a70d4..8e20c17f8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/storage/vr/StorageVirtualRealitySwitch.java @@ -1,56 +1,18 @@ package club.joylink.rtss.simulation.cbtc.data.storage.vr; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; -import club.joylink.rtss.util.jsonSerialize.Boolean2NumDeserializer; -import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; -import java.util.Objects; - @Getter @Setter @NoArgsConstructor -public class StorageVirtualRealitySwitch extends StorageVirtualRealityDeviceStatus { - - /** - * 是否定位 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean normal; - - /** - * 是否反位 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean reverse; - - // -------------运行逻辑控制参数------------- - /** - * 是否正在转换 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean setting; - - /** - * 道岔转换剩余时间 - */ - private Float remainTime; - - /** - * 道岔转换指令——是否转动到定位 - */ - @JsonSerialize(using = Boolean2NumSerializer.class) - @JsonDeserialize(using = Boolean2NumDeserializer.class) - private Boolean toNormal; +public class StorageVirtualRealitySwitch extends StorageControllableVrDevice { + private SwitchIndication p; public StorageVirtualRealitySwitch(VirtualRealitySwitch s) { super(s); @@ -69,27 +31,14 @@ public class StorageVirtualRealitySwitch extends StorageVirtualRealityDeviceStat public static StorageVirtualRealitySwitch convert2Storage(VirtualRealitySwitch s) { boolean change = false; StorageVirtualRealitySwitch storageSwitch = new StorageVirtualRealitySwitch(s); - if (!s.isNormal()) { + if (!SwitchIndication.N.equals(s.getP())) { change = true; - storageSwitch.setNormal(s.isNormal()); + storageSwitch.setP(s.getP()); } - if (s.isReverse()) { + if (s.isTurning()) { change = true; - storageSwitch.setReverse(s.isReverse()); + storageSwitch.saveFrom(s); } - if (s.isSetting()) { - change = true; - storageSwitch.setSetting(s.isSetting()); - } - if (Objects.nonNull(s.getRemainTime())) { - change = true; - storageSwitch.setRemainTime(s.getRemainTime()); - } - if (s.isToNormal()) { - change = true; - storageSwitch.setToNormal(s.isToNormal()); - } - if (change) { return storageSwitch; } @@ -99,10 +48,11 @@ public class StorageVirtualRealitySwitch extends StorageVirtualRealityDeviceStat @Override public void recover2Simulation(VirtualRealityDevice vrDevice, SimulationDataRepository repository) { VirtualRealitySwitch s = (VirtualRealitySwitch) vrDevice; - s.setNormal(normal != null ? normal : true); - s.setReverse(reverse != null ? reverse : false); - s.setSetting(setting != null ? setting : false); - s.setRemainTime(remainTime); - s.setToNormal(toNormal != null ? toNormal : false); + if (this.p != null) { + s.setP(p); + } + if (this.getRemain() > 0) { + this.recoverTo(s); + } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/RouteStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/RouteStatusVO.java index 9093a9dac..52b10a8f1 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/RouteStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/RouteStatusVO.java @@ -13,10 +13,6 @@ import lombok.Setter; @Setter public class RouteStatusVO extends DeviceStatusVO { - /** 是否CBTC模式 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private Boolean cbtcMode; - /** ats自动控制 */ @JsonSerialize(using = Boolean2NumSerializer.class) private Boolean atsControl; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SignalStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SignalStatusVO.java index 11a0be3b3..99bdc8f04 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SignalStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SignalStatusVO.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data.vo; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; import com.fasterxml.jackson.annotation.JsonInclude; @@ -38,17 +39,10 @@ public class SignalStatusVO extends DeviceStatusVO{ @JsonSerialize(using = Boolean2NumSerializer.class) private Boolean logicLight; - /** 绿灯开放 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private Boolean greenOpen; - - /** 黄灯开放 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private Boolean yellowOpen; - - /** 红灯开放 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private Boolean redOpen; + /** + * 当前信号显示 + */ + private SignalAspect aspect; /** 信号机延时解锁倒计时 */ @JsonInclude(JsonInclude.Include.ALWAYS) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SwitchStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SwitchStatusVO.java index e024bb8a8..e68cf45f4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SwitchStatusVO.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/SwitchStatusVO.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.data.vo; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.util.jsonSerialize.Boolean2NumSerializer; import com.fasterxml.jackson.annotation.JsonInclude; @@ -34,17 +35,16 @@ public class SwitchStatusVO extends DeviceStatusVO { @JsonSerialize(using = Boolean2NumSerializer.class) private Boolean fpLock; - /** 是否进路延续保护锁闭 */ + /** + * 是否进路延续保护锁闭 + */ @JsonSerialize(using = Boolean2NumSerializer.class) private Boolean overlapLock; - /** 是否定位 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private Boolean normalPosition; - - /** 是否反位 */ - @JsonSerialize(using = Boolean2NumSerializer.class) - private Boolean reversePosition; + /** + * 道岔位置表示 + */ + private SwitchIndication pos; @JsonInclude private Integer delayTime; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java index 9bf1d8744..83b8145b2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java @@ -554,6 +554,7 @@ public class TrainInfo extends MapElement { this.destinationCode = ""; this.planRoutingType = null; this.type = TrainType.MANUAL; + this.dt = 0; } public void startTurnBack(Section endSection) { @@ -569,6 +570,7 @@ public class TrainInfo extends MapElement { this.type = TrainType.HEAD; this.routing = null; this.atsTriggerRouteMap.clear(); + this.dt = 0; } public void frontTurnBackStart() { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsIbpStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsIbpStatusVO.java new file mode 100644 index 000000000..5772e3d7f --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsIbpStatusVO.java @@ -0,0 +1,65 @@ +package club.joylink.rtss.simulation.cbtc.data.vo.iscs; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +public class IscsIbpStatusVO extends IscsStatusVO { + /** 上行状态 */ + private DirectionalStatus upStatus; + + /** 下行状态 */ + private DirectionalStatus downStatus; + + public IscsIbpStatusVO(String code, DeviceType deviceType, + DirectionalStatus upStatus, DirectionalStatus downStatus) { + super(code, deviceType); + this.upStatus = upStatus; + this.downStatus = downStatus; + } + + @Getter + public static class DirectionalStatus { + /** 操作允许 */ + private boolean operate; + + /** 开门命令 */ + private boolean openCommand; + + /** 开边门命令 */ + private boolean openSideCommand; + + /** 关门命令 */ + private boolean closeCommand; + + public DirectionalStatus(boolean operate, boolean openCommand, + boolean openSideCommand, boolean closeCommand) { + this.operate = operate; + this.openCommand = openCommand; + this.openSideCommand = openSideCommand; + this.closeCommand = closeCommand; + } + + public boolean compareAndChange(boolean operate, boolean openCommand, boolean openSideCommand, boolean closeCommand) { + boolean change = false; + if (this.operate != operate) { + this.operate = operate; + change = true; + } + if (this.openCommand != openCommand) { + this.openCommand = openCommand; + change = true; + } + if (this.openSideCommand != openSideCommand) { + this.openSideCommand = openSideCommand; + change = true; + } + if (this.closeCommand != closeCommand) { + this.closeCommand = closeCommand; + change = true; + } + return change; + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPsdStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPsdStatusVO.java new file mode 100644 index 000000000..06fb0e20e --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPsdStatusVO.java @@ -0,0 +1,49 @@ +package club.joylink.rtss.simulation.cbtc.data.vo.iscs; + +import lombok.Getter; + +@Getter +public class IscsPsdStatusVO extends IscsStatusVO{ + private DirectionalStatus upStatus; + + private DirectionalStatus downStatus; + + public IscsPsdStatusVO(String code, DeviceType deviceType, + DirectionalStatus upStatus, DirectionalStatus downStatus) { + super(code, deviceType); + this.upStatus = upStatus; + this.downStatus = downStatus; + } + + public enum Status { + OPEN, + CLOSE, + DCU_FAULT, + UNDEFINED, + } + + @Getter + public static class DirectionalStatus { + private Status status; + + private boolean isolationMode; + + public DirectionalStatus(Status status, boolean isolationMode) { + this.status = status; + this.isolationMode = isolationMode; + } + + public boolean compareAndChange(Status status, boolean isolationMode) { + boolean change = false; + if (this.status != status) { + this.status = status; + change = true; + } + if (this.isolationMode != isolationMode) { + this.isolationMode = isolationMode; + change = true; + } + return change; + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPslStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPslStatusVO.java new file mode 100644 index 000000000..9d67eb557 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsPslStatusVO.java @@ -0,0 +1,63 @@ +package club.joylink.rtss.simulation.cbtc.data.vo.iscs; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +public class IscsPslStatusVO extends IscsStatusVO{ + private DirectionalStatus upStatus; + + private DirectionalStatus downStatus; + + public IscsPslStatusVO(String code, DeviceType deviceType, DirectionalStatus upStatus, + DirectionalStatus downStatus) { + super(code, deviceType); + this.upStatus = upStatus; + this.downStatus = downStatus; + } + + @Getter + public static class DirectionalStatus { + /** 操作允许 */ + private boolean operate; + + /** 开门命令 */ + private boolean openCommand; + + /** 关门命令 */ + private boolean closeCommand; + + /** 互锁解除 */ + private boolean interlockRelease; + + public DirectionalStatus(boolean operate, boolean openCommand, + boolean closeCommand, boolean interlockRelease) { + this.operate = operate; + this.openCommand = openCommand; + this.closeCommand = closeCommand; + this.interlockRelease = interlockRelease; + } + + public boolean compareAndChange(boolean operate, boolean openCommand, boolean closeCommand, boolean interlockRelease) { + boolean change = false; + if (this.operate != operate) { + this.operate = operate; + change = true; + } + if (this.openCommand != openCommand) { + this.openCommand = openCommand; + change = true; + } + if (this.closeCommand != closeCommand) { + this.closeCommand = closeCommand; + change = true; + } + if (this.interlockRelease != interlockRelease) { + this.interlockRelease = interlockRelease; + change = true; + } + return change; + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsSafetyCircleStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsSafetyCircleStatusVO.java new file mode 100644 index 000000000..946c896ab --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsSafetyCircleStatusVO.java @@ -0,0 +1,54 @@ +package club.joylink.rtss.simulation.cbtc.data.vo.iscs; + +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +public class IscsSafetyCircleStatusVO extends IscsStatusVO{ + private DirectionalStatus upStatus; + + private DirectionalStatus downStatus; + + public IscsSafetyCircleStatusVO(String code, DeviceType deviceType, + DirectionalStatus upStatus, DirectionalStatus downStatus) { + super(code, deviceType); + this.upStatus = upStatus; + this.downStatus = downStatus; + } + + @Getter + public static class DirectionalStatus { + /** PFDC故障 */ + private boolean pfdcFault; + + /** 总线故障 */ + private boolean busFault; + + /** 安全回路状态 */ + private boolean safetyCircle; + + public DirectionalStatus(boolean pfdcFault, boolean busFault, boolean safetyCircle) { + this.pfdcFault = pfdcFault; + this.busFault = busFault; + this.safetyCircle = safetyCircle; + } + + public boolean compareAndChange(boolean pfdcFault, boolean busFault, boolean safetyCircle) { + boolean change = false; + if (this.pfdcFault != pfdcFault) { + this.pfdcFault = pfdcFault; + change = true; + } + if (this.busFault != busFault) { + this.busFault = busFault; + change = true; + } + if (this.safetyCircle != safetyCircle) { + this.safetyCircle = safetyCircle; + change = true; + } + return change; + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsStatusVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsStatusVO.java new file mode 100644 index 000000000..da129b629 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/iscs/IscsStatusVO.java @@ -0,0 +1,25 @@ +package club.joylink.rtss.simulation.cbtc.data.vo.iscs; + +import club.joylink.rtss.simulation.Watchable; +import lombok.Getter; + +@Getter +public class IscsStatusVO extends Watchable { + private String code; + + private DeviceType deviceType; + + public IscsStatusVO(String code, DeviceType deviceType) { + this.code = code; + this.deviceType = deviceType; + } + + public enum DeviceType { + /** 滑动门 */ + SLIDING_DOOR, + IBP, + PSL, + /** 安全回路 */ + SAFETY_CIRCLE + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/ControllableVrDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/ControllableVrDevice.java new file mode 100644 index 000000000..857ad94de --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/ControllableVrDevice.java @@ -0,0 +1,95 @@ +package club.joylink.rtss.simulation.cbtc.data.vr; + +import lombok.Getter; + +/** + * 可以控制的虚拟真实设备 + */ +@Getter +public abstract class ControllableVrDevice extends VirtualRealityDevice { + /** + * 转换时间,单位ms + */ + private final int turnTime; + /** + * 控制指令 + */ + private C command; + /** + * 剩余时间 + */ + private int remain; + + protected ControllableVrDevice(String code, String name, DeviceType deviceType, int turnTime) { + super(code, name, deviceType); + this.turnTime = turnTime; + } + + @Override + public void reset() { + this.command = null; + this.remain = 0; + } + + public void recover(C command, int remain) { + this.command = command; + this.remain = remain; + } + + public boolean control(C command) { + if (this.command != null && this.command.equals(command)) { //相同指令 + return false; + } + if (!this.checkConditionBeforeControl(command)) { //是否符合条件 + return false; + } + this.command = command; + this.remain = this.turnTime; + return true; + } + + /** + * 接受指定前的条件检查 + * @param command + * @return true-符合条件,可以控制;false-不符合,不能控制 + */ + protected boolean checkConditionBeforeControl(C command) { + return true; + } + + /** + * 是否转换中 + * @return + */ + public boolean isTurning() { + return this.remain > 0; + } + /** + * + * @param interval 转换的间隔时间,单位ms + * @return + */ + public int turning(int interval) { + this.doTurn(); + this.remain -= interval; + if (this.remain <= 0) { + this.finish(); + } + return remain; + } + + public void finish() { + if(this.command == null) + return; + this.doFinish(this.command); + this.remain = 0; + } + + protected void doTurn() {} + + /** + * 完成执行 + * @param command + */ + protected abstract void doFinish(C command); +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityDevice.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityDevice.java index e87dbbe9d..a3ebcacc5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityDevice.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityDevice.java @@ -13,9 +13,6 @@ import java.util.Objects; @Getter public abstract class VirtualRealityDevice extends MapNamedElement { - /** 所属仿真group */ - private String group; - /** 连接的项目真实设备id */ private RealDeviceConfig realDevice; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java index 46772786c..dee04fdde 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityScreenDoor.java @@ -1,6 +1,5 @@ package club.joylink.rtss.simulation.cbtc.data.vr; -import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import lombok.Getter; import lombok.Setter; @@ -10,7 +9,21 @@ import lombok.Setter; */ @Getter @Setter -public class VirtualRealityScreenDoor extends VirtualRealityDevice { +public class VirtualRealityScreenDoor extends ControllableVrDevice { + + public boolean isCommandOpen() { + return Operation.K.equals(this.getCommand()); + } + + /** + * 道岔支持的操作 + */ + public enum Operation { + /** 开门 */ + K, + /** 关门 */ + G, + } /** * 是否关闭 @@ -33,45 +46,64 @@ public class VirtualRealityScreenDoor extends VirtualRealityDevice { private boolean interlockRelease; /** - * 是否开门/关门过程 - */ - private boolean setting; - - /** - * 开门/关门剩余时间 - */ - private Float remainTime; - - /** - * 开/关门指令:true:开门指令,false:关门指令 - */ - private boolean commandOpen; - - /** - * 正处于psl盘控制下 + * psl操作允许 */ private boolean pslControl; + /** + * ibp盘操作允许 + */ + private boolean ibpControl; + private Fault fault; public VirtualRealityScreenDoor(String code, String name) { - super(code, name, MapElement.DeviceType.PSD); + super(code, name, MapElement.DeviceType.PSD, 3*1000); this.close = true; this.lock = true; } @Override public void reset() { + super.reset(); this.close = true; this.lock = true; this.open2End = false; this.interlockRelease = false; - this.setting = false; - this.remainTime = null; this.pslControl = false; this.fault = null; } + @Override + protected void doTurn() { + this.setClose(false); + this.open2End = false; + } + + @Override + protected void doFinish(Operation command) { + switch (command) { + case K:{ + this.setClose(false); + this.open2End = true; + break; + } + case G: { + this.open2End = false; + this.setClose(true); + this.setLock(true); + break; + } + } + } + + public void setClose(boolean close) { + if ((Fault.CANNOT_BE_CLOSED.equals(this.fault) && close)|| + (Fault.CANNOT_BE_OPENED.equals(this.fault) && !close)) + return; + this.close = close; + } + public void setLock(boolean lock) { if (Fault.NO_CLOSE_AND_LOCK.equals(this.fault) && lock) return; @@ -86,66 +118,6 @@ public class VirtualRealityScreenDoor extends VirtualRealityDevice { return this.lock && this.close; } - /** - * 开始开/关门过程 - */ - public synchronized void startSetting(boolean open) { - if (this.fault != null) { - switch (fault) { - case CANNOT_BE_CLOSED: - if (!open) { - return; - } - break; - case CANNOT_BE_OPENED: - if (open) { - return; - } - break; - } - } - this.remainTime = 3f; - this.commandOpen = open; - this.setting = true; - } - - public void running() { - if (this.isCommandOpen() && this.isLock()) { // 如果开门,先解锁 - this.setLock(false); - } else if (!this.isCommandOpen() && this.isOpen2End()) { // 关门,取消开门到位状态 - this.setOpen2End(false); - } - Float remainTime = this.getRemainTime(); - remainTime -= SimulationModule.VRD.getRateS(); - if (remainTime < 0) { - this.endSetting(); - } else { - this.setRemainTime(remainTime); - } - } - - /** - * 开/关门过程完成 - */ - public synchronized void endSetting() { - this.setting = false; - this.remainTime = null; - if (this.commandOpen) { - this.setLock(false); - this.close = false; - this.open2End = true; - } else { - this.open2End = false; - this.close = true; - this.setLock(true); - } - } - - public synchronized void overSetting() { - this.setting = false; - this.remainTime = null; - } - /** * 全部关门 */ @@ -154,7 +126,7 @@ public class VirtualRealityScreenDoor extends VirtualRealityDevice { this.close = close; this.setLock(lock); if (close && lock && this.isSettingClose()) { - this.overSetting(); + this.finish(); } } @@ -163,16 +135,16 @@ public class VirtualRealityScreenDoor extends VirtualRealityDevice { this.close = false; this.open2End = end; if (end && this.isSettingOpen()) { - this.overSetting(); + this.finish(); } } public boolean isSettingOpen() { - return this.isSetting() && this.isCommandOpen(); + return Operation.K.equals(this.getCommand()) && this.getRemain() > 0; } public boolean isSettingClose() { - return this.isSetting() && !this.isCommandOpen(); + return Operation.G.equals(this.getCommand()) && this.getRemain() > 0; } /** @@ -195,7 +167,7 @@ public class VirtualRealityScreenDoor extends VirtualRealityDevice { @Override public void apply(VirtualRealityScreenDoor door) { door.setFault(null); - door.startSetting(true); + door.control(Operation.K); door.setFault(this); } }, @@ -203,7 +175,7 @@ public class VirtualRealityScreenDoor extends VirtualRealityDevice { @Override public void apply(VirtualRealityScreenDoor door) { door.setFault(null); - door.startSetting(false); + door.control(Operation.G); door.setFault(this); } }, diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySignal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySignal.java index d4f517bfe..c83cb66d5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySignal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySignal.java @@ -1,59 +1,47 @@ package club.joylink.rtss.simulation.cbtc.data.vr; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.constant.SignalModel; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import lombok.Getter; import lombok.Setter; -import java.util.Objects; - /** * 虚拟真实信号机 */ @Getter @Setter -public class VirtualRealitySignal extends VirtualRealityDevice { - +public class VirtualRealitySignal extends ControllableVrDevice { /** - * 绿灯亮 + * 信号机灯位类型 */ - private boolean greenOpen; - + SignalModel model; /** - * 黄灯亮 + * 当前显示 */ - private boolean yellowOpen; - - /** - * 红灯亮 - */ - private boolean redOpen; + SignalAspect aspect; private Fault fault; - public VirtualRealitySignal(String code, String name) { - super(code, name, MapElement.DeviceType.SIGNAL); + public VirtualRealitySignal(String code, String name, SignalModel model) { + super(code, name, MapElement.DeviceType.SIGNAL, 500); + this.model = model; } @Override public void reset() { - this.greenOpen = false; - this.yellowOpen = false; - this.redOpen = false; + super.reset(); + this.aspect = SignalAspect.No; this.fault = null; } - public void apply(boolean greenOpen, boolean yellowOpen, boolean redOpen) { + public void apply(SignalAspect aspect) { if (Fault.MAIN_FILAMENT_BROKEN.equals(fault)) return; - this.greenOpen = greenOpen; - this.yellowOpen = yellowOpen; - this.redOpen = redOpen; - } - - public boolean isSame(boolean green, boolean yellow, boolean red) { - return Objects.equals(this.greenOpen, green) && - Objects.equals(this.yellowOpen, yellow) && - Objects.equals(this.redOpen, red); + if (aspect.equals(this.getCommand())) { + this.finish(); + } } /** @@ -62,21 +50,24 @@ public class VirtualRealitySignal extends VirtualRealityDevice { * @return */ public boolean isBlack() { - return Objects.equals(this.greenOpen, false) && - Objects.equals(this.yellowOpen, false) && - Objects.equals(this.redOpen, false); + return SignalAspect.No.equals(this.aspect); } public String debugStr() { - return String.format("%s-%s:{red:%s, green:%s, yellow:%s}", this.getName(), this.getCode(), - this.redOpen, this.greenOpen, this.yellowOpen); + return String.format("%s-%s: %s", this.getName(), this.getCode(), this.aspect); + } + + @Override + protected void doFinish(SignalAspect command) { + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(command); + this.aspect = command; } public enum Fault { MAIN_FILAMENT_BROKEN { @Override public void apply(VirtualRealitySignal vrSignal) { - vrSignal.apply(false, false, true); + vrSignal.apply(vrSignal.getModel().getDefaultAspect()); } }; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java index 42507904a..3b5711f04 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealitySwitch.java @@ -1,151 +1,101 @@ package club.joylink.rtss.simulation.cbtc.data.vr; -import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import lombok.Getter; import lombok.Setter; -import java.util.Objects; - /** * 虚拟真实道岔 */ @Getter @Setter -public class VirtualRealitySwitch extends VirtualRealityDevice { +public class VirtualRealitySwitch extends ControllableVrDevice { + @Override + protected boolean checkConditionBeforeControl(Operation command) { + switch (command) { + case NP: + return !(SwitchIndication.N == this.p); + case RP: + return !(SwitchIndication.R == this.p); + } + return true; + } + + @Override + protected void doTurn() { + this.p = SwitchIndication.NO; + } + + @Override + protected void doFinish(Operation command) { + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(command); + if (Fault.SQUEEZE.equals(this.getFault())) { + return; + } + switch (command) { + case NP: + this.p = SwitchIndication.N; + break; + case RP: + this.p = SwitchIndication.R; + break; + } + } + + public boolean isPosN() { + return SwitchIndication.N.equals(this.p); + } + + public boolean isPosR() { + return SwitchIndication.R.equals(this.p); + } + + public boolean isCommandNp() { + return Operation.NP.equals(this.getCommand()); + } /** - * 虚拟道岔转换时间 + * 道岔支持的操作 */ - private float settingTime; + public enum Operation { + /** 定操 */ + NP, + /** 反操 */ + RP, + } - /** - * 是否定位 - */ - private boolean normal; - - /** - * 是否反位 - */ - private boolean reverse; + private SwitchIndication p; // -------------运行逻辑控制参数------------- - /** - * 是否正在转换 - */ - private boolean setting; - - /** - * 道岔转换剩余时间 - */ - private Float remainTime; - - /** - * 道岔转换超时剩余时间(超时还没转换到位,即为失表) - */ - private int timeoutRemain; - - /** - * 道岔转换指令——是否转动到定位 - */ - private boolean toNormal; private Fault fault; - public VirtualRealitySwitch(String code, String name) { - super(code, name, MapElement.DeviceType.SWITCH); - this.normal = true; // 初始化的默认状态 - this.reverse = false; + public VirtualRealitySwitch(String code, String name, int turnTime) { + super(code, name, MapElement.DeviceType.SWITCH, turnTime * 1000); + this.p = SwitchIndication.N; } @Override public void reset() { - this.normal = true; - this.reverse = false; - this.setting = false; - this.remainTime = null; - this.timeoutRemain = 0; - this.toNormal = this.normal; + super.reset(); + this.p = SwitchIndication.N; this.fault = null; } public void apply(boolean normalPosition, boolean reversePosition) { - this.normal = normalPosition; - this.reverse = reversePosition; - if (this.isSetting() && ((this.toNormal && normalPosition) || (!this.toNormal && reversePosition))) { - this.overSetting(); - } - } - - private void overSetting() { - this.setting = false; - this.remainTime = null; - this.timeoutRemain = 0; - } - - /*public boolean isFault() { - return Objects.nonNull(this.fault); - }*/ - - /** - * 开始转换 - */ - public void startSetting(boolean toNormal) { - this.remainTime = this.settingTime; - this.timeoutRemain = 10 * 1000; // 仿真系统默认为10s - this.toNormal = toNormal; - this.setting = true; - } - - /** - * 转换结束 - */ - public void endSetting() { - this.setting = false; - this.remainTime = null; - this.timeoutRemain = 0; - if (Fault.SQUEEZE.equals(this.fault)) { - return; - } - if (this.toNormal) { - this.normal = true; - this.reverse = false; + if (normalPosition) { + this.p = SwitchIndication.N; + } else if (reversePosition) { + this.p = SwitchIndication.R; } else { - this.normal = false; - this.reverse = true; + this.p = SwitchIndication.NO; } - } - - /** - * 是否失表 - * - * @return - */ - public boolean isLoss() { - return !this.isNormal() && !this.isReverse(); - } - - /** - * 失去表示 - */ - public void loss() { - if (this.normal) { - this.normal = false; + if ((Operation.NP.equals(this.getCommand()) && SwitchIndication.N.equals(this.p)) || + (Operation.RP.equals(this.getCommand()) && SwitchIndication.R.equals(this.p))) { + this.finish(); } - if (this.reverse) { - this.reverse = false; - } - } - - public void timeoutLogicRunning() { - this.timeoutRemain -= SimulationConstants.VRD_LOOP_RATE; - if (timeoutRemain < 0) { - this.overSetting(); - } - } - - public boolean isSettingTo(boolean toNormal) { - return this.isSetting() && Objects.equals(toNormal, this.toNormal); } public enum Fault { @@ -158,8 +108,7 @@ public class VirtualRealitySwitch extends VirtualRealityDevice { if (this.equals(vrSwitch.getFault())) return false; vrSwitch.setFault(this); - vrSwitch.setNormal(false); - vrSwitch.setReverse(false); + vrSwitch.setP(SwitchIndication.EX); return true; } }; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index 422bfeabd..14c19d6d0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -324,6 +324,16 @@ public class VirtualRealityTrain extends VirtualRealityDevice { */ private Door door2; + /** + * 门模式 + */ + private DoorMode doorMode; + + /** + * 门选 + */ + private DoorSelection doorSelection; + /** * 牵引力,单位kN * 公式 fk = 350 (0 <= v <= 36km/h) @@ -486,8 +496,10 @@ public class VirtualRealityTrain extends VirtualRealityDevice { this.gear = ControlGear.Drive; this.communication = true; this.atpOn = true; - this.door1 = new Door("1"); - this.door2 = new Door("2"); + this.door1 = new Door(this, "1"); + this.door2 = new Door(this, "2"); + this.doorMode = DoorMode.AM; + this.doorSelection = DoorSelection.Z; } @Override @@ -531,8 +543,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice { this.changeEndsRemainTime = 0; this.atoOn = false; this.atpOn = false; - this.door1 = new Door("1"); - this.door2 = new Door("2"); this.fk = 0; this.fb = 0; this.tbControl = null; @@ -553,6 +563,8 @@ public class VirtualRealityTrain extends VirtualRealityDevice { this.autoOpenATO = false; this.fault = null; this.released = false; + this.doorMode = DoorMode.AM; + this.doorSelection = DoorSelection.Z; } public boolean isEB() { @@ -724,14 +736,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice { this.ma2 = null; } - /** - * 执行车门开/关过程 - */ - public void doorTurning() { - this.door1.running(); - this.door2.running(); - } - public float getProtectSpeedKmPh() { return (float) (this.atpSpeed * 3.6); } @@ -740,14 +744,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice { return (float) (this.atoSpeed * 3.6); } - /** - * 车门是否正在关闭 - */ - public boolean isDoorClosing() { - return (this.door1.isTurning() && !this.door1.isCommandOpen()) || - (this.door2.isTurning() && !this.door2.isCommandOpen()); - } - public SectionPosition calculateTailPosition() { this.tailPosition = CalculateService.calculateNextPositionByStartAndLen(this.headPosition, !right, this.getLen()); return this.tailPosition; @@ -891,7 +887,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { boolean right = this.right; Section section = this.headPosition.getSection(); Signal signal = section.getSignalOf(right); - if (signal == null || !signal.isClose()) { //没有同向信号机或信号机不处于信号关闭状态 + if (signal == null || !signal.isForbidAspect()) { //没有同向信号机或信号机不处于信号关闭状态 throw new SimulationException(SimulationExceptionType.Invalid_Operation, "指令要求:列车车头所在区段有同向信号机并且信号关闭"); } @@ -921,7 +917,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { boolean right = this.right; Section section = this.headPosition.getSection(); Signal signal = section.getSignalOf(right); - if (signal == null || !signal.isGuideOpen()) { + if (signal == null || !signal.isGuideAspect()) { throw new SimulationException(SimulationExceptionType.Invalid_Operation, "指令要求:列车车头所在区段有同向信号机并且开放引导信号"); } @@ -931,7 +927,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { if (section.isStandTrack() || section.isTurnBackTrack()) { sectionPosition = new SectionPosition(section, section.getStopPointByDirection(right)); break; - } else if (section.getSignalOf(right) != null && !section.getSignalOf(right).isNormalOpen()) { //同向信号机未正常开放 + } else if (section.getSignalOf(right) != null && !section.getSignalOf(right).isMainAspect()) { //同向信号机未正常开放 sectionPosition = new SectionPosition(section, section.getSignalOf(right).getOffset()); break; } @@ -950,7 +946,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { Section section = headPosition.getSection(); boolean right = this.right; Signal signal = section.getSignalOf(right); - if (signal != null && signal.isNormalOpen()) { //如果车头区段的同向信号机正常开放 + if (signal != null && signal.isMainAspect()) { //如果车头区段的同向信号机正常开放 SectionPosition signalPosition = new SectionPosition(section, signal.getOffset()); return CalculateService.calculateDistance(headPosition, signalPosition, right); } @@ -1080,29 +1076,28 @@ public class VirtualRealityTrain extends VirtualRealityDevice { @Getter @Setter - public class Door { + public static class Door extends ControllableVrDevice { + + /** + * 道岔支持的操作 + */ + public enum Operation { + /** 开门 */ + K, + /** 关门 */ + G, + } + + private VirtualRealityTrain train; private String code; private boolean close; private boolean lock; - /** - * 是否开/关门过程中 - */ - private boolean turning; - - /** - * 命令:true-开门命令,false-关门命令 - */ - private boolean commandOpen; - - /** - * 过程剩余时间 - */ - private float remainTime; - - public Door(String code) { + public Door(VirtualRealityTrain train, String code) { + super(code, code, DeviceType.TRAIN_DOOR, 2 * 1000); + this.train = train; this.code = code; this.close = true; this.lock = true; @@ -1116,48 +1111,33 @@ public class VirtualRealityTrain extends VirtualRealityDevice { return this.close && this.lock; } - public void open() { - this.commandOpen = true; - this.remainTime = 2; - this.turning = true; - } - - public void close() { - this.commandOpen = false; - this.remainTime = 2; - this.turning = true; - } - public boolean isOpening() { - return this.turning && this.commandOpen; + return this.getRemain() > 0 && Operation.K.equals(this.getCommand()); } public boolean isClosing() { - return this.turning && !this.commandOpen; + return this.getRemain() > 0 && Operation.G.equals(this.getCommand()); } - public void running() { - if (this.turning) { - if (this.lock) { + @Override + protected void doTurn() { + this.lock = false; + this.close = false; + } + + @Override + protected void doFinish(Operation command) { + switch (command) { + case K: this.lock = false; - } - this.remainTime -= SimulationModule.VRD.getRateS(); - if (this.remainTime < 0) { - this.finish(); - } + this.close = false; + break; + case G: + this.close = true; + this.lock = true; + break; } } - - public void finish() { - this.turning = false; - this.remainTime = -1; - if (this.commandOpen) { - this.close = false; - } else { - this.close = true; - } - this.lock = true; - } } public boolean passedResponder() { @@ -1274,4 +1254,43 @@ public class VirtualRealityTrain extends VirtualRealityDevice { ACCELERATE, } + public enum DoorMode { + /** + * 自动开手动关 + */ + AM, + /** + * 手动开手动关 + */ + MM, + /** + * 自动开自动关 + */ + AA, + ; + + public boolean isAuto(boolean open) { + return (open && this.equals(MM)) || (!open && !this.equals(AA)); + } + } + + public enum DoorSelection { + /** + * 左 + */ + L, + /** + * 右 + */ + R, + /** + * 零位 + */ + Z, + ; + + public boolean match(boolean right) { + return (right && this.equals(R)) || (!right && this.equals(L)); + } + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/SimulationRealDeviceThread.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/SimulationRealDeviceThread.java index 1cf941c0c..1cf581569 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/SimulationRealDeviceThread.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/SimulationRealDeviceThread.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.cbtc.device.real; -import com.digitalpetri.modbus.responses.ReadCoilsResponse; +import club.joylink.rtss.constants.Project; +import club.joylink.rtss.constants.ProjectDeviceType; import club.joylink.rtss.simulation.cbtc.GroupSimulationCache; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; @@ -9,16 +10,15 @@ import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.*; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.PlcGateway; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import club.joylink.rtss.simulation.cbtc.event.SimulationResetEvent; -import club.joylink.rtss.constants.Project; -import club.joylink.rtss.constants.ProjectDeviceType; +import com.digitalpetri.modbus.responses.ReadCoilsResponse; 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.context.event.EventListener; import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; @@ -33,7 +33,8 @@ public class SimulationRealDeviceThread { @Autowired public GroupSimulationCache groupSimulationCache; - + @Autowired + private VirtualRealityDeviceService virtualRealityDeviceService; @Autowired private PlcGatewayConnectManager plcGatewayConnectManager; @@ -65,8 +66,6 @@ public class SimulationRealDeviceThread { } } - @Async("realDeviceExecutor") -// @Scheduled(fixedRate = SimulationConstants.VRD_LOOP_RATE) public void controlDevice() { this.groupSimulationCache.getGroupSimulationMap().forEach((group, simulation) -> { List realDeviceList = simulation.getRealDeviceList(); @@ -82,14 +81,10 @@ public class SimulationRealDeviceThread { } } for (VirtualRealityScreenDoor vrPsd : vrPsdSet) { - if (vrPsd.isSetting()) { - vrPsd.running(); - } + this.virtualRealityDeviceService.turning(simulation, vrPsd); } for (VirtualRealitySwitch vrSwitch : vrSwitchSet) { - if (vrSwitch.isSetting()) { - vrSwitch.timeoutLogicRunning(); - } + this.virtualRealityDeviceService.turning(simulation, vrSwitch); } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gzb/GzbSignalServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gzb/GzbSignalServiceImpl.java index 727a10a7a..8f7d4ebb6 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gzb/GzbSignalServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gzb/GzbSignalServiceImpl.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; @@ -61,20 +62,9 @@ public class GzbSignalServiceImpl implements RealDeviceService { boolean bw9 = RealDeviceConfig.getBitOf(signalStatus, config.getW9()); boolean bw10 = RealDeviceConfig.getBitOf(signalStatus, config.getW10()); boolean bw11 = RealDeviceConfig.getBitOf(signalStatus, config.getW11()); - // 故障 -// if (brf) { -// this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWyr(), bwyr, true, channel); -// this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWg(), bwg, true, channel); -// this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWy(), bwy, true, channel); -// this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWr(), bwr, true, channel); -// log.error(String.format("信号机[%s]故障", switchConfig.getProjectDevice())); -// return; -// } -// boolean greenOpen = !bryr && brg && bry; -// boolean yellowOpen = bryr || (!brg && bry); -// boolean redOpen = !brg && !bry; + // 信号机采集控制 - if (vrSignal.isRedOpen() && vrSignal.isYellowOpen()) { // 开红黄 + if (SignalAspect.RY.equals(vrSignal.getCommand())) { // 开红黄 if (!br0 && !br1 && br2 && !br3 && br4) { // 黄红灯已开 return; } @@ -82,7 +72,7 @@ public class GzbSignalServiceImpl implements RealDeviceService { this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW9(), bw9, false, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW10(), bw10, false, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW11(), bw11, true, channel); - } else if (vrSignal.isRedOpen()) { // 开红灯 + } else if (SignalAspect.R.equals(vrSignal.getCommand())) { // 开红灯 if (!br0 && !br1 && !br2 && !br3 && br4) { // 红灯已开 return; } @@ -90,7 +80,7 @@ public class GzbSignalServiceImpl implements RealDeviceService { this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW9(), bw9, false, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW10(), bw10, false, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW11(), bw11, false, channel); - } else if (vrSignal.isGreenOpen()) { // 开绿灯 + } else if (SignalAspect.G.equals(vrSignal.getCommand())) { // 开绿灯 if (br0 && br1 && !br2 && !br3 && br4) { // 绿灯已开 return; } @@ -98,7 +88,7 @@ public class GzbSignalServiceImpl implements RealDeviceService { this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW9(), bw9, true, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW10(), bw10, true, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW11(), bw11, false, channel); - } else if (vrSignal.isYellowOpen()) { // 开黄灯 + } else if (SignalAspect.Y.equals(vrSignal.getCommand())) { // 开黄灯 if (br0 && !br1 && !br2 && !br3 && br4) { // 黄灯已开 return; } @@ -106,7 +96,7 @@ public class GzbSignalServiceImpl implements RealDeviceService { this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW9(), bw9, true, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW10(), bw10, false, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getW11(), bw11, false, channel); - } else if (vrSignal.isBlack()) { // 灭灯 + } else if (SignalAspect.No.equals(vrSignal.getCommand())) { // 灭灯 if (!br4) { // 已灭灯 return; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gzb/GzbSwitchServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gzb/GzbSwitchServiceImpl.java index 6cabd7a9f..1b40cf3ba 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gzb/GzbSwitchServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/gzb/GzbSwitchServiceImpl.java @@ -61,8 +61,8 @@ public class GzbSwitchServiceImpl implements RealDeviceService { boolean wbnp = RealDeviceConfig.getBitOf(switchStatus, config.getWnp()); boolean wbrp = RealDeviceConfig.getBitOf(switchStatus, config.getWrp()); - if (vrSwitch.isSetting()) { // 道岔转动中 - if (vrSwitch.isToNormal()) { // 定操 + if (vrSwitch.isTurning()) { // 道岔转动中 + if (vrSwitch.isCommandNp()) { // 定操 this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWrp(), wbrp, false, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWsn(), wbl, true, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWnp(), wbnp, true, channel); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1IbpServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1IbpServiceImpl.java index c5659eb63..c6b9a2ad7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1IbpServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1IbpServiceImpl.java @@ -1,7 +1,6 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.service; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; -import club.joylink.rtss.simulation.cbtc.CI.service.StandService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.ESP; import club.joylink.rtss.simulation.cbtc.data.map.Stand; @@ -14,6 +13,7 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDevice import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1IbpConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PscConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PslConfig; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import club.joylink.rtss.vo.client.project.*; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; @@ -34,10 +34,8 @@ public class Heb1IbpServiceImpl implements RealDeviceService { @Autowired private CiApiService ciApiService; - @Autowired - private StandService standService; - + private VirtualRealityDeviceService virtualRealityDeviceService; @Autowired private Heb1PslServiceImpl heb1PslService; @@ -130,13 +128,13 @@ public class Heb1IbpServiceImpl implements RealDeviceService { if (!vrPsd.isSettingOpen() && !vrPsd.isOpen2End()) { log.info(String.format("仿真[%s]IBP设备[%s]执行控制上行PSD开门", simulation.getId(), pslConfig.getProjectDevice())); - this.standService.controlVrPSD(simulation, vrPsd, true); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.K); } } else if (rbsxgm && !rbsxkm) { if (!vrPsd.isSettingClose() && !vrPsd.isClose()) { log.info(String.format("仿真[%s]IBP设备[%s]执行控制上行PSD关门", simulation.getId(), pslConfig.getProjectDevice())); - this.standService.controlVrPSD(simulation, vrPsd, false); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.G); } } } @@ -180,13 +178,13 @@ public class Heb1IbpServiceImpl implements RealDeviceService { if (!vrPsd.isSettingOpen() && !vrPsd.isOpen2End()) { log.info(String.format("仿真[%s]IBP设备[%s]执行控制下行PSD开门", simulation.getId(), pslConfig.getProjectDevice())); - this.standService.controlVrPSD(simulation, vrPsd, true); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.K); } } else if (rbxxgm && !rbxxkm) { if (!vrPsd.isSettingClose() && !vrPsd.isClose()) { log.info(String.format("仿真[%s]IBP设备[%s]执行控制下行PSD关门", simulation.getId(), pslConfig.getProjectDevice())); - this.standService.controlVrPSD(simulation, vrPsd, false); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.G); } } } @@ -268,7 +266,7 @@ public class Heb1IbpServiceImpl implements RealDeviceService { this.heb1PscService.controlIbpGm(pscConfig, false, channel); } } else { - if (!vrPsd.isSetting()) { + if (!vrPsd.isTurning()) { this.heb1PscService.controlIbpEnable(pscConfig, false, channel); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1PslServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1PslServiceImpl.java index 7ab7408c2..eeee97e2d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1PslServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1PslServiceImpl.java @@ -1,7 +1,6 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.service; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; -import club.joylink.rtss.simulation.cbtc.CI.service.StandService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.ESP; import club.joylink.rtss.simulation.cbtc.data.map.PSD; @@ -13,6 +12,7 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDevice import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.handler.ModbusMessageHandler2; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PscConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.Heb1PslConfig; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import club.joylink.rtss.vo.client.project.PscConfigVO; import club.joylink.rtss.vo.client.project.PslConfigVO; import io.netty.buffer.ByteBuf; @@ -32,9 +32,7 @@ public class Heb1PslServiceImpl implements RealDeviceService { @Autowired private PlcGatewayService plcGatewayService; - @Autowired - private StandService standService; - + private VirtualRealityDeviceService virtualRealityDeviceService; @Autowired private CiApiService ciApiService; @@ -107,7 +105,7 @@ public class Heb1PslServiceImpl implements RealDeviceService { if (vrExist && !vrPsd.isSettingOpen() && !vrPsd.isOpen2End()) { log.info(String.format("仿真[%s]PSL设备[%s]执行控制PSD开门", simulation.getId(), pslConfig.getProjectDevice())); - this.standService.controlVrPSD(simulation, vrPsd, true); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.K); } } // 关门按钮 @@ -116,7 +114,7 @@ public class Heb1PslServiceImpl implements RealDeviceService { if (vrExist && !vrPsd.isSettingClose() && !vrPsd.isClose()) { log.info(String.format("仿真[%s]PSL设备[%s]执行控制PSD关门", simulation.getId(), pslConfig.getProjectDevice())); - this.standService.controlVrPSD(simulation, vrPsd, false); + this.virtualRealityDeviceService.control(simulation, vrPsd, VirtualRealityScreenDoor.Operation.G); } } // 互锁解除按钮 @@ -183,8 +181,8 @@ public class Heb1PslServiceImpl implements RealDeviceService { boolean sn; boolean km; boolean gm; - if (vrPsd.isSetting()) { - if (vrPsd.isCommandOpen()) { // 开门 + if (vrPsd.isTurning()) { + if (VirtualRealityScreenDoor.Operation.K.equals(vrPsd.getCommand())) { // 开门 sn = true; km = true; gm = false; @@ -226,7 +224,7 @@ public class Heb1PslServiceImpl implements RealDeviceService { if (rpslcz) { this.heb1PscService.controlPslEnable(pscConfig, true, channel); } else { - if (!vrPsd.isSetting()) { + if (!vrPsd.isTurning()) { this.heb1PscService.controlPslEnable(pscConfig, false, channel); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1SwitchServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1SwitchServiceImpl.java index beb5bdf72..16a7fb7f2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1SwitchServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/heb/service/Heb1SwitchServiceImpl.java @@ -58,8 +58,8 @@ public class Heb1SwitchServiceImpl implements RealDeviceService { boolean wbnp = RealDeviceConfig.getBitOf(switchStatus, config.getWnp()); boolean wbrp = RealDeviceConfig.getBitOf(switchStatus, config.getWrp()); - if (vrSwitch.isSetting()) { // 道岔转动中 - if (vrSwitch.isToNormal()) { // 定操 + if (vrSwitch.isTurning()) { // 道岔转动中 + if (vrSwitch.isCommandNp()) { // 定操 this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWrp(), wbrp, false, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWl(), wbl, true, channel); this.plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, config.getWnp(), wbnp, true, channel); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuConfig.java new file mode 100644 index 000000000..474340e9a --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuConfig.java @@ -0,0 +1,21 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; + +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.ProjectDeviceVO; +import club.joylink.rtss.vo.client.project.richor.RichorDcuConfigVO; +import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO; +import lombok.Getter; + +import java.util.Objects; + +@Getter +public class RichorDcuConfig extends RealDeviceConfig { + private RichorDcuConfigVO configVO; + public RichorDcuConfig(ProjectDeviceVO deviceVO) { + super(deviceVO); + if (Objects.nonNull(deviceVO.getConfig())) { + this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorDcuConfigVO.class); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuServiceImpl.java new file mode 100644 index 000000000..3077b5780 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorDcuServiceImpl.java @@ -0,0 +1,57 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsSafetyCircleStatusVO; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; +import club.joylink.rtss.vo.client.project.richor.RichorDcuConfigVO; +import io.netty.buffer.ByteBuf; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; + +@Slf4j +@Component +public class RichorDcuServiceImpl implements RealDeviceService { + @Autowired + private ApplicationContext applicationContext; + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof RichorDcuConfig; + } + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + RichorDcuConfig config = (RichorDcuConfig) deviceConfig; + RichorDcuConfigVO configVO = config.getConfigVO(); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); + boolean aqhl = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_aqhl()); + SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); + String iscsCode = configVO.getIscsCode(); + IscsSafetyCircleStatusVO iscsStatus = (IscsSafetyCircleStatusVO) iscsRepository.findStatus(iscsCode); + boolean change; + if (iscsStatus == null) { + IscsSafetyCircleStatusVO.DirectionalStatus upStatus = new IscsSafetyCircleStatusVO.DirectionalStatus(true, true, aqhl); + iscsStatus = new IscsSafetyCircleStatusVO(iscsCode, IscsStatusVO.DeviceType.SAFETY_CIRCLE, upStatus, null); + iscsRepository.addStatus(iscsStatus); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class); + simulation.watch(iscsStatus, watcher); + change = true; + } else { + IscsSafetyCircleStatusVO.DirectionalStatus upStatus = iscsStatus.getUpStatus(); + change = upStatus.compareAndChange(true, true, aqhl); + } + if (change) { + iscsStatus.fireWatcher(null, null); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpConfig.java new file mode 100644 index 000000000..9a625d591 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpConfig.java @@ -0,0 +1,23 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; + +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.ProjectDeviceVO; +import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO; +import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO; +import lombok.Getter; +import lombok.Setter; + +import java.util.Objects; + +@Getter +public class RichorIbpConfig extends RealDeviceConfig { + private RichorIbpConfigVO configVO; + + public RichorIbpConfig(ProjectDeviceVO deviceVO) { + super(deviceVO); + if (Objects.nonNull(deviceVO.getConfig())) { + this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorIbpConfigVO.class); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpServiceImpl.java new file mode 100644 index 000000000..8723c9a35 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorIbpServiceImpl.java @@ -0,0 +1,170 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; + +import club.joylink.rtss.simulation.cbtc.CI.CiApiService; +import club.joylink.rtss.simulation.cbtc.CI.service.VrPsdService; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.MapConfig; +import club.joylink.rtss.simulation.cbtc.data.map.Stand; +import club.joylink.rtss.simulation.cbtc.data.map.Station; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsIbpStatusVO; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; +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.device.PlcGateway; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; +import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO; +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.context.ApplicationContext; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Slf4j +@Component +public class RichorIbpServiceImpl implements RealDeviceService { + + @Autowired + private PlcGatewayService plcGatewayService; + + @Autowired + private CiApiService ciApiService; + + @Autowired + private ApplicationContext applicationContext; + + @Autowired + private VrPsdService vrPsdService; + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof RichorIbpConfig; + } + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + PlcGateway plcGateway = simulation.getPlcGateway(); + RichorIbpConfigVO configVO = ((RichorIbpConfig) deviceConfig).getConfigVO(); + Channel channel = plcGateway.getChannel(); + int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sx_kcd(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_xx_kcd(), false, channel); + plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), false, channel); + } + + public static void main(String[] args) { + int addr = 2; + int bit = 9; + System.out.println((addr + 1) * 16 + (bit + 8) % 16); + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); + if (plcGateway == null) + return; + RichorIbpConfig config = (RichorIbpConfig) deviceConfig; + Station station = (Station) config.getMapElement(); + if (station == null) + return; + RichorIbpConfigVO configVO = config.getConfigVO(); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); + boolean r_xx_jjtc = !RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_jjtc()); + boolean r_xx_qxjt = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_qxjt()); + boolean r_xx_kc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_kc()); + boolean r_xx_qxkc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xx_qxkc()); + boolean r_sx_jjtc = !RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_jjtc()); + boolean r_sx_qxjt = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_qxjt()); + boolean r_sx_kc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_kc()); + boolean r_sx_qxkc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_qxkc()); + boolean r_sd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sd()); + boolean r_qdbj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_qdbj()); + boolean w_fmq = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fmq()); + boolean w_sx_jjtcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_jjtcd()); + boolean w_xx_jjtcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_jjtcd()); + boolean w_sx_kcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sx_kcd()); + boolean w_xx_kcd = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_xx_kcd()); + boolean r_sx_czyx = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_czyx()); + boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km()); + boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm()); + int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); + Channel channel = plcGateway.getChannel(); + //查找真实设备和vr设备 + SimulationDataRepository repository = simulation.getRepository(); + MapConfig mapConfig = repository.getConfig(); + List stands = station.getAllNormalStands(); + List upStands = station.getNormalStand(mapConfig.isRight(true)); + List downStands = station.getNormalStand(mapConfig.isRight(false)); + //输入 + if (r_xx_jjtc) + downStands.forEach(stand -> ciApiService.standEC(simulation, stand)); + if (r_xx_qxjt) + downStands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand)); + if (r_xx_kc) { + for (Stand stand : downStands) { + if (!stand.isIbpHoldTrain()) { + ciApiService.ibpHoldTrain(simulation, stand.getCode()); + } + } + } + if (r_xx_qxkc) + downStands.forEach(stand -> ciApiService.ibpHoldTrainCancel(simulation, stand.getCode())); + if (r_sx_jjtc) + upStands.forEach(stand -> ciApiService.standEC(simulation, stand)); + if (r_sx_qxjt) + upStands.forEach(stand -> ciApiService.cancelStandEC(simulation, stand)); + if (r_sx_kc) { + for (Stand stand : upStands) { + if (!stand.isIbpHoldTrain()) { + ciApiService.ibpHoldTrain(simulation, stand.getCode()); + } + } + } + if (r_sx_qxkc) + upStands.forEach(stand -> ciApiService.ibpHoldTrainCancel(simulation, stand.getCode())); + upStands.forEach(stand -> stand.getPsd().getVirtualScreenDoor().setIbpControl(r_sx_czyx)); + //输出 + if (r_sd) { + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, true, channel); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, true, channel); + } else { + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_fmq(), w_fmq, false, channel); + boolean upHoldTrain = upStands.stream().anyMatch(Stand::isIbpHoldTrain); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_kcd(), w_sx_kcd, upHoldTrain, channel); + boolean upEc = upStands.stream().anyMatch(Stand::isEmergencyClosed); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sx_jjtcd(), w_sx_jjtcd, upEc, channel); + boolean downHoldTrain = downStands.stream().anyMatch(Stand::isIbpHoldTrain); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_kcd(), w_xx_kcd, downHoldTrain, channel); + boolean downEc = downStands.stream().anyMatch(Stand::isEmergencyClosed); + plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_xx_jjtcd(), w_xx_jjtcd, downEc, channel); + } + //ISCS状态 + SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); + String iscsCode = configVO.getIscsCode(); + IscsIbpStatusVO iscsStatus = (IscsIbpStatusVO) iscsRepository.findStatus(iscsCode); + boolean change; + if (iscsStatus == null) { + IscsIbpStatusVO.DirectionalStatus downStatus = + new IscsIbpStatusVO.DirectionalStatus(r_sx_czyx, r_sx_km, false, r_sx_gm); + iscsStatus = new IscsIbpStatusVO(iscsCode, IscsStatusVO.DeviceType.IBP, null, downStatus); + iscsRepository.addStatus(iscsStatus); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class); + simulation.watch(iscsStatus, watcher); + change = true; + } else { + IscsIbpStatusVO.DirectionalStatus downStatus = iscsStatus.getDownStatus(); + change = downStatus.compareAndChange(r_sx_czyx, r_sx_km, false, r_sx_gm); + } + if (change) { + iscsStatus.fireWatcher(null, null); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdConfig.java new file mode 100644 index 000000000..12c9de475 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdConfig.java @@ -0,0 +1,21 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; + +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.ProjectDeviceVO; +import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO; +import lombok.Getter; + +import java.util.Objects; + +@Getter +public class RichorPsdConfig extends RealDeviceConfig { + private RichorPsdConfigVO configVO; + + public RichorPsdConfig(ProjectDeviceVO deviceVO) { + super(deviceVO); + if (Objects.nonNull(deviceVO.getConfig())) { + this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorPsdConfigVO.class); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdServiceImpl.java new file mode 100644 index 000000000..a3924604a --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPsdServiceImpl.java @@ -0,0 +1,84 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsIbpStatusVO; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsPsdStatusVO; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; +import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO; +import io.netty.buffer.ByteBuf; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +@Slf4j +@Component +public class RichorPsdServiceImpl implements RealDeviceService { + @Autowired + private ApplicationContext applicationContext; + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof RichorPsdConfig; + } + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { +// PlcGateway plcGateway = simulation.getPlcGateway(); +// RichorPsdConfig config = (RichorPsdConfig) deviceConfig; +// RichorPsdConfigVO configVO = config.getConfigVO(); +// Channel channel = plcGateway.getChannel(); +// int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); +// +// VirtualRealityScreenDoor vrPsd = (VirtualRealityScreenDoor) config.getMapElement(); +// if (vrPsd != null) { +// vrPsd.startSetting(false); +// } + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + RichorPsdConfig config = (RichorPsdConfig) deviceConfig; + RichorPsdConfigVO configVO = config.getConfigVO(); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); + boolean km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_wgm()); + boolean sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_sj()); + boolean dcugz = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_dcugz()); + boolean r_sx_glms = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_glms()); + String iscsCode = configVO.getIscsCode(); + if (StringUtils.hasText(iscsCode)) { + IscsPsdStatusVO.Status status; + if (km) { + status = IscsPsdStatusVO.Status.OPEN; + } else if (sj) { + status = IscsPsdStatusVO.Status.CLOSE; + } else if (dcugz) { + status = IscsPsdStatusVO.Status.DCU_FAULT; + } else { + status = IscsPsdStatusVO.Status.UNDEFINED; + } + SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); + IscsPsdStatusVO iscsStatus = (IscsPsdStatusVO) iscsRepository.findStatus(iscsCode); + boolean change = false; + if (iscsStatus == null) { + IscsPsdStatusVO.DirectionalStatus downStatus = new IscsPsdStatusVO.DirectionalStatus(status, r_sx_glms); + iscsStatus = new IscsPsdStatusVO(iscsCode, IscsStatusVO.DeviceType.SLIDING_DOOR, null, downStatus); + iscsRepository.addStatus(iscsStatus); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class); + simulation.watch(iscsStatus, watcher); + change = true; + } else { + IscsPsdStatusVO.DirectionalStatus downStatus = iscsStatus.getDownStatus(); + change = downStatus.compareAndChange(status, r_sx_glms); + } + if (change) { + iscsStatus.fireWatcher(null, null); + } + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslConfig.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslConfig.java new file mode 100644 index 000000000..6e20eb9a0 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslConfig.java @@ -0,0 +1,24 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; + +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.ProjectDeviceVO; +import club.joylink.rtss.vo.client.project.richor.RichorPsdConfigVO; +import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.Objects; + +@Getter +public class RichorPslConfig extends RealDeviceConfig { + private RichorPslConfigVO configVO; + + public RichorPslConfig(ProjectDeviceVO deviceVO) { + super(deviceVO); + if (Objects.nonNull(deviceVO.getConfig())) { + this.configVO = JsonUtils.read(deviceVO.getConfig(), RichorPslConfigVO.class); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslServiceImpl.java new file mode 100644 index 000000000..bab2f8c22 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/richor/RichorPslServiceImpl.java @@ -0,0 +1,67 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor; + +import club.joylink.rtss.simulation.cbtc.CI.device.CiStandService; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.Stand; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsPslStatusVO; +import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig; +import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher; +import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO; +import io.netty.buffer.ByteBuf; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class RichorPslServiceImpl implements RealDeviceService { + @Autowired + private CiStandService standService; + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof RichorPslConfig; + } + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + RichorPslConfig config = (RichorPslConfig) deviceConfig; + RichorPslConfigVO configVO = config.getConfigVO(); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), configVO.getQuantity()); + boolean r_sx_czyx = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_czyx()); + boolean r_sx_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_km()); + boolean r_sx_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_gm()); + boolean r_sx_hsjc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_sx_hsjc()); + //信号系统状态 + Stand stand = (Stand) config.getMapElement(); + if (stand != null) { + stand.getPsd().getVirtualScreenDoor().setPslControl(r_sx_czyx); + standService.setOrCancelInterlockRelease(simulation, stand, r_sx_hsjc); + } + //ISCS状态 + SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); + String iscsCode = configVO.getIscsCode(); + IscsPslStatusVO iscsStatus = (IscsPslStatusVO) iscsRepository.findStatus(iscsCode); + boolean change; + if (iscsStatus == null) { + IscsPslStatusVO.DirectionalStatus downStatus = new IscsPslStatusVO.DirectionalStatus(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc); + iscsStatus = new IscsPslStatusVO(iscsCode, IscsStatusVO.DeviceType.PSL, null, downStatus); + iscsRepository.addStatus(iscsStatus); + IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class); + simulation.watch(iscsStatus, watcher); + change = true; + } else { + IscsPslStatusVO.DirectionalStatus downStatus = iscsStatus.getDownStatus(); + change = downStatus.compareAndChange(r_sx_czyx, r_sx_km, r_sx_gm, r_sx_hsjc); + } + if (change) { + iscsStatus.fireWatcher(null, null); + } + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdServiceImpl.java index bdc9df1f2..869d5e701 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPsdServiceImpl.java @@ -38,7 +38,7 @@ public class SdyPsdServiceImpl implements RealDeviceService { this.plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_jb(), false, channel); //关响铃 VirtualRealityScreenDoor vrPsd = (VirtualRealityScreenDoor) config.getMapElement(); if (vrPsd != null) { - vrPsd.startSetting(false); + vrPsd.control(VirtualRealityScreenDoor.Operation.G); } // plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_jb(), false, channel); //关警报 // if (config.getR_km() != null && config.getR_km()) { //确保关门 diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslServiceImpl.java index 342e67ad0..259f52e4e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/sdy/SdyPslServiceImpl.java @@ -116,12 +116,12 @@ public class SdyPslServiceImpl implements RealDeviceService { if (vrPsd != null) { if (r_gm_button && !r_km_button) { if (!vrPsd.isSettingClose() && !vrPsd.isClose()) { - vrPsd.startSetting(false); + vrPsd.control(VirtualRealityScreenDoor.Operation.G); } } if (r_km_button && !r_gm_button) { if (!vrPsd.isOpen2End()) { - vrPsd.startSetting(true); + vrPsd.control(VirtualRealityScreenDoor.Operation.K); } } } else if (realPsd != null) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/xty/XtyPsdServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/xty/XtyPsdServiceImpl.java index 7c9bbef1d..69547bf75 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/xty/XtyPsdServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/xty/XtyPsdServiceImpl.java @@ -60,7 +60,7 @@ public class XtyPsdServiceImpl implements RealDeviceService { int wvkm = configVO.getWvkm(); // 开门控制值 int wvgm = configVO.getWvgm();// 关门控制值 - if (vrPsd.isSetting()) { // 屏蔽门设置中且为信号系统可操作状态 + if (vrPsd.isTurning()) { // 屏蔽门设置中且为信号系统可操作状态 if (autoMode && vrPsd.isCommandOpen() && (cv & wvkm) != wvkm) { // 开门 this.plcGatewayService.checkEqualAndWriteSingleRegister(plcGateway.getConfig().getAddr(), configVO.getWbi(), cv, wvkm, plcGateway.getChannel()); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRDeviceLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRDeviceLogicLoop.java index e567a3b63..e5b6fbfa3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRDeviceLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VRDeviceLogicLoop.java @@ -5,11 +5,9 @@ import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.data.CalculateService; 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.Section; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor; -import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +import club.joylink.rtss.simulation.cbtc.data.vr.ControllableVrDevice; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -32,16 +30,13 @@ public class VRDeviceLogicLoop { // long start = System.currentTimeMillis(); // 虚拟真实道岔转动过程 SimulationDataRepository repository = simulation.getRepository(); - List vrSwitchList = repository.getVrListByType(MapElement.DeviceType.SWITCH, VirtualRealitySwitch.class); - vrSwitchList.forEach(vrSwitch -> - this.virtualRealityDeviceService.virtualSwitchSettingLogic(simulation, vrSwitch)); - // 虚拟真实屏蔽门开/关门 - List psdList = repository.getVrListByType(MapElement.DeviceType.PSD, VirtualRealityScreenDoor.class); - psdList.forEach(vrPsd -> - this.virtualRealityDeviceService.virtualScreenDoorSettingLogic(vrPsd)); + List list = repository.getAllControllableVrDevice(); + for (ControllableVrDevice device : list) { + this.virtualRealityDeviceService.turning(simulation, device); + } List onlineTrainList = repository.getOnlineTrainList(); onlineTrainList.forEach(train -> - this.virtualRealityDeviceService.virtualTrainDoorTurning(train)); + this.virtualRealityDeviceService.virtualTrainDoorTurning(simulation, train)); // 列车占压计轴区段检查 this.updateTrainOccupySection(simulation); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VirtualRealityDeviceService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VirtualRealityDeviceService.java index 5057fbcf1..8ceb98684 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VirtualRealityDeviceService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/virtual/VirtualRealityDeviceService.java @@ -1,7 +1,7 @@ package club.joylink.rtss.simulation.cbtc.device.virtual; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.communication.vo.*; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.vr.*; @@ -19,43 +19,35 @@ public class VirtualRealityDeviceService { private ApplicationContext applicationContext; /** - * 虚拟室外道岔转换过程控制逻辑 - * + * 控制设备 * @param simulation - * @param virtualSwitch + * @param device + * @param command */ - public void virtualSwitchSettingLogic(Simulation simulation, VirtualRealitySwitch virtualSwitch) { - if (virtualSwitch.isSetting() && !virtualSwitch.isConnectReal()) { // 排列中 - float remainTime = virtualSwitch.getRemainTime(); - remainTime -= SimulationModule.VRD.getRateS(); - if (remainTime < 0) { // 转换完成 - virtualSwitch.endSetting(); - } else { - virtualSwitch.loss(); - virtualSwitch.setRemainTime(remainTime); - } + public void control(Simulation simulation, ControllableVrDevice device, Object command) { + if (device.control(command)) { + // 发送控制事件 + SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, device); + this.applicationContext.publishEvent(event); } } - /** - * 虚拟室外站台屏蔽门开/关门过程控制逻辑 - * - * @param virtualScreenDoor - */ - public void virtualScreenDoorSettingLogic(VirtualRealityScreenDoor virtualScreenDoor) { - if (virtualScreenDoor.isSetting() && !virtualScreenDoor.isConnectReal()) { // 排列中 - virtualScreenDoor.running(); + public void turning(Simulation simulation, ControllableVrDevice device) { + if (!device.isConnectReal() && device.getRemain() > 0) { + device.turning(SimulationModule.VRD.getRateMs()); } } /** * 列车车门开/关过程控制 * + * @param simulation * @param train */ - public void virtualTrainDoorTurning(VirtualRealityTrain train) { + public void virtualTrainDoorTurning(Simulation simulation, VirtualRealityTrain train) { if (!train.isConnectReal()) { - train.doorTurning(); + this.turning(simulation, train.getDoor1()); + this.turning(simulation, train.getDoor2()); } } @@ -66,34 +58,27 @@ public class VirtualRealityDeviceService { switch (deviceType) { case SWITCH:{ VirtualRealitySwitch aSwitch = (VirtualRealitySwitch) value; - ControllableDevice ctrlMsg = new SwitchTurn(aSwitch, aSwitch.isNormal()); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); + this.control(simulation, aSwitch, VirtualRealitySwitch.Operation.NP); + aSwitch.finish(); break; } case SIGNAL:{ - ControllableDevice ctrlMsg = new SignalLight((VirtualRealitySignal) value); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); + this.control(simulation, (VirtualRealitySignal) value, SignalAspect.No); + ((VirtualRealitySignal) value).finish(); break; } case PSD:{ VirtualRealityScreenDoor psd = (VirtualRealityScreenDoor) value; - ControllableDevice ctrlMsg = new PsdSwitch(psd, psd.isOpen2End()); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); + this.control(simulation, psd, VirtualRealityScreenDoor.Operation.G); + psd.finish(); break; } case TRAIN:{ VirtualRealityTrain train = (VirtualRealityTrain) value; - VirtualRealityTrain.Door door1 = train.getDoor1(); - TrainDoorSwitch ctrlMsg = new TrainDoorSwitch(train, door1, door1.isOpen()); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); - VirtualRealityTrain.Door door2 = train.getDoor2(); - ctrlMsg = new TrainDoorSwitch(train, door2, door2.isOpen()); - event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); + this.control(simulation, train.getDoor1(), VirtualRealityTrain.Door.Operation.G); + train.getDoor1().finish(); + this.control(simulation, train.getDoor2(), VirtualRealityTrain.Door.Operation.G); + train.getDoor2().finish(); break; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationDeviceControlEvent.java b/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationDeviceControlEvent.java index 7e8eab8bc..c1ad1ce3d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationDeviceControlEvent.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/event/SimulationDeviceControlEvent.java @@ -1,7 +1,7 @@ package club.joylink.rtss.simulation.cbtc.event; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.communication.vo.ControllableDevice; +import club.joylink.rtss.simulation.cbtc.data.vr.ControllableVrDevice; import lombok.Getter; /** @@ -10,10 +10,11 @@ import lombok.Getter; @Getter public class SimulationDeviceControlEvent extends AbstractSimulationEvent { - private ControllableDevice ctrlMsg; + ControllableVrDevice device; - public SimulationDeviceControlEvent(Object source, Simulation simulation, ControllableDevice ctrlMsg) { + public SimulationDeviceControlEvent(Object source, Simulation simulation, ControllableVrDevice device) { super(source, simulation); - this.ctrlMsg = ctrlMsg; + this.device = device; } + } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java index 1bbc2521c..43fe8abaa 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.cbtc.member; import club.joylink.rtss.constants.MapPrdTypeEnum; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; @@ -43,6 +44,9 @@ public class MemberManager { for (Station station : stationList) { if (station.isNormal()) { this.addRole(simulation, SimulationMember.Type.STATION_SUPERVISOR, null, station); + } else if (station.isDepot()) { + // 车辆段调度 + this.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER, station.getName()+"调度", station); } } // 司机 @@ -52,8 +56,8 @@ public class MemberManager { } // 工电调度 this.addRole(simulation, SimulationMember.Type.ELECTRIC_DISPATCHER); - // 车辆段调度 - this.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER); +// // 车辆段调度 +// this.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER); // 车辆段信号楼 this.addRole(simulation, SimulationMember.Type.DEPOT_SIGNAL_BUILDING); // 停车场信号楼 @@ -82,6 +86,11 @@ public class MemberManager { this.playRole(simulation, userId, dispatcherList.get(0).getId()); break; } + case DEPOT_IL:{ + List ddList = simulation.querySimulationMembersOfRole(SimulationMember.Type.DEPOT_DISPATCHER); + this.playRole(simulation, userId, ddList.get(0).getId()); + break; + } } } } @@ -104,6 +113,14 @@ public class MemberManager { case DISPATCHER:{ break; } + case DEPOT_DISPATCHER:{ + if (Objects.isNull(device) || + !Objects.equals(device.getDeviceType(), MapElement.DeviceType.STATION) || + !((Station) device).isDepot()) { + BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.exception("车辆段调度必须关联车辆段/停车场车站"); + } + break; + } case STATION_SUPERVISOR:{ if (Objects.isNull(device) || !Objects.equals(device.getDeviceType(), MapElement.DeviceType.STATION) || diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java index d71d0619a..d86f6eea5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATO/service/ATOService.java @@ -3,7 +3,6 @@ package club.joylink.rtss.simulation.cbtc.onboard.ATO.service; import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.communication.vo.TrainDoorSwitch; import club.joylink.rtss.simulation.cbtc.constant.DriveMode; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.data.CalculateService; @@ -13,7 +12,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; -import club.joylink.rtss.simulation.cbtc.event.SimulationDeviceControlEvent; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve; import club.joylink.rtss.simulation.cbtc.onboard.ATP.OnboardAtpApiService; import lombok.extern.slf4j.Slf4j; @@ -34,6 +33,8 @@ public class ATOService { @Autowired private ApplicationContext applicationContext; + @Autowired + private VirtualRealityDeviceService virtualRealityDeviceService; @Autowired private CiApiService ciApiService; @@ -211,7 +212,7 @@ public class ATOService { // nextStopStandSection.getName(), nextStopStandSection.getCode())); boolean parking = true; Signal signal = target.getSignalOf(right); - if (!train.isHold() && (train.isJump() && (Objects.isNull(signal) || signal.isNormalOpen()) || !train.isNextParking())) { + if (!train.isHold() && (train.isJump() && (Objects.isNull(signal) || signal.isMainAspect()) || !train.isNextParking())) { parking = false; } if (parking) { @@ -414,10 +415,7 @@ public class ATOService { if (door.isOpening() || door.isOpen()) { return; } - TrainDoorSwitch ctrlMsg = new TrainDoorSwitch(train, door, true); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); - door.open(); + this.virtualRealityDeviceService.control(simulation, door, VirtualRealityTrain.Door.Operation.K); log.debug(String.format("列车[%s-%s|%s|%s]开门[%s]", train.getGroupNumber(), train.getServiceNumber(), train.getTripNumber(), train.getDestinationCode(), @@ -428,10 +426,7 @@ public class ATOService { if (door.isClosing() || door.isClose()) { return; } - TrainDoorSwitch ctrlMsg = new TrainDoorSwitch(train, door, false); - SimulationDeviceControlEvent event = new SimulationDeviceControlEvent(this, simulation, ctrlMsg); - this.applicationContext.publishEvent(event); - door.close(); + this.virtualRealityDeviceService.control(simulation, door, VirtualRealityTrain.Door.Operation.G); log.debug(String.format("列车[%s-%s|%s|%s]关门[%s]", train.getGroupNumber(), train.getServiceNumber(), train.getTripNumber(), train.getDestinationCode(), diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java index c96d8afee..2f3e241b2 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPLogicLoop.java @@ -4,7 +4,6 @@ import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.*; import club.joylink.rtss.simulation.cbtc.data.CalculateService; -import club.joylink.rtss.simulation.cbtc.data.map.MapConfig; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.simulation.cbtc.data.map.Stand; @@ -111,7 +110,7 @@ public class ATPLogicLoop { // 对于ITC列车,若列车在站台,且出站信号机开放,且ITC移动授权终点为出站信号机,手动进行释放操作 boolean right = train.isRight(); Signal signal = section.getSignalOf(right); - if (signal != null && signal.isNormalOpen() && + if (signal != null && signal.isMainAspect() && (ma2.getDevice().equals(signal) || (ma2.calculateDistanceToEoa() <= 0))) { // 信号机开放,前一个ITC-MA的终点就是此信号机 或 到终点的移动授权距离小于0(应该是折返轨情况) // 手动释放 @@ -234,6 +233,8 @@ public class ATPLogicLoop { private void driveModeControl(Simulation simulation, VirtualRealityTrain train) { DriveMode preDriveMode = train.getPreDriveMode(); + if (preDriveMode == null) + return; DriveMode driveMode = train.getDriveMode(); SectionPosition headPosition = train.getHeadPosition(); SectionPosition tailPosition = train.getTailPosition(); @@ -293,19 +294,18 @@ public class ATPLogicLoop { switch (activity) { case PARK: // 停靠 train.nextParkedTrainActivity(); + if (train.isAtoOn()) { + atoService.closeATO(train); + train.setAutoOpenATO(true); + } break; case OPEN_DOOR: // 开门 - if (train.isAtoOn()) { + if (!train.getDoorMode().equals(VirtualRealityTrain.DoorMode.MM)) { // 不是自动开门 this.atoService.syncOpenDoor(simulation, train); } if (this.isAllDoorOpen(simulation, train)) { train.nextParkedTrainActivity(); - if (train.isAtoOn()) { - atoService.closeATO(train); - train.setAutoOpenATO(true); - } } -// } break; case BOARD: // 乘客乘降 break; @@ -319,6 +319,9 @@ public class ATPLogicLoop { // } // 可以关门 // this.atoService.syncCloseDoor(simulation, train); + if (train.getDoorMode().equals(VirtualRealityTrain.DoorMode.AA)) { // 自动关门 + this.atoService.syncCloseDoor(simulation, train); + } if (this.isAllDoorClose(simulation, train)) { train.nextParkedTrainActivity(); } @@ -381,10 +384,10 @@ public class ATPLogicLoop { SectionPosition headPosition = train.getHeadPosition(); Signal signal = headPosition.getSection().getSignalOf(train.isRight()); if (signal != null) {// 站台前方信号未开放 - if (!signal.isNormalOpen() && !(train.isRMMode() || train.isNRMMode())) { + if (!signal.isMainAspect() && !(train.isRMMode() || train.isNRMMode())) { return false; } - if (signal.isNormalOpen()) { + if (signal.isMainAspect()) { // 信号机开放,但移动授权终点还是此信号机(可能是ITC未到达此信号机主应答器) MaService.Ma ma2 = train.getMa2(); if (ma2 != null && ma2.getDevice().equals(signal) && !train.isReleased()) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java index 95adfdafc..be14dc358 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/ATP/ATPService.java @@ -293,6 +293,14 @@ public class ATPService { log.warn(String.format("列车[%s]未停止,不能操作车门", train.getGroupNumber())); return; } + if (!train.getDoorMode().isAuto(open)) { + log.warn(String.format("列车[%s]门模式自动,不能操作车门", train.getGroupNumber())); + return; + } + if (!train.getDoorSelection().match(right)) { + log.warn(String.format("列车[%s]门选择与操作不匹配", train.getGroupNumber())); + return; + } List standList = train.getHeadPosition().getSection().getStandList(); VirtualRealityTrain.Door door = train.getDoorByDirection(right); if (open) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/TrainTargetUpdateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/TrainTargetUpdateService.java index e255a1a28..898593198 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/TrainTargetUpdateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/onboard/TrainTargetUpdateService.java @@ -52,7 +52,7 @@ public class TrainTargetUpdateService { continue; } Signal signal = temp.getSignalOf(right); - if (signal != null && !signal.isNormalOpen()) { + if (signal != null && !signal.isMainAspect()) { newTarget = temp; if (temp.isFunctionTrack()) break; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java index b92e4d88f..8587f62d3 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/robot/RobotLogicLoop.java @@ -5,11 +5,14 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher; import club.joylink.rtss.simulation.cbtc.ATS.operation.handler.DriverOperateHandler; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsStationService; import club.joylink.rtss.simulation.cbtc.CI.CiApiService; +import club.joylink.rtss.simulation.cbtc.CI.service.VrPsdService; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.constant.SimulationModule; import club.joylink.rtss.simulation.cbtc.data.CalculateService; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.Section; +import club.joylink.rtss.simulation.cbtc.data.map.Stand; import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO; @@ -26,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Component; +import org.springframework.util.CollectionUtils; import java.util.Collections; import java.util.List; @@ -66,6 +70,9 @@ public class RobotLogicLoop { @Autowired private ATPService atpService; + @Autowired + private VrPsdService vrPsdService; + /** * 根据目标位置运行 */ @@ -94,17 +101,14 @@ public class RobotLogicLoop { break; case CLOSE_DOOR: atoService.syncCloseDoor(simulation, train); -// atpService.openOrCloseDoor(simulation, train, false, false); -// atpService.openOrCloseDoor(simulation, train, true, false); -// if (!train.isCommunicable()) { -// Section headSection = train.getHeadPosition().getSection(); -// List standList = headSection.getStandList(); -// if (!CollectionUtils.isEmpty(standList)) { -// for (Stand stand : standList) { -// ciApiService.closeScreenDoor(simulation, stand.getCode()); -// } -// } -// } + SectionPosition headPosition = train.getHeadPosition(); + Section section = headPosition.getSection(); + List standList = section.getStandList(); + if (!CollectionUtils.isEmpty(standList)) { + //这里应该先转操作允许/禁止钥匙再关门,暂时这样简单处理 + standList.forEach(stand -> vrPsdService.controlVrPSD(simulation, + stand.getPsd().getVirtualScreenDoor(), false, VrPsdService.CommandSource.PSL)); + } break; case START: if (train.isAutoOpenATO()) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java b/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java index 0d1c1bf78..1275a673a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/tool/DeviceStatusModifyTool.java @@ -1,12 +1,15 @@ package club.joylink.rtss.simulation.cbtc.tool; import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainLoadService; -import club.joylink.rtss.simulation.cbtc.CI.service.RouteService; +import club.joylink.rtss.simulation.cbtc.CI.device.CiRouteService; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; +import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; +import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -23,9 +26,10 @@ import java.util.Objects; @Slf4j @Component public class DeviceStatusModifyTool { - @Autowired - private RouteService routeService; + private VirtualRealityDeviceService virtualRealityDeviceService; + @Autowired + private CiRouteService routeService; @Autowired private AtsTrainLoadService atsTrainLoadService; @@ -40,7 +44,7 @@ public class DeviceStatusModifyTool { this.batchSetRouteFlsSwitchPositionAndLock(route.getFlsList()); // 进路元素锁闭 route.getSectionList().forEach(section -> section.routeLocking(route, route.getStart().isRight())); - if (this.routeService.checkCanOverlapSet(simulation, route)) { + if (route.isSettingOverlap()) { SectionPath overlapPath = route.selectOverlapElement(); if (Objects.nonNull(overlapPath)) { this.batchSetRouteFlsSwitchPositionAndLock(overlapPath.getFlsList()); @@ -53,8 +57,7 @@ public class DeviceStatusModifyTool { route.setNormalUnlock(false); route.setLock(true); simulation.getRepository().addSettingRoute(route); - Signal.LightColor color = Signal.LightColor.getByIsGreen(route.isOpenGreen()); - this.openSignalDirectly(route.getStart(), color); + this.openSignalDirectly(route.getStart(), route.getAspect()); route.getStart().setLockedRoute(route); } @@ -72,7 +75,7 @@ public class DeviceStatusModifyTool { } } for (SwitchElement switchElement : switchElementList) { - switchElement.getASwitch().ciUse(switchElement.isNormal()); +// switchElement.getASwitch().ciUse(switchElement.isNormal()); this.setSingleSwitchPositionDirectly(switchElement.getASwitch(), switchElement.isNormal()); switchElement.getASwitch().fpLock(); } @@ -98,37 +101,29 @@ public class DeviceStatusModifyTool { } public void openGuideSignalDirectly(Signal signal) { - signal.changeLightType(false); VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); - virtualSignal.apply(false, true, true); - signal.apply(false, true, true); + SignalAspect guideAspect = virtualSignal.getModel().getGuideAspect(); + virtualSignal.control(guideAspect); + virtualSignal.finish(); + signal.changeLightType(false); + signal.setAspect(guideAspect); } /** * 直接开灯(默认逻辑点灯) * @param signal - * @param color + * @param aspect */ - private void openSignalDirectly(Signal signal, Signal.LightColor color) { + private void openSignalDirectly(Signal signal, SignalAspect aspect) { VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); signal.changeLightType(true); if (signal.isLogicLight() && !signal.isVirtual()) { - virtualSignal.apply(false, false, false); - } - switch (color) { - case YELLOW: - signal.apply(false, true, false); - if (!signal.isLogicLight()) { - virtualSignal.apply(false, true, false); - } - break; - case GREEN: - signal.apply(true, false, false); - if (!signal.isLogicLight()) { - virtualSignal.apply(true, false, false); - } - break; + virtualSignal.control(SignalAspect.No); + } else { + virtualSignal.control(aspect); } + virtualSignal.finish(); + signal.setAspect(aspect); } /** @@ -138,12 +133,14 @@ public class DeviceStatusModifyTool { public void closeSignalDirectly(Signal signal) { VirtualRealitySignal virtualSignal = signal.getVirtualSignal(); signal.changeLightType(true); + SignalAspect defaultAspect = virtualSignal.getModel().getDefaultAspect(); if (signal.isLogicLight()) { - virtualSignal.apply(false, false, false); + virtualSignal.control(SignalAspect.No); } else { - virtualSignal.apply(false, false, true); + virtualSignal.control(defaultAspect); } - signal.apply(false, false, true); + virtualSignal.finish(); + signal.setAspect(defaultAspect); } /** @@ -156,10 +153,10 @@ public class DeviceStatusModifyTool { if (!CollectionUtils.isEmpty(switchList)) { for (SwitchElement switchElement : switchList) { if (switchElement.getASwitch().isOverlapLock() && - switchElement.getASwitch().isOnPosition(!switchElement.isNormal())) { + switchElement.isOnPosition()) { continue; } - switchElement.getASwitch().ciUse(switchElement.isNormal()); +// switchElement.getASwitch().ciUse(switchElement.isNormal()); this.setSingleSwitchPositionDirectly(switchElement.getASwitch(), switchElement.isNormal()); if (routeLock) { switchElement.getASwitch().routeLock(route); @@ -178,15 +175,13 @@ public class DeviceStatusModifyTool { public void setSingleSwitchPositionDirectly(Switch aSwitch, boolean normal) { VirtualRealitySwitch virtualSwitch = aSwitch.getVirtualSwitch(); if (normal) { - virtualSwitch.setNormal(true); - virtualSwitch.setReverse(false); - aSwitch.setNormalPosition(true); - aSwitch.setReversePosition(false); + virtualSwitch.control(VirtualRealitySwitch.Operation.NP); + virtualSwitch.finish(); + aSwitch.setPos(SwitchIndication.N); } else { - virtualSwitch.setReverse(true); - virtualSwitch.setNormal(false); - aSwitch.setReversePosition(true); - aSwitch.setNormalPosition(false); + virtualSwitch.control(VirtualRealitySwitch.Operation.NP); + virtualSwitch.finish(); + aSwitch.setPos(SwitchIndication.R); } } diff --git a/src/main/java/club/joylink/rtss/simulation/rt/ATS/bo/AtsRepositoryBuilder.java b/src/main/java/club/joylink/rtss/simulation/rt/ATS/bo/AtsRepositoryBuilder.java index e6084699c..7822152ec 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/ATS/bo/AtsRepositoryBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/ATS/bo/AtsRepositoryBuilder.java @@ -1,8 +1,11 @@ package club.joylink.rtss.simulation.rt.ATS.bo; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; -import club.joylink.rtss.simulation.rt.ATS.bo.plan.AtsRunPlanBuilder; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapSignalNewVO; +import club.joylink.rtss.vo.map.graph.MapSwitchVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; import java.util.List; import java.util.Map; diff --git a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java index 869df2e3a..e1a31c69a 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/CIL/bo/CilRepositoryBuilder.java @@ -2,6 +2,16 @@ package club.joylink.rtss.simulation.rt.CIL.bo; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapESPVO; +import club.joylink.rtss.vo.map.graph.MapPSDVO; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapSignalNewVO; +import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; +import club.joylink.rtss.vo.map.graph.MapSwitchVO; +import club.joylink.rtss.vo.map.logic.MapAutoSignalNewVO; +import club.joylink.rtss.vo.map.logic.MapOverlapVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; import org.springframework.util.CollectionUtils; import java.util.ArrayList; diff --git a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrdRepositoryBuilder.java b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrdRepositoryBuilder.java index 6da055371..edd5df961 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrdRepositoryBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/SRD/bo/SrdRepositoryBuilder.java @@ -3,6 +3,12 @@ package club.joylink.rtss.simulation.rt.SRD.bo; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapPSDVO; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapSignalNewVO; +import club.joylink.rtss.vo.map.graph.MapSwitchVO; +import club.joylink.rtss.vo.map.graph.MapTrainModelVO; +import club.joylink.rtss.vo.map.graph.MapTrainVO; import org.springframework.util.StringUtils; import java.util.List; diff --git a/src/main/java/club/joylink/rtss/simulation/rt/iscs/IscsStatusPublisher.java b/src/main/java/club/joylink/rtss/simulation/rt/iscs/IscsStatusPublisher.java new file mode 100644 index 000000000..1666d7e0f --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/rt/iscs/IscsStatusPublisher.java @@ -0,0 +1,38 @@ +package club.joylink.rtss.simulation.rt.iscs; + +import club.joylink.rtss.simulation.Simulation; +import club.joylink.rtss.simulation.SimulationTriggerMessagePublisher; +import club.joylink.rtss.simulation.Watchable; +import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository; +import com.sun.source.tree.ReturnTree; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class IscsStatusPublisher extends SimulationTriggerMessagePublisher { + public static final String Name = "iscs"; + public static final String Destination = String.format("%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", "psd"); + + club.joylink.rtss.simulation.cbtc.Simulation simulation; + public IscsStatusPublisher(club.joylink.rtss.simulation.cbtc.Simulation simulation) { + super(Name, Collections.singletonList(Destination)); + this.simulation = simulation; + } + + @Override + public Object buildMessageOfSubscribe(String destination) { + SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository(); + return iscsRepository.getAllStatus(); + } + + @Override + public List getNeedBuildDestination(Watchable watchable) { + return new ArrayList<>(this.getDestinationParamsMap().keySet()); + } + + @Override + public Object buildMessage(Watchable watchable) { + return Collections.singletonList(watchable); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepositoryBuilder.java b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepositoryBuilder.java index bdf699bb8..22e41713d 100644 --- a/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepositoryBuilder.java +++ b/src/main/java/club/joylink/rtss/simulation/rt/repo/CommonRepositoryBuilder.java @@ -3,6 +3,15 @@ package club.joylink.rtss.simulation.rt.repo; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.vo.map.*; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapSignalNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; +import club.joylink.rtss.vo.map.graph.MapSwitchVO; +import club.joylink.rtss.vo.map.logic.MapOverlapVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; +import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java index c6e32b064..5ed8fd813 100644 --- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java +++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java @@ -188,5 +188,8 @@ public enum WebSocketMessageType { /**广播消息 */ BROADCAST, + + /** ------------ISCS消息------------- */ + ISCS, ; } diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapButtonVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapButtonVO.java deleted file mode 100644 index 8b07500e8..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapButtonVO.java +++ /dev/null @@ -1,35 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * 按钮对象 - */ -@Getter -@Setter -@NoArgsConstructor -public class MapButtonVO { - /** - * 编号 - */ - @NotBlank(message = "编号不能为空") - private String code; - /** - * 类型 - */ - @NotBlank(message = "类型不能为空") - private String type; - - @NotNull(message = "坐标不能为Null") - private Point position; - /** - * 车站 - */ - private String stationCode; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapLinkVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapLinkVO.java deleted file mode 100644 index cc62e8afb..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapLinkVO.java +++ /dev/null @@ -1,71 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.PositiveOrZero; - -@Getter -@Setter -public class MapLinkVO { - - /** - * link 编码 - */ - @NotBlank(message="link 编码不能为空") - private String code; - - /** - * link名称 - */ - @NotBlank(message="link名称不能为空") - private String name; - - /** - * link 类型-数据字典值 - */ - @NotBlank(message="link 类型不能为空") - private String type; - - /** - * 实际长度:单位m - */ - @NotNull(message="实际长度不能为Null") - @PositiveOrZero(message="实际长度必须>=0") - private Float lengthFact; - - /** - * 起点坐标 - */ - @NotNull(message="起点坐标不能为Null") - private Point lp; - - /** - * 终点坐标 - */ - @NotNull(message="终点坐标不能为Null") - private Point rp; - - /** - * 左正向link 编码:0为尽头 - */ - private String leftFdCode; - - /** - * 左侧向link 编码:0为尽头 - */ - private String leftSdCode; - - /** - * 右正向link 编码:0为尽头 - */ - private String rightFdCode; - - /** - * 右侧向link 编码:0为尽头 - */ - private String rightSdCode; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapRouteSettingSignalVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapRouteSettingSignalVO.java deleted file mode 100644 index 0dd6c0bd1..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapRouteSettingSignalVO.java +++ /dev/null @@ -1,36 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * 车站进路排列指示灯草稿 - */ -@Getter -@Setter -@NoArgsConstructor -public class MapRouteSettingSignalVO { - - /** - * 编码 - */ - @NotBlank(message="编码不能为空") - private String code; - - /** - * 所属车站编码 - */ - @NotBlank(message="所属车站编码不能为空") - private String stationCode; - - /** - * 画图坐标 - */ - @NotNull(message="画图坐标不能为Null") - private Point position; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapSectionVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapSectionVO.java deleted file mode 100644 index a20c4a0d8..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapSectionVO.java +++ /dev/null @@ -1,249 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -@NoArgsConstructor -@Getter -@Setter -@EqualsAndHashCode -public class MapSectionVO { - - /** - * 编码 - */ - @NotBlank(message="编码不能为空") - private String code; - - /** - * 名称 - */ - @NotNull(message="名称不能为Null") - private String name; - - /** - * 所属Link编码 - */ - @NotBlank(message="所属Link编码不能为空") - private String linkCode; - - /** - * 所属车站 编号 - */ - private String stationCode; - -// /** -// * 是否显示名称:false-不显示,true-显示 -// */ -// @NotNull(message="{draftSectionVO.nameShow.notNull}") -// private Boolean nameShow; - - /** - * 名称显示坐标 - */ - private Point namePosition; - - /** - * 是否显示计轴器:false-不显示,true-显示 - */ - @NotNull(message="是否显示计轴器不能为Null") - private Boolean axleShow; - - /** - * 左端相对Link偏移量:单位m - */ - @NotNull(message="左端相对Link偏移量不能为Null") - private Float offsetLeft; - - /** - * 左端分隔符类型 - */ - @NotBlank(message="左端分隔符类型不能为空") - private String sepTypeLeft; - - /** - * 右端相对Link偏移量:单位m - */ - @NotNull(message="右端相对Link偏移量不能为Null") - private Float offsetRight; - - /** - * 右端分隔符类型 - */ - @NotBlank(message="右端分隔符类型不能为空") - private String sepTypeRight; - - private Float lengthFact; - - /** - * 逻辑区段数量 - */ - @NotNull(message="逻辑区段数量不能为空") - private List logicSectionNum; - - /** - * 是否显示逻辑区段:false-不显示,true-显示 - */ - @NotNull(message="是否显示逻辑区段不能为Null") - private Boolean logicSectionShow; - -// /** -// * 是否显示逻辑区段名称 -// */ -// @ApiModelProperty(value="是否显示逻辑区段名称") -// @NotNull(message="是否显示逻辑区段名称不能为Null") -// private Boolean logicSectionNameShow; - - /** - * 列车位置类型 - */ - @NotNull(message="列车位置类型不能为Null") - private String trainPosType; - - /** - * 点坐标列表 - */ - @NotEmpty(message = "点坐标列表不能为null") - private List points; - - /** - * 关联的物理区段编号 - */ - private String parentCode; - - /** - * 区段类型:物理区段/逻辑区段/道岔物理区段 - */ - @NotNull(message="区段类型不能为Null") - private String type; - - /** - * 逻辑区段列表 - */ - @JsonIgnore - List logicList; - - /** - * 是否站台轨 - */ - @NotNull(message="是否站台轨不能为Null") - private Boolean isStandTrack; - - /** - * 站台轨名称 - */ - private String standTrackName; - - /** - * 站台轨名称坐标 - */ - private Point standTrackNamePosition; - - /** - * 是否折返轨 - */ - @NotNull(message="是否折返轨不能为Null") - private Boolean isReentryTrack; - - /** - * 折返轨名称 - */ - private String reentryTrackName; - - /** - * 折返轨名称坐标 - */ - private Point reentryTrackNamePosition; - - /** - * 是否转换轨 - */ - @NotNull(message="是否转换轨不能为Null") - private Boolean isTransferTrack; - - /** - * 转换轨名称 - */ - private String transferTrackName; - - /** - * 转换轨名称坐标 - */ - private Point transferTrackNamePosition; - - /** - * 是否道岔区段 - */ - @NotNull(message="是否道岔区段不能为Null") - private Boolean isSwitchSection; - - /** - * 道岔区段关联道岔编号 - */ - private String relSwitchCode; - - /** - * 逻辑区段按名称排序方式:true-从小到大,false-从大到小 - */ - private Boolean logicSectionNameSort; - - /** - * 区段是否为曲线 - */ - private Boolean isCurve; - - /** - * 关联站台编码 - */ - private String relStandCode; - - /** - * 左向停车点偏移量 - */ - private Float leftStopPointOffset; - - /** - * 右向停车点偏移量 - */ - private Float rightStopPointOffset; - - /** - * 目的地码 - */ - private String destinationCode; - - /** - * 目的地码坐标 - */ - private Point destinationCodePoint; - -// /** -// * 是否显示目的地码 -// */ -// @ApiModelProperty(value = "是否显示目的地码") -// private Boolean destinationCodeShow; - - /** - * 左侧公里标(厘米) - */ - private Float kmRangeLeft; - - /** - * 右侧公里标(厘米) - */ - private Float kmRangeRight; - - /** - * 区间 - */ - private String region; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapSignalVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapSignalVO.java deleted file mode 100644 index 974fffe5d..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapSignalVO.java +++ /dev/null @@ -1,132 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * 信号机草稿 - */ -@Getter -@Setter -public class MapSignalVO { - - /** - * 编码 - */ - @NotBlank(message="编码不能为空") - private String code; - - /** - * 名称 - */ - @NotBlank(message="名称不能为空") - private String name; - - /** - * 唯一名称 - */ - @NotBlank(message = "唯一名称不能为空") - private String uniqueName; - - /** - * 所属Link编码 - */ - @NotBlank(message="所属Link编码不能为空") - private String linkCode; - - /** - * 所属车站 编号 - */ - private String stationCode; - - /** - * 坐标 - */ - @NotNull(message="坐标不能为Null") - private Point position; - -// /** -// * 是否显示信号机名称:false-不显示,true-显示 -// */ -// @NotNull(message="是否显示信号机名称不能为Null") -// private Boolean nameShow; - - /** - * 名称显示坐标 - */ - private Point namePosition; - - /** - * 信号机灯位类型 - */ - @NotBlank(message="信号机灯位类型不能为空") - private String lampPositionType; - - /** - * 用途类型 - */ - @NotBlank(message="用途类型不能为空") - private String useType; - - /** - * 灯柱类型 - */ - @NotBlank(message="灯柱类型不能为空") - private String lampPostType; - - /** - * 位置类型 - */ - @NotBlank(message="位置类型不能为空") - private String positionType; - /** - * 显示方向类型 - */ - @NotBlank(message="显示方向类型不能为空") - private String directionShowType; - - /** - * 方向类型 - */ - @NotBlank(message="方向类型不能为空") - private String directionType; - - /** - * 是否显示按钮:false-不显示,true-显示 - */ - @NotNull(message="是否显示按钮不能为Null") - private Boolean buttonShow; - - /** - * 按钮坐标 - */ - @NotNull(message="按钮坐标不能为Null") - private Point buttonPosition; - - /** - * 所属Link偏移量:单位m - */ - @NotNull(message="所属Link偏移量不能为Null") - private Float offset; - - /** - * 是否显示引导信号:false-不显示,true-显示 - */ - @NotNull(message="是否显示引导信号不能为Null") - private Boolean guideShow; - - /** - * 引导信号位置坐标 - */ - @NotNull(message="引导信号位置坐标不能为Null") - private Point guidePosition; - - /** - * 旋转角度 - */ - private Integer rotate; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapStationControlVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapStationControlVO.java deleted file mode 100644 index 70b3adb71..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapStationControlVO.java +++ /dev/null @@ -1,53 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * 车站控制模式 VO 对象 - * @author sheng - * - */ -@Getter -@Setter -@NoArgsConstructor -public class MapStationControlVO { - - @NotBlank(message="编码不能为空") - private String code; - - @NotBlank(message="所属车站编码不能为空") - private String stationCode; - - @NotNull(message="坐标不能为Null") - private Point position; - /** - * 中控显示内容 - */ - @NotBlank(message="中控显示内容不能为空") - private String zokContent; - /** - * 站控显示内容 - */ - @NotBlank(message="站控显示内容不能为空") - private String zakContent; - /** - * 紧急站控显示内容 - */ - @NotBlank(message="紧急站控显示内容不能为空") - private String jjzkContent; - /** - * 站中控显示内容 - */ - @NotBlank(message="站中控显示内容不能为空") - private String zzkContent; - /** - * 连锁控显示内容 - */ - private String lskContent; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapStationCounterVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapStationCounterVO.java deleted file mode 100644 index 5dbaf589d..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapStationCounterVO.java +++ /dev/null @@ -1,57 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * 车站计数器 - */ -@Getter -@Setter -@NoArgsConstructor -public class MapStationCounterVO { - - /** - * 唯一编号 - */ - @NotBlank(message = "编号不能为空") - private String code; - - /** - * 所属车站 编号 - */ - @NotBlank(message = "车站不能为空") - private String stationCode; - - /** - * 名称 - */ - private String name; - - /** - * 画图坐标 - */ - @NotNull(message = "坐标不能为空") - private Point position; - - /** - * 计数器类型 - */ - @NotBlank(message = "计数器类型不能为空") - private String type; - - /** - * 计数器值 - */ - private Integer val; - - /** - * 最大值 - */ - private Integer max; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapStationDelayUnlockShowVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapStationDelayUnlockShowVO.java deleted file mode 100644 index 102ddefbb..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapStationDelayUnlockShowVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -@Getter -@Setter -@NoArgsConstructor -public class MapStationDelayUnlockShowVO { - - /** - * 唯一编号 - */ - @NotBlank(message = "编号不能为空") - private String code; - - /** - * 所属车站 编号 - */ - @NotBlank(message = "所属车站不能为空") - private String stationCode; - - /** - * 延时解锁时间 - */ - private Integer unlockTime; - - /** - * 画图坐标 - */ - @NotNull(message = "坐标不能为空") - private Point position; - - /** - * 文字字体 - */ - @NotBlank(message = "文字字体不能为空") - private String font; - - /** - * 文字颜色 - */ - @NotBlank(message = "文字颜色不能为空") - private String fontColor; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapStationStandVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapStationStandVO.java deleted file mode 100644 index 1758b692d..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapStationStandVO.java +++ /dev/null @@ -1,88 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - * 车站站台 - */ -@NoArgsConstructor -@Getter -@Setter -public class MapStationStandVO { - - /** - * 编码 - */ - @NotBlank(message="编码不能为空") - private String code; - - /** - * 名称 - */ - @NotBlank(message="名称不能为空") - private String name; - - /** - * 车站编码 - */ - @NotBlank(message="所属车站编码不能为空") - private String stationCode; - - /** - * 所属设备集中站 - */ - @NotBlank(message = "所属设备集中站不能为空") - private String deviceStationCode; - - /** - * 画图坐标 - */ - @NotNull(message="画图坐标不能为Null") - private Point position; - - /** - * 长度 - */ - @NotNull(message="长度不能为Null") - private Integer width; - - /** - * 宽度 - */ - @NotNull(message="宽度不能为Null") - private Integer height; - - /** - * 是否有屏蔽门:false-没有,true-有 - */ - @NotNull(message="是否有屏蔽门不能为Null") - private Boolean hasDoor; - - /** - * 屏蔽门方位类型 - */ - @NotBlank(message="屏蔽门方位类型不能为空") - private String doorLocationType; - - /** - * 行驶方向 - */ - @NotBlank(message="行驶方向不能为空") - private String direction; - - /** - * 是否可见 - */ - private Boolean visible; - - /** - * 站台轨 - */ - private MapSectionVO standTrack; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapStationVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapStationVO.java deleted file mode 100644 index 7b69cb6e9..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapStationVO.java +++ /dev/null @@ -1,113 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -/** - * 车站 - */ -@Getter -@Setter -public class MapStationVO { - - /** - * 编码 - */ - @NotBlank(message="编码不能为空") - private String code; - - /** - * 名称 - */ - @NotBlank(message="名称不能为空") - private String name; - - /** - * 画图坐标 - */ - @NotNull(message="名称不能为Null") - private Point position; - - /** - * 车站名称字体 - */ - @NotBlank(message="车站名称字体不能为空") - private String nameFont; - - /** - * 名称颜色 - */ - @NotBlank(message="名称颜色不能为空") - private String nameFontColor; - - /** - * 公里标内容 - */ - @NotBlank(message="公里标内容不能为空") - private String kmPost; - -// /** -// * 是否显示公里标 -// */ -// @ApiModelProperty(value="是否显示公里标") -// @NotNull(message="是否显示公里标不能为Null") -// private Boolean kmPostShow; - - /** - * 公里标字体 - */ - @NotBlank(message="公里标字体不能为空") - private String kmPostFont; - - /** - * 公里标颜色 - */ - @NotBlank(message="公里标颜色不能为空") - private String kmPostFontColor; - - /** - * 公里标距离(毫米) - */ - private Float kmRange; - - /** - * 所属设备集中站编码 - */ - private String concentrateStationCode; - - /** - * 真实运行图站名 - */ - private String runPlanName; - - /** - * 是否可见 - */ - private Boolean visible; - - /** - * 是否集中站 - */ - private Boolean centralized; - - /** - * 所属zc区域编码 - */ - private String zcCode; - - private List standList; - - public void addStand(MapStationStandVO standVO) { - if(Objects.isNull(getStandList())) { - this.standList = new ArrayList<>(); - } - this.standList.add(standVO); - } -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/MapTrainWindowVO.java b/src/main/java/club/joylink/rtss/vo/client/map/MapTrainWindowVO.java deleted file mode 100644 index fa351b2c3..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/MapTrainWindowVO.java +++ /dev/null @@ -1,48 +0,0 @@ -package club.joylink.rtss.vo.client.map; - -import club.joylink.rtss.vo.map.Point; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; - -/** - *车次窗 - */ -@NoArgsConstructor -@Getter -@Setter -public class MapTrainWindowVO { - - /** - *车次窗唯一编码 - */ - @NotBlank(message="车次窗编码不能为空") - private String code; - - /** - *坐标 - */ - @NotNull(message="坐标不能为空") - private Point point; - - /** - *车次窗宽度 - */ - @NotNull(message="车次窗宽度不能为空") - private Integer width; - - /** - *车次窗高度 - */ - @NotNull(message="车次窗高度不能为空") - private Integer height; - - /** - *所属区段编码 - */ - @NotBlank(message="所属区段编码不能为空") - private String sectionCode; -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/RealLineListVO.java b/src/main/java/club/joylink/rtss/vo/client/map/RealLineListVO.java index 0af5fa4f6..b6d7a1fb7 100644 --- a/src/main/java/club/joylink/rtss/vo/client/map/RealLineListVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/map/RealLineListVO.java @@ -1,7 +1,7 @@ package club.joylink.rtss.vo.client.map; import club.joylink.rtss.entity.RealLine; -import club.joylink.rtss.vo.map.Point; +import club.joylink.rtss.vo.map.graph.Point; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Getter; diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/ConflictingSignalVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/ConflictingSignalVO.java deleted file mode 100644 index 67931b92c..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/ConflictingSignalVO.java +++ /dev/null @@ -1,26 +0,0 @@ -package club.joylink.rtss.vo.client.map.newmap; - -import club.joylink.rtss.vo.map.MapCISwitchVO; -import lombok.Getter; -import lombok.Setter; - -import javax.validation.constraints.NotBlank; -import java.util.List; - -/** - * 敌对信号 - */ -@Getter -@Setter -public class ConflictingSignalVO { - /** - * 信号机code - */ - @NotBlank(message = "敌对信号信号机code不能为空") - private String signalCode; - /** - * 道岔位置条件 - */ - private List switchPositionList; - -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapApproachSectionQueryVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapApproachSectionQueryVO.java deleted file mode 100644 index 46711c867..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapApproachSectionQueryVO.java +++ /dev/null @@ -1,13 +0,0 @@ -package club.joylink.rtss.vo.client.map.newmap; - -import club.joylink.rtss.vo.client.PageQueryVO; -import lombok.Getter; -import lombok.Setter; - -@Getter -@Setter -public class MapApproachSectionQueryVO extends PageQueryVO { - - private String signalCode; - -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapOverlapRelSectionSwitchVO.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapOverlapRelSectionSwitchVO.java deleted file mode 100644 index d987c4849..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/MapOverlapRelSectionSwitchVO.java +++ /dev/null @@ -1,43 +0,0 @@ -package club.joylink.rtss.vo.client.map.newmap; - -import club.joylink.rtss.simulation.cbtc.data.map.RouteOverlapElement; -import club.joylink.rtss.vo.map.MapCISwitchVO; -import lombok.Getter; -import lombok.Setter; -import org.springframework.util.CollectionUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * 延续保护线路 - */ -@Getter -@Setter -public class MapOverlapRelSectionSwitchVO { - - /** - * 进路延续保护区段数据列表 - */ - private List routeOverlapSectionList; - - /** - * 进路延续保护道岔数据列表 - */ - private List routeOverlapSwitchList; - - public MapOverlapRelSectionSwitchVO(){ - routeOverlapSectionList = new ArrayList<>(); - routeOverlapSwitchList = new ArrayList<>(); - } - - public static List convertBO2VOList(List list) { - List voList = new ArrayList<>(); - if (!CollectionUtils.isEmpty(list)) { - for (RouteOverlapElement routeOverlapElement : list) { - - } - } - return voList; - } -} diff --git a/src/main/java/club/joylink/rtss/vo/client/map/newmap/validate/RailwayRouteCreateCheck.java b/src/main/java/club/joylink/rtss/vo/client/map/newmap/validate/RailwayRouteCreateCheck.java deleted file mode 100644 index 3be2dbd52..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/map/newmap/validate/RailwayRouteCreateCheck.java +++ /dev/null @@ -1,4 +0,0 @@ -package club.joylink.rtss.vo.client.map.newmap.validate; - -public interface RailwayRouteCreateCheck { -} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java b/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java index 0d0ece033..e7e4d5abc 100644 --- a/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/project/ProjectDeviceVO.java @@ -9,10 +9,16 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDevice import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSignalConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.gzb.GzbSwitchConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.heb.device.*; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorDcuConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorIbpConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorPsdConfig; +import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.richor.RichorPslConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPsdConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.sdy.SdyPslConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.xty.XtyPsdConfig; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.client.project.richor.RichorIbpConfigVO; +import club.joylink.rtss.vo.client.project.richor.RichorPslConfigVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.NoArgsConstructor; @@ -104,12 +110,39 @@ public class ProjectDeviceVO { case SDY: { return sdyDeviceConfigConvert(voList); } + case RICHOR_JOINT: { + return richorJointDeviceConfigConvert(voList); + } } } return list; } + private static List richorJointDeviceConfigConvert(List voList) { + List list = new ArrayList<>(); + for (ProjectDeviceVO deviceVO : voList) { + switch (deviceVO.getType()) { + case IBP: + list.add(new RichorIbpConfig(deviceVO)); + break; + case PLC_GATEWAY: + list.add(new PlcGateway(deviceVO)); + break; + case PSD: + list.add(new RichorPsdConfig(deviceVO)); + break; + case PSL: + list.add(new RichorPslConfig(deviceVO)); + break; + case DCU: + list.add(new RichorDcuConfig(deviceVO)); + break; + } + } + return list; + } + private static List sdyDeviceConfigConvert(List voList) { List list = new ArrayList<>(); for (ProjectDeviceVO deviceVO : voList) { diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorDcuConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorDcuConfigVO.java new file mode 100644 index 000000000..ef2515262 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorDcuConfigVO.java @@ -0,0 +1,35 @@ +package club.joylink.rtss.vo.client.project.richor; + +import club.joylink.rtss.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * 安全回路 + */ +@Getter +@Setter +@NoArgsConstructor +public class RichorDcuConfigVO { + private String iscsCode = "dcu"; + + /** + * 网关位开始地址 + */ + private Integer addr = 0; + /** + * 位数量 + */ + private Integer quantity = 80; + + /* ----------------------状态位---------------------- */ + /** 安全回路 */ + private Integer r_sx_aqhl = 68; + + @JsonIgnore + public String toJson() { + return JsonUtils.writeValueAsString(this); + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorIbpConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorIbpConfigVO.java new file mode 100644 index 000000000..e821e9d6b --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorIbpConfigVO.java @@ -0,0 +1,123 @@ +package club.joylink.rtss.vo.client.project.richor; + +import club.joylink.rtss.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class RichorIbpConfigVO { + /** + * ibp盘绑定的车站 + */ + private String stationCode = "Station25166"; + + private String iscsCode = "ibp"; + /** + * 网关位开始地址 + */ + private Integer addr = 0; + /** + * 位数量 + */ + private Integer quantity = 80; + + /*---------------- 屏蔽门 ----------------*/ + /** + * 下行紧急停车(1是false)(因为只能接常闭点) + */ + private Integer r_xx_jjtc = 0; + + /** + * 下行取消紧停 + */ + private Integer r_xx_qxjt = 1; + + /** + * 下行扣车 + */ + private Integer r_xx_kc = 2; + + /** + * 下行取消扣车 + */ + private Integer r_xx_qxkc = 3; + + /** + * 上行紧急停车(1是false)(因为只能接常闭点) + */ + private Integer r_sx_jjtc = 4; + + /** + * 上行取消紧停 + */ + private Integer r_sx_qxjt = 5; + + /** + * 上行扣车 + */ + private Integer r_sx_kc = 6; + + /** + * 上行取消扣车 + */ + private Integer r_sx_qxkc = 7; + + /** + * 试灯 + */ + private Integer r_sd = 8; + + /** + * 切断报警 + */ + private Integer r_qdbj = 9; + + /** + * 蜂鸣器 + */ + private Integer w_fmq = 18; + + /** + * 下行紧急停车灯 + */ + private Integer w_xx_jjtcd = 20; + + /** + * 下行扣车灯 + */ + private Integer w_xx_kcd = 21; + + /** + * 上行紧急停车灯 + */ + private Integer w_sx_jjtcd = 22; + + /** + * 上行扣车灯 + */ + private Integer w_sx_kcd = 23; + + + /** 操作允许 */ + private Integer r_sx_czyx = 77; + + /** 开门命令 */ + private Integer r_sx_km = 75; + + /** 关门命令 */ + private Integer r_sx_gm = 76; + + public RichorIbpConfigVO(Integer addr, Integer quantity) { + this.addr = addr; + this.quantity = quantity; + } + + @JsonIgnore + public String toJson() { + return JsonUtils.writeValueAsString(this); + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPsdConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPsdConfigVO.java new file mode 100644 index 000000000..4e0ebc7c8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPsdConfigVO.java @@ -0,0 +1,109 @@ +package club.joylink.rtss.vo.client.project.richor; + +import club.joylink.rtss.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; + +@Getter +@Setter +@NoArgsConstructor +public class RichorPsdConfigVO { +// /** +// * 关联的站台屏蔽门code +// */ +// @NotBlank(message = "关联的站台屏蔽门code不能为空") +// private String psdCode; + + /** + * 关联的ISCS元素的code + */ + private String iscsCode = "FuzhouPsd_33"; + /** + * 网关位开始地址 + */ + private Integer addr = 0; + /** + * 位数量 + */ + private Integer quantity = 144; + + /*---------------- 屏蔽门 ----------------*/ + /** + * 自动模式 + */ + private Integer r_sx_zdms = 136; + + /** + * 处于手动开模式 + */ + private Integer r_sx_sdkm = 137; + + /** + * 处于手动关模式 + */ + private Integer r_sx_sdgm = 138; + + /** + * 处于隔离模式 + */ + private Integer r_sx_glms = 139; + + /** + * 门未关闭 + */ + private Integer r_sx_wgm = 140; + + /** + * 滑动门DCU故障 + */ + private Integer r_sx_dcugz = 141; + + /** + * 滑动门电机故障 + */ + private Integer r_sx_djgz = 142; + + /** + * 处于手动解锁模式 + */ + private Integer r_sx_sdjs = 143; + + /** + * 滑动门门锁开关故障 + */ + private Integer r_sx_mskggz = 128; + + /** + * 滑动门开关遇阻故障 + */ + private Integer r_sx_yzgz = 129; + + /** + * 滑动门通讯故障 + */ + private Integer r_sx_txgz = 130; + + /** + * 滑动门关闭且锁紧 + */ + private Integer r_sx_sj = 131; + + /** + * 对位隔离 + */ + private Integer r_sx_dwgl = 132; + + public RichorPsdConfigVO(Integer addr, Integer quantity) { + this.addr = addr; + this.quantity = quantity; + } + + @JsonIgnore + public String toJson() { + return JsonUtils.writeValueAsString(this); + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPslConfigVO.java b/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPslConfigVO.java new file mode 100644 index 000000000..d24abfae8 --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/project/richor/RichorPslConfigVO.java @@ -0,0 +1,43 @@ +package club.joylink.rtss.vo.client.project.richor; + +import club.joylink.rtss.util.JsonUtils; +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class RichorPslConfigVO { + private String standCode = "PF59020"; + + private String iscsCode = "psl"; + + /** + * 网关位开始地址 + */ + private Integer addr = 0; + /** + * 位数量 + */ + private Integer quantity = 64; + + /** 状态位 */ + /** 操作允许 */ + private Integer r_sx_czyx = 52; + + /** 开门命令 */ + private Integer r_sx_km = 50; + + /** 关门命令 */ + private Integer r_sx_gm = 51; + + /** 互锁解除 */ + private Integer r_sx_hsjc = 49; + + @JsonIgnore + public String toJson() { + return JsonUtils.writeValueAsString(this); + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanArrivalTime.java b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanArrivalTime.java index 2350890eb..a18dfb259 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanArrivalTime.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/RunPlanArrivalTime.java @@ -1,6 +1,6 @@ package club.joylink.rtss.vo.client.runplan; -import club.joylink.rtss.vo.map.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParkingTimeVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParkingTimeVO.java index da3de2812..aa40a94f3 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParkingTimeVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanParkingTimeVO.java @@ -1,7 +1,7 @@ package club.joylink.rtss.vo.client.runplan.user; import club.joylink.rtss.entity.RunPlanParktime; -import club.joylink.rtss.vo.map.MapStationParkingTimeVO; +import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java index f3b126e18..a41cb5b8a 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRoutingVO.java @@ -2,8 +2,8 @@ package club.joylink.rtss.vo.client.runplan.user; import club.joylink.rtss.entity.RunPlanRouting; import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.vo.map.MapRoutingDataVO; -import club.joylink.rtss.vo.map.MapSectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; import club.joylink.rtss.vo.map.MapVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; diff --git a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java index 7907b2d2d..47959a752 100644 --- a/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/runplan/user/RunPlanRunlevelVO.java @@ -1,7 +1,7 @@ package club.joylink.rtss.vo.client.runplan.user; import club.joylink.rtss.entity.RunPlanRunlevel; -import club.joylink.rtss.vo.map.MapStationRunLevelVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import club.joylink.rtss.vo.map.validate.RunLevelCreateCheck; import club.joylink.rtss.vo.map.validate.RunLevelGenerateCheck; import club.joylink.rtss.vo.map.validate.RunLevelUpdateCheck; diff --git a/src/main/java/club/joylink/rtss/vo/map/InitPositionConfig.java b/src/main/java/club/joylink/rtss/vo/map/InitPositionConfig.java index 3d910e8d5..df666e587 100644 --- a/src/main/java/club/joylink/rtss/vo/map/InitPositionConfig.java +++ b/src/main/java/club/joylink/rtss/vo/map/InitPositionConfig.java @@ -1,5 +1,6 @@ package club.joylink.rtss.vo.map; +import club.joylink.rtss.vo.map.graph.Point; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java b/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java index 43cbba12f..347522167 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/MapGraphDataNewVO.java @@ -2,6 +2,7 @@ package club.joylink.rtss.vo.map; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.map.display.DisplayVO; +import club.joylink.rtss.vo.map.graph.*; import lombok.Getter; import lombok.Setter; import org.springframework.util.StringUtils; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapLogicDataNewVO.java b/src/main/java/club/joylink/rtss/vo/map/MapLogicDataNewVO.java index 758d04f8b..3a9cd7506 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapLogicDataNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/MapLogicDataNewVO.java @@ -1,6 +1,17 @@ package club.joylink.rtss.vo.map; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.vo.map.logic.MapAutoReentryVO; +import club.joylink.rtss.vo.map.logic.MapAutoSignalNewVO; +import club.joylink.rtss.vo.map.logic.MapDestinationCodeDefinitionVO; +import club.joylink.rtss.vo.map.logic.MapOverlapVO; +import club.joylink.rtss.vo.map.logic.MapRouteFlankProtectionNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteNewVO; +import club.joylink.rtss.vo.map.logic.MapRouteOverrunVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; +import club.joylink.rtss.vo.map.logic.MapSignalApproachSectionVO; +import club.joylink.rtss.vo.map.logic.MapStationParkingTimeVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapTurnBackStrategyOptionVO.java b/src/main/java/club/joylink/rtss/vo/map/MapTurnBackStrategyOptionVO.java deleted file mode 100644 index 217c24e9e..000000000 --- a/src/main/java/club/joylink/rtss/vo/map/MapTurnBackStrategyOptionVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package club.joylink.rtss.vo.map; - -import club.joylink.rtss.simulation.cbtc.constant.TurnBackStrategyType; -import lombok.Getter; -import lombok.Setter; - -import java.util.List; - -@Getter -@Setter -public class MapTurnBackStrategyOptionVO { - - private Integer id; - - private String label; - - private TurnBackStrategyType type; - - private List sectionList; - -} diff --git a/src/main/java/club/joylink/rtss/vo/map/MapVO.java b/src/main/java/club/joylink/rtss/vo/map/MapVO.java index b81158ba7..58c78ecc4 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/MapVO.java @@ -5,6 +5,11 @@ import club.joylink.rtss.entity.DraftMapWithBLOBs; import club.joylink.rtss.entity.MapInfo; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.client.map.MapDataVO; +import club.joylink.rtss.vo.map.graph.MapSectionNewVO; +import club.joylink.rtss.vo.map.graph.MapStationNewVO; +import club.joylink.rtss.vo.map.graph.MapStationStandNewVO; +import club.joylink.rtss.vo.map.logic.MapRoutingDataVO; +import club.joylink.rtss.vo.map.logic.MapStationRunLevelVO; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; diff --git a/src/main/java/club/joylink/rtss/vo/map/display/DisplayVO.java b/src/main/java/club/joylink/rtss/vo/map/display/DisplayVO.java index 12cca72b4..bf42827ad 100644 --- a/src/main/java/club/joylink/rtss/vo/map/display/DisplayVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/display/DisplayVO.java @@ -1,5 +1,6 @@ package club.joylink.rtss.vo.map.display; +import club.joylink.rtss.constants.MapPrdTypeEnum; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -10,6 +11,7 @@ import java.util.List; @Setter @NoArgsConstructor public class DisplayVO { + private MapPrdTypeEnum type; private List stationCodeList; private List elementList; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapArrowVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapArrowVO.java similarity index 96% rename from src/main/java/club/joylink/rtss/vo/map/MapArrowVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapArrowVO.java index 0db24d05d..264b692a0 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapArrowVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapArrowVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapAutomaticRouteButtonVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapAutomaticRouteButtonVO.java similarity index 90% rename from src/main/java/club/joylink/rtss/vo/map/MapAutomaticRouteButtonVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapAutomaticRouteButtonVO.java index 881ba68fb..776c3710b 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapAutomaticRouteButtonVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapAutomaticRouteButtonVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapAxleCounterButtonVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapAxleCounterButtonVO.java similarity index 90% rename from src/main/java/club/joylink/rtss/vo/map/MapAxleCounterButtonVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapAxleCounterButtonVO.java index 5329d6d0e..1f6213a50 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapAxleCounterButtonVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapAxleCounterButtonVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapCycleButtonVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapCycleButtonVO.java similarity index 92% rename from src/main/java/club/joylink/rtss/vo/map/MapCycleButtonVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapCycleButtonVO.java index 5ed33be67..70c112d69 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapCycleButtonVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapCycleButtonVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapDirectionRodVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapDirectionRodVO.java similarity index 96% rename from src/main/java/club/joylink/rtss/vo/map/MapDirectionRodVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapDirectionRodVO.java index 1ec9a7f5e..66dfea8ef 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapDirectionRodVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapDirectionRodVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapESPVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapESPVO.java similarity index 86% rename from src/main/java/club/joylink/rtss/vo/map/MapESPVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapESPVO.java index 26dfb9914..d51e32664 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapESPVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapESPVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapIndicatorLightVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapIndicatorLightVO.java similarity index 95% rename from src/main/java/club/joylink/rtss/vo/map/MapIndicatorLightVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapIndicatorLightVO.java index 868c51de6..fcd17a069 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapIndicatorLightVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapIndicatorLightVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapLcVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapLcVO.java similarity index 92% rename from src/main/java/club/joylink/rtss/vo/map/MapLcVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapLcVO.java index 93e357428..cadf0341f 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapLcVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapLcVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapLineVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapLineVO.java similarity index 96% rename from src/main/java/club/joylink/rtss/vo/map/MapLineVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapLineVO.java index ed69806ec..36d2f2f0b 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapLineVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapLineVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapOuterFrameVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapOuterFrameVO.java similarity index 95% rename from src/main/java/club/joylink/rtss/vo/map/MapOuterFrameVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapOuterFrameVO.java index 0693c55fb..7723ecd41 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapOuterFrameVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapOuterFrameVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapPSDVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapPSDVO.java similarity index 96% rename from src/main/java/club/joylink/rtss/vo/map/MapPSDVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapPSDVO.java index 80f30982b..124615654 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapPSDVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapPSDVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapPowerLineVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapPowerLineVO.java similarity index 97% rename from src/main/java/club/joylink/rtss/vo/map/MapPowerLineVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapPowerLineVO.java index 55ad9c215..7a864a776 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapPowerLineVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapPowerLineVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapResourceVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapResourceVO.java similarity index 96% rename from src/main/java/club/joylink/rtss/vo/map/MapResourceVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapResourceVO.java index ecad47df1..2f20803a8 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapResourceVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapResourceVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapResponderVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapResponderVO.java similarity index 97% rename from src/main/java/club/joylink/rtss/vo/map/MapResponderVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapResponderVO.java index 505c2e5da..8bdb5ce03 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapResponderVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapResponderVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import club.joylink.rtss.simulation.cbtc.data.map.Responder; import lombok.EqualsAndHashCode; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapSectionNewVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapSectionNewVO.java similarity index 99% rename from src/main/java/club/joylink/rtss/vo/map/MapSectionNewVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapSectionNewVO.java index 6572f96da..9865f37b7 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapSectionNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapSectionNewVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import club.joylink.rtss.simulation.cbtc.data.map.Section; import lombok.EqualsAndHashCode; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapSignalButtonVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalButtonVO.java similarity index 94% rename from src/main/java/club/joylink/rtss/vo/map/MapSignalButtonVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapSignalButtonVO.java index 893f64941..6c5ef2c2b 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapSignalButtonVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalButtonVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapSignalNewVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java similarity index 94% rename from src/main/java/club/joylink/rtss/vo/map/MapSignalNewVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java index 1203edfde..2cc320073 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapSignalNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapSignalNewVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import club.joylink.rtss.simulation.cbtc.data.map.Signal; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -36,6 +36,8 @@ public class MapSignalNewVO { /** 信号机类型 */ private Signal.SignalType type; + /** 信号机型号 */ + private String signalModel; /** 是否进路终端 */ private boolean routeEnd; @@ -177,6 +179,8 @@ public class MapSignalNewVO { /**是否无延续保护*/ private boolean noOverlap; + /** CTC级别是否办理延续保护 */ + private boolean ctcSetOverlap = true; // 暂默认true,即办理延续保护 /** * 传输信号机关联的信号机 */ diff --git a/src/main/java/club/joylink/rtss/vo/map/MapStationNewVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapStationNewVO.java similarity index 99% rename from src/main/java/club/joylink/rtss/vo/map/MapStationNewVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapStationNewVO.java index 13cd44405..d685043df 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapStationNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapStationNewVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapStationSplitVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapStationSplitVO.java similarity index 95% rename from src/main/java/club/joylink/rtss/vo/map/MapStationSplitVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapStationSplitVO.java index ada8bc8a8..4e57276ac 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapStationSplitVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapStationSplitVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapStationStandNewVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapStationStandNewVO.java similarity index 93% rename from src/main/java/club/joylink/rtss/vo/map/MapStationStandNewVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapStationStandNewVO.java index 8e7149ca3..15189cf74 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapStationStandNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapStationStandNewVO.java @@ -1,6 +1,5 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; -import club.joylink.rtss.simulation.cbtc.data.map.Stand; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; @@ -47,7 +46,7 @@ public class MapStationStandNewVO { /** * 默认折返策略(02-无人折返,03-自动换端) */ - private Stand.TurnBackType defaultReentryStrategy; + private String defaultReentryStrategy; /** diff --git a/src/main/java/club/joylink/rtss/vo/map/MapSwitchVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapSwitchVO.java similarity index 97% rename from src/main/java/club/joylink/rtss/vo/map/MapSwitchVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapSwitchVO.java index fd9c625b5..37c585301 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapSwitchVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapSwitchVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapTempSpeedLimitVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapTempSpeedLimitVO.java similarity index 93% rename from src/main/java/club/joylink/rtss/vo/map/MapTempSpeedLimitVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapTempSpeedLimitVO.java index 477a52372..1c0ddc596 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapTempSpeedLimitVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapTempSpeedLimitVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapTextVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapTextVO.java similarity index 96% rename from src/main/java/club/joylink/rtss/vo/map/MapTextVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapTextVO.java index 973f17369..a22127e30 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapTextVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapTextVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapTotalGuideLockButtonVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapTotalGuideLockButtonVO.java similarity index 90% rename from src/main/java/club/joylink/rtss/vo/map/MapTotalGuideLockButtonVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapTotalGuideLockButtonVO.java index 0ed906086..210450622 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapTotalGuideLockButtonVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapTotalGuideLockButtonVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapTrainModelVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapTrainModelVO.java similarity index 98% rename from src/main/java/club/joylink/rtss/vo/map/MapTrainModelVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapTrainModelVO.java index 91eb2b4fa..8cdcc4292 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapTrainModelVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapTrainModelVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapTrainVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapTrainVO.java similarity index 93% rename from src/main/java/club/joylink/rtss/vo/map/MapTrainVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapTrainVO.java index 94157a444..1eec97253 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapTrainVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapTrainVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapTrainWindowNewVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapTrainWindowNewVO.java similarity index 95% rename from src/main/java/club/joylink/rtss/vo/map/MapTrainWindowNewVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapTrainWindowNewVO.java index 8012b7860..618999fce 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapTrainWindowNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapTrainWindowNewVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapTurnBackStrategyVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapTurnBackStrategyVO.java similarity index 50% rename from src/main/java/club/joylink/rtss/vo/map/MapTurnBackStrategyVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapTurnBackStrategyVO.java index ff8e69a18..589a8fd0a 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapTurnBackStrategyVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapTurnBackStrategyVO.java @@ -1,5 +1,6 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; +import club.joylink.rtss.simulation.cbtc.constant.TurnBackStrategyType; import lombok.Getter; import lombok.Setter; @@ -23,4 +24,17 @@ public class MapTurnBackStrategyVO { private Integer initId; + @Getter + @Setter + public static class MapTurnBackStrategyOptionVO { + + private Integer id; + + private String label; + + private TurnBackStrategyType type; + + private List sectionList; + + } } diff --git a/src/main/java/club/joylink/rtss/vo/map/MapZcVO.java b/src/main/java/club/joylink/rtss/vo/map/graph/MapZcVO.java similarity index 96% rename from src/main/java/club/joylink/rtss/vo/map/MapZcVO.java rename to src/main/java/club/joylink/rtss/vo/map/graph/MapZcVO.java index 33178f93a..53aab8b0f 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapZcVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/MapZcVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/src/main/java/club/joylink/rtss/vo/map/Point.java b/src/main/java/club/joylink/rtss/vo/map/graph/Point.java similarity index 96% rename from src/main/java/club/joylink/rtss/vo/map/Point.java rename to src/main/java/club/joylink/rtss/vo/map/graph/Point.java index 9092433a6..15ee414e5 100644 --- a/src/main/java/club/joylink/rtss/vo/map/Point.java +++ b/src/main/java/club/joylink/rtss/vo/map/graph/Point.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.graph; import club.joylink.rtss.util.JsonUtils; import lombok.Getter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapAutoReentryVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapAutoReentryVO.java similarity index 98% rename from src/main/java/club/joylink/rtss/vo/map/MapAutoReentryVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapAutoReentryVO.java index e1b94bf3e..05220f4b8 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapAutoReentryVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapAutoReentryVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapAutoReentry; import club.joylink.rtss.simulation.cbtc.data.map.Cycle; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapAutoSignalNewVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapAutoSignalNewVO.java similarity index 98% rename from src/main/java/club/joylink/rtss/vo/map/MapAutoSignalNewVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapAutoSignalNewVO.java index a32ad5603..f28d1517c 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapAutoSignalNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapAutoSignalNewVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapAutoSignal; import club.joylink.rtss.simulation.cbtc.data.map.*; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapDestinationCodeDefinitionVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapDestinationCodeDefinitionVO.java similarity index 98% rename from src/main/java/club/joylink/rtss/vo/map/MapDestinationCodeDefinitionVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapDestinationCodeDefinitionVO.java index 3662c6db0..02db822e0 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapDestinationCodeDefinitionVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapDestinationCodeDefinitionVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.simulation.cbtc.data.map.DestinationCodeDefinition; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapOverlapVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapOverlapVO.java similarity index 97% rename from src/main/java/club/joylink/rtss/vo/map/MapOverlapVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapOverlapVO.java index 6d3002b74..3dcb552ad 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapOverlapVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapOverlapVO.java @@ -1,8 +1,9 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapOverlap; import club.joylink.rtss.simulation.cbtc.data.map.RouteOverlap; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.map.MapSectionPathVO; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapRouteFlankProtectionNewVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapRouteFlankProtectionNewVO.java similarity index 98% rename from src/main/java/club/joylink/rtss/vo/map/MapRouteFlankProtectionNewVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapRouteFlankProtectionNewVO.java index 85c7d502b..0eb573f97 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapRouteFlankProtectionNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapRouteFlankProtectionNewVO.java @@ -1,10 +1,11 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapRouteFlankProtection; import club.joylink.rtss.simulation.cbtc.data.map.RouteFls; import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.map.MapCISwitchVO; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapRouteNewVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapRouteNewVO.java similarity index 94% rename from src/main/java/club/joylink/rtss/vo/map/MapRouteNewVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapRouteNewVO.java index 332a4e4c6..2f5af9180 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapRouteNewVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapRouteNewVO.java @@ -1,8 +1,11 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapRoute; +import club.joylink.rtss.simulation.cbtc.constant.SignalAspect; import club.joylink.rtss.simulation.cbtc.data.map.*; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.map.MapCISwitchVO; +import club.joylink.rtss.vo.map.MapRouteAspectVO; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import lombok.Getter; @@ -95,6 +98,10 @@ public class MapRouteNewVO { * 1-红;2-绿;3-黄;4-黄红;5-绿绿;6-绿黄;7-黄黄;8-黄闪黄;9-白红;10-蓝;11-白;12-红闪; */ private Integer signalAspect; + /** + * 信号显示 + */ + private SignalAspect aspect; /** * 中间信号机(大铁通过进路) @@ -104,7 +111,7 @@ public class MapRouteNewVO { * 中间信号显示 */ private Integer midSignalAspect; - + @Deprecated private boolean greenOpen; private boolean turnBack; @@ -212,9 +219,9 @@ public class MapRouteNewVO { vo.setCode(route.getCode()); vo.setName(route.getName()); vo.setStartSignalCode(route.getStart().getCode()); - vo.setEndSignalCode(route.getDestination().getCode()); + vo.setEndSignalCode(Objects.nonNull(route.getDestination()) ? route.getDestination().getCode() : null); vo.setEndButtonSignalCode(Objects.nonNull(route.getDestinationButtonSignal()) ? route.getDestinationButtonSignal().getCode() : null); - vo.setGreenOpen(route.isOpenGreen()); + vo.setAspect(route.getAspect()); vo.setTurnBack(route.isTurnBack()); vo.setAtp(route.isAtp()); vo.setGround(route.isGround()); diff --git a/src/main/java/club/joylink/rtss/vo/map/MapRouteOverrunVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapRouteOverrunVO.java similarity index 94% rename from src/main/java/club/joylink/rtss/vo/map/MapRouteOverrunVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapRouteOverrunVO.java index dd341905e..e2c412f5e 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapRouteOverrunVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapRouteOverrunVO.java @@ -1,8 +1,8 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapRouteOverrun; -import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.map.MapCISwitchVO; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapRoutingDataVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapRoutingDataVO.java similarity index 98% rename from src/main/java/club/joylink/rtss/vo/map/MapRoutingDataVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapRoutingDataVO.java index 287c6e643..e411e65be 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapRoutingDataVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapRoutingDataVO.java @@ -1,8 +1,9 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapRouting; import club.joylink.rtss.simulation.cbtc.data.map.Routing; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.map.MapRoutingSectionNewVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; import lombok.Setter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapSignalApproachSectionVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapSignalApproachSectionVO.java similarity index 97% rename from src/main/java/club/joylink/rtss/vo/map/MapSignalApproachSectionVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapSignalApproachSectionVO.java index 0e829e437..f797202fe 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapSignalApproachSectionVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapSignalApproachSectionVO.java @@ -1,8 +1,9 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapSignalApproachSection; import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.map.MapSectionPathVO; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapStationParkingTimeVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapStationParkingTimeVO.java similarity index 98% rename from src/main/java/club/joylink/rtss/vo/map/MapStationParkingTimeVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapStationParkingTimeVO.java index 38142f9d6..0b6f58c32 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapStationParkingTimeVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapStationParkingTimeVO.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapParkingTime; import lombok.Getter; diff --git a/src/main/java/club/joylink/rtss/vo/map/MapStationRunLevelVO.java b/src/main/java/club/joylink/rtss/vo/map/logic/MapStationRunLevelVO.java similarity index 98% rename from src/main/java/club/joylink/rtss/vo/map/MapStationRunLevelVO.java rename to src/main/java/club/joylink/rtss/vo/map/logic/MapStationRunLevelVO.java index aca7c4511..e95087582 100644 --- a/src/main/java/club/joylink/rtss/vo/map/MapStationRunLevelVO.java +++ b/src/main/java/club/joylink/rtss/vo/map/logic/MapStationRunLevelVO.java @@ -1,8 +1,9 @@ -package club.joylink.rtss.vo.map; +package club.joylink.rtss.vo.map.logic; import club.joylink.rtss.entity.DraftMapRunLevel; import club.joylink.rtss.util.JsonUtils; import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; +import club.joylink.rtss.vo.map.MapRoutingSectionNewVO; import club.joylink.rtss.vo.map.validate.RunLevelCreateCheck; import club.joylink.rtss.vo.map.validate.RunLevelGenerateCheck; import club.joylink.rtss.vo.map.validate.RunLevelUpdateCheck; diff --git a/src/main/java/club/joylink/rtss/websocket/StompMessageService.java b/src/main/java/club/joylink/rtss/websocket/StompMessageService.java index acaf9d092..cf8286b9d 100644 --- a/src/main/java/club/joylink/rtss/websocket/StompMessageService.java +++ b/src/main/java/club/joylink/rtss/websocket/StompMessageService.java @@ -22,6 +22,18 @@ public class StompMessageService { @Autowired private SimpMessagingTemplate SMT; + public void send(SocketMessageVO messageVO) { + if (Objects.nonNull(messageVO) && Objects.nonNull(messageVO.getBody())) { + if (!(messageVO.getBody() instanceof Collection) || !CollectionUtils.isEmpty((Collection) messageVO.getBody())) { + Object send = getPayload(messageVO); + for (Object o : messageVO.getTopicList()) { + String topic = (String) o; + this.SMT.convertAndSend(topic, send); + } + } + } + } + public void sendToUser(String user, SocketMessageVO messageVO) { if (Objects.nonNull(messageVO) && Objects.nonNull(messageVO.getBody()) && StringUtils.hasText(user)) { if (!(messageVO.getBody() instanceof Collection) || !CollectionUtils.isEmpty((Collection) messageVO.getBody())) { diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9fbd12698..34f82c1d8 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -163,9 +163,9 @@ common: spring: profiles: local datasource: - url: jdbc:mysql://160.20.60.16:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true + url: jdbc:mysql://192.168.1.254:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true username: root - password: heblocal + password: localdb tencent-cloud: allow-send: false