增加从仿真中获取iscs状态逻辑;增加闸机设备

This commit is contained in:
joylink_zhangsai 2022-09-28 17:44:26 +08:00
parent f5f6188ff5
commit d1f6e14f42
18 changed files with 332 additions and 27 deletions

View File

@ -6,18 +6,31 @@ import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.SimulationIscsDataRepository;
import club.joylink.rtss.simulation.cbtc.data.iscs.Audio;
import club.joylink.rtss.simulation.cbtc.data.map.MapConfig;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.vo.iscs.*;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityGate;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
import club.joylink.rtss.simulation.rt.iscs.IscsStatusPublisher;
import club.joylink.rtss.vo.client.iscs.PlayParamVO;
import club.joylink.rtss.vo.client.iscs.TimedPlayParamVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
@Component
public class IscsLogicLoop {
public static final String JOB_NAME = "ISCS_LOGIC_LOOP";
public static final int RATE = 1000;
public static final String MESSAGE_JOB_NAME = "ISCS_MESSAGE_SENDER";
@Autowired
private IscsInteractiveService iscsInteractiveService;
@ -65,7 +78,91 @@ public class IscsLogicLoop {
}
}
public void addJob(Simulation simulation) {
public void UpdateStatusAndSend(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository();
MapConfig config = repository.getConfig();
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
Map<String, IscsStatusVO> statusVOMap = iscsRepository.getStatusVOMap();
//IBP
List<VirtualRealityIbp> vrIbpList = repository.getVrListByType(MapElement.DeviceType.IBP, VirtualRealityIbp.class);
for (VirtualRealityIbp vrIbp : vrIbpList) {
IscsStatusVO iscsStatusVO = statusVOMap.get(vrIbp.getCode());
if (iscsStatusVO == null) {
IscsIbpStatusVO iscsIbpStatusVO = new IscsIbpStatusVO(vrIbp);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class);
simulation.watch(iscsIbpStatusVO, watcher);
statusVOMap.put(iscsIbpStatusVO.getCode(), iscsIbpStatusVO);
iscsIbpStatusVO.fireWatcher(null, null);
} else {
IscsIbpStatusVO iscsIbpStatusVO = (IscsIbpStatusVO) iscsStatusVO;
boolean change = iscsIbpStatusVO.compareAndChange(vrIbp);
if (change) iscsIbpStatusVO.fireWatcher(null, null);
}
}
//PSD
for (Station station : repository.getStationList()) {
boolean upRight = config.isUpRight();
List<Stand> rightStands = station.getNormalStand(true);
Stand rightStand = null;
if (!CollectionUtils.isEmpty(rightStands))
rightStand = rightStands.get(0);
List<Stand> leftStands = station.getNormalStand(false);
Stand leftStand = null;
if (!CollectionUtils.isEmpty(leftStands))
leftStand = leftStands.get(0);
Stand upStand = upRight ? rightStand : leftStand;
Stand downStand = upRight ? leftStand : rightStand;
//PSD
String iscsPsdCode = station.getCode() + "_ISCS_PSD";
VirtualRealityScreenDoor upPsd = upStand == null ? null : upStand.getPsd().getVirtualScreenDoor();
VirtualRealityScreenDoor downPsd = downStand == null ? null : downStand.getPsd().getVirtualScreenDoor();
IscsPsdStatusVO iscsPsdStatusVO = (IscsPsdStatusVO) statusVOMap.get(iscsPsdCode);
if (iscsPsdStatusVO == null) {
iscsPsdStatusVO = new IscsPsdStatusVO(iscsPsdCode, station.getCode(), upPsd, downPsd);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class);
simulation.watch(iscsPsdStatusVO, watcher);
statusVOMap.put(iscsPsdStatusVO.getCode(), iscsPsdStatusVO);
iscsPsdStatusVO.fireWatcher(null, null);
} else {
boolean change = iscsPsdStatusVO.compareAndChange(upPsd, downPsd);
if (change) iscsPsdStatusVO.fireWatcher(null, null);
}
//PSL
String iscsPslCode = station.getCode() + "_ISCS_PSL";
VirtualRealityPsl upPsl = upStand == null ? null : upStand.getVrPsl();
VirtualRealityPsl downPsl = downStand == null ? null : downStand.getVrPsl();
IscsPslStatusVO iscsPslStatusVO = (IscsPslStatusVO) statusVOMap.get(iscsPslCode);
if (iscsPslStatusVO == null) {
iscsPslStatusVO = new IscsPslStatusVO(iscsPslCode, station.getCode(), upPsl, downPsl);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class);
simulation.watch(iscsPslStatusVO, watcher);
statusVOMap.put(iscsPslStatusVO.getCode(), iscsPslStatusVO);
iscsPslStatusVO.fireWatcher(null, null);
} else {
boolean change = iscsPslStatusVO.compareAndChange(upPsl, downPsl);
if (change) iscsPslStatusVO.fireWatcher(null, null);
}
//GATE
VirtualRealityGate vrGate = station.getVrGate();
IscsGateStatusVO iscsGateStatusVO = (IscsGateStatusVO) statusVOMap.get(vrGate.getCode());
if (iscsGateStatusVO == null) {
iscsGateStatusVO = new IscsGateStatusVO(vrGate.getCode(), station.getCode(), vrGate);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class);
simulation.watch(iscsGateStatusVO, watcher);
statusVOMap.put(iscsGateStatusVO.getCode(), iscsGateStatusVO);
iscsGateStatusVO.fireWatcher(null, null);
} else {
boolean change = iscsGateStatusVO.compareAndChange(vrGate);
if (change) iscsGateStatusVO.fireWatcher(null, null);
}
}
iscsRepository.getStatusStream(IscsStatusVO.DeviceType.GATE, "Station61238").forEach(vo -> System.out.println(vo.getStationCode()));
}
public void addJobs(Simulation simulation) {
simulation.addJob(JOB_NAME, () -> run(simulation), RATE);
simulation.addJob(MESSAGE_JOB_NAME, () -> UpdateStatusAndSend(simulation), RATE);
}
}

