车站中增加计数器;仿真Members和Users改为有序Map
This commit is contained in:
parent
f3df206427
commit
aaa7e414bc
@ -82,8 +82,8 @@ public abstract class Simulation<U extends SimulationUser, M extends Simulation
|
||||
|
||||
private Map<String, SimulationRepository> repositoryMap = new ConcurrentHashMap<>();
|
||||
@Setter
|
||||
private Map<String, M> simulationMemberMap = new ConcurrentHashMap<>();
|
||||
private Map<String, U> simulationUserMap = new ConcurrentHashMap<>();
|
||||
private Map<String, M> simulationMemberMap = new ConcurrentSkipListMap<>(); //2022-08-16 为前端展示成员有序
|
||||
private Map<String, U> simulationUserMap = new ConcurrentSkipListMap<>();
|
||||
private List<Operation> operationList = new ArrayList<>();
|
||||
private Map<String, Map<String, SimulationFaultVO>> deviceFaultMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
@ -0,0 +1,25 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.event.SimulationOperationEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AtsListener {
|
||||
/**
|
||||
* 计数字段名
|
||||
*/
|
||||
public static final String COUNT_PARAM_NAME = "_COUNT";
|
||||
|
||||
public void handle(SimulationOperationEvent event) {
|
||||
String countName = (String) event.getParams().get(COUNT_PARAM_NAME);
|
||||
if (countName == null)
|
||||
return;
|
||||
MapElement device = event.getMember().getDevice();
|
||||
if (device instanceof Station) {
|
||||
Station station = (Station) device;
|
||||
station.count(countName);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -197,8 +197,12 @@ public class Station extends MayOutOfOrderDevice {
|
||||
*/
|
||||
private boolean allowAutonomy;
|
||||
|
||||
@Override
|
||||
/**
|
||||
* 操作计数器
|
||||
*/
|
||||
private Map<String, Integer> counter;
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
if (vrIbp != null) {
|
||||
@ -223,6 +227,7 @@ public class Station extends MayOutOfOrderDevice {
|
||||
preResetValidDuration = new AtomicInteger(0);
|
||||
sGuideMasterLock = false;
|
||||
xGuideMasterLock = false;
|
||||
counter = null;
|
||||
}
|
||||
|
||||
public List<Stand> getStandOf(boolean right) {
|
||||
@ -459,6 +464,13 @@ public class Station extends MayOutOfOrderDevice {
|
||||
return Fault.ATS_ROUTE_TRIGGER_FAULT.equals(getFault());
|
||||
}
|
||||
|
||||
public void count(String countName) {
|
||||
if (this.counter == null) {
|
||||
this.counter = new HashMap<>();
|
||||
}
|
||||
this.counter.merge(countName, 1, Integer::sum);
|
||||
}
|
||||
|
||||
public enum ControlMode {
|
||||
/**
|
||||
* 交出未被接收
|
||||
|
@ -11,6 +11,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@ -90,6 +91,11 @@ public class StationStatus extends DeviceStatus {
|
||||
*/
|
||||
private boolean allowAutonomy;
|
||||
|
||||
/**
|
||||
* 计数器
|
||||
*/
|
||||
private Map<String, Integer> counter;
|
||||
|
||||
public StationStatus(Station station) {
|
||||
super(station.getCode(), station.getDeviceType());
|
||||
controlMode = station.getControlMode();
|
||||
@ -107,6 +113,7 @@ public class StationStatus extends DeviceStatus {
|
||||
sGuideMasterLock = station.isSGuideMasterLock();
|
||||
xGuideMasterLock = station.isXGuideMasterLock();
|
||||
allowAutonomy = station.isAllowAutonomy();
|
||||
counter = station.getCounter();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -190,6 +197,11 @@ public class StationStatus extends DeviceStatus {
|
||||
allowAutonomy = station.isAllowAutonomy();
|
||||
status.setAllowAutonomy(allowAutonomy);
|
||||
}
|
||||
if (!Objects.equals(counter, station.getCounter())) {
|
||||
change = true;
|
||||
counter = station.getCounter();
|
||||
status.setCounter(counter);
|
||||
}
|
||||
return change;
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@ -65,6 +66,8 @@ public class StorageStation extends StorageStatusDevice {
|
||||
|
||||
private Integer preResetValidDuration;
|
||||
|
||||
private Map<String, Integer> counter;
|
||||
|
||||
public StorageStation(Station station) {
|
||||
super(station);
|
||||
}
|
||||
@ -111,6 +114,7 @@ public class StorageStation extends StorageStatusDevice {
|
||||
if (station.getPreResetValidDuration() != null && station.getPreResetValidDuration().get() != 0) {
|
||||
this.setPreResetValidDuration(station.getPreResetValidDuration().get());
|
||||
}
|
||||
this.counter = station.getCounter();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -133,5 +137,6 @@ public class StorageStation extends StorageStatusDevice {
|
||||
station.setEmergencyController(emergencyController != null ? emergencyController : false);
|
||||
station.setControlApplicant(controlApplicant != null ? simulation.getSimulationMemberById(controlApplicant) : null);
|
||||
station.setPreResetValidDuration(new AtomicInteger(Objects.requireNonNullElse(preResetValidDuration, 0)));
|
||||
station.setCounter(counter);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 车站状态
|
||||
@ -87,6 +88,8 @@ public class StationStatusVO extends DeviceStatusVO {
|
||||
|
||||
private Boolean allowAutonomy;
|
||||
|
||||
private Map<String, Integer> counter;
|
||||
|
||||
public StationStatusVO(Station station) {
|
||||
super(station.getCode(), station.getDeviceType());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user