武汉8号线列车位置显示功能调整
This commit is contained in:
parent
b425e5b36b
commit
114be10e1b
@ -92,12 +92,12 @@ public class NewAtsTrainLoadService {
|
|||||||
//重叠检测
|
//重叠检测
|
||||||
SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
|
SectionPosition headPosition = new SectionPosition(section, tp.getLocation() - section.getKmMin());
|
||||||
// SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
|
// SectionPosition headPosition = new SectionPosition(section, section.getStopPointByDirection(right));
|
||||||
SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
|
// SectionPosition tailPosition = CalculateService.calculateNextPositionByStartAndLen(headPosition, !right, train.getLen(), false);
|
||||||
boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
|
// boolean willOverlap = vrTrainRunningService.willOverlap(simulation, headPosition, tailPosition);
|
||||||
if(willOverlap){
|
// if(willOverlap){
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
|
// BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotTrue(willOverlap, "列车重叠");
|
||||||
// 列车上线并构建ATS监控列车信息
|
// 列车上线并构建ATS监控列车信息
|
||||||
manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
|
manualTrainOnlineAndSupervise(simulation, train, headPosition, right);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,10 @@ public class LogTest {
|
|||||||
LogTest lt = new LogTest();
|
LogTest lt = new LogTest();
|
||||||
List<TrainPosition> list = lt.readFile("d:\\spring.log2");
|
List<TrainPosition> list = lt.readFile("d:\\spring.log2");
|
||||||
// lt.query(list,"024");
|
// lt.query(list,"024");
|
||||||
lt.queryAll(list);
|
list = lt.query(list,"015",Section.SectionRoadType.RIGHT);
|
||||||
|
for (TrainPosition tp : list) {
|
||||||
|
System.out.println(tp.dateFormat() + " --->" + tp.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void queryAll(List<TrainPosition> list){
|
public void queryAll(List<TrainPosition> list){
|
||||||
@ -43,6 +46,11 @@ public class LogTest {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<TrainPosition> query(List<TrainPosition> list, List<String> groups, Section.SectionRoadType roadType){
|
||||||
|
List<TrainPosition> newList = list.stream().filter(d->groups.contains(d.getGroupNum()) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
||||||
|
return newList;
|
||||||
|
}
|
||||||
public List<TrainPosition> query(List<TrainPosition> list, String groupNum, Section.SectionRoadType roadType){
|
public List<TrainPosition> query(List<TrainPosition> list, String groupNum, Section.SectionRoadType roadType){
|
||||||
List<TrainPosition> newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
List<TrainPosition> newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum) && d.getRoadType() == roadType ).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
||||||
return newList;
|
return newList;
|
||||||
@ -51,6 +59,20 @@ public class LogTest {
|
|||||||
List<TrainPosition> newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum)).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
List<TrainPosition> newList = list.stream().filter(d->Objects.equals(d.getGroupNum(),groupNum)).sorted(Comparator.comparing(TrainPosition::getReceiveTime)).collect(Collectors.toList());
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
public List<TrainPosition> readSource(String file){
|
||||||
|
List<TrainPosition> list = Lists.newArrayList();
|
||||||
|
try(BufferedReader reader = new BufferedReader(new FileReader(file))){
|
||||||
|
// StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
String content = null;
|
||||||
|
while((content = reader.readLine()) != null){
|
||||||
|
TrainPosition tp = JsonUtils.read(content, TrainPosition.class);
|
||||||
|
list.add(tp);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
public List<TrainPosition> readFile(String file) {
|
public List<TrainPosition> readFile(String file) {
|
||||||
|
|
||||||
List<TrainPosition> list = Lists.newArrayList();
|
List<TrainPosition> list = Lists.newArrayList();
|
||||||
|
@ -6,6 +6,11 @@ import lombok.Data;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|
||||||
@ -28,6 +33,12 @@ public class TrainPosition {
|
|||||||
public boolean isRight(){
|
public boolean isRight(){
|
||||||
return this.direction == 1;
|
return this.direction == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String dateFormat(){
|
||||||
|
Instant instant = Instant.ofEpochMilli(this.receiveTime);
|
||||||
|
ZoneId zone = ZoneId.systemDefault();
|
||||||
|
return LocalDateTime.ofInstant(instant, zone).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return JsonUtils.writeValueNullableFieldAsString(this);
|
return JsonUtils.writeValueNullableFieldAsString(this);
|
||||||
|
@ -6,6 +6,7 @@ import club.joylink.rtss.util.JsonUtils;
|
|||||||
import club.joylink.rtss.util.test.LogTest;
|
import club.joylink.rtss.util.test.LogTest;
|
||||||
import club.joylink.rtss.vo.ws.TrainPosition;
|
import club.joylink.rtss.vo.ws.TrainPosition;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.messaging.simp.stomp.StompSession;
|
import org.springframework.messaging.simp.stomp.StompSession;
|
||||||
import org.springframework.util.concurrent.ListenableFuture;
|
import org.springframework.util.concurrent.ListenableFuture;
|
||||||
@ -37,16 +38,18 @@ public class StompClientManager {
|
|||||||
StompSession stompSession = future.get();
|
StompSession stompSession = future.get();
|
||||||
LogTest lt = new LogTest();
|
LogTest lt = new LogTest();
|
||||||
List<TrainPosition> list = lt.readFile("d:\\spring.log2");
|
List<TrainPosition> list = lt.readFile("d:\\spring.log2");
|
||||||
|
// List<TrainPosition> list = lt.readSource("d:\\t.txt");
|
||||||
// runToLeft(stompSession,"001");
|
// runToLeft(stompSession,"001");
|
||||||
// runToRight(stompSession,"002");
|
// runToRight(stompSession,"002");
|
||||||
list = lt.query(list,"004", Section.SectionRoadType.RIGHT);
|
// list = lt.query(list,"042",Section.SectionRoadType.RIGHT);
|
||||||
|
// list = lt.query(list, Lists.newArrayList("015","037"), Section.SectionRoadType.RIGHT);
|
||||||
send(stompSession,list);
|
send(stompSession,list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void send(StompSession stompSession,List<TrainPosition> list){
|
public static void send(StompSession stompSession,List<TrainPosition> list){
|
||||||
//48,55,56,65,75,121,127,138,150,155,162。。,183
|
//48,55,56,65,75,121,127,138,150,155,162。。,183
|
||||||
//128
|
//128
|
||||||
for (int i = 183; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
TrainPosition tp = list.get(i);
|
TrainPosition tp = list.get(i);
|
||||||
String val = JsonUtils.writeValueNullableFieldAsString(tp);
|
String val = JsonUtils.writeValueNullableFieldAsString(tp);
|
||||||
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
|
Instant instant = Instant.ofEpochMilli(tp.getReceiveTime());
|
||||||
@ -58,7 +61,10 @@ public class StompClientManager {
|
|||||||
if(i > 0){
|
if(i > 0){
|
||||||
TrainPosition old = list.get(i - 1);
|
TrainPosition old = list.get(i - 1);
|
||||||
try {
|
try {
|
||||||
long sleepTime = tp.getReceiveTime() - old.getReceiveTime();
|
long sleepTime = (tp.getReceiveTime() - old.getReceiveTime());
|
||||||
|
if(sleepTime > 10000){
|
||||||
|
sleepTime = sleepTime / 1000;
|
||||||
|
}
|
||||||
System.out.println("index:" + i + "sleep:"+sleepTime);
|
System.out.println("index:" + i + "sleep:"+sleepTime);
|
||||||
TimeUnit.MILLISECONDS.sleep(sleepTime);
|
TimeUnit.MILLISECONDS.sleep(sleepTime);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
Loading…
Reference in New Issue
Block a user