View File

@ -24,7 +24,7 @@ public class IscsMessageCollectAndDispatcher {
if (status == null) {
status = new IscsAudioStatusVO(audio);
iscsRepository.addStatus(status);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class);
simulation.watch(status, watcher);
status.fireWatcher(null, null);
} else {

View File

@ -210,7 +210,7 @@ public class SimulationLifeCycleServiceImpl implements SimulationLifeCycleServic
powerSupplyService.addJobs(simulation);
iVirtualRealityPslService.addJobs(simulation);
iscsMessageCollectAndDispatcher.addJob(simulation);
iscsLogicLoop.addJob(simulation);
iscsLogicLoop.addJobs(simulation);
pisLogicLoop.addJobs(simulation);
}
atpLogicLoop.addJobs(simulation);

View File

@ -1354,14 +1354,6 @@ public class MapDeviceBuilder {
elementMap.put(station.getCode(), station);
station.setCentralized(stationVO.isCentralized());
station.setDepot(stationVO.isDepot());
// if (station.isCentralized() && !station.isDepot()) {
// ZC zc = (ZC) elementMap.get(stationVO.getZcCode());
// if (Objects.isNull(zc)) {
// errMsgList.add(String.format("车站[%s(%s)]未关联ZC或ZC不存在请在ZC设备处选择管理的集中站列表", station.getName(), station.getCode()));
// } else {
// station.setZc(zc);
// }
// }
if (Objects.isNull(stationVO.getKmRange())) {
errMsgList.add(String.format("车站[%s(%s)]未设置距离", stationVO.getName(), stationVO.getCode()));
} else {
@ -1384,6 +1376,7 @@ public class MapDeviceBuilder {
if (station.isHasControlMode()) { // 有控制模式初始化为中控
station.setControlMode(Station.ControlMode.Center);
}
station.setVrGate(new VirtualRealityGate(station.getCode() + "_GATE", station.getName() + "闸机"));
});
// 设备集中站下的车站关联ZC联锁站下的车站关联联锁站
stationList.forEach(stationVO -> {
@ -1398,7 +1391,6 @@ public class MapDeviceBuilder {
station.getName(), station.getCode(), code));
} else {
normal.setDeviceStation(station);
// normal.setZc(station.getZc());
}
});
}

View File

