Merge remote-tracking branch 'origin/master'
# Conflicts: # xian-ncc-da-message
This commit is contained in:
commit
e5ff8453c6
@ -43,16 +43,18 @@ public class LineGraphicDataRepository {
|
||||
*/
|
||||
public static void putLineGraph(PublishedGi publishGi) {
|
||||
try {
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage =
|
||||
LayoutGraphicsProto.RtssGraphicStorage.parseFrom(publishGi.getProto());
|
||||
Map<String, Map<String, ? extends Builder>> lineDataMap = new HashMap<>();
|
||||
// 构建区段
|
||||
sectionInitLineGraph(lineDataMap, storage);
|
||||
// 构建道岔
|
||||
switchInitLineGraph(lineDataMap, storage);
|
||||
// 设置公里标
|
||||
setUpKilometerCode(lineDataMap, storage);
|
||||
lineGraphMap.put(publishGi.getLineId(), lineDataMap);
|
||||
if (publishGi.getLineId() != null) {
|
||||
LayoutGraphicsProto.RtssGraphicStorage storage =
|
||||
LayoutGraphicsProto.RtssGraphicStorage.parseFrom(publishGi.getProto());
|
||||
Map<String, Map<String, ? extends Builder>> lineDataMap = new HashMap<>();
|
||||
// 构建区段
|
||||
sectionInitLineGraph(lineDataMap, storage);
|
||||
// 构建道岔
|
||||
switchInitLineGraph(lineDataMap, storage);
|
||||
// 设置公里标
|
||||
setUpKilometerCode(lineDataMap, storage);
|
||||
lineGraphMap.put(publishGi.getLineId(), lineDataMap);
|
||||
}
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
log.error("反序列化信息失败", e);
|
||||
}
|
||||
|
@ -25,9 +25,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 线路设备信息更新
|
||||
*/
|
||||
/** 线路设备信息更新 */
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LineDeviceStatusService {
|
||||
@ -73,17 +71,31 @@ public class LineDeviceStatusService {
|
||||
public void refreshTestData() {
|
||||
List<MessageData> allMockData = nccMockDataService.loadAllTrainInitData();
|
||||
DeviceStatusConvertorManager.doConvertor(allMockData);
|
||||
int frequency = 1500, stopTime = 30000;
|
||||
AtomicLong id = new AtomicLong(0);
|
||||
AtomicLong resetTimes = new AtomicLong(stopTime);
|
||||
Executors.newSingleThreadScheduledExecutor()
|
||||
.scheduleWithFixedDelay(
|
||||
() -> {
|
||||
int count = (int) (Math.random() * 12);
|
||||
List<MessageData> updateMockData =
|
||||
nccMockDataService.loadUpdateData(id, MessageId.TRAIN_RECORD.name(), count);
|
||||
DeviceStatusConvertorManager.doConvertor(updateMockData);
|
||||
boolean isEmpty = true;
|
||||
if (resetTimes.get() == stopTime) { // 代表还没有停顿,不相等说明已经进入空循环
|
||||
int count = (int) (Math.random() * 12);
|
||||
List<MessageData> updateMockData =
|
||||
nccMockDataService.loadUpdateData(id, MessageId.TRAIN_RECORD.name(), count);
|
||||
DeviceStatusConvertorManager.doConvertor(updateMockData);
|
||||
isEmpty = updateMockData.size() == 0;
|
||||
}
|
||||
if (isEmpty) { // 假数据已经用完了,开始重复使用,中间停顿30000ms
|
||||
if (resetTimes.get() <= 0) {
|
||||
id.set(0);
|
||||
resetTimes.set(stopTime);
|
||||
} else {
|
||||
resetTimes.set(resetTimes.get() - frequency);
|
||||
}
|
||||
}
|
||||
},
|
||||
1500,
|
||||
1500,
|
||||
frequency,
|
||||
frequency,
|
||||
TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
@ -70,21 +70,20 @@ public class LineDeviceMessageServer implements IMessageServer {
|
||||
@Override
|
||||
public List<TopicMessage> onTick() {
|
||||
if (this.lineIdSet.isEmpty()) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<TopicMessage> messages = Lists.newArrayList();
|
||||
for (String lineId : this.lineIdSet) {
|
||||
DeviceStatusData deviceDataSource = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.DEVICE);
|
||||
if (!deviceDataSource.isStatusVOEmpty()) {
|
||||
WsLineMessage.Builder msg = WsLineMessage.newBuilder();
|
||||
fillBuilderFunction((field) -> deviceDataSource.getStatusVOMap().get(field), msg);
|
||||
DeviceStatusDataOperate.clearStatusVOMap(DeviceStatusDataRepository.getDeviceStatusData(lineId));
|
||||
String destination = this.createPlace("lineId", lineId);
|
||||
messages.add(new TopicMessage(destination, msg.build().toByteArray()));
|
||||
String destination = this.createPlace("lineId", lineId);
|
||||
if (deviceDataSource.isStatusVOEmpty()) {
|
||||
messages.add(new TopicMessage(destination, null));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(messages)) {
|
||||
return null;
|
||||
WsLineMessage.Builder msg = WsLineMessage.newBuilder();
|
||||
fillBuilderFunction((field) -> deviceDataSource.getStatusVOMap().get(field), msg);
|
||||
DeviceStatusDataOperate.clearStatusVOMap(DeviceStatusDataRepository.getDeviceStatusData(lineId));
|
||||
messages.add(new TopicMessage(destination, msg.build().toByteArray()));
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
@ -53,37 +53,29 @@ public class LineTrainMessageServer implements IMessageServer {
|
||||
@Override
|
||||
public List<TopicMessage> onTick() {
|
||||
if (this.lineIdSet.isEmpty()) {
|
||||
return null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<TopicMessage> messages = Lists.newArrayList();
|
||||
for (String lineId : this.lineIdSet) {
|
||||
String destination = this.createPlace("lineId", lineId);
|
||||
TrainDataSource trainInfoData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.TRAIN);
|
||||
WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder();
|
||||
if (!CollectionUtils.isEmpty(trainInfoData.getAllTrain())) {
|
||||
for (TrainInfo.Builder trainInfo : trainInfoData.getAllTrain()) {
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainBlock", "block");
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRemove", "remove");
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRecord", "record");
|
||||
trainInfoData.reput(trainInfo);
|
||||
trainMessage.addTrainInfo(trainInfo);
|
||||
}
|
||||
String destination = this.createPlace("lineId", lineId);
|
||||
messages.add(new TopicMessage(destination, trainMessage.build().toByteArray()));
|
||||
if (CollectionUtils.isEmpty(trainInfoData.getAllTrain())) {
|
||||
messages.add(new TopicMessage(destination, null));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(messages)) {
|
||||
return null;
|
||||
WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder();
|
||||
for (TrainInfo.Builder trainInfo : trainInfoData.getAllTrain()) {
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainBlock", "block");
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRemove", "remove");
|
||||
trainInfoData.fillBlockOrRecordOrRemove(trainInfo, "TrainRecord", "record");
|
||||
trainInfoData.reput(trainInfo);
|
||||
trainMessage.addTrainInfo(trainInfo);
|
||||
}
|
||||
|
||||
messages.add(new TopicMessage(destination, trainMessage.build().toByteArray()));
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
WsLineTrainMessage.Builder trainMessage = WsLineTrainMessage.newBuilder();
|
||||
trainMessage.addTrainInfo(TrainInfo.newBuilder());
|
||||
Map<FieldDescriptor, Object> maper = trainMessage.getAllFields();
|
||||
System.out.println(maper);
|
||||
maper.forEach((k, v) -> {
|
||||
System.out.println(k.getName());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a5229b090fd21a5f72cd437ccb9623257724cbed
|
||||
Subproject commit 269d2b054f463bec5abf0330dfdb5cd48f66a8f2
|
Loading…
Reference in New Issue
Block a user