rt仿真调整
This commit is contained in:
parent
f189b728fd
commit
190f510ba3
@ -1,22 +1,18 @@
|
||||
package club.joylink.rtss.simulation.rt.ATS;
|
||||
|
||||
import club.joylink.rtss.simulation.SimulationUser;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.AtsRepository;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.AtsRepositoryBuilder;
|
||||
import club.joylink.rtss.simulation.rt.RtSimulation;
|
||||
import club.joylink.rtss.simulation.rt.RtSimulationSubscribeTopic;
|
||||
import club.joylink.rtss.simulation.rt.RtSimulationUser;
|
||||
import club.joylink.rtss.vo.client.map.MapVO;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ATS逻辑
|
||||
*/
|
||||
@Component
|
||||
public class AtsLogicService {
|
||||
public static final int Main_Logic_Rate = 1000;
|
||||
|
||||
public void init(RtSimulation rtSimulation, MapVO mapVO) {
|
||||
AtsRepository atsRepository = AtsRepositoryBuilder.buildFrom(mapVO);
|
||||
rtSimulation.addRepository(atsRepository);
|
||||
@ -25,28 +21,4 @@ public class AtsLogicService {
|
||||
rtSimulation.addMessagePublisher(atsMessagePublisher);
|
||||
}
|
||||
|
||||
// public void addJobs(RtSimulation rtSimulation) {
|
||||
// for (RtSimulationSubscribeTopic topic : RtSimulationSubscribeTopic.values()) {
|
||||
// rtSimulation.addFixedRateJob("MESSAGE-" + topic.name(), () -> sendMessages(rtSimulation, topic), topic.getRate());
|
||||
// }
|
||||
// }
|
||||
|
||||
public void sendMessages(RtSimulation rtSimulation, RtSimulationSubscribeTopic topic) {
|
||||
AtsRepository repository = rtSimulation.getRepository(AtsRepository.NAME, AtsRepository.class);
|
||||
List<List<Object>> messages = repository.removeReady2SendMessages();
|
||||
if (!CollectionUtils.isEmpty(messages)) {
|
||||
List<RtSimulationUser> simulationUsers = rtSimulation.getSimulationUsers();
|
||||
String dest = topic.buildDestination(rtSimulation.getId());
|
||||
for (SimulationUser simulationUser : simulationUsers) {
|
||||
if (simulationUser.isSubscribe(dest)) {
|
||||
rtSimulation.pushMessageToUser(simulationUser.getId(), dest, messages);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<List<Object>> getAllMessages(RtSimulation rtSimulation) {
|
||||
AtsRepository repository = rtSimulation.getRepository(AtsRepository.NAME, AtsRepository.class);
|
||||
return repository.getAllMessages();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
package club.joylink.rtss.simulation.rt.ATS;
|
||||
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.AtsRepository;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.AtsTrain;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AtsTrainRouteService {
|
||||
|
||||
public void triggerRouteForTrain(AtsRepository atsRepository, AtsTrain atsTrain) {
|
||||
if (atsTrain.isPlanTrain()) { // 计划车
|
||||
this.triggerForPlanTrain(atsRepository, atsTrain);
|
||||
} else if (atsTrain.isHeadTrain()) { // 头码车
|
||||
this.triggerForHeadTrain(atsRepository, atsTrain);
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerForPlanTrain(AtsRepository atsRepository, AtsTrain atsTrain) {
|
||||
this.simpleTrigger(atsRepository, atsTrain);
|
||||
}
|
||||
|
||||
private void simpleTrigger(AtsRepository atsRepository, AtsTrain atsTrain) {
|
||||
if (atsTrain.getNextSectionId() == null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerForHeadTrain(AtsRepository atsRepository, AtsTrain atsTrain) {
|
||||
this.simpleTrigger(atsRepository, atsTrain);
|
||||
}
|
||||
|
||||
}
|
@ -3,11 +3,12 @@ package club.joylink.rtss.simulation.rt.ATS.bo;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
import club.joylink.rtss.simulation.SimulationRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.plan.AtsRunPlan;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.plan.AtsStationPlan;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.plan.AtsTripPlan;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@ -15,10 +16,6 @@ public class AtsRepository extends SimulationRepository {
|
||||
public static final String NAME = "ATS";
|
||||
|
||||
AtsRunPlan runPlan;
|
||||
// TODO: 2021/4/22 如果设备id有重复,那不同类的设备的消息需要分开存
|
||||
Map<String, List<Object>> messageMap = new HashMap<>();
|
||||
|
||||
Map<String, List<Object>> ready2SendMessageMap = new HashMap<>();
|
||||
|
||||
Map<String, AtsRoute> routeMap = new HashMap<>();
|
||||
Map<String, AtsRunPlan> runPlanMap = new HashMap<>();
|
||||
@ -69,22 +66,7 @@ public class AtsRepository extends SimulationRepository {
|
||||
return atsRoute;
|
||||
}
|
||||
|
||||
public void ready2Send(String id, int i, Object value) {
|
||||
List<Object> message = messageMap.get(id);
|
||||
if (message != null) {
|
||||
message.set(i, value);
|
||||
ready2SendMessageMap.putIfAbsent(id, message);
|
||||
}
|
||||
}
|
||||
|
||||
public List<List<Object>> removeReady2SendMessages() {
|
||||
ArrayList<List<Object>> messages = new ArrayList<>(this.ready2SendMessageMap.values());
|
||||
ready2SendMessageMap.clear();
|
||||
return messages;
|
||||
|
||||
}
|
||||
|
||||
public List<List<Object>> getAllMessages() {
|
||||
return new ArrayList<>(this.messageMap.values());
|
||||
public AtsTripPlan getTripPlanBy(String sn, String tn) {
|
||||
return this.runPlan.getTripPlanBy(sn, tn);
|
||||
}
|
||||
}
|
||||
|
@ -18,15 +18,14 @@ public class AtsRepositoryBuilder {
|
||||
buildRoutes(logicDataNew.getRouteList(), atsRepository.routeMap);
|
||||
buildSections(graphDataNew.getSectionList(), atsRepository.sectionMap);
|
||||
buildSignals(graphDataNew.getSignalList(), atsRepository.signalMap);
|
||||
buildSwitches(graphDataNew.getSwitchList(), atsRepository.switchMap, atsRepository.messageMap);
|
||||
buildSwitches(graphDataNew.getSwitchList(), atsRepository.switchMap);
|
||||
return atsRepository;
|
||||
}
|
||||
|
||||
private static void buildSwitches(List<MapSwitchVO> switchList, Map<String, AtsSwitch> switchMap, Map<String, List<Object>> messageMap) {
|
||||
private static void buildSwitches(List<MapSwitchVO> switchList, Map<String, AtsSwitch> switchMap) {
|
||||
for (MapSwitchVO switchVO : switchList) {
|
||||
AtsSwitch atsSwitch = new AtsSwitch(switchVO.getCode(), switchVO.getName());
|
||||
switchMap.put(atsSwitch.getId(), atsSwitch);
|
||||
messageMap.put(atsSwitch.getId(), atsSwitch.buildMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,35 @@
|
||||
package club.joylink.rtss.simulation.rt.ATS.bo;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ATS监控列车
|
||||
*/
|
||||
@Getter
|
||||
public class AtsTrain extends AtsDevice {
|
||||
|
||||
int type; // 列车类型
|
||||
public static final int TYPE_P = 1; // 计划车
|
||||
public static final int TYPE_H = 2; // 头码车
|
||||
public static final int TYPE_M = 3; // 人工车
|
||||
int direction;
|
||||
public static final int DIRECTION_N = 0; // 未知
|
||||
public static final int DIRECTION_R = 1; // 右
|
||||
public static final int DIRECTION_L = -1; // 左
|
||||
String sectionId; // 轨道区段(计轴区段或道岔区段)
|
||||
int offset; // 轨道区段偏移
|
||||
String logicSectionId; // 逻辑区段(逻辑区段或道岔计轴区段或岔心)
|
||||
String sn;// 服务号/表号
|
||||
String tn;// 车次号/圈数
|
||||
String dn;// 目的地号
|
||||
String destSectionId; // 目的地区段id
|
||||
String nextSectionId; // 下一目标区段id
|
||||
List<String> routeList;//ats为此列车办理的进路
|
||||
|
||||
|
||||
public AtsTrain(String id, String name) {
|
||||
super(id, name);
|
||||
}
|
||||
@ -12,4 +38,12 @@ public class AtsTrain extends AtsDevice {
|
||||
public List<Object> buildMessage() {
|
||||
return Arrays.asList(this.id);
|
||||
}
|
||||
|
||||
public boolean isPlanTrain() {
|
||||
return TYPE_P == this.type;
|
||||
}
|
||||
|
||||
public boolean isHeadTrain() {
|
||||
return TYPE_H == this.type;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package club.joylink.rtss.simulation.rt.ATS.bo;
|
||||
package club.joylink.rtss.simulation.rt.ATS.bo.plan;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@ -6,8 +6,8 @@ import java.time.LocalTime;
|
||||
|
||||
@Getter
|
||||
public class AtsStationPlan {
|
||||
AtsStation station;
|
||||
AtsSection section;
|
||||
String stationId;
|
||||
String sectionId;
|
||||
LocalTime arriveTime;// 到站时间
|
||||
LocalTime leaveTime;// 出发时间
|
||||
int parkTime;// 停靠时长
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.rtss.simulation.rt.ATS.bo;
|
||||
package club.joylink.rtss.simulation.rt.ATS.bo.plan;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.List;
|
||||
@ -13,12 +14,16 @@ public class AtsTripPlan {
|
||||
boolean in;// 回库
|
||||
boolean out;// 出库
|
||||
boolean spare;// 备用
|
||||
AtsStation startStation;
|
||||
AtsSection startSection;
|
||||
String startStationId;
|
||||
String startSectionId;
|
||||
LocalTime startTime;
|
||||
AtsStation endStation;
|
||||
AtsSection endSection;
|
||||
String endStationId;
|
||||
String endSectionId;
|
||||
LocalTime endTime;
|
||||
List<AtsStationPlan> stationPlanList;
|
||||
boolean depart; // 是否已经发车
|
||||
|
||||
public static String buildSTNumber(String sn, String tn) {
|
||||
return String.format("%s%s", StringUtils.hasText(sn)?sn:"", StringUtils.hasText(tn)?tn:"");
|
||||
}
|
||||
}
|
@ -16,7 +16,6 @@ import club.joylink.rtss.vo.client.map.MapVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Component
|
||||
@ -58,8 +57,10 @@ public class RtSimulationService {
|
||||
}
|
||||
|
||||
private void initCreatorPlayMember(RtSimulation rtSimulation) {
|
||||
List<RtSimulationMember> memberList = rtSimulation.querySimulationMembersOfRole(RtSimulationMember.Role.LOWS);
|
||||
this.simulationManager.memberPlayedByUser(rtSimulation.getId(), memberList.get(0).getId(), rtSimulation.getCreator().getId());
|
||||
// RtSimulationMember simulationMember = rtSimulation.querySimulationMemberById("2");
|
||||
// List<RtSimulationMember> memberList = rtSimulation.querySimulationMembersOfRole(RtSimulationMember.Role.LOWS);
|
||||
// 大铁暂时默认新绛站值班员
|
||||
this.simulationManager.memberPlayedByUser(rtSimulation.getId(), "2", rtSimulation.getCreator().getId());
|
||||
}
|
||||
|
||||
private void initSimulationMember(RtSimulation rtSimulation) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package club.joylink.rtss.simulation.rt;
|
||||
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.AtsRepository;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.AtsRunPlan;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.AtsStationPlan;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.AtsTripPlan;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.plan.AtsRunPlan;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.plan.AtsStationPlan;
|
||||
import club.joylink.rtss.simulation.rt.ATS.bo.plan.AtsTripPlan;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
Loading…
Reference in New Issue
Block a user