atp切除调整

This commit is contained in:
tiger_zhou 2023-09-04 17:32:31 +08:00
parent 4c277754cc
commit eadaa81df9
6 changed files with 76 additions and 33 deletions

View File

@ -1,7 +1,12 @@
package club.joylink.xiannccda.ats.message.collect.convertor;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.ats.message.MessageId;
import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum;
import club.joylink.xiannccda.ats.warn.TrainAlertEvent;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@ -17,5 +22,13 @@ public class TrainRemoveConvertor extends DefaultConvertor {
return DataTypeEnum.TRAIN;
}
@Override
protected void eventHandle(List<Builder> builders) {
AlertManager alertManager = AlertManager.getDefault();
for (Builder builder : builders) {
if (builder instanceof TrainRemove.Builder trainRemove) {
alertManager.emit(new TrainAlertEvent(trainRemove));
}
}
}
}

View File

@ -19,7 +19,6 @@ import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType
import club.joylink.xiannccda.entity.DeviceAreaConfig;
import club.joylink.xiannccda.service.AlertInfoService;
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
import com.baomidou.mybatisplus.extension.ddl.history.OracleDdlGenerator;
import com.google.protobuf.GeneratedMessageV3;
import com.google.protobuf.GeneratedMessageV3.Builder;
import java.util.Map;
@ -35,8 +34,9 @@ import org.springframework.stereotype.Component;
public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener<SwitchAndTrackLedAlertEvent> {
private DeviceGuardConfigService configService;
private AlertInfoService alertInfoService;
private final DeviceGuardConfigService configService;
private final AlertInfoService alertInfoService;
private final AlertManager alertManager = AlertManager.getDefault();
public AxleSwitchTrackLedAlertListener(DeviceGuardConfigService configService, AlertInfoService alertInfoService) {
@ -87,7 +87,7 @@ public class AxleSwitchTrackLedAlertListener implements AlertSourceEventListener
}
private void emit(boolean light, Builder build, Section section, AlertType alertType) {
AlertManager alertManager = AlertManager.getDefault();
Integer lineId = DeviceStatusDataOperate.findFieldVal(build, "lineId", Integer.class);
String id = DeviceStatusDataOperate.findFieldVal(build, "id", String.class);
GuardConfig guardConfig = configService.getGuardConfig(lineId);

View File

@ -35,7 +35,7 @@ public class SwitchLostAlertMonitoringTask implements AlertMonitoringTask {
}
private AlertManager alertManager = AlertManager.getDefault();
private final AlertManager alertManager = AlertManager.getDefault();
Map<String, Switch.Builder> deviceMap = new ConcurrentHashMap<>();

View File

@ -1,11 +1,11 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
import com.google.protobuf.GeneratedMessageV3;
public class TrainAlertEvent extends DeviceAlertEvent<TrainInfo.Builder> {
public class TrainAlertEvent extends DeviceAlertEvent<GeneratedMessageV3.Builder> {
public TrainAlertEvent(TrainInfo.Builder source) {
public TrainAlertEvent(GeneratedMessageV3.Builder source) {
super(source);
}
}

View File

@ -13,6 +13,7 @@ import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode;
import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
import club.joylink.xiannccda.service.AlertInfoService;
import club.joylink.xiannccda.service.config.DeviceGuardConfigService;
import java.util.Map;
@ -42,10 +43,35 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
public void putTrainInfoMonitor(TrainInfo.Builder train) {
log.info("线路[{}] 车组号[{}] 列车状态[{}] 加入ATP检测中...", train.getLineId(), train.getGroupId(), train.getMode());
// this.trainInfoMap.put(train.getGroupId(), train);
this.lineTrainGroupMap.put(train.getGroupId(), train.getLineId());
}
/**
* 判断紧致后发生atp切除并恢复
* <p>
* 如果没有发生atp切除后续任务会删除对应的信息
*
* @param train
*/
public void recoverAtpCut(TrainInfo.Builder train) {
if (lineTrainGroupMap.containsKey(train.getGroupId())) {
//之前发生过紧制
boolean exist = alertManager.deviceIsExist(train.getLineId(), CUSTOM_NAME, train.getGroupId());
if (exist) {
//判断之前是否发生过atp切除
this.removeTrainInfo(train.getLineId(), train.getGroupId());
}
}
}
public void trainRemoveAllInfo(TrainRemove.Builder remove) {
this.removeTrainInfo(remove.getLineId(), remove.getGroupId());
}
private void removeTrainInfo(int lineId, String trainGroupId) {
this.lineTrainGroupMap.remove(trainGroupId);
alertManager.removeAlterDevice(lineId, CUSTOM_NAME, trainGroupId);
}
@Override
public String getName() {
@ -61,12 +87,12 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
return;
}
Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), sectionCode, Section.class);
// if (alertManager.putAlterDevice(trainInfo.getLineId(), CUSTOM_NAME, trainInfo.getGroupId())) {
log.info("列车紧制ATP检测告警 线路[{}] 列车车组号[{}] 所在设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
String alertMsg = String.format("列车[%s] 紧制导致ATP切除所在区段[%s]", trainInfo.getGroupId(), section.getCode());
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, section.getCommon().getId(), trainInfo, alertMsg, false);
alertManager.emit(alertInfo);
// }
if (alertManager.putAlterDevice(trainInfo.getLineId(), CUSTOM_NAME, trainInfo.getGroupId())) {
log.info("列车紧制ATP检测告警 线路[{}] 列车车组号[{}] 所在设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName());
String alertMsg = String.format("列车[%s] 紧制导致ATP切除所在区段[%s]", trainInfo.getGroupId(), section.getCode());
NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRAIN, section.getCommon().getId(), trainInfo, alertMsg, false);
alertManager.emit(alertInfo);
}
}
@Override
@ -83,7 +109,9 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask {
if (Objects.equals(false, timeOver) && trainMode.getIpModeTrainAtpCut()) {
//列车时间ATP切除且时间没有到告警
this.trainAlert(trainInfo);
} else if (timeOver) {
}/* else if (Objects.equals(false, trainMode.getIpModeTrainAtpCut())) {
}*/ else if (timeOver) {
this.lineTrainGroupMap.remove(groupId);
}
}

View File

@ -1,17 +1,12 @@
package club.joylink.xiannccda.ats.warn;
import club.joylink.xiannccda.alert.NccAlertInfo;
import club.joylink.xiannccda.alert.core.AlertDeviceType;
import club.joylink.xiannccda.alert.core.AlertManager;
import club.joylink.xiannccda.alert.core.AlertSourceEventListener;
import club.joylink.xiannccda.ats.cache.LineGraphicDataRepository;
import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType;
import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode;
import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo;
import club.joylink.xiannccda.service.AlertInfoService;
import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove;
import com.google.protobuf.GeneratedMessageV3;
import java.util.Objects;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
@ -28,15 +23,22 @@ public class TrainModeAlertListener implements AlertSourceEventListener<TrainAle
@Override
public void accept(TrainAlertEvent event) {
TrainInfo.Builder trainInfo = event.getSource();
TrainMode trainMode = trainInfo.getMode();
if (trainMode.getIpModeTrainEbAlarm()) {
//列车紧急制动
log.info("列车紧制ATP检测 线路[{}] 列车车组号[{}] 所在设备[{}] 是否ATP切除[{}] 是否紧制[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName(),
trainMode.getIpModeTrainAtpCut(),
trainMode.getIpModeTrainEbAlarm());
this.atpCutAlertMonitoringTask.putTrainInfoMonitor(trainInfo);
GeneratedMessageV3.Builder trainMsgBuild = event.getSource();
if (trainMsgBuild instanceof TrainInfo.Builder trainInfo) {
TrainMode trainMode = trainInfo.getMode();
if (trainMode.getIpModeTrainEbAlarm()) {
//列车紧急制动
log.info("列车紧制ATP检测 线路[{}] 列车车组号[{}] 所在设备[{}] 是否ATP切除[{}] 是否紧制[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName(),
trainMode.getIpModeTrainAtpCut(),
trainMode.getIpModeTrainEbAlarm());
this.atpCutAlertMonitoringTask.putTrainInfoMonitor(trainInfo);
} else if (Objects.equals(false, trainMode.getIpModeTrainAtpCut())) {
this.atpCutAlertMonitoringTask.recoverAtpCut(trainInfo);
}
} else if (trainMsgBuild instanceof TrainRemove.Builder trainRemove) {
this.atpCutAlertMonitoringTask.trainRemoveAllInfo(trainRemove);
}
}
}