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

This commit is contained in:
joylink_zhangsai 2022-07-14 18:02:28 +08:00
commit abdf784bd9
4 changed files with 95 additions and 61 deletions

View File

@ -148,14 +148,12 @@ public class StationDirectionService {
private final ButtonThenInterface turnAssistThen = (simulation, stationDirection) -> {
// 总辅助弹起后
if (!stationDirection.isMainAssistStatus()) {
// 接发辅助倒计时重置
// 辅助状态重置
stationDirection.resetAssistStatus();
// 总辅助抬起后将辅助准备状态
stationDirection.setAssistReadyStatus(false);
// 相对方向辅助准备状态也恢复
StationDirection relativeDirection = getRelativeStationDirection(simulation, stationDirection);
if (relativeDirection != null) {
relativeDirection.setAssistReadyStatus(false);
relativeDirection.resetAssistStatus(); // 邻站辅助状态完毕
}
}
};
@ -165,16 +163,11 @@ public class StationDirectionService {
*/
private final ButtonThenInterface receiveAssistThen = (simulation, stationDirection) -> {
// 接辅助完成后,改变接方向
stationDirection.setRunStatus(StationDirection.ReceiveAndDeliverModel.R);
stationDirection.setAssistReadyStatus(true);
// 办理完成后
stationDirection.resetAssistStatus();
// 邻站修改发方向
StationDirection adjacentDirection = getRelativeStationDirection(simulation, stationDirection);
if (adjacentDirection != null) {
adjacentDirection.setRunStatus(StationDirection.ReceiveAndDeliverModel.D);
adjacentDirection.setAssistReadyStatus(true);
adjacentDirection.resetAssistStatus();
}
};
@ -182,17 +175,26 @@ public class StationDirectionService {
* 发辅助按钮后续操作
*/
private final ButtonThenInterface deliverAssistThen = (simulation, stationDirection) -> {
// 按下发辅助弹起接辅助
stationDirection.setReceiveAssistStatus(false);
if (stationDirection.isReceiveAssistStatus()) { // 原接辅助在按下情况下
// 按下发辅助弹起接辅助
stationDirection.setReceiveAssistStatus(false);
// 重置辅助计时开始时间
stationDirection.setAssistTime(simulation.getCorrectSystemTime());
// 邻站修改发方向
StationDirection adjacentDirection = getRelativeStationDirection(simulation, stationDirection);
if (adjacentDirection != null) { // 邻站状态重置
adjacentDirection.resetAssistStatus();
adjacentDirection.setAssistReadyStatus(false);
}
}
// 如果辅助按钮按下时间为空则初始化
if (stationDirection.getAssistTime() == null) {
stationDirection.setAssistTime(simulation.getCorrectSystemTime());
}
// 重新设置倒计时时间
stationDirection.getRemain().set(StationDirection.DEFAULT_DELIVER_DELAY_TIME);
// 就绪状态恢复
stationDirection.setAssistReadyStatus(false);
// 邻站修改发方向
StationDirection adjacentDirection = getRelativeStationDirection(simulation, stationDirection);
if (adjacentDirection != null) {
adjacentDirection.setAssistReadyStatus(false);
}
};
/**
@ -451,7 +453,7 @@ public class StationDirectionService {
StationDirection relativeStationDirection = null;
if (stationDirection.isDataConfig()) {
relativeStationDirection = stationDirection.getRelativeStationDirection();
} else {
} else { // TODO: 待数据统一之后下方代码可删除 20220714
// 获取邻站实体
Optional<Station> adjacentStationOptional = getAdjacentStationOptional(simulation, stationDirection);
if (adjacentStationOptional.isPresent()) {

View File

@ -62,8 +62,10 @@ public class CiLogic {
if (stationDirection.monitorRouteChangeStatus()) {
stationDirection.modifyRunStatus();
}
// 如果倒数结束弹起接发辅助按钮
if (stationDirection.getRemain().decrementAndGet() <= 0) {
// 如果倒数结束弹起接发辅助按钮,超过50秒时不再自动抬起
if (!stationDirection.isAssistReadyStatus()
&& !stationDirection.assistDurationPass50(simulation.getCorrectSystemTime())
&& stationDirection.getRemain().decrementAndGet() <= 0) {
stationDirection.setDeliverAssistStatus(false);
stationDirection.setReceiveAssistStatus(false);
stationDirection.getRemain().set(0);

View File

@ -1665,6 +1665,7 @@ public class InterlockBuilder2 {
if (stationDirection.getRunStatus() != null) {
model = new StationDirection(stationDirection);
} else {
// TODO: 待数据统一之后下方构建代码可删除 20220714
model = new StationDirection(stationDirection.getCode(), stationDirection.getName(), stationDirection.getLabelEnum());
}
// 注入信号灯数据

View File

@ -29,6 +29,11 @@ public class StationDirection extends MapNamedElement {
*/
public static final int DEFAULT_RECEIVE_DELAY_TIME = 15;
/**
* 辅助持续时间当超过此时间将持续按下
*/
public static final int DEFAULT_DURATION_TIME = 50;
/**
* 车站
*/
@ -174,6 +179,12 @@ public class StationDirection extends MapNamedElement {
*/
private LocalDateTime changeDirectionTime;
/**
* 发辅助初始操作时间在接发互相转换时重置初始辅助操作就绪后置空
*/
private LocalDateTime assistTime;
// TODO: 待数据统一之后这个构造函数代码可删除 20220714
public StationDirection(String code, String name, DirectionLabelEnum labelEnum) {
this(code, name);
this.labelEnum = labelEnum;
@ -228,7 +239,15 @@ public class StationDirection extends MapNamedElement {
public void modifyRunStatus() {
// 自动模式
if (DirectionRunModel.A.equals(this.runModel)) {
List<Route> oldList = this.currentRouteList;
this.currentRouteList = getNowRouteList();
// 辅助状态下进路列表发生切换说明方向已发生改变
if (this.currentRouteList.equals(oldList) && this.assistReadyStatus) {
this.resetAssistStatus();
if (this.relativeStationDirection != null) { // 相对车站也重置辅助状态
this.relativeStationDirection.resetAssistStatus();
}
}
}
}
@ -249,17 +268,8 @@ public class StationDirection extends MapNamedElement {
* 辅助灯状态
*/
public void refreshAssistStatus() {
// 判断改方动作是否完成
if (judgeChangeDirectionReady()) {
// 倒计时归零
this.remain.set(0);
// 发车辅助按钮弹起
this.deliverAssistStatus = false;
// 接车辅助按钮弹起
this.receiveAssistStatus = false;
}
// 如果总辅助接发任意一方按下为白灯
if (this.mainAssistStatus && (this.deliverAssistStatus || this.receiveAssistStatus || this.assistReadyStatus)) {
if (this.mainAssistStatus && (this.deliverAssistStatus || this.receiveAssistStatus)) {
this.assistAspect = IndicatorStatusEnum.O;
} else {
this.assistAspect = IndicatorStatusEnum.F;
@ -309,6 +319,7 @@ public class StationDirection extends MapNamedElement {
*
* @return 对应方向
*/
// TODO: 数据统一之后获取对应方向代码可删除 20220714
public DirectionLabelEnum getRelativeDirectionLabelEnum() {
if (this.isDataConfig) {
return this.getRelativeStationDirection().getLabelEnum();
@ -383,6 +394,17 @@ public class StationDirection extends MapNamedElement {
this.deliverAssistStatus = false;
this.receiveAssistStatus = false;
this.remain.set(0);
this.assistTime = null;
}
/**
* 辅助按压时间超过50s
*
* @return 是否超过50
*/
public boolean assistDurationPass50(LocalDateTime currentDateTime) {
return this.assistTime != null
&& this.assistTime.plusSeconds(DEFAULT_DURATION_TIME).isBefore(currentDateTime);
}
/**
@ -400,6 +422,8 @@ public class StationDirection extends MapNamedElement {
this.deliverAspect = IndicatorStatusEnum.F;
this.sectionAspect = IndicatorStatusEnum.F;
this.assistAspect = IndicatorStatusEnum.F;
this.assistTime = null;
this.changeDirectionTime = null;
}
/**
@ -408,6 +432,7 @@ public class StationDirection extends MapNamedElement {
private ReceiveAndDeliverModel getDefaultReceiveAndDeliver() {
if (this.isDataConfig) {
return this.defaultRunStatus;
// TODO: 待数据统一之后下方代码可删除 20220714
} else if (DirectionLabelEnum.X.equals(labelEnum) || DirectionLabelEnum.S.equals(labelEnum)) { // XS方向为接车方向默认亮起
return ReceiveAndDeliverModel.R;
} else if (DirectionLabelEnum.XF.equals(labelEnum) || DirectionLabelEnum.SF.equals(labelEnum)) { // SFXF方向默认发车灯亮起
@ -423,6 +448,7 @@ public class StationDirection extends MapNamedElement {
private DirectionRunModel getDefaultDirectionRunModel() {
if (this.isDataConfig) {
return this.runModel;
// TODO: 待数据统一之后下方代码可删除 20220714
} else if (DirectionLabelEnum.XD.equals(labelEnum) || DirectionLabelEnum.SD.equals(labelEnum)) {
return DirectionRunModel.S;
} else { // SDXD
@ -448,25 +474,6 @@ public class StationDirection extends MapNamedElement {
return isLock;
}
/**
* 判断改方是否完成
*/
private boolean judgeChangeDirectionReady() {
boolean isReady;
// 根据接发状态获取进路信息
ReceiveAndDeliverModel defaultModel = getDefaultReceiveAndDeliver();
// 接方向在判断发车进路办理后就会取消辅助状态
if (ReceiveAndDeliverModel.R.equals(defaultModel)) {
// 改方按钮是否按下,代表正在改方
// 进路已锁闭,发车已就绪
isReady = this.changeDirectionStatus && this.deliverRouteList.stream().anyMatch(Route::isLock);
} else {
// 发车进路需要判断接车进路是否办理
isReady = this.receiveRouteList.stream().anyMatch(Route::isLock);
}
return isReady;
}
/**
* 自动模式下的接发车判断
*/
@ -512,13 +519,26 @@ public class StationDirection extends MapNamedElement {
*/
private List<Route> getNowRouteList() {
if (this.assistReadyStatus) { // 辅助状态办理完成
return ReceiveAndDeliverModel.R.equals(this.runStatus) ? this.receiveRouteList : this.deliverRouteList;
} else if (ReceiveAndDeliverModel.D.equals(this.defaultRunStatus)) {
return this.changeDirectionStatus ? this.receiveRouteList : this.deliverRouteList;
} else if (ReceiveAndDeliverModel.R.equals(this.defaultRunStatus)) {
return this.changeDirectionStatus ? this.deliverRouteList : this.receiveRouteList;
if (this.receiveAssistStatus) { // 接辅助状态
return this.receiveRouteList;
} else if (this.deliverAssistStatus) { // 发辅助状态
return this.deliverRouteList;
} else {
return this.currentRouteList; // 原有的进路列表
}
} else if (this.changeDirectionStatus) { // 改方状态下
if (ReceiveAndDeliverModel.D.equals(this.defaultRunStatus)) { // 原发使用接进路列表
return this.receiveRouteList;
} else { // 原接使用发进路列表
return this.deliverRouteList;
}
} else {
if (ReceiveAndDeliverModel.D.equals(this.defaultRunStatus)) { // 初始状态下
return this.deliverRouteList;
} else {
return this.receiveRouteList;
}
}
return null;
}
/**
@ -527,14 +547,23 @@ public class StationDirection extends MapNamedElement {
* @return 运行方向
*/
private ReceiveAndDeliverModel getNowRunStatus() {
if (this.assistReadyStatus) { // 辅助状态办理完成,不修改接发状态
return this.runStatus;
} else if (ReceiveAndDeliverModel.D.equals(this.defaultRunStatus)) {
return this.changeDirectionStatus ? ReceiveAndDeliverModel.R : ReceiveAndDeliverModel.D;
} else if (ReceiveAndDeliverModel.R.equals(this.defaultRunStatus)) {
return this.changeDirectionStatus ? ReceiveAndDeliverModel.D : ReceiveAndDeliverModel.R;
if (this.assistReadyStatus) { // 辅助状态办理完成
if (this.receiveAssistStatus) { // 接辅助为接状态
return ReceiveAndDeliverModel.R;
} else if (this.deliverAssistStatus) { // 发辅助为发状态
return ReceiveAndDeliverModel.D;
} else {
return this.runStatus; // 默认原有状态
}
} else if (this.changeDirectionStatus) { // 改方状态下
if (ReceiveAndDeliverModel.D.equals(this.defaultRunStatus)) { // 原发变接
return ReceiveAndDeliverModel.R;
} else { // 原接变发
return ReceiveAndDeliverModel.D;
}
} else {
return this.defaultRunStatus; // 默认状态
}
return null;
}
/**