@ -85,9 +85,18 @@ public class SimulationIscsDataRepository {
}
public List<IscsStatusVO> getStatusByDeviceType(IscsStatusVO.DeviceType type) {
return getStatusStream(type).collect(Collectors.toList());
}
public Stream<IscsStatusVO> getStatusStream(IscsStatusVO.DeviceType type) {
return statusVOMap.values().stream()
.filter(vo -> Objects.equals(type, vo.getDeviceType()));
}
public Stream<IscsStatusVO> getStatusStream(IscsStatusVO.DeviceType type, String stationCode) {
return statusVOMap.values().stream()
.filter(vo -> Objects.equals(type, vo.getDeviceType()))
.collect(Collectors.toList());
.filter(vo -> Objects.equals(stationCode, vo.getStationCode()));
}
public List<IscsSystemResourcesVO> querySystemResources(String system, String type) {

View File

@ -141,6 +141,8 @@ public abstract class MapElement {
LCD,
/** iscs LED */
LED,
/** 闸机 */
GATE,
}
/**

View File

@ -6,6 +6,7 @@ import club.joylink.rtss.simulation.cbtc.CI.data.StationDirection;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.TurnBackStrategyType;
import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityGate;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
@ -121,6 +122,11 @@ public class Station extends MayOutOfOrderDevice {
*/
private VirtualRealityIbp vrIbp;
/**
* 虚拟真实闸机
*/
private VirtualRealityGate vrGate;
//---------------------状态属性------------------------
/**

View File

@ -0,0 +1,29 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityGate;
import lombok.Getter;
@Getter
public class IscsGateStatusVO extends IscsStatusVO{
/**
* -1未定义0故障1正常
*/
private int status;
private static final int UNDEFINED = -1;
private static final int FAULT = 0;
private static final int NORMAL = 1;
public IscsGateStatusVO(String code, String stationCode, VirtualRealityGate vrGate) {
super(code, DeviceType.GATE, stationCode);
status = vrGate.isFault() ? FAULT : NORMAL;
}
public boolean compareAndChange(VirtualRealityGate vrGate) {
int i = vrGate.isFault() ? FAULT : NORMAL;
if (status != i) {
status = i;
return true;
}
return false;
}
}

View File

