Merge remote-tracking branch 'origin/test' into test-training2

# Conflicts:
#	src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java
This commit is contained in:
joylink_zhangsai 2022-08-24 15:26:18 +08:00
commit 7f870d52ce
24 changed files with 809 additions and 629 deletions

View File

@ -4,25 +4,31 @@ import lombok.Getter;
@Getter
public enum MapPrdTypeEnum {
LOCAL("01", "ATS现地工作站"),
CENTER("02", "ATS行调工作站"),
JOINT("03", "综合演练云平台"),
DRIVER("04", "司机模拟驾驶系统"),
SCHEDULING("05", "派班工作站"),
ISCS("06", "ISCS工作站"),
BIG_SCREEN("07", "大屏工作站"),
RUN_PLAN_MAKE("08", "运行图编制工作站"),
DEPOT_IL("09", "车辆段联锁工作站"),
CTC("10", "CTC工作站")
LOCAL("01", "ATS现地工作站", "车站"),
CENTER("02", "ATS行调工作站", "调度台"),
JOINT("03", "综合演练云平台", null),
DRIVER("04", "司机模拟驾驶系统", null),
SCHEDULING("05", "派班工作站", null),
ISCS("06", "ISCS工作站", null),
BIG_SCREEN("07", "大屏工作站", null),
RUN_PLAN_MAKE("08", "运行图编制工作站", null),
DEPOT_IL("09", "车辆段联锁工作站", null),
// CTC("10", "CTC工作站")
;
private String code;
private String msg;
MapPrdTypeEnum(String code, String msg) {
/**
* 大铁子系统名称
*/
private String railName;
MapPrdTypeEnum(String code, String msg, String railName) {
this.code = code;
this.msg = msg;
this.railName = railName;
}
public static MapPrdTypeEnum getMapPrdTypeEnumByCode(String code) {

View File

@ -60,6 +60,8 @@ public enum Project {
RICHOR_CXJS,
/** 哈盈达-铁路 */
HYD_RAILWAY,
/** 武汉8号线 */
WH
;
public static boolean isDefault(Project project) {

View File

@ -64,20 +64,18 @@ public class MapSystemService implements IMapSystemService {
public void generateSystem(Long mapId) {
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertTrue(iMapService.isExist(mapId),
String.format("id为[%s]的地图不存在", mapId));
for (MapPrdTypeEnum value : MapPrdTypeEnum.values()) {
if (MapPrdTypeEnum.CTC.equals(value)) {
MapVO mapDetail = iMapService.getMapDetail(mapId);
if (!mapDetail.getConfigVO().isRailway()) {
for (MapPrdTypeEnum value : MapPrdTypeEnum.values()) {
boolean railway = mapDetail.getConfigVO().isRailway();
if (railway && value.getRailName() == null)
continue;
}
}
generate(mapId, value);
generate(mapId, value, railway);
}
}
private void generate(Long mapId, MapPrdTypeEnum value) {
private void generate(Long mapId, MapPrdTypeEnum value, boolean railway) {
MapSystem system = new MapSystem();
system.setName(value.getMsg());
system.setName(railway ? value.getRailName() : value.getMsg());
system.setMapId(mapId);
system.setPrdType(value.getCode());
system.setStatus(StatusEnum.Valid.getCode());
@ -108,7 +106,12 @@ public class MapSystemService implements IMapSystemService {
String.format("id为[%s]的地图不存在", mapId));
MapPrdTypeEnum prdTypeEnum = MapPrdTypeEnum.getMapPrdTypeEnumByCode(prdType);
BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(prdTypeEnum);
generate(mapId, prdTypeEnum);
MapVO mapDetail = iMapService.getMapDetail(mapId);
boolean railway = mapDetail.getConfigVO().isRailway();
if (railway && prdTypeEnum.getRailName() == null) {
return;
}
generate(mapId, prdTypeEnum, railway);
}
private boolean isExist(Long mapId, String prdType, String type) {

View File

@ -405,11 +405,11 @@ public class DraftMapRouteServiceImpl implements DraftMapRouteService {
}
} else { //反向信号机
if (destination.equals(last.getSignalOf(!right))) {
sections.remove(i);
// sections.remove(i);
break;
}
}
sections.remove(i);
sections.remove(i); //最后一个区段上没有与终端信号机相同的信号机
}
//添加进路
Route route = new Route(routeCodeGenerator.next(), "D_" + signal.getShowName() + "-" + destination.getShowName());

View File

@ -82,8 +82,8 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
private Map<String, SimulationRepository> repositoryMap = new ConcurrentHashMap<>();
@Setter
private Map<String, M> simulationMemberMap = new ConcurrentHashMap<>();
private Map<String, U> simulationUserMap = new ConcurrentHashMap<>();
private Map<String, M> simulationMemberMap = new ConcurrentSkipListMap<>(); //2022-08-16 为前端展示成员有序
private Map<String, U> simulationUserMap = new ConcurrentSkipListMap<>();
private List<Operation> operationList = new ArrayList<>();
private Map<String, Map<String, SimulationFaultVO>> deviceFaultMap = new ConcurrentHashMap<>();

View File

@ -0,0 +1,29 @@
package club.joylink.rtss.simulation.cbtc.ATS;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.event.SimulationOperationEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
@Component
public class AtsListener {
/**
* 计数字段名
*/
public static final String COUNT_PARAM_NAME = "_COUNT";
@EventListener
public void handle(SimulationOperationEvent event) {
if (event.getSuccessful() != null)
return;
String countName = (String) event.getParams().get(COUNT_PARAM_NAME);
if (countName == null)
return;
MapElement device = event.getMember().getDevice();
if (device instanceof Station) {
Station station = (Station) device;
station.count(countName);
}
}
}

View File

@ -467,9 +467,9 @@ public class AtsTrainService {
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
b = vrSignal != null && vrSignal.getModel().getDefaultAspect().equals(vrSignal.getAspect());
}
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且同向信号机为禁止信号");
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且为禁止信号");
param.setThroughSignal(signal);
param.setThroughSignalAspect(signal.getVirtualSignal().getModel().getDefaultAspect());
param.setThroughSignalAspect(signal.getDefaultAspect());
} else if (param.isThroughGuideSignal()) { // 越引导行驶
Signal signal = section.getSignalOf(right);
boolean b = false;
@ -477,9 +477,9 @@ public class AtsTrainService {
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
b = vrSignal != null && vrSignal.getModel().getGuideAspect().equals(vrSignal.getAspect());
}
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且同向信号机为引导信号");
BusinessExceptionAssertEnum.OPERATION_FAIL.assertTrue(b, "需要车头所在区段前方有同向信号机,且为引导信号");
param.setThroughSignal(signal);
param.setThroughSignalAspect(signal.getVirtualSignal().getModel().getDefaultAspect());
param.setThroughSignalAspect(signal.getGuideAspect());
} else if (param.isDriverNextStand()){ // 行驶至前方车站
// 列车车头所在区段
Section headSection = train.getHeadPosition().getSection();

View File

@ -6,7 +6,6 @@ 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.*;
import club.joylink.rtss.simulation.cbtc.data.map.Route.MultiRouteAspect;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService;
@ -413,8 +412,15 @@ public class CiApiServiceImpl2 implements CiApiService {
} else {
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("signalCode和routeCode不能都为空");
}
// 判断是否要进行进路判断大铁可以不对进路判断
boolean firstCheck = config.isRailway() ? false : config.isGuideNeedRouteSettingFirst();
if (route == null && signal.getRouteList().stream().anyMatch(Route::isAnySwitchMasterLock)) {
openGuideAspect4GuideMasterLock(simulation, signal);
return;
} else {
}
boolean firstCheck = config.isGuideNeedRouteSettingFirst();
//条件检查
if (firstCheck) {
List<Route> routeList = signal.getRouteList();
@ -454,21 +460,9 @@ public class CiApiServiceImpl2 implements CiApiService {
} else if (!CollectionUtils.isEmpty(signal.getRouteList())) {
List<Route> collect;
if (config.isRailway()) { // 大铁配置引导进路
// collect = getCtcGuideRouteList(repository, signal);
// if (collect == null) {
// return;
// }
collect = signal.getRouteList().stream()
.filter(Route::isTrainRoute)
.filter(route1 -> !route1.hasReverseSwitch())
.filter(route1 -> {
List<SwitchElement> switchList = route1.getSwitchList();
if (!CollectionUtils.isEmpty(switchList)) {
return switchList.stream()
.allMatch(se -> se.isOnPosition() || se.getASwitch().isGuideMasterLock());
}
return true;
}) //大铁直接办理引导进路需道岔在正确位置或道岔引导总锁
.filter(route1 -> route1.isAllSwitchIsOnPos() || route1.isAnySwitchMasterLock())
.collect(Collectors.toList());
BusinessExceptionAssertEnum.OPERATION_FAIL.assertCollectionNotEmpty(collect,
signal.debugStr() + "无符合条件的进路");
@ -498,6 +492,14 @@ public class CiApiServiceImpl2 implements CiApiService {
}
}
/**
* 在引导总锁的状态下开放引导信号
* 引导总锁之后
*/
private void openGuideAspect4GuideMasterLock(Simulation simulation, Signal signal) {
signalService.controlSignalAspect(simulation, signal, signal.getGuideAspect());
}
@Override
public void setEst(Simulation simulation, ESP esp) {

View File

@ -21,6 +21,10 @@ import java.util.Objects;
@Slf4j
@Component
public class CiLogic {
interface JobName {
String SECTION_STOP_COUNTDOWN = "SECTION_STOP_COUNTDOWN";
}
@Autowired
private CiDeviceStatusCollector deviceStatusCollector;
@Autowired
@ -78,11 +82,54 @@ public class CiLogic {
}
}
/**
* 区段停稳倒计时
*/
public void sectionStopCountDown(Simulation simulation) {
for (Section section : simulation.getRepository().getHasStopCountDownSections()) {
int stopCountDown = section.getStopCountDown();
if (stopCountDown == 0) {
//股道占用且股道有占用
if (section.isOccupied()) {
if (section.getNextRunningSectionOf(false).isOccupied() || section.getNextRunningSectionOf(true).isOccupied()) {
section.readyStartStopCountDown();
}
}
} else {
if (stopCountDown == -1) {
// 股道占用股道两边没有占用股道没有进路锁闭或该进路正在正常解锁
if (section.isOccupied()) {
if ((!section.getNextRunningSectionOf(false).isOccupied()
&& !section.getNextRunningSectionOf(true).isOccupied())
&& (section.getRoute() == null || section.getRoute().isNormalUnlock())) {
section.startStopCountDown();
}
}
} else {
section.setStopCountDown(stopCountDown - SimulationConstants.CI_LOOP_RATE);
if (stopCountDown <= 0) {
section.setStopCountDown(0);
}
}
}
}
}
private void signalMonitor(Simulation simulation, Signal signal) {
signalControlService.controlLightOfSignal(simulation, signal);
//控制通过信号机的显示信号机前第一个区段被占用开红灯第二个区段被占用开黄灯否则开绿灯
if (signal.isPassingSignal()) {
if (simulation.getRepository().getConfig().isRailway()) {
railwaySignalMonitor(simulation, signal);
}
}
private void railwaySignalMonitor(Simulation simulation, Signal signal) {
if (signal.isGuideAspect() && signal.getLockedRoute() == null) { //引导总锁后开放的引导信号
if (signal.getRouteList().stream().noneMatch(Route::isAnySwitchMasterLock)) {
signalControlService.controlSignalAspect(simulation, signal, signal.getDefaultAspect());
}
}
if (signal.isPassingSignal()) {
boolean right = signal.isRight();
Section section = signal.getSection();
Section one = section.getNextSection(right);
@ -106,7 +153,6 @@ public class CiLogic {
signalControlService.controlSignalAspect(simulation, signal, SignalAspect.G);
}
}
}
/**
* 进路监控
@ -234,5 +280,6 @@ public class CiLogic {
public void addJobs(Simulation simulation) {
simulation.addJob(SimulationModule.CI.name(), () -> run(simulation), SimulationConstants.CI_LOOP_RATE);
simulation.addJob(JobName.SECTION_STOP_COUNTDOWN, () -> sectionStopCountDown(simulation), SimulationConstants.CI_LOOP_RATE);
}
}

View File

@ -1116,6 +1116,7 @@ public class MapDeviceBuilder {
section.setVirtualAxleCounter(axleCounter);
deviceMap.put(axleCounter.getCode(), axleCounter);
}
section.setHasStopCountDown(sectionVO.isHasStopCD());
}
}

View File

@ -1248,4 +1248,10 @@ public class SimulationDataRepository {
}
return stream.collect(Collectors.toList());
}
public List<Section> getHasStopCountDownSections() {
return getListByType(MapElement.DeviceType.SECTION, Section.class).stream()
.filter(Section::isHasStopCountDown)
.collect(Collectors.toList());
}
}

View File

@ -264,6 +264,10 @@ public class Route extends MapNamedElement {
public boolean isMultiRoute() {
return null!=this.multiRouteAspects&&!this.multiRouteAspects.isEmpty();
}
/**
* 所有道岔都在正确位置
*/
public boolean isAllSwitchIsOnPos() {
if (!CollectionUtils.isEmpty(switchList)) {
return switchList.stream().allMatch(SwitchElement::isOnPosition);
@ -271,6 +275,16 @@ public class Route extends MapNamedElement {
return true;
}
/**
* 进路道岔中有任意一个处于引导总锁状态
*/
public boolean isAnySwitchMasterLock() {
if (!CollectionUtils.isEmpty(switchList)) {
return switchList.stream().map(SwitchElement::getASwitch).anyMatch(Switch::isGuideMasterLock);
}
return false;
}
/**
* 进路是否开放(进路是否锁闭并开放指定信号灯)
*

View File

@ -164,6 +164,11 @@ public class Section extends DelayUnlockDevice {
*/
private Set<ZC> zcs = new HashSet<>();
/**
* 有停稳计时
*/
private boolean hasStopCountDown;
// ------------------状态属性---------------------
/**
@ -261,6 +266,14 @@ public class Section extends DelayUnlockDevice {
*/
private List<ShuntingType> shuntingTypeList;
/**
* 停稳倒计时
* 0 表示初始状态
* -1 表示准备开始计时
* 非负数表示当前计时
*/
private int stopCountDown;
@Override
public void reset() {
super.reset();
@ -282,12 +295,29 @@ public class Section extends DelayUnlockDevice {
this.closed = false;
this.badShunt = false;
this.shuntingTypeList = new ArrayList<>();
this.stopCountDown = 0;
}
/**
* 开始停稳倒计时
*/
public void startStopCountDown() {
stopCountDown = 40 * 1000;
}
/**
* 准备开始停稳倒计时
*/
public void readyStartStopCountDown() {
stopCountDown = -1;
}
public int getStopCountDownInSeconds() {
return stopCountDown / 1000;
}
/**
* 区段是否被列车占用
*
* @return
*/
public boolean isOccupied() {
return this.nctOccupied || this.ctOccupied || this.isLogicOccupied();

View File

@ -197,8 +197,12 @@ public class Station extends MayOutOfOrderDevice {
*/
private boolean allowAutonomy;
@Override
/**
* 操作计数器
*/
private Map<String, Integer> counter;
@Override
public void reset() {
super.reset();
if (vrIbp != null) {
@ -223,6 +227,7 @@ public class Station extends MayOutOfOrderDevice {
preResetValidDuration = new AtomicInteger(0);
sGuideMasterLock = false;
xGuideMasterLock = false;
counter = null;
}
public List<Stand> getStandOf(boolean right) {
@ -459,6 +464,13 @@ public class Station extends MayOutOfOrderDevice {
return Fault.ATS_ROUTE_TRIGGER_FAULT.equals(getFault());
}
public void count(String countName) {
if (this.counter == null) {
this.counter = new HashMap<>();
}
this.counter.merge(countName, 1, Integer::sum);
}
public enum ControlMode {
/**
* 交出未被接收

View File

@ -126,6 +126,8 @@ public class SectionStatus extends DeviceStatus {
*/
private boolean badShunt;
private Integer stopCountDown;
public SectionStatus(Section section) {
super(section.getCode(), section.getDeviceType());
this.blockade = section.isBlockade();
@ -147,6 +149,7 @@ public class SectionStatus extends DeviceStatus {
this.fault = section.getFault() == null ? null : section.getFault().toString();
this.shuntingTypeList = section.getShuntingTypeList();
this.badShunt = section.isBadShunt();
this.stopCountDown = section.getStopCountDownInSeconds();
}
@Override
@ -250,6 +253,13 @@ public class SectionStatus extends DeviceStatus {
this.badShunt = section.isBadShunt();
status.setBadShunt(this.badShunt);
}
int stopCountDownInSeconds = section.getStopCountDownInSeconds();
if (!Objects.equals(this.stopCountDown, stopCountDownInSeconds)) {
change = true;
this.stopCountDown = stopCountDownInSeconds;
}
status.setStopCountDown(stopCountDown == 0 ? null : stopCountDown);
return change;
}

View File

@ -11,6 +11,8 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import java.time.LocalTime;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
/**
@ -90,6 +92,11 @@ public class StationStatus extends DeviceStatus {
*/
private boolean allowAutonomy;
/**
* 计数器
*/
private Map<String, Integer> counter;
public StationStatus(Station station) {
super(station.getCode(), station.getDeviceType());
controlMode = station.getControlMode();
@ -107,6 +114,9 @@ public class StationStatus extends DeviceStatus {
sGuideMasterLock = station.isSGuideMasterLock();
xGuideMasterLock = station.isXGuideMasterLock();
allowAutonomy = station.isAllowAutonomy();
if (station.getCounter() != null) {
counter = new HashMap<>(station.getCounter());
}
}
@Override
@ -190,6 +200,15 @@ public class StationStatus extends DeviceStatus {
allowAutonomy = station.isAllowAutonomy();
status.setAllowAutonomy(allowAutonomy);
}
if (!Objects.equals(counter, station.getCounter())) {
change = true;
if (counter == null) {
counter = new HashMap<>(station.getCounter());
} else {
counter.putAll(station.getCounter());
}
status.setCounter(counter);
}
return change;
}

View File

@ -106,6 +106,11 @@ public class StorageSection extends StorageDelayUnlockDevice {
*/
private Boolean badShunt;
/**
* 停稳倒计时
*/
private Integer stopCountDown;
public StorageSection(Section section) {
super(section);
}
@ -176,6 +181,10 @@ public class StorageSection extends StorageDelayUnlockDevice {
this.shuntingTypeList = section.getShuntingTypeList();
this.badShunt = section.isBadShunt();
}
if (section.getStopCountDown() != 0) {
change = true;
this.stopCountDown = section.getStopCountDown();
}
return change;
}
@ -197,5 +206,6 @@ public class StorageSection extends StorageDelayUnlockDevice {
section.setSpeedLimitBeforeFault(speedLimitBeforeFault);
section.setShuntingTypeList(shuntingTypeList != null ? shuntingTypeList : new ArrayList<>());
section.setBadShunt(badShunt != null ? badShunt : false);
section.setStopCountDown(stopCountDown == null ? 0 : stopCountDown);
}
}

View File

@ -13,6 +13,7 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import java.time.LocalTime;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
@ -65,6 +66,8 @@ public class StorageStation extends StorageStatusDevice {
private Integer preResetValidDuration;
private Map<String, Integer> counter;
public StorageStation(Station station) {
super(station);
}
@ -111,6 +114,7 @@ public class StorageStation extends StorageStatusDevice {
if (station.getPreResetValidDuration() != null && station.getPreResetValidDuration().get() != 0) {
this.setPreResetValidDuration(station.getPreResetValidDuration().get());
}
this.counter = station.getCounter();
return true;
}
@ -133,5 +137,6 @@ public class StorageStation extends StorageStatusDevice {
station.setEmergencyController(emergencyController != null ? emergencyController : false);
station.setControlApplicant(controlApplicant != null ? simulation.getSimulationMemberById(controlApplicant) : null);
station.setPreResetValidDuration(new AtomicInteger(Objects.requireNonNullElse(preResetValidDuration, 0)));
station.setCounter(counter);
}
}

View File

@ -99,6 +99,9 @@ public class SectionStatusVO extends DeviceStatusVO {
private Boolean badShunt;
@JsonInclude
private Integer stopCountDown;
public SectionStatusVO(Section section) {
super(section.getCode(), section.getDeviceType());
}

View File

@ -10,6 +10,7 @@ import lombok.Getter;
import lombok.Setter;
import java.time.LocalTime;
import java.util.Map;
/**
* 车站状态
@ -87,6 +88,8 @@ public class StationStatusVO extends DeviceStatusVO {
private Boolean allowAutonomy;
private Map<String, Integer> counter;
public StationStatusVO(Station station) {
super(station.getCode(), station.getDeviceType());
}

View File

@ -106,11 +106,11 @@ public class MemberManager {
this.playRole(simulation, userId, ddList.get(0).getId());
break;
}
case CTC: {
List<SimulationMember> list = simulation.querySimulationMembersOfRole(SimulationMember.Type.RAIL_CTC);
this.playRole(simulation, userId, list.get(0).getId());
break;
}
// case CTC: {
// List<SimulationMember> list = simulation.querySimulationMembersOfRole(SimulationMember.Type.RAIL_CTC);
// this.playRole(simulation, userId, list.get(0).getId());
// break;
// }
}
}
}

View File

@ -46,6 +46,11 @@ public class MapIndicatorLightVO {
*/
private boolean right;
/**
* 计数器类型
*/
private String counterType;
// public enum Type{
// AtsControl,
// CenterCommunication,

View File

@ -48,6 +48,16 @@ public class MapSectionNewVO {
*/
private Point namePosition;
/**
* 有停稳计时
*/
private boolean hasStopCD;
/**
* 停车倒计时显示坐标
*/
private Point stopCDPosition;
/**
* 是否显示计轴器false-不显示true-显示
*/