哈尔滨问题:日志、信号机灯丝熔断故障

This commit is contained in:
joylink_zhangsai 2020-12-17 18:22:55 +08:00
parent 5d94ef018a
commit 0cd9867530
11 changed files with 246 additions and 57 deletions

View File

@ -16,6 +16,7 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.fault.FaultRuleVO;
import club.joylink.rtss.vo.client.map.MapVO;
import club.joylink.rtss.vo.client.map.newmap.MapDestinationCodeDefinitionVO;
@ -23,6 +24,7 @@ import club.joylink.rtss.vo.client.map.newmap.MapStationNewVO;
import club.joylink.rtss.vo.client.runplan.PlanTripNumberVO;
import club.joylink.rtss.vo.client.runplan.RunPlanEChartsDataVO;
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 io.swagger.annotations.Api;
@ -295,7 +297,7 @@ public class SimulationV1Controller {
@ApiOperation("获取仿真日志")
@GetMapping("/{group}/log")
public List<SimulationLog> getLog(@PathVariable String group) {
return groupSimulationService.getLog(group);
public PageVO<SimulationLog> getLog(@PathVariable String group, SimulationLogPagedQueryVO queryVO) {
return groupSimulationService.getLog(group, queryVO);
}
}

View File

@ -1,6 +1,6 @@
package club.joylink.rtss.simulation.cbtc.ATS.data;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.vo.client.simulationv1.SimulationMemberVO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@ -17,7 +17,7 @@ import java.util.Map;
public class SimulationLog {
private Integer id;
private SimulationMember member;
private SimulationMemberVO member;
private LocalDateTime time;

View File

@ -12,6 +12,7 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
import club.joylink.rtss.simulation.cbtc.script.ScriptBO;
import club.joylink.rtss.vo.LoginUserInfoVO;
import club.joylink.rtss.vo.UserVO;
import club.joylink.rtss.vo.client.PageVO;
import club.joylink.rtss.vo.client.fault.FaultRuleVO;
import club.joylink.rtss.vo.client.map.MapVO;
import club.joylink.rtss.vo.client.map.newmap.MapDestinationCodeDefinitionVO;
@ -271,7 +272,7 @@ public interface GroupSimulationService {
* 获取仿真日志
* @return
*/
List<SimulationLog> getLog(String group);
PageVO<SimulationLog> getLog(String group, SimulationLogPagedQueryVO queryVO);
void changePassengerFlow(String group, Long passengerFlowId);
}

View File

@ -392,7 +392,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
public void triggeringAutoFault(Simulation simulation, FaultRuleVO faultRule) {
faultRule.setTriggeringTime(simulation.getCorrectSystemTime());
this.stompMessageService.sendToUser(String.valueOf(simulation.getCreator().getId()),
SocketMessageFactory.build(WebSocketMessageType.Simulation_AutoFault_Trigger, simulation.getGroup(), faultRule.getId()+"::"+faultRule.getTriggeringTime()));
SocketMessageFactory.build(WebSocketMessageType.Simulation_AutoFault_Trigger, simulation.getGroup(), faultRule.getId() + "::" + faultRule.getTriggeringTime()));
}
@Override
@ -888,7 +888,47 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
}
@Override
public List<SimulationLog> getLog(String group) {
return getSimulationByGroup(group).getLogs();
public PageVO<SimulationLog> getLog(String group, SimulationLogPagedQueryVO queryVO) {
List<SimulationLog> logs = getSimulationByGroup(group).getLogs();
//根据时间筛选
if (!CollectionUtils.isEmpty(logs)) {
if (queryVO.getStartTime() != null || queryVO.getEndTime() != null) {
logs = logs.stream().filter(log->{
boolean flag = true;
if (queryVO.getStartTime() != null) {
flag = flag && !log.getTime().isBefore(queryVO.getStartTime());
}
if (queryVO.getEndTime() != null) {
flag = flag && !log.getTime().isAfter(queryVO.getEndTime());
}
return flag;
}).collect(Collectors.toList());
}
}
PageVO<SimulationLog> pageVO = new PageVO<>();
pageVO.setPageSize(queryVO.getPageSize());
if (CollectionUtils.isEmpty(logs)) {
pageVO.setPageNum(1);
pageVO.setList(new ArrayList<>());
pageVO.setTotal(0);
} else {
//根据分页信息筛选
int maxPageNum = logs.size() / queryVO.getPageSize() + 1;
int pageNum = Math.min(maxPageNum, queryVO.getPageNum());
int start = (pageNum - 1) * queryVO.getPageSize();
int end = pageNum * queryVO.getPageSize();
start = Math.min(start, logs.size() - 1);
end = Math.min(end, logs.size());
if (start >= logs.size()) {
start = logs.size() - 1;
}
pageVO.setPageNum(pageNum);
pageVO.setTotal(logs.size());
pageVO.setList(logs.subList(start, end));
}
return pageVO;
}
}

View File

@ -1,14 +1,14 @@
package club.joylink.rtss.simulation.cbtc;
import club.joylink.rtss.simulation.cbtc.ATS.data.SimulationLog;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.event.SimulationOperationEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationUserPlayChangeEvent;
import club.joylink.rtss.vo.client.simulationv1.SimulationMemberVO;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* 仿真日志监听器
*/
@ -21,13 +21,15 @@ public class SimulationLogListener {
Simulation simulation = event.getSimulation();
SimulationLog log = new SimulationLog();
log.setId(simulation.getIdGenerator().generateLogId());
log.setTime(LocalDateTime.now());
log.setTime(simulation.getCorrectSystemTime());
if (event.getCancelPlayMember() == null) { //登录
log.setMember(event.getSimulationUser().getPlayedMember());
log.setMember(new SimulationMemberVO(event.getSimulationUser().getPlayedMember()));
log.setEvent(log.new Event(SimulationLog.EventType.LOGIN));
} else { //登出
log.setMember(event.getCancelPlayMember());
SimulationMemberVO memberVO = new SimulationMemberVO(event.getCancelPlayMember());
memberVO.setUserId(event.getSimulationUser().getUser().getId());
log.setMember(memberVO);
log.setEvent(log.new Event(SimulationLog.EventType.LOGOUT));
}
simulation.addLog(log);
@ -38,12 +40,16 @@ public class SimulationLogListener {
public void handle(SimulationOperationEvent event) {
if (event.getSuccessful() == null || !event.getSuccessful())
return;
String operate = event.getOperate();
if (Operation.Type.Set_Fault.name().equals(operate) || Operation.Type.Cancel_Fault.name().equals(operate))
return;
Simulation simulation = event.getSimulation();
SimulationLog log = new SimulationLog();
SimulationLog.Event logEvent = log.new Event(SimulationLog.EventType.OPERATE, event.getOperate(), event.getParams());
SimulationLog.Event logEvent = log.new Event(SimulationLog.EventType.OPERATE, operate, event.getParams());
log.setId(simulation.getIdGenerator().generateLogId());
log.setMember(event.getMember());
log.setTime(event.getSimulationTime());
log.setMember(new SimulationMemberVO(event.getMember()));
log.setTime(simulation.getCorrectSystemTime());
log.setEvent(logEvent);
simulation.addLog(log);
}

View File

@ -30,81 +30,131 @@ public class Signal extends MayOutOfOrderDevice {
private String showName;
/** 设备集中站 */
/**
* 设备集中站
*/
private Station deviceStation;
/** 联锁站 */
/**
* 联锁站
*/
private Station interlockStation;
/** 在哪个区段上 */
/**
* 在哪个区段上
*/
private Section section;
/** 在区段上的偏移量 */
/**
* 在区段上的偏移量
*/
private Float offset;
/** 是否虚拟信号机 */
/**
* 是否虚拟信号机
*/
private boolean virtual;
/** 是否无延续保护 */
/**
* 是否无延续保护
*/
private boolean noOverlap;
/** 信号机类型 */
/**
* 信号机类型
*/
private SignalType type;
/** 是否进路终端 */
/**
* 是否进路终端
*/
private boolean routeEnd;
/** 不生成基本进路的信号机终端 */
/**
* 不生成基本进路的信号机终端
*/
private List<String> ignoreRouteEnd;
/** 是否引导信号机 */
/**
* 是否引导信号机
*/
private boolean callOn;
/** 是否折返信号 */
/**
* 是否折返信号
*/
private boolean turnBack;
/** 方向:true-向右false-向左 */
/**
* 方向:true-向右false-向左
*/
private boolean right;
/** 是否可以灭灯显示CTC级 */
/**
* 是否可以灭灯显示CTC级
*/
private boolean ctc;
/** 虚拟真实室外信号机 */
/**
* 虚拟真实室外信号机
*/
private VirtualRealitySignal virtualSignal;
/** 接近区段路径 */
/**
* 接近区段路径
*/
private List<SectionPath> approachPathList;
/** 进路列表 */
/**
* 进路列表
*/
private List<Route> routeList;
/** 接近锁闭解锁时间 */
/**
* 接近锁闭解锁时间
*/
private int routeReleaseTime;
/** 自动信号 */
/**
* 自动信号
*/
private AutoSignal autoSignal;
// ------------------状态属性---------------------
/** 当前锁闭的进路 */
/**
* 当前锁闭的进路
*/
private Route lockedRoute;
/** 是否封锁 */
/**
* 是否封锁
*/
private boolean blockade;
/** 逻辑点灯/物理点灯 */
/**
* 逻辑点灯/物理点灯
*/
private boolean logicLight;
/** 绿灯开放 */
/**
* 绿灯开放
*/
private boolean greenOpen;
/** 黄灯开放 */
/**
* 黄灯开放
*/
private boolean yellowOpen;
/** 红灯开放 */
/**
* 红灯开放
*/
private boolean redOpen;
/** 信号机延时解锁倒计时单位ms */
/**
* 信号机延时解锁倒计时单位ms
*/
private int delayTime;
/**
@ -112,7 +162,9 @@ public class Signal extends MayOutOfOrderDevice {
*/
private int guideRemain;
/** 列车接近信息:0-无接近列车1-接近为通信车2-接近为非通信车 */
/**
* 列车接近信息:0-无接近列车1-接近为通信车2-接近为非通信车
*/
private SignalApproachMessage.ApproachMessage approachMsg;
@Override
@ -135,6 +187,10 @@ public class Signal extends MayOutOfOrderDevice {
}
public void changeLightType(boolean logic) {
if (SignalFault.MAIN_FILAMENT_BROKEN.equals(getFault()) && logic) {
return;
}
if (this.isCtc()) {
this.logicLight = logic;
} else {
@ -144,6 +200,7 @@ public class Signal extends MayOutOfOrderDevice {
/**
* 信号是否关闭
*
* @return
*/
public boolean isClose() {
@ -221,6 +278,7 @@ public class Signal extends MayOutOfOrderDevice {
/**
* 是否阻挡信号机
*
* @return
*/
public boolean isBlockingSignal() {
@ -229,6 +287,7 @@ public class Signal extends MayOutOfOrderDevice {
/**
* 是否通过信号机
*
* @return
*/
public boolean isPassingSignal() {
@ -237,6 +296,7 @@ public class Signal extends MayOutOfOrderDevice {
/**
* 是否防护信号机
*
* @return
*/
public boolean isProtectionSignal() {
@ -245,6 +305,7 @@ public class Signal extends MayOutOfOrderDevice {
/**
* 是否与轨道常规运行方向相反
*
* @return
*/
public boolean isOppositeToSection() {
@ -254,6 +315,7 @@ public class Signal extends MayOutOfOrderDevice {
/**
* 是否与轨道常规运行方向相同
*
* @return
*/
public boolean isSameDirectionToSection() {
@ -302,17 +364,25 @@ public class Signal extends MayOutOfOrderDevice {
* 信号机类型
*/
public enum SignalType {
/** 防护信号机 */
/**
* 防护信号机
*/
PROTECTION,
/** 阻挡信号机 */
/**
* 阻挡信号机
*/
BLOCKING,
/** 通过信号机 */
/**
* 通过信号机
*/
PASSING
}
public enum SignalFault implements DeviceFault {
/** 主灯丝断丝故障 */
MAIN_FILAMENT_BROKEN{
/**
* 主灯丝熔断故障
*/
MAIN_FILAMENT_BROKEN {
@Override
public boolean apply(MayOutOfOrderDevice device) {
if (Objects.equals(device.getFault(), this)) {
@ -320,10 +390,16 @@ public class Signal extends MayOutOfOrderDevice {
}
device.setFault(this);
Signal signal = (Signal) device;
if (!signal.isLogicLight()) { //如果是物理点灯
VirtualRealitySignal realSignal = signal.getVirtualSignal();
realSignal.apply(false, false, true);
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);
// }
return true;
}
};
@ -331,8 +407,12 @@ public class Signal extends MayOutOfOrderDevice {
@Override
public void fix(MayOutOfOrderDevice device) {
Signal signal = (Signal) device;
if (signal.getFault().equals(this)) {
System.out.println();
if (this.equals(signal.getFault())) {
signal.setFault(null);
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
if (vrSignal != null && vrSignal.getFault() != null) {
vrSignal.getFault().fix(vrSignal);
}
}
}
}

View File

@ -1,12 +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.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;
@ -28,6 +28,8 @@ public class StorageVirtualRealitySignal extends StorageVirtualRealityDeviceStat
@JsonDeserialize(using = Boolean2NumDeserializer.class)
private Boolean redOpen;
private VirtualRealitySignal.Fault fault;
public StorageVirtualRealitySignal(VirtualRealitySignal signal) {
super(signal);
}
@ -47,6 +49,10 @@ public class StorageVirtualRealitySignal extends StorageVirtualRealityDeviceStat
change = true;
storageSignal.setRedOpen(signal.isRedOpen());
}
if (signal.getFault() != null) {
change = true;
storageSignal.setFault(signal.getFault());
}
if (change) {
return storageSignal;
@ -60,5 +66,6 @@ public class StorageVirtualRealitySignal extends StorageVirtualRealityDeviceStat
signal.setGreenOpen(greenOpen != null ? greenOpen : false);
signal.setYellowOpen(yellowOpen != null ? yellowOpen : false);
signal.setRedOpen(redOpen != null ? redOpen : false);
signal.setFault(fault);
}
}

View File

@ -185,6 +185,7 @@ public class VirtualRealityScreenDoor extends VirtualRealityDevice {
public enum Fault {
CANNOT_BE_CLOSED {
@Override
public void apply(VirtualRealityScreenDoor door) {
door.setFault(this);
door.updateOpen2End(true);

View File

@ -13,15 +13,23 @@ import java.util.Objects;
@Setter
public class VirtualRealitySignal extends VirtualRealityDevice {
/** 绿灯亮 */
/**
* 绿灯亮
*/
private boolean greenOpen;
/** 黄灯亮 */
/**
* 黄灯亮
*/
private boolean yellowOpen;
/** 红灯亮 */
/**
* 红灯亮
*/
private boolean redOpen;
private Fault fault;
public VirtualRealitySignal(String code, String name) {
super(code, name, MapElement.DeviceType.SIGNAL);
}
@ -31,9 +39,12 @@ public class VirtualRealitySignal extends VirtualRealityDevice {
this.greenOpen = false;
this.yellowOpen = false;
this.redOpen = false;
this.fault = null;
}
public void apply(boolean greenOpen, boolean yellowOpen, boolean redOpen) {
if (Fault.MAIN_FILAMENT_BROKEN.equals(fault))
return;
this.greenOpen = greenOpen;
this.yellowOpen = yellowOpen;
this.redOpen = redOpen;
@ -47,6 +58,7 @@ public class VirtualRealitySignal extends VirtualRealityDevice {
/**
* 是否黑灯显示
*
* @return
*/
public boolean isBlack() {
@ -59,4 +71,20 @@ public class VirtualRealitySignal extends VirtualRealityDevice {
return String.format("%s-%s:{red:%s, green:%s, yellow:%s}", this.getName(), this.getCode(),
this.redOpen, this.greenOpen, this.yellowOpen);
}
public enum Fault {
MAIN_FILAMENT_BROKEN {
@Override
public void apply(VirtualRealitySignal vrSignal) {
vrSignal.apply(false, false, true);
}
};
public abstract void apply(VirtualRealitySignal vrSignal);
public void fix(VirtualRealitySignal vrSignal) {
if (this.equals(vrSignal.getFault()))
vrSignal.setFault(null);
}
}
}

View File

@ -108,6 +108,7 @@ public class ATPLogicLoop {
}
}
private void onboardLogicRun2(Simulation simulation, VirtualRealityTrain train) {
this.maCheckAndChangeRunLevel(simulation, train);

View File

@ -0,0 +1,23 @@
package club.joylink.rtss.vo.client.simulationv1;
import club.joylink.rtss.vo.client.PageQueryVO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
/**
* 仿真日志分页查询对象
*/
@Getter
@Setter
@NoArgsConstructor
public class SimulationLogPagedQueryVO extends PageQueryVO {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endTime;
}