@ -1,14 +1,20 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
public class IscsIbpStatusVO extends IscsStatusVO {
/** 上行状态 */
/**
* 上行状态
*/
private DirectionalStatus upStatus;
/** 下行状态 */
/**
* 下行状态
*/
private DirectionalStatus downStatus;
public IscsIbpStatusVO(String code, String stationCode,
@ -18,19 +24,83 @@ public class IscsIbpStatusVO extends IscsStatusVO {
this.downStatus = downStatus;
}
public IscsIbpStatusVO(VirtualRealityIbp vrIbp) {
super(vrIbp.getCode(), DeviceType.IBP, vrIbp.getStation().getCode());
upStatus = new DirectionalStatus();
downStatus = new DirectionalStatus();
for (VirtualRealityIbp.IbpElement element : vrIbp.getAllElements()) {
if (element.getUp() == null)
continue;
DirectionalStatus dirStatus = element.getUp() ? upStatus : downStatus;
VirtualRealityIbp.Mean mean = element.getMean();
if (mean == null)
continue;
switch (mean) {
case KM:
dirStatus.setOpenCommand(element.isOn());
break;
case PSD_SMKM:
dirStatus.setOpenSideCommand(element.isOn());
break;
case GM:
dirStatus.setCloseCommand(element.isOn());
break;
case PSD_CZYX_LIGHT:
dirStatus.setOperate(element.isOn());
break;
}
}
}
public boolean compareAndChange(VirtualRealityIbp vrIbp) {
DirectionalStatus upStatus = new DirectionalStatus();
DirectionalStatus downStatus = new DirectionalStatus();
for (VirtualRealityIbp.IbpElement element : vrIbp.getAllElements()) {
if (element.getUp() == null)
continue;
DirectionalStatus dirStatus = element.getUp() ? upStatus : downStatus;
if (element.getMean() == null)
continue;
switch (element.getMean()) {
case KM:
dirStatus.setOpenCommand(element.isOn());
break;
case PSD_SMKM:
dirStatus.setOpenSideCommand(element.isOn());
break;
case GM:
dirStatus.setCloseCommand(element.isOn());
break;
case PSD_CZYX_LIGHT:
dirStatus.setOperate(element.isOn());
break;
}
}
return this.upStatus.compareAndChange(upStatus) || this.downStatus.compareAndChange(downStatus);
}
@Getter
@Setter
@NoArgsConstructor
public static class DirectionalStatus {
/** 操作允许 */
/**
* 操作允许
*/
private boolean operate = true;
/** 开门命令 */
/**
* 开门命令
*/
private boolean openCommand = true;
/** 开边门命令 */
/**
* 开边门命令
*/
private boolean openSideCommand = true;
/** 关门命令 */
/**
* 关门命令
*/
private boolean closeCommand = true;
public DirectionalStatus(boolean operate, boolean openCommand,
@ -41,6 +111,10 @@ public class IscsIbpStatusVO extends IscsStatusVO {
this.closeCommand = closeCommand;
}
public boolean compareAndChange(DirectionalStatus dirStatus) {
return this.compareAndChange(dirStatus.isOperate(), dirStatus.isOpenCommand(), dirStatus.isOpenSideCommand(), dirStatus.isCloseCommand());
}
public boolean compareAndChange(boolean operate, boolean openCommand, boolean openSideCommand, boolean closeCommand) {
boolean change = false;
if (this.operate != operate) {

View File

@ -1,10 +1,11 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter
public class IscsPsdStatusVO extends IscsStatusVO{
public class IscsPsdStatusVO extends IscsStatusVO {
private DirectionalStatus upStatus;
private DirectionalStatus downStatus;
@ -16,6 +17,23 @@ public class IscsPsdStatusVO extends IscsStatusVO{
this.downStatus = downStatus;
}
public IscsPsdStatusVO(String code, String stationCode, VirtualRealityScreenDoor upPsd, VirtualRealityScreenDoor downPsd) {
super(code, IscsStatusVO.DeviceType.SLIDING_DOOR, stationCode);
if (upPsd != null)
upStatus = new DirectionalStatus(upPsd);
if (downPsd != null)
downStatus = new DirectionalStatus(downPsd);
}
public boolean compareAndChange(VirtualRealityScreenDoor upPsd, VirtualRealityScreenDoor downPsd) {
boolean change = false;
if (upPsd != null)
change = change || upStatus.compareAndChange(upPsd);
if (downPsd != null)
change = change || downStatus.compareAndChange(downPsd);
return change;
}
public enum Status {
OPEN,
CLOSE,
@ -28,13 +46,25 @@ public class IscsPsdStatusVO extends IscsStatusVO{
public static class DirectionalStatus {
private Status status = Status.CLOSE;
private boolean isolationMode = true;
/**
* 隔离模式
*/
private boolean isolationMode = false;
public DirectionalStatus(VirtualRealityScreenDoor vrPsd) {
status = getStatus(vrPsd);
}
public DirectionalStatus(Status status, boolean isolationMode) {
this.status = status;
this.isolationMode = isolationMode;
}
public boolean compareAndChange(VirtualRealityScreenDoor vrPsd) {
Status status = getStatus(vrPsd);
return compareAndChange(status, false);
}
public boolean compareAndChange(Status status, boolean isolationMode) {
boolean change = false;
if (this.status != status) {
@ -47,5 +77,9 @@ public class IscsPsdStatusVO extends IscsStatusVO{
}
return change;
}
private Status getStatus(VirtualRealityScreenDoor vrPsd) {
return vrPsd.isLockAndClose() ? Status.CLOSE : Status.OPEN;
}
}
}

View File

@ -1,5 +1,6 @@
package club.joylink.rtss.simulation.cbtc.data.vo.iscs;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -16,6 +17,23 @@ public class IscsPslStatusVO extends IscsStatusVO{
this.downStatus = downStatus;
}
public IscsPslStatusVO(String code, String stationCode, VirtualRealityPsl upPsl, VirtualRealityPsl downPsl) {
super(code, DeviceType.PSL, stationCode);
if (upPsl != null)
upStatus = new DirectionalStatus(upPsl);
if (downPsl != null)
downStatus = new DirectionalStatus(downPsl);
}
public boolean compareAndChange(VirtualRealityPsl upPsl, VirtualRealityPsl downPsl) {
boolean change = false;
if (upPsl != null)
change = change || upStatus.compareAndChange(upPsl);
if (downPsl != null)
change = change || downStatus.compareAndChange(downPsl);
return change;
}
@Getter
@NoArgsConstructor
public static class DirectionalStatus {
@ -39,6 +57,17 @@ public class IscsPslStatusVO extends IscsStatusVO{
this.interlockRelease = interlockRelease;
}
public DirectionalStatus(VirtualRealityPsl vrPsl) {
this.operate = vrPsl.isPslczLight();
this.openCommand = vrPsl.isKmButton();
this.closeCommand = vrPsl.isGmButton();
this.interlockRelease = vrPsl.isHsjcLight();
}
public boolean compareAndChange(VirtualRealityPsl vrPsl) {
return compareAndChange(vrPsl.isPslczLight(), vrPsl.isKmButton(), vrPsl.isGmButton(), vrPsl.isHsjcLight());
}
public boolean compareAndChange(boolean operate, boolean openCommand, boolean closeCommand, boolean interlockRelease) {
boolean change = false;
if (this.operate != operate) {

View File

@ -27,5 +27,6 @@ public class IscsStatusVO extends Watchable {
/** 广播 */
AUDIO,
VR_AUDIO,
GATE,
}
}

View File

@ -0,0 +1,19 @@
package club.joylink.rtss.simulation.cbtc.data.vr;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class VirtualRealityGate extends VirtualRealityDevice{
private boolean fault;
public VirtualRealityGate(String code, String name) {
super(code, name, DeviceType.GATE);
}
@Override
public void reset() {
fault = false;
}
}

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.hhcj;
import club.joylink.rtss.services.IVirtualRealityIbpService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityIbp;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
@ -496,6 +497,8 @@ public class HhcjIbpServiceImpl implements RealDeviceService {
} else if (r_xfsb_tzxfb2){
config.setXfsb_yxxfb2(false);
}
Station station = vrIbp.getStation();
station.getVrGate().setFault(r_zj_jjsf);
boolean w_zdft_l101 = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_zdft_l101());
boolean w_zdft_l102 = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_zdft_l102());

View File

@ -154,7 +154,7 @@ public class ZjdIbpServiceImpl implements RealDeviceService {
iscsStatus = new IscsIbpStatusVO(iscsCode,
vrIbp.getStation().getCode(), null, downStatus);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {

View File

@ -67,7 +67,7 @@ public class ZjdPsdServiceImpl implements RealDeviceService {
IscsPsdStatusVO.DirectionalStatus downStatus = new IscsPsdStatusVO.DirectionalStatus(status, r_sx_glms);
iscsStatus = new IscsPsdStatusVO(iscsCode, configVO.getStationCode(), null, downStatus);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {

View File

@ -59,7 +59,7 @@ public class ZjdPslServiceImpl implements RealDeviceService {
iscsStatus = new IscsPslStatusVO(iscsCode,
vrPsl.getStand().getStation().getCode(), null, downStatus);
iscsRepository.addStatus(iscsStatus);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.Name, IscsStatusPublisher.class);
IscsStatusPublisher watcher = simulation.getMessagePublisher(IscsStatusPublisher.NAME, IscsStatusPublisher.class);
simulation.watch(iscsStatus, watcher);
change = true;
} else {

View File

@ -11,17 +11,19 @@ import java.util.*;
import java.util.stream.Collectors;
public class IscsStatusPublisher extends SimulationTriggerMessagePublisher {
public static final String Name = "iscs";
public static final String NAME = "iscs";
public static final String PSD_PATH = "psd";
public static final String PSD_PATTERN = String.format("%s/%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", PSD_PATH, "{stationCode}");
public static final String PA_PATH = "pa";
public static final String PA_PATTERN = String.format("%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", PA_PATH);
public static final String PIS_PATH = "pis";
public static final String PIS_PATTERN = String.format("%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", PIS_PATH);
public static final String GATE_PATH = "gate";
public static final String GATE_PATTERN = String.format("%s/%s/%s/%s", Simulation.MESSAGE_SUB_PREFIX, "iscs", GATE_PATH, "{stationCode}");
club.joylink.rtss.simulation.cbtc.Simulation simulation;
public IscsStatusPublisher(club.joylink.rtss.simulation.cbtc.Simulation simulation) {
super(Name, Arrays.asList(PSD_PATTERN, PA_PATTERN, PIS_PATTERN));
super(NAME, Arrays.asList(PSD_PATTERN, PA_PATTERN, PIS_PATTERN, GATE_PATTERN));
this.simulation = simulation;
}
@ -36,10 +38,19 @@ public class IscsStatusPublisher extends SimulationTriggerMessagePublisher {
result = buildPaMessage();
} else if (destination.contains(PIS_PATH)) {
result = buildPisMessage();
} else if (destination.contains(GATE_PATH)) {
String s = list.get(1);
result = buildGateMessage(s);
}
return result;
}
private Object buildGateMessage(String stationCode) {
SimulationIscsDataRepository iscsRepository = simulation.getIscsRepository();
List<IscsStatusVO> collect = iscsRepository.getStatusStream(IscsStatusVO.DeviceType.GATE, stationCode).collect(Collectors.toList());
return collect;
}
private Object buildPaMessage() {
List<IscsStatusVO> audioStatus = simulation.getIscsRepository().getStatusByDeviceType(IscsStatusVO.DeviceType.AUDIO);
audioStatus = audioStatus.stream()
@ -75,7 +86,6 @@ public class IscsStatusPublisher extends SimulationTriggerMessagePublisher {
collect.add(new IscsIbpStatusVO("", stationCode, new IscsIbpStatusVO.DirectionalStatus(),
new IscsIbpStatusVO.DirectionalStatus()));
}
iscsRepository.addStatus(collect);
return collect;
}