[修改]成都工业职业技术学院项目设备联动逻辑

This commit is contained in:
thesai 2024-04-17 10:42:05 +08:00
parent aae729b637
commit 5d15ba3240
17 changed files with 1189 additions and 893 deletions

View File

@ -70,6 +70,8 @@ public class WebConfig implements WebMvcConfigurer {
whiteList.add("/api/v2/paper/composition/oldData/handle"); whiteList.add("/api/v2/paper/composition/oldData/handle");
whiteList.add("/api/user/sync"); whiteList.add("/api/user/sync");
whiteList.add("/dataHandle"); whiteList.add("/dataHandle");
//modbus测试
whiteList.add("/api/test/modbus/writeCoil");
registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList); registry.addInterceptor(authenticateInterceptor).excludePathPatterns(whiteList);
} }

View File

@ -34,6 +34,8 @@ import club.joylink.rtss.vo.client.project.UDPClientConfigVO;
import club.joylink.rtss.vo.client.project.UDPLowConfigVO; import club.joylink.rtss.vo.client.project.UDPLowConfigVO;
import club.joylink.rtss.vo.client.project.VrIbpConfigVO; import club.joylink.rtss.vo.client.project.VrIbpConfigVO;
import club.joylink.rtss.vo.client.project.VrpsdConfigVO; import club.joylink.rtss.vo.client.project.VrpsdConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgySectionConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgySignalConfigVO; import club.joylink.rtss.vo.client.project.cgy.CgySignalConfigVO;
import club.joylink.rtss.vo.client.project.cgy.CgySwitchConfigVO; import club.joylink.rtss.vo.client.project.cgy.CgySwitchConfigVO;
import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO; import club.joylink.rtss.vo.client.project.gzb.GzbSignalConfigVO;
@ -579,7 +581,7 @@ public class DeviceServiceImpl implements DeviceService {
plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name()); plcGateway.setType(ProjectDeviceType.PLC_GATEWAY.name());
plcGateway.setCreator(accountVO.getId()); plcGateway.setCreator(accountVO.getId());
plcGateway.setCreateTime(now); plcGateway.setCreateTime(now);
PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 16); PlcGatewayConfigVO plcGatewayConfigVO = new PlcGatewayConfigVO(0, 64);
plcGateway.setConfig(plcGatewayConfigVO.toJson()); plcGateway.setConfig(plcGatewayConfigVO.toJson());
list.add(plcGateway); list.add(plcGateway);
//SIGNAL //SIGNAL
@ -589,7 +591,7 @@ public class DeviceServiceImpl implements DeviceService {
signal1.setType(ProjectDeviceType.SIGNAL.name()); signal1.setType(ProjectDeviceType.SIGNAL.name());
signal1.setCreator(accountVO.getId()); signal1.setCreator(accountVO.getId());
signal1.setCreateTime(now); signal1.setCreateTime(now);
signal1.setConfig(new CgySignalConfigVO(null, 2, 3, 4, 11, 12, 13).toJson()); signal1.setConfig(new CgySignalConfigVO("S13289", 0, 1, 2, 3, 4, 5, 16, 17, 18, 19).toJson());
list.add(signal1); list.add(signal1);
ProjectDevice signal2 = new ProjectDevice(); ProjectDevice signal2 = new ProjectDevice();
signal2.setProjectCode(projectCode); signal2.setProjectCode(projectCode);
@ -597,7 +599,7 @@ public class DeviceServiceImpl implements DeviceService {
signal2.setType(ProjectDeviceType.SIGNAL.name()); signal2.setType(ProjectDeviceType.SIGNAL.name());
signal2.setCreator(accountVO.getId()); signal2.setCreator(accountVO.getId());
signal2.setCreateTime(now); signal2.setCreateTime(now);
signal2.setConfig(new CgySignalConfigVO(null, 5, 6, 7, 14, 15, 16).toJson()); signal2.setConfig(new CgySignalConfigVO("X44854", 6, 7, 8, 9, 10, 11, 20, 21, 22, 23).toJson());
list.add(signal2); list.add(signal2);
//SWITCH //SWITCH
ProjectDevice aSwitch = new ProjectDevice(); ProjectDevice aSwitch = new ProjectDevice();
@ -606,17 +608,50 @@ public class DeviceServiceImpl implements DeviceService {
aSwitch.setType(ProjectDeviceType.SWITCH.name()); aSwitch.setType(ProjectDeviceType.SWITCH.name());
aSwitch.setCreator(accountVO.getId()); aSwitch.setCreator(accountVO.getId());
aSwitch.setCreateTime(now); aSwitch.setCreateTime(now);
aSwitch.setConfig(new CgySwitchConfigVO().toJson()); aSwitch.setConfig(new CgySwitchConfigVO("W37779").toJson());
list.add(aSwitch); list.add(aSwitch);
// //SECTION //PSL
// ProjectDevice section = new ProjectDevice(); ProjectDevice psl = new ProjectDevice();
// section.setProjectCode(projectCode); psl.setProjectCode(projectCode);
// section.setCode(prefix + "section"); psl.setCode(prefix + "psl");
// section.setType(ProjectDeviceType.SECTION.name()); psl.setType(ProjectDeviceType.PSL.name());
// section.setCreator(accountVO.getId()); psl.setCreator(accountVO.getId());
// section.setCreateTime(now); psl.setCreateTime(now);
// section.setConfig(new CgySectionConfigVO().toJson()); psl.setConfig(new CgyPslConfigVO("PF59020_PSL").toJson());
// list.add(section); list.add(psl);
//SECTION
ProjectDevice section106 = new ProjectDevice();
section106.setProjectCode(projectCode);
section106.setCode(prefix + "section106");
section106.setType(ProjectDeviceType.SECTION.name());
section106.setCreator(accountVO.getId());
section106.setCreateTime(now);
section106.setConfig(new CgySectionConfigVO(null, 35).toJson());
list.add(section106);
ProjectDevice section104 = new ProjectDevice();
section104.setProjectCode(projectCode);
section104.setCode(prefix + "section104");
section104.setType(ProjectDeviceType.SECTION.name());
section104.setCreator(accountVO.getId());
section104.setCreateTime(now);
section104.setConfig(new CgySectionConfigVO(null, 36).toJson());
list.add(section104);
ProjectDevice section101 = new ProjectDevice();
section101.setProjectCode(projectCode);
section101.setCode(prefix + "section101");
section101.setType(ProjectDeviceType.SECTION.name());
section101.setCreator(accountVO.getId());
section101.setCreateTime(now);
section101.setConfig(new CgySectionConfigVO(null, 37).toJson());
list.add(section101);
ProjectDevice section102 = new ProjectDevice();
section102.setProjectCode(projectCode);
section102.setCode(prefix + "section102");
section102.setType(ProjectDeviceType.SECTION.name());
section102.setCreator(accountVO.getId());
section102.setCreateTime(now);
section102.setConfig(new CgySectionConfigVO(null, 38).toJson());
list.add(section102);
return list; return list;
} }

View File

@ -12,152 +12,166 @@ import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent; import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent;
import club.joylink.rtss.vo.client.psl.PslStatus; import club.joylink.rtss.vo.client.psl.PslStatus;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.HashMap;
import java.util.Map;
@Service @Service
public class VirtualRealityPslService implements IVirtualRealityPslService { public class VirtualRealityPslService implements IVirtualRealityPslService {
@Autowired @Autowired
private GroupSimulationService groupSimulationService; private GroupSimulationService groupSimulationService;
@Autowired @Autowired
private ApplicationContext applicationContext; private ApplicationContext applicationContext;
@Autowired @Autowired
private CiApiService ciApiService; private CiApiService ciApiService;
@Override @Override
public PslStatus getStatus(String group, String standCode) { public PslStatus getStatus(String group, String standCode) {
Simulation simulation = groupSimulationService.getSimulationByGroup(group); Simulation simulation = groupSimulationService.getSimulationByGroup(group);
SimulationDataRepository repository = simulation.getRepository(); SimulationDataRepository repository = simulation.getRepository();
Map<String, PslStatus> pslStatusMap = repository.getPslStatusMap(); Map<String, PslStatus> pslStatusMap = repository.getPslStatusMap();
PslStatus status = pslStatusMap.get(standCode); PslStatus status = pslStatusMap.get(standCode);
if (status != null) { if (status != null) {
return status; return status;
}
Stand stand = repository.getByCode(standCode, Stand.class);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(stand.getPsd(),
String.format("%s没有屏蔽门", stand.debugStr()));
VirtualRealityPsl vrPsl = collectStatus(stand);
status = new PslStatus(vrPsl);
pslStatusMap.put(standCode, status);
return status;
}
@Override
public void pressTheButton(Simulation simulation, String standCode,
VirtualRealityPsl.Button button) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
VirtualRealityPsl vrPsl = collectStatus(stand);
theButtonIsPressed(simulation, vrPsl, button);
}
private void theButtonIsPressed(Simulation simulation, VirtualRealityPsl vrPsl,
VirtualRealityPsl.Button button) {
Stand stand = vrPsl.getStand();
switch (button) {
case YXJZ:
vrPsl.setYxjzKey(!vrPsl.isYxjzKey());
break;
case HSJC:
vrPsl.setHsjcKey(!vrPsl.isHsjcKey());
ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey());
break;
case KM:
ciApiService.openScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
break;
case GM:
ciApiService.closeScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
break;
case SD:
vrPsl.setSdButton(!vrPsl.isSdButton());
break;
}
}
@Override
public void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl,
VirtualRealityPsl.Button button, boolean on) {
switch (button) {
case YXJZ:
vrPsl.setYxjzKey(on);
break;
case HSJC:
vrPsl.setHsjcKey(on);
break;
case KM:
vrPsl.setKmButton(on);
break;
case GM:
vrPsl.setGmButton(on);
break;
case SD:
vrPsl.setSdButton(on);
break;
}
effective(simulation, vrPsl.getStand(), button, on);
}
private void effective(Simulation simulation, Stand stand, VirtualRealityPsl.Button button,
boolean on) {
switch (button) {
case YXJZ:
break;
case HSJC:
ciApiService.setOrCancelInterlockRelease(simulation, stand, on);
break;
case KM:
if (on) {
ciApiService.openScreenDoor(simulation, stand.getCode(),
CiStandService.PsdCommandSource.PSL);
} }
Stand stand = repository.getByCode(standCode, Stand.class); break;
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(stand.getPsd(), case GM:
String.format("%s没有屏蔽门", stand.debugStr())); if (on) {
VirtualRealityPsl vrPsl = collectStatus(stand); ciApiService.closeScreenDoor(simulation, stand.getCode(),
status = new PslStatus(vrPsl); CiStandService.PsdCommandSource.PSL);
pslStatusMap.put(standCode, status);
return status;
}
@Override
public void pressTheButton(Simulation simulation, String standCode, VirtualRealityPsl.Button button) {
Stand stand = simulation.getRepository().getByCode(standCode, Stand.class);
VirtualRealityPsl vrPsl = collectStatus(stand);
theButtonIsPressed(simulation, vrPsl, button);
}
private void theButtonIsPressed(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button) {
Stand stand = vrPsl.getStand();
switch (button) {
case YXJZ:
vrPsl.setYxjzKey(!vrPsl.isYxjzKey());
break;
case HSJC:
vrPsl.setHsjcKey(!vrPsl.isHsjcKey());
ciApiService.setOrCancelInterlockRelease(simulation, stand, vrPsl.isHsjcKey());
break;
case KM:
ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case GM:
ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case SD:
vrPsl.setSdButton(!vrPsl.isSdButton());
break;
} }
break;
case SD:
break;
} }
}
@Override @Override
public void updateStatus(Simulation simulation, VirtualRealityPsl vrPsl, VirtualRealityPsl.Button button, boolean on) { public void addJobs(Simulation simulation) {
switch (button) { simulation.addJobIfAbsent(Simulation.JobName.pslStatus,
case YXJZ: () -> this.collectAndDispatcher(simulation), SimulationConstants.PSL_STATUS_COLLECT_RATE);
vrPsl.setYxjzKey(on); }
break;
case HSJC: public void collectAndDispatcher(Simulation simulation) {
vrPsl.setHsjcKey(on); SimulationDataRepository repository = simulation.getRepository();
break; Map<String, PslStatus> ibpStatusMap = repository.getPslStatusMap();
case KM: Map<String, PslStatus> collectionMap = new HashMap<>();
case GM: for (Stand stand : repository.getStandList()) {
break; if (stand.getVrPsl() == null) {
case SD: continue;
vrPsl.setSdButton(on); }
break; VirtualRealityPsl vrPsl = this.collectStatus(stand);
PslStatus pslStatus = ibpStatusMap.get(stand.getCode());
if (pslStatus == null) {
PslStatus newStatus = new PslStatus(vrPsl);
ibpStatusMap.put(stand.getCode(), newStatus);
collectionMap.put(stand.getCode(), newStatus);
} else {
PslStatus difference = pslStatus.collectDifference(vrPsl);
if (difference != null) {
collectionMap.put(stand.getCode(), difference);
} }
effective(simulation, vrPsl.getStand(), button, on); }
} }
if (!CollectionUtils.isEmpty(collectionMap)) {
applicationContext.publishEvent(
new SimulationPslStatusEvent(this, simulation, collectionMap));
}
}
private void effective(Simulation simulation, Stand stand, VirtualRealityPsl.Button button, boolean on) { private VirtualRealityPsl collectStatus(Stand stand) {
switch (button) { VirtualRealityPsl vrPsl = stand.getVrPsl();
case YXJZ: PSD psd = stand.getPsd();
break; vrPsl.setQbgmLight(vrPsl.isSdButton() || psd.isCloseAndLock());
case HSJC: vrPsl.setPslczLight(vrPsl.isSdButton() || vrPsl.isYxjzKey());
ciApiService.setOrCancelInterlockRelease(simulation, stand, on); vrPsl.setHsjcLight(vrPsl.isSdButton() || vrPsl.isHsjcKey());
break; vrPsl.setKmLight(vrPsl.isSdButton() || !psd.isClose());
case KM: vrPsl.setGmLight(vrPsl.isSdButton() || psd.isClose());
if (on) return vrPsl;
ciApiService.openScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL); }
break;
case GM:
if (on)
ciApiService.closeScreenDoor(simulation, stand.getCode(), CiStandService.PsdCommandSource.PSL);
break;
case SD:
break;
}
}
@Override
public void addJobs(Simulation simulation) {
simulation.addJobIfAbsent(Simulation.JobName.pslStatus,
() -> this.collectAndDispatcher(simulation), SimulationConstants.PSL_STATUS_COLLECT_RATE);
}
public void collectAndDispatcher(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository();
Map<String, PslStatus> ibpStatusMap = repository.getPslStatusMap();
Map<String, PslStatus> collectionMap = new HashMap<>();
for (Stand stand : repository.getStandList()) {
if (stand.getVrPsl() == null)
continue;
VirtualRealityPsl vrPsl = this.collectStatus(stand);
PslStatus pslStatus = ibpStatusMap.get(stand.getCode());
if (pslStatus == null) {
PslStatus newStatus = new PslStatus(vrPsl);
ibpStatusMap.put(stand.getCode(), newStatus);
collectionMap.put(stand.getCode(), newStatus);
} else {
PslStatus difference = pslStatus.collectDifference(vrPsl);
if (difference != null) {
collectionMap.put(stand.getCode(), difference);
}
}
}
if (!CollectionUtils.isEmpty(collectionMap)) {
applicationContext.publishEvent(new SimulationPslStatusEvent(this, simulation, collectionMap));
}
}
private VirtualRealityPsl collectStatus(Stand stand) {
VirtualRealityPsl vrPsl = stand.getVrPsl();
PSD psd = stand.getPsd();
vrPsl.setQbgmLight(vrPsl.isSdButton() || psd.isCloseAndLock());
vrPsl.setPslczLight(vrPsl.isSdButton() || vrPsl.isYxjzKey());
vrPsl.setHsjcLight(vrPsl.isSdButton() || vrPsl.isHsjcKey());
vrPsl.setKmLight(vrPsl.isSdButton() || !psd.isClose());
vrPsl.setGmLight(vrPsl.isSdButton() || psd.isClose());
return vrPsl;
}
} }

View File

@ -6,192 +6,204 @@ import club.joylink.rtss.simulation.cbtc.data.map.Switch;
import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement; import club.joylink.rtss.simulation.cbtc.data.map.SwitchElement;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService; import club.joylink.rtss.simulation.cbtc.device.virtual.VirtualRealityDeviceService;
import java.util.List;
import java.util.Objects;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Objects;
@Component @Component
public class CiSwitchControlService { public class CiSwitchControlService {
@Autowired
private VirtualRealityDeviceService virtualRealityDeviceService;
/** @Autowired
* 道岔单锁 private VirtualRealityDeviceService virtualRealityDeviceService;
*
* @param aSwitch /**
*/ * 道岔单锁
public void singleLock(Switch aSwitch) { *
if (!aSwitch.isSingleLock()) { * @param aSwitch
aSwitch.setSingleLock(true); */
} public void singleLock(Switch aSwitch) {
if (!aSwitch.isSingleLock()) {
aSwitch.setSingleLock(true);
} }
}
/** /**
* 道岔单解 * 道岔单解
* *
* @param aSwitch * @param aSwitch
*/ */
public void singleUnlock(Switch aSwitch) { public void singleUnlock(Switch aSwitch) {
if (aSwitch.isSingleLock()) { if (aSwitch.isSingleLock()) {
aSwitch.setSingleLock(false); aSwitch.setSingleLock(false);
}
} }
}
/** /**
* 封锁(封锁后包含道岔的进路不能排列) * 封锁(封锁后包含道岔的进路不能排列)
* *
* @param aSwitch * @param aSwitch
*/ */
public void blockade(Switch aSwitch) { public void blockade(Switch aSwitch) {
if (!aSwitch.isBlockade()) { if (!aSwitch.isBlockade()) {
aSwitch.setBlockade(true); aSwitch.setBlockade(true);
aSwitch.getA().setBlockade(true); aSwitch.getA().setBlockade(true);
aSwitch.getB().setBlockade(true); aSwitch.getB().setBlockade(true);
aSwitch.getC().setBlockade(true); aSwitch.getC().setBlockade(true);
}
aSwitch.setInit(false);
} }
aSwitch.setInit(false);
}
/** /**
* 解封 * 解封
* *
* @param aSwitch * @param aSwitch
*/ */
public void unblock(Switch aSwitch) { public void unblock(Switch aSwitch) {
if (aSwitch.isBlockade()) { if (aSwitch.isBlockade()) {
aSwitch.setBlockade(false); aSwitch.setBlockade(false);
aSwitch.getA().setBlockade(false); aSwitch.getA().setBlockade(false);
aSwitch.getB().setBlockade(false); aSwitch.getB().setBlockade(false);
aSwitch.getC().setBlockade(false); aSwitch.getC().setBlockade(false);
}
} }
}
/** /**
* 强转道岔 * 强转道岔
* *
* @param simulation * @param simulation
* @param aSwitch * @param aSwitch
* @return * @return
*/ */
public SwitchIndication forceTurn(Simulation simulation, Switch aSwitch) { public SwitchIndication forceTurn(Simulation simulation, Switch aSwitch) {
if (!aSwitch.isSectionOccupied()) { if (!aSwitch.isSectionOccupied()) {
return null; return null;
}
if (aSwitch.isLocked()) {
return null;
}
// 设置强扳授权
aSwitch.setForceTurnRemain(120 * 1000);
SwitchIndication pos = this.turn(simulation, aSwitch);
// 手动释放强扳
aSwitch.setForceTurnRemain(0);
return pos;
} }
if (aSwitch.isLocked()) {
return null;
}
// 设置强扳授权
aSwitch.setForceTurnRemain(120 * 1000);
SwitchIndication pos = this.turn(simulation, aSwitch);
// 手动释放强扳
aSwitch.setForceTurnRemain(0);
return pos;
}
/** /**
* 道岔转动 * 道岔转动
* *
* @param simulation * @param simulation
* @param aSwitch * @param aSwitch
* @return * @return
*/ */
public SwitchIndication turn(Simulation simulation, Switch aSwitch) { public SwitchIndication turn(Simulation simulation, Switch aSwitch) {
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch(); VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
boolean lastTurnToN = vrSwitch.isLastTurnToN(); boolean lastTurnToN; //最后转向的方向主要是为了解决失表的情况下每次转动道岔要向不同方向转动
if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) { if (vrSwitch.isPosN()) {
Switch linkedSwitch = aSwitch.queryLinkedSwitch(); lastTurnToN = true;
if (Objects.nonNull(linkedSwitch)) { } else if (vrSwitch.isPosR()) {
if (lastTurnToN) { lastTurnToN = false;
this.turn2ReversePosition(simulation, linkedSwitch); } else {
} else { lastTurnToN = vrSwitch.isLastTurnToN();
this.turn2NormalPosition(simulation, linkedSwitch); }
} if (simulation.getRepository().getConfig().isSwitchNRTurnChain()) {
} Switch linkedSwitch = aSwitch.queryLinkedSwitch();
} if (Objects.nonNull(linkedSwitch)) {
if (lastTurnToN) { if (lastTurnToN) {
if (this.turn2ReversePosition(simulation, aSwitch)) { this.turn2ReversePosition(simulation, linkedSwitch);
return SwitchIndication.R;
}
} else { } else {
if (this.turn2NormalPosition(simulation, aSwitch)) { this.turn2NormalPosition(simulation, linkedSwitch);
return SwitchIndication.N;
}
} }
return null; }
} }
if (lastTurnToN) {
if (this.turn2ReversePosition(simulation, aSwitch)) {
return SwitchIndication.R;
}
} else {
if (this.turn2NormalPosition(simulation, aSwitch)) {
return SwitchIndication.N;
}
}
return null;
}
/** /**
* 道岔定操 * 道岔定操
* *
* @param simulation * @param simulation
* @param aSwitch * @param aSwitch
*/ */
public boolean turn2NormalPosition(Simulation simulation, Switch aSwitch) { public boolean turn2NormalPosition(Simulation simulation, Switch aSwitch) {
if (!this.checkTurnCondition(aSwitch)) { if (!this.checkTurnCondition(aSwitch)) {
return false; return false;
}
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
this.virtualRealityDeviceService.control(simulation, vrSwitch, VirtualRealitySwitch.Operation.NP);
return true;
} }
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
this.virtualRealityDeviceService.control(simulation, vrSwitch,
VirtualRealitySwitch.Operation.NP);
return true;
}
/** /**
* 道岔反操 * 道岔反操
* *
* @param simulation * @param simulation
* @param aSwitch * @param aSwitch
* @return * @return
*/ */
public boolean turn2ReversePosition(Simulation simulation, Switch aSwitch) { public boolean turn2ReversePosition(Simulation simulation, Switch aSwitch) {
if (!this.checkTurnCondition(aSwitch)) { if (!this.checkTurnCondition(aSwitch)) {
return false; return false;
}
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
this.virtualRealityDeviceService.control(simulation, vrSwitch, VirtualRealitySwitch.Operation.RP);
return true;
} }
VirtualRealitySwitch vrSwitch = aSwitch.getVirtualSwitch();
this.virtualRealityDeviceService.control(simulation, vrSwitch,
VirtualRealitySwitch.Operation.RP);
return true;
}
/** /**
* 检查道岔转动条件 * 检查道岔转动条件
* *
* @param aSwitch * @param aSwitch
* @return * @return
*/ */
private boolean checkTurnCondition(Switch aSwitch) { private boolean checkTurnCondition(Switch aSwitch) {
// 道岔锁闭 或者 道岔占用且无强扳授权则不能转动 // 道岔锁闭 或者 道岔占用且无强扳授权则不能转动
return !(aSwitch.isLocked() || (aSwitch.isSectionOccupied() && aSwitch.getForceTurnRemain() <= 0)); return !(aSwitch.isLocked() || (aSwitch.isSectionOccupied()
} && aSwitch.getForceTurnRemain() <= 0));
}
/** /**
* 确保道岔位置正确 * 确保道岔位置正确
*/ */
public boolean ensureSwitchPosCurrent(Simulation simulation, List<SwitchElement> switchElements, boolean guideSetting) { public boolean ensureSwitchPosCurrent(Simulation simulation, List<SwitchElement> switchElements,
boolean allOn = true; boolean guideSetting) {
if (switchElements == null) { boolean allOn = true;
return true; if (switchElements == null) {
} return true;
for (SwitchElement switchElement : switchElements) {
boolean onPos = this.turnRouteSwitch(simulation, switchElement);
if (!onPos && !(guideSetting && switchElement.getASwitch().isLoss() && switchElement.getASwitch().isGuideMasterLock())) { //不在正确位置并且不是办理引导进路中的引导总锁的失表道岔
allOn = false;
}
}
return allOn;
} }
for (SwitchElement switchElement : switchElements) {
boolean onPos = this.turnRouteSwitch(simulation, switchElement);
if (!onPos && !(guideSetting && switchElement.getASwitch().isLoss()
&& switchElement.getASwitch().isGuideMasterLock())) { //不在正确位置并且不是办理引导进路中的引导总锁的失表道岔
allOn = false;
}
}
return allOn;
}
public boolean turnRouteSwitch(Simulation simulation, SwitchElement switchElement) { public boolean turnRouteSwitch(Simulation simulation, SwitchElement switchElement) {
boolean onPos = true; boolean onPos = true;
if (!switchElement.isOnPosition()) { if (!switchElement.isOnPosition()) {
onPos = false; onPos = false;
if (switchElement.isNormal()) { if (switchElement.isNormal()) {
this.turn2NormalPosition(simulation, switchElement.getASwitch()); this.turn2NormalPosition(simulation, switchElement.getASwitch());
} else { } else {
this.turn2ReversePosition(simulation, switchElement.getASwitch()); this.turn2ReversePosition(simulation, switchElement.getASwitch());
} }
}
return onPos;
} }
return onPos;
}
} }

View File

@ -189,8 +189,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
Simulation.FunctionalType functionalType) { Simulation.FunctionalType functionalType) {
Objects.requireNonNull(mapId, "地图id不能为空"); Objects.requireNonNull(mapId, "地图id不能为空");
Objects.requireNonNull(functionalType, "仿真功能类型不能为空"); Objects.requireNonNull(functionalType, "仿真功能类型不能为空");
SimulationBuildParams params = this.prepareSimulationParams(loginUserInfoVO, mapId, SimulationBuildParams params = this.prepareSimulationParams(loginUserInfoVO, mapId, prdType,
prdType, functionalType); functionalType);
String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(),
mapId); mapId);
Simulation simulation = this.simulationLifeCycleService.create(params, group); Simulation simulation = this.simulationLifeCycleService.create(params, group);
@ -212,17 +212,13 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
List<RunPlanParkingTimeVO> parkTimeList = this.prepareParkTimeData(mapVO, loginUserInfoVO, List<RunPlanParkingTimeVO> parkTimeList = this.prepareParkTimeData(mapVO, loginUserInfoVO,
mapId); mapId);
// 获取操作定义数据 // 获取操作定义数据
List<CommandDefinitionVO> operationDefinitionList = this.iCommandService List<CommandDefinitionVO> operationDefinitionList = this.iCommandService.queryDefinitionsByLineCode(
.queryDefinitionsByLineCode(mapVO.getLineCode()); mapVO.getLineCode());
SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder(); SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder();
// 都有的属性构造 // 都有的属性构造
builder.loginUserInfo(loginUserInfoVO) builder.loginUserInfo(loginUserInfoVO).createTime(LocalDateTime.now()).map(mapVO)
.createTime(LocalDateTime.now()) .userRunLevelList(runLevelList).userParkTimeList(parkTimeList)
.map(mapVO) .operationDefinitionList(operationDefinitionList).prodType(prdType)
.userRunLevelList(runLevelList)
.userParkTimeList(parkTimeList)
.operationDefinitionList(operationDefinitionList)
.prodType(prdType)
.functionalType(functionalType); .functionalType(functionalType);
//运行图选择性构造 //运行图选择性构造
LocalDate runPlanDate = SimulationConstants.getRunPlanDate(); LocalDate runPlanDate = SimulationConstants.getRunPlanDate();
@ -236,9 +232,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId, schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId,
runPlanDate); runPlanDate);
} else { } else {
schedulingPlanNewVO = this.schedulingService schedulingPlanNewVO = this.schedulingService.querySchedulingPlanUserFirst(
.querySchedulingPlanUserFirst(loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), runPlanDate);
runPlanDate);
} }
builder.schedulingPlan(schedulingPlanNewVO); builder.schedulingPlan(schedulingPlanNewVO);
} }
@ -294,15 +289,12 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
// 获取地图数据 // 获取地图数据
MapVO mapVO = this.iMapService.getMapDetail(mapId); MapVO mapVO = this.iMapService.getMapDetail(mapId);
// 获取操作定义数据 // 获取操作定义数据
List<CommandDefinitionVO> operationDefinitionList = this.iCommandService List<CommandDefinitionVO> operationDefinitionList = this.iCommandService.queryDefinitionsByLineCode(
.queryDefinitionsByLineCode(mapVO.getLineCode()); mapVO.getLineCode());
SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder(); SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder();
// 都有的属性构造 // 都有的属性构造
builder.loginUserInfo(loginUserInfoVO) builder.loginUserInfo(loginUserInfoVO).createTime(LocalDateTime.now()).map(mapVO)
.createTime(LocalDateTime.now()) .operationDefinitionList(operationDefinitionList).prodType(prdType)
.map(mapVO)
.operationDefinitionList(operationDefinitionList)
.prodType(prdType)
.functionalType(functionalType); .functionalType(functionalType);
//运行图选择性构造 //运行图选择性构造
LocalDate runPlanDate = SimulationConstants.getRunPlanDate(); LocalDate runPlanDate = SimulationConstants.getRunPlanDate();
@ -314,9 +306,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId, schedulingPlanNewVO = this.schedulingService.queryCommonSchedulingPlanOfDay(mapId,
runPlanDate); runPlanDate);
} else { } else {
schedulingPlanNewVO = this.schedulingService schedulingPlanNewVO = this.schedulingService.querySchedulingPlanUserFirst(
.querySchedulingPlanUserFirst(loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), loginUserInfoVO.getAccountVO().getId(), runPlanVO.getId(), runPlanDate);
runPlanDate);
} }
builder.schedulingPlan(schedulingPlanNewVO); builder.schedulingPlan(schedulingPlanNewVO);
} }
@ -368,8 +359,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
confirmHasPermission(loginUserInfoVO.getAccountVO(), mapId, prodCode); confirmHasPermission(loginUserInfoVO.getAccountVO(), mapId, prodCode);
MapPrdTypeEnum prdType = MapPrdTypeEnum.getMapPrdTypeEnumByCode(prodCode); MapPrdTypeEnum prdType = MapPrdTypeEnum.getMapPrdTypeEnumByCode(prodCode);
Simulation simulation = this.create(loginUserInfoVO, mapId, Simulation simulation = this.create(loginUserInfoVO, mapId, prdType,
prdType,
Simulation.FunctionalType.SIMULATION); Simulation.FunctionalType.SIMULATION);
if (Objects.equals(MapPrdTypeEnum.BIG_SCREEN, prdType)) { if (Objects.equals(MapPrdTypeEnum.BIG_SCREEN, prdType)) {
@ -573,8 +563,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group); Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
this.simulationLifeCycleService.checkErrorThrow(simulation); this.simulationLifeCycleService.checkErrorThrow(simulation);
List<TripPlan> tripPlanList = simulation.getRepository().getAllTripPlanList(); List<TripPlan> tripPlanList = simulation.getRepository().getAllTripPlanList();
List<String> tripNumberList = tripPlanList.stream() List<String> tripNumberList = tripPlanList.stream().map(TripPlan::getTripNumber)
.map(TripPlan::getTripNumber)
.collect(Collectors.toList()); .collect(Collectors.toList());
return tripNumberList; return tripNumberList;
} }
@ -652,8 +641,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
RunPlanVO runPlan = this.iRunPlanTemplateService.getRunPlan(templateId); RunPlanVO runPlan = this.iRunPlanTemplateService.getRunPlan(templateId);
// 重新加载运行计划匹配的派班计划 // 重新加载运行计划匹配的派班计划
Long userId = simulation.getBuildParams().getUser().getId(); Long userId = simulation.getBuildParams().getUser().getId();
SchedulingPlanNewVO schedulingPlan = this.schedulingService SchedulingPlanNewVO schedulingPlan = this.schedulingService.querySchedulingPlanUserFirst(userId,
.querySchedulingPlanUserFirst(userId, templateId, SimulationConstants.getRunPlanDate()); templateId, SimulationConstants.getRunPlanDate());
this.simulationLifeCycleService.reloadRunPlan(simulation, runPlan, schedulingPlan); this.simulationLifeCycleService.reloadRunPlan(simulation, runPlan, schedulingPlan);
simulation.getRepository().clearChangeTrips(); //清除掉之前的车次计划变化信息 simulation.getRepository().clearChangeTrips(); //清除掉之前的车次计划变化信息
} }
@ -673,8 +662,7 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
ScriptBO scriptBO = iScriptService.getScriptBOById(scriptId, simulation); ScriptBO scriptBO = iScriptService.getScriptBOById(scriptId, simulation);
iScriptSimulationService.scriptCoverSimulation(simulation, scriptBO); iScriptSimulationService.scriptCoverSimulation(simulation, scriptBO);
SocketMessageVO<Boolean> message = SocketMessageFactory.build( SocketMessageVO<Boolean> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Script_Loaded, WebSocketMessageType.Simulation_Script_Loaded, simulation.getId(), true);
simulation.getId(), true);
Set<String> userIds = simulation.getSimulationUserIds(); Set<String> userIds = simulation.getSimulationUserIds();
stompMessageService.sendToUser(userIds, message); stompMessageService.sendToUser(userIds, message);
} }
@ -851,11 +839,9 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
@Override @Override
public List<SimulationVO> queryJointSimulationByUser(LoginUserInfoVO loginUserInfoVO) { public List<SimulationVO> queryJointSimulationByUser(LoginUserInfoVO loginUserInfoVO) {
List<Simulation> jointSimulationList = this.groupSimulationCache.queryAllJointSimulation(); List<Simulation> jointSimulationList = this.groupSimulationCache.queryAllJointSimulation();
List<Simulation> userJointSimulationList = jointSimulationList.stream() List<Simulation> userJointSimulationList = jointSimulationList.stream().filter(
.filter(simulation -> simulation -> simulation.isSame(loginUserInfoVO.getProject()) && simulation.containsUser(
simulation.isSame(loginUserInfoVO.getProject()) && loginUserInfoVO.getAccountVO().getId())).collect(Collectors.toList());
simulation.containsUser(loginUserInfoVO.getAccountVO().getId()))
.collect(Collectors.toList());
List<SimulationVO> simulationVOList = SimulationVO.convert2VOList(userJointSimulationList); List<SimulationVO> simulationVOList = SimulationVO.convert2VOList(userJointSimulationList);
return simulationVOList; return simulationVOList;
@ -864,13 +850,11 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
@Override @Override
public void kickOut(String group, Long userId, AccountVO user) { public void kickOut(String group, Long userId, AccountVO user) {
Simulation simulation = this.getSimulationByGroup(group); Simulation simulation = this.getSimulationByGroup(group);
BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS BusinessExceptionAssertEnum.INSUFFICIENT_PERMISSIONS.assertTrue(simulation.isAdmin(user));
.assertTrue(simulation.isAdmin(user));
SimulationUser simulationUser = simulation.querySimulationUserById(userId); SimulationUser simulationUser = simulation.querySimulationUserById(userId);
if (Objects.nonNull(simulationUser)) { if (Objects.nonNull(simulationUser)) {
ProjectDeviceVO projectDevice = simulationUser.getProjectDevice(); ProjectDeviceVO projectDevice = simulationUser.getProjectDevice();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNull(projectDevice);
.assertNull(projectDevice);
this.kickOut(simulation, simulationUser); this.kickOut(simulation, simulationUser);
} }
} }
@ -903,12 +887,12 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
Simulation simulation = this.getSimulationByGroup(group); Simulation simulation = this.getSimulationByGroup(group);
List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList(); List<RealDeviceConfig> realDeviceList = simulation.getRealDeviceList();
if (!CollectionUtils.isEmpty(realDeviceList)) { if (!CollectionUtils.isEmpty(realDeviceList)) {
Set<ProjectDeviceType> displayDeviceTypes = Set<ProjectDeviceType> displayDeviceTypes = new HashSet<>(
new HashSet<>( List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL,
List.of(ProjectDeviceType.PSD, ProjectDeviceType.SWITCH, ProjectDeviceType.SIGNAL, ProjectDeviceType.PLC_GATEWAY, ProjectDeviceType.IBP, ProjectDeviceType.SECTION,
ProjectDeviceType.PLC_GATEWAY, ProjectDeviceType.IBP, ProjectDeviceType.SECTION)); ProjectDeviceType.PSL));
realDeviceList = realDeviceList realDeviceList = realDeviceList.stream()
.stream().filter(device -> displayDeviceTypes.contains(device.getDeviceType())) .filter(device -> displayDeviceTypes.contains(device.getDeviceType()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
// List<RealDevice> showList = null; // List<RealDevice> showList = null;
@ -953,8 +937,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
//校验目标成员类型 //校验目标成员类型
SimulationMember targetMember = simulation.getSimulationMemberById( SimulationMember targetMember = simulation.getSimulationMemberById(
initiateVO.getTargetMemberId()); initiateVO.getTargetMemberId());
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertEquals(targetMember.getType(),
.assertEquals(targetMember.getType(), commandType.getMemberType(), "目标成员不正确"); commandType.getMemberType(), "目标成员不正确");
ScriptBO script = simulation.getScript(); ScriptBO script = simulation.getScript();
if (script != null && script.isBgSet()) { //剧本背景已经保存 if (script != null && script.isBgSet()) { //剧本背景已经保存
@ -1008,15 +992,13 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
public void alarmConfirm(String group, List<String> codes, AccountVO accountVO) { public void alarmConfirm(String group, List<String> codes, AccountVO accountVO) {
Simulation simulation = groupSimulationCache.getSimulationByGroup(group); Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
simulation.getRepository().getAlarmList().stream() simulation.getRepository().getAlarmList().stream()
.filter(atsAlarm -> codes.contains(atsAlarm.getCode())) .filter(atsAlarm -> codes.contains(atsAlarm.getCode())).filter(atsAlarm -> {
.filter(atsAlarm -> {
if (atsAlarm.isConfirmed()) { if (atsAlarm.isConfirmed()) {
codes.remove(atsAlarm.getCode()); codes.remove(atsAlarm.getCode());
return false; return false;
} }
return true; return true;
}) }).forEach(atsAlarm -> atsAlarm.confirm(accountVO, simulation.getCorrectSystemTime()));
.forEach(atsAlarm -> atsAlarm.confirm(accountVO, simulation.getCorrectSystemTime()));
this.applicationContext.publishEvent(new SimulationAlarmConfirmEvent(this, simulation, codes)); this.applicationContext.publishEvent(new SimulationAlarmConfirmEvent(this, simulation, codes));
} }
@ -1057,20 +1039,15 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
int end = pageNum * queryVO.getPageSize(); int end = pageNum * queryVO.getPageSize();
start = Math.min(start, logs.size() - 1); start = Math.min(start, logs.size() - 1);
end = Math.min(end, logs.size()); end = Math.min(end, logs.size());
logs = logs.stream() logs = logs.stream().filter(log -> {
.filter(log -> { if (queryVO.getStartTime() != null && log.getTime().isBefore(queryVO.getStartTime())) {
if (queryVO.getStartTime() != null && log.getTime() return false;
.isBefore(queryVO.getStartTime())) { }
return false; if (queryVO.getEndTime() != null && log.getTime().isAfter(queryVO.getEndTime())) {
} return false;
if (queryVO.getEndTime() != null && log.getTime().isAfter(queryVO.getEndTime())) { }
return false; return true;
} }).skip(start).limit(end - start).collect(Collectors.toList());
return true;
})
.skip(start)
.limit(end - start)
.collect(Collectors.toList());
pageVO.setList(logs); pageVO.setList(logs);
} else { } else {
pageVO.setPageNum(1); pageVO.setPageNum(1);
@ -1173,23 +1150,21 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
Long mapId, String prdType) { Long mapId, String prdType) {
if (accountVO.isThirdChildAccount()) { if (accountVO.isThirdChildAccount()) {
List<LoginUserInfoVO> loginInfos = this.loginSessionManager.getAllLoginUserInfos(); List<LoginUserInfoVO> loginInfos = this.loginSessionManager.getAllLoginUserInfos();
Set<LoginUserInfoVO> thirdLoginList = loginInfos.stream() Set<LoginUserInfoVO> thirdLoginList = loginInfos.stream().filter(
.filter(loginUserInfoVO -> loginUserInfoVO.getAccountVO().isThirdChildAccount() loginUserInfoVO -> loginUserInfoVO.getAccountVO().isThirdChildAccount()
&& loginUserInfoVO.getAccountVO().getParentAccount() && loginUserInfoVO.getAccountVO().getParentAccount()
.equals(accountVO.getParentAccount())) .equals(accountVO.getParentAccount())).collect(Collectors.toSet());
.collect(Collectors.toSet());
Set<String> thirdLoginAccountIdList = thirdLoginList.stream() Set<String> thirdLoginAccountIdList = thirdLoginList.stream()
.map(loginUserInfoVO -> loginUserInfoVO.getAccountVO().getId().toString()) .map(loginUserInfoVO -> loginUserInfoVO.getAccountVO().getId().toString())
.collect(Collectors.toSet()); .collect(Collectors.toSet());
long count = this.simulationManager.getSimulationList().stream() long count = this.simulationManager.getSimulationList().stream()
.filter(simulation -> simulation instanceof Simulation) .filter(simulation -> simulation instanceof Simulation)
.map(simulation -> ((Simulation) simulation)) .map(simulation -> ((Simulation) simulation)).filter(simulation -> {
.filter(simulation -> {
if (simulation.getBuildParams().getMap().getId().equals(mapId)) { if (simulation.getBuildParams().getMap().getId().equals(mapId)) {
if (!((MapPrdTypeEnum.JOINT.getCode().equals(prdType) && if (!((MapPrdTypeEnum.JOINT.getCode().equals(prdType) && MapPrdTypeEnum.JOINT.equals(
MapPrdTypeEnum.JOINT.equals(simulation.getBuildParams().getProdType())) || simulation.getBuildParams().getProdType())) || (
(!MapPrdTypeEnum.JOINT.getCode().equals(prdType) && !MapPrdTypeEnum.JOINT.getCode().equals(prdType) && !MapPrdTypeEnum.JOINT.equals(
!MapPrdTypeEnum.JOINT.equals(simulation.getBuildParams().getProdType())))) { simulation.getBuildParams().getProdType())))) {
return false; return false;
} }
for (String accountId : simulation.getSimulationUserIds()) { for (String accountId : simulation.getSimulationUserIds()) {
@ -1199,11 +1174,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
} }
} }
return false; return false;
}) }).count();
.count(); int sum = ups.stream().mapToInt(userPermissionVO -> userPermissionVO.getRemains()).sum();
int sum = ups.stream()
.mapToInt(userPermissionVO -> userPermissionVO.getRemains())
.sum();
if (sum <= count) { if (sum <= count) {
return false; return false;
} else { } else {

View File

@ -9,79 +9,85 @@ import lombok.Setter;
*/ */
@Getter @Getter
@Setter @Setter
public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealityScreenDoor.Operation> { public class VirtualRealityScreenDoor extends
ControllableVrDevice<VirtualRealityScreenDoor.Operation> {
public boolean isCommandOpen() { public boolean isCommandOpen() {
return Operation.K.equals(this.getCommand()); return Operation.K.equals(this.getCommand());
} }
/** /**
* 道岔支持的操作 * 道岔支持的操作
*/ */
public enum Operation { public enum Operation {
/** 开门 */ /**
K, * 开门
/** 关门 */ */
G, K,
} /**
* 关门
/** */
* 是否关闭 G,
*/ }
private boolean close;
/**
/** * 是否关闭
* 是否开门到位 */
*/ private boolean close;
private boolean open2End;
/**
/** * 是否开门到位
* 是否锁闭 */
*/ private boolean open2End;
private boolean lock;
/**
/** * 是否锁闭
* psl盘互锁解除 */
*/ private boolean lock;
private boolean pslInterlockRelease;
/**
/** * psl盘互锁解除
* ibp盘互锁解除 */
*/ private boolean pslInterlockRelease;
private boolean ibpInterlockRelease;
/**
private Fault fault; * ibp盘互锁解除
*/
public VirtualRealityScreenDoor(String code, String name) { private boolean ibpInterlockRelease;
super(code, name, MapElement.DeviceType.PSD, 3*1000);
this.close = true; private Fault fault;
this.lock = true;
} public VirtualRealityScreenDoor(String code, String name) {
super(code, name, MapElement.DeviceType.PSD, 3 * 1000);
@Override this.close = true;
public void reset() { this.lock = true;
super.reset(); }
this.close = true;
this.lock = true; @Override
this.open2End = false; public void reset() {
this.pslInterlockRelease = false; super.reset();
this.ibpInterlockRelease = false; this.close = true;
this.fault = null; this.lock = true;
} this.open2End = false;
this.pslInterlockRelease = false;
@Override this.ibpInterlockRelease = false;
protected boolean checkConditionBeforeControl(Operation command) { this.fault = null;
if (command == null) }
return false;
switch (command) { @Override
case K: protected boolean checkConditionBeforeControl(Operation command) {
return !open2End; if (command == null) {
case G: return false;
return !isLockAndClose(); }
default: switch (command) {
throw new IllegalStateException("Unexpected value: " + command); case K:
} return !open2End;
case G:
return !isLockAndClose();
default:
throw new IllegalStateException("Unexpected value: " + command);
} }
}
// @Override // @Override
// protected boolean checkConditionBeforeControl(Operation command) { // protected boolean checkConditionBeforeControl(Operation command) {
@ -101,148 +107,153 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
// return true; // return true;
// } // }
@Override @Override
protected void doTurn() { protected void doTurn() {
Operation command = getCommand(); Operation command = getCommand();
if (command == null) { if (command == null) {
return; return;
}
switch (command) {
case K:{
if (this.isOpen2End())
setRemain(0);
else
setClose(false);
break;
}
case G: {
if (this.isLockAndClose())
setRemain(0);
else
setOpen2End(false);
break;
}
default:
throw new IllegalStateException("Unexpected value: " + command);
}
} }
switch (command) {
case K: {
if (this.isOpen2End()) {
setRemain(0);
} else {
setClose(false);
}
break;
}
case G: {
if (this.isLockAndClose()) {
setRemain(0);
} else {
setOpen2End(false);
}
break;
}
default:
throw new IllegalStateException("Unexpected value: " + command);
}
}
@Override @Override
protected void doFinish(Operation command) { protected void doFinish(Operation command) {
switch (command) { switch (command) {
case K:{ case K: {
this.setClose(false); this.setClose(false);
this.open2End = true; this.open2End = true;
break; break;
} }
case G: { case G: {
this.open2End = false; this.open2End = false;
this.setClose(true); this.setClose(true);
this.setLock(true); this.setLock(true);
break; break;
} }
}
} }
}
public boolean isInterlockRelease() { public boolean isInterlockRelease() {
return pslInterlockRelease || ibpInterlockRelease; return pslInterlockRelease || ibpInterlockRelease;
} }
public void setClose(boolean close) { public void setClose(boolean close) {
if ((Fault.CANNOT_BE_CLOSED.equals(this.fault) && close)|| if ((Fault.CANNOT_BE_CLOSED.equals(this.fault) && close) ||
(Fault.CANNOT_BE_OPENED.equals(this.fault) && !close)) (Fault.CANNOT_BE_OPENED.equals(this.fault) && !close)) {
return; return;
this.close = close; }
} this.close = close;
}
public void setLock(boolean lock) { public void setLock(boolean lock) {
if (Fault.NO_CLOSE_AND_LOCK.equals(this.fault) && lock) if (Fault.NO_CLOSE_AND_LOCK.equals(this.fault) && lock) {
return; return;
this.lock = lock; }
} this.lock = lock;
}
// public void updateIL(boolean il) { // public void updateIL(boolean il) {
// this.interlockRelease = il; // this.interlockRelease = il;
// } // }
public boolean isLockAndClose() { public boolean isLockAndClose() {
return this.lock && this.close; return this.lock && this.close;
} }
/** /**
* 全部关门 * 全部关门
*/ */
public void updateLockAndClose(boolean close, boolean lock) { public void updateLockAndClose(boolean close, boolean lock) {
this.open2End = false; this.open2End = false;
this.close = close; this.close = close;
this.setLock(lock); this.setLock(lock);
if (close && lock && this.isSettingClose()) { if (close && lock && this.isSettingClose()) {
this.finish(); this.finish();
} }
} }
public void updateOpen2End(boolean end) { public void updateOpen2End(boolean end) {
this.setLock(false); this.setLock(false);
this.close = false; this.close = false;
this.open2End = end; this.open2End = end;
if (end && this.isSettingOpen()) { if (end && this.isSettingOpen()) {
this.finish(); this.finish();
} }
} }
public boolean isSettingOpen() { public boolean isSettingOpen() {
return Operation.K.equals(this.getCommand()) && this.getRemain() > 0; return Operation.K.equals(this.getCommand()) && this.getRemain() > 0;
} }
public boolean isSettingClose() { public boolean isSettingClose() {
return Operation.G.equals(this.getCommand()) && this.getRemain() > 0; return Operation.G.equals(this.getCommand()) && this.getRemain() > 0;
} }
/** /**
* 开关门进行中 * 开关门进行中
*/ */
public void turning() { public void turning() {
if (this.lock) { if (this.lock) {
this.setLock(false); this.setLock(false);
} }
if (this.close) { if (this.close) {
this.close = false; this.close = false;
} }
if (this.open2End) { if (this.open2End) {
this.open2End = false; this.open2End = false;
} }
} }
public enum Fault { public enum Fault {
CANNOT_BE_CLOSED { CANNOT_BE_CLOSED {
@Override @Override
public void apply(VirtualRealityScreenDoor door) { public void apply(VirtualRealityScreenDoor door) {
door.setFault(null); // door.setFault(null);
door.control(Operation.K); // door.control(Operation.K);
door.setFault(this); door.setFault(this);
} }
}, },
CANNOT_BE_OPENED { CANNOT_BE_OPENED {
@Override @Override
public void apply(VirtualRealityScreenDoor door) { public void apply(VirtualRealityScreenDoor door) {
door.setFault(null); // door.setFault(null);
door.control(Operation.G); // door.control(Operation.G);
door.setFault(this); door.setFault(this);
} }
}, },
NO_CLOSE_AND_LOCK { NO_CLOSE_AND_LOCK {
@Override @Override
public void apply(VirtualRealityScreenDoor door) { public void apply(VirtualRealityScreenDoor door) {
door.setLock(false); door.setLock(false);
door.setFault(this); door.setFault(this);
} }
}; };
public abstract void apply(VirtualRealityScreenDoor door); public abstract void apply(VirtualRealityScreenDoor door);
public void fix(VirtualRealityScreenDoor vrPSD) { public void fix(VirtualRealityScreenDoor vrPSD) {
if (this.equals(vrPSD.getFault())) if (this.equals(vrPSD.getFault())) {
vrPSD.setFault(null); vrPSD.setFault(null);
} }
} }
}
} }

View File

@ -13,141 +13,147 @@ import lombok.Setter;
@Setter @Setter
public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwitch.Operation> { public class VirtualRealitySwitch extends ControllableVrDevice<VirtualRealitySwitch.Operation> {
private SwitchIndication p; private SwitchIndication p;
// -------------运行逻辑控制参数------------- // -------------运行逻辑控制参数-------------
private Fault fault; private Fault fault;
private Operation lastOperation; private Operation lastOperation;
@Override @Override
public boolean control(Operation command) { public boolean control(Operation command) {
boolean control = super.control(command); boolean control = super.control(command);
if (control && command != null) { if (control && command != null) {
this.lastOperation = command; this.lastOperation = command;
}
return control;
} }
return control;
}
@Override @Override
protected boolean checkConditionBeforeControl(Operation command) { protected boolean checkConditionBeforeControl(Operation command) {
switch (command) { switch (command) {
case NP: case NP:
return !(SwitchIndication.N == this.p); return !(SwitchIndication.N == this.p);
case RP: case RP:
return !(SwitchIndication.R == this.p); return !(SwitchIndication.R == this.p);
}
return true;
} }
return true;
}
@Override @Override
protected void doTurn() { protected void doTurn() {
this.p = SwitchIndication.NO; this.p = SwitchIndication.NO;
}
@Override
protected void doFinish(Operation command) {
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(command);
if (Fault.SQUEEZE.equals(this.getFault()) || Fault.SPLIT.equals(this.getFault())) {
return;
} }
switch (command) {
@Override case NP:
protected void doFinish(Operation command) { this.p = SwitchIndication.N;
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(command); break;
if (Fault.SQUEEZE.equals(this.getFault()) || Fault.SPLIT.equals(this.getFault())) { case RP:
return; this.p = SwitchIndication.R;
} break;
switch (command) {
case NP:
this.p = SwitchIndication.N;
break;
case RP:
this.p = SwitchIndication.R;
break;
}
} }
}
public boolean isPosN() { public boolean isPosN() {
return SwitchIndication.N.equals(this.p); return SwitchIndication.N.equals(this.p);
} }
public boolean isPosR() { public boolean isPosR() {
return SwitchIndication.R.equals(this.p); return SwitchIndication.R.equals(this.p);
} }
public boolean isCommandNp() { public boolean isCommandNp() {
return Operation.NP.equals(this.getCommand()); return Operation.NP.equals(this.getCommand());
} }
/**
* 道岔支持的操作
*/
public enum Operation {
/** /**
* 道岔支持的操作 * 定操
*/ */
public enum Operation { NP,
/** 定操 */ /**
NP, * 反操
/** 反操 */ */
RP, RP,
} }
public VirtualRealitySwitch(String code, String name, int turnTime) { public VirtualRealitySwitch(String code, String name, int turnTime) {
super(code, name, MapElement.DeviceType.SWITCH, turnTime * 1000); super(code, name, MapElement.DeviceType.SWITCH, turnTime * 1000);
this.p = SwitchIndication.N; this.p = SwitchIndication.N;
} }
@Override @Override
public void reset() { public void reset() {
super.reset(); super.reset();
this.p = SwitchIndication.N; this.p = SwitchIndication.N;
this.fault = null; this.fault = null;
this.lastOperation = Operation.NP; this.lastOperation = Operation.NP;
} }
public void apply(boolean normalPosition, boolean reversePosition) { public void apply(boolean normalPosition, boolean reversePosition) {
if (normalPosition) { if (normalPosition) {
this.p = SwitchIndication.N; this.p = SwitchIndication.N;
} else if (reversePosition) { } else if (reversePosition) {
this.p = SwitchIndication.R; this.p = SwitchIndication.R;
} else { } else {
this.p = SwitchIndication.NO; this.p = SwitchIndication.NO;
}
if ((Operation.NP.equals(this.getCommand()) && SwitchIndication.N.equals(this.p)) ||
(Operation.RP.equals(this.getCommand()) && SwitchIndication.R.equals(this.p))) {
this.finish();
}
}
//最后一次是否是转向定位
public boolean isLastTurnToN() {
return this.lastOperation == Operation.NP;
}
public enum Fault {
SPLIT {
@Override
public boolean apply(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault())) {
return false;
} }
if ((Operation.NP.equals(this.getCommand()) && SwitchIndication.N.equals(this.p)) || vrSwitch.setFault(this);
(Operation.RP.equals(this.getCommand()) && SwitchIndication.R.equals(this.p))) { vrSwitch.setP(SwitchIndication.NO);
this.finish(); return true;
} }
} },
/**
//最后一次是否是转向定位 * 挤岔
public boolean isLastTurnToN() { */
return this.lastOperation == Operation.NP; SQUEEZE {
} @Override
public boolean apply(VirtualRealitySwitch vrSwitch) {
public enum Fault { if (this.equals(vrSwitch.getFault())) {
SPLIT { return false;
@Override
public boolean apply(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault()))
return false;
vrSwitch.setFault(this);
vrSwitch.setP(SwitchIndication.NO);
return true;
}
},
/**
* 挤岔
*/
SQUEEZE {
@Override
public boolean apply(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault()))
return false;
vrSwitch.setFault(this);
vrSwitch.setP(SwitchIndication.EX);
return true;
}
};
public abstract boolean apply(VirtualRealitySwitch vrSwitch);
public void fix(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault())) {
vrSwitch.setFault(null);
}
} }
vrSwitch.setFault(this);
vrSwitch.setP(SwitchIndication.EX);
return true;
}
};
public abstract boolean apply(VirtualRealitySwitch vrSwitch);
public void fix(VirtualRealitySwitch vrSwitch) {
if (this.equals(vrSwitch.getFault())) {
vrSwitch.setFault(null);
}
} }
}
} }

View File

@ -0,0 +1,26 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.RealDeviceConfig;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO;
import club.joylink.rtss.vo.client.project.sdy.SdyPslConfigVO;
import lombok.Getter;
@Getter
public class CgyPslConfig extends RealDeviceConfig {
private CgyPslConfigVO configVO;
public CgyPslConfig(ProjectDeviceVO projectDevice) {
super(projectDevice);
if (projectDevice != null) {
this.configVO = JsonUtils.read(projectDevice.getConfig(), CgyPslConfigVO.class);
}
}
@Override
public String findDeviceCode() {
return configVO.findDeviceCode();
}
}

View File

@ -0,0 +1,86 @@
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy;
import club.joylink.rtss.services.psl.IVirtualRealityPslService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl.Button;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.PlcGateway;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.common.RealDeviceConfig;
import club.joylink.rtss.vo.client.project.cgy.CgyPslConfigVO;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
@Slf4j
@Component
public class CgyPslServiceImpl implements RealDeviceService {
@Autowired
private PlcGatewayService plcGatewayService;
@Autowired
private IVirtualRealityPslService virtualRealityPslService;
@Override
public boolean canHandle(RealDeviceConfig deviceConfig) {
return deviceConfig instanceof CgyPslConfig;
}
@Override
public void init(Simulation simulation, RealDeviceConfig deviceConfig) {
// PlcGateway plcGateway = simulation.getPlcGateway();
// CgyPslConfigVO configVO = ((CgyPslConfig) deviceConfig).getConfigVO();
// Channel channel = plcGateway.getChannel();
// int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_gm_light(), false, channel);
// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_km_light(), false, channel);
// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_psl_light(), false, channel);
// plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_gbsj_light(), false, channel);
}
@Override
public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) {
PlcGateway plcGateway = simulation.queryPlcGatewayDevice();
if (plcGateway == null) {
return;
}
CgyPslConfig config = (CgyPslConfig) deviceConfig;
CgyPslConfigVO configVO = config.getConfigVO();
if (!StringUtils.hasText(configVO.getPslCode())) {
return;
}
VirtualRealityPsl vrPsl = simulation.getRepository()
.getByCode(configVO.getPslCode(), VirtualRealityPsl.class);
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(),
configVO.getQuantity());
boolean r_km_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_km_btn());
boolean r_gm_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_gm_btn());
boolean r_yxjz_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yxjz_btn());
boolean r_hsjc_key = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_hsjc_key());
boolean r_xy_btn = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_xy_btn());
boolean w_km_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_km_light());
boolean w_gm_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gm_light());
boolean w_yxcz_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yxcz_light());
boolean w_gbsj_light = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gbsj_light());
//向vrPSL同步操作
virtualRealityPslService.updateStatus(simulation, vrPsl, Button.KM, r_km_btn);
virtualRealityPslService.updateStatus(simulation, vrPsl, Button.GM, r_gm_btn);
virtualRealityPslService.updateStatus(simulation, vrPsl, Button.YXJZ, r_yxjz_btn);
virtualRealityPslService.updateStatus(simulation, vrPsl, Button.HSJC, r_hsjc_key);
//向实体PSL同步状态
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
Channel channel = plcGateway.getChannel();
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_km_light(),
w_km_light, vrPsl.isKmLight(), channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gm_light(),
w_gm_light, vrPsl.isGmLight(), channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxcz_light(),
w_yxcz_light, vrPsl.isYxjzKey(), channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gbsj_light(),
w_gbsj_light, vrPsl.isQbgmLight(), channel);
}
}

View File

@ -46,29 +46,34 @@ public class CgySignalServiceImpl implements RealDeviceService {
Channel channel = plcGateway.getChannel(); Channel channel = plcGateway.getChannel();
switch (aspect) { switch (aspect) {
case No: case No:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel);
break; break;
case R: case R:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel);
break; break;
case G: case G:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), true, channel);
break; break;
case Y: case Y:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel);
break; break;
case RY: case RY:
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_red(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_ddj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_green(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_lxj(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yellow(), true, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_yxj(), true, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_zxj(), false, channel);
break; break;
default: default:
log.error("不支持的显示:{}", aspect); log.error("不支持的显示:{}", aspect);
@ -91,84 +96,82 @@ public class CgySignalServiceImpl implements RealDeviceService {
ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(),
configVO.getQuantity()); configVO.getQuantity());
boolean r_r = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_red()); //同步信号显示
boolean r_g = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_green()); SignalAspect aspect = getAspect(deviceStatus, configVO);
boolean r_y = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yellow()); vrSignal.apply(aspect);
//驱动信号显示
SignalAspect aspect = null;
if (!r_r && !r_g && !r_y) {
aspect = SignalAspect.No;
} else if (r_r && !r_g && !r_y) {
aspect = SignalAspect.R;
} else if (!r_r && r_g && !r_y) {
aspect = SignalAspect.G;
} else if (!r_r && !r_g && r_y) {
aspect = SignalAspect.Y;
} else if (r_r && !r_g && r_y) {
aspect = SignalAspect.RY;
}
if (aspect == null) {
log.error("未知的信号组合[红:%s][绿:%s][黄:%s]", r_r, r_g, r_y);
} else {
vrSignal.apply(aspect);
}
if (vrSignal.isTurning()) { if (vrSignal.isTurning()) {
boolean w_r = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_red()); boolean w_ddj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_ddj());
boolean w_g = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_green()); boolean w_lxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_lxj());
boolean w_y = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yellow()); boolean w_yxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_yxj());
boolean w_zxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_zxj());
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
Channel channel = plcGateway.getChannel(); Channel channel = plcGateway.getChannel();
SignalAspect command = vrSignal.getCommand(); SignalAspect command = vrSignal.getCommand();
switch (command) { switch (command) {
case No: case No:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj, true,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj,
false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj,
false, false,
channel); channel);
break; break;
case R: case R:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj,
false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj,
false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj,
false, false,
channel); channel);
break; break;
case G: case G:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj,
false, channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, true,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj, true,
channel);
break; break;
case Y: case Y:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj, true,
true, channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj,
false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj,
false,
channel); channel);
break; break;
case RY: case RY:
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_red(), w_r, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_ddj(), w_ddj,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_green(), w_g,
false, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yellow(), w_y, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_lxj(), w_lxj,
true, false,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_yxj(), w_yxj, true,
channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_zxj(), w_zxj,
false,
channel); channel);
break; break;
default: default:
@ -177,4 +180,22 @@ public class CgySignalServiceImpl implements RealDeviceService {
} }
} }
} }
private SignalAspect getAspect(ByteBuf deviceStatus, CgySignalConfigVO configVO) {
boolean r_ddj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_ddj());
boolean r_lxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_lxj());
boolean r_yxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_yxj());
boolean r_zxj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_zxj());
if (r_yxj) {
return SignalAspect.RY;
} else if (r_lxj && r_zxj) {
return SignalAspect.G;
} else if (r_lxj) {
return SignalAspect.Y;
} else if (!r_ddj) {
return SignalAspect.R;
} else {
return SignalAspect.No;
}
}
} }

View File

@ -35,7 +35,7 @@ public class CgySwitchServiceImpl implements RealDeviceService {
CgySwitchConfigVO configVO = config.getConfigVO(); CgySwitchConfigVO configVO = config.getConfigVO();
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr(); int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
Channel channel = plcGateway.getChannel(); Channel channel = plcGateway.getChannel();
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_sj(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_js(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dc(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_dc(), false, channel);
plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_fc(), false, channel); plcGatewayService.writeSingleCoil(baseAddr, configVO.getW_fc(), false, channel);
} }
@ -63,7 +63,7 @@ public class CgySwitchServiceImpl implements RealDeviceService {
boolean r_fb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_fb()); boolean r_fb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_fb());
vrSwitch.apply(r_db, r_fb); vrSwitch.apply(r_db, r_fb);
//以下操作实体设备的逻辑中防止继电器长期接通的逻辑将定反操视为技能共用3秒冷却技能持续时间也是3秒 //以下操作实体设备的逻辑中防止继电器长期接通的逻辑将定反操视为技能共用3秒冷却技能持续时间也是3秒
if (config.isEnd()) { //此判断既可视为操作是否冷却也可视为持续时间是否耗尽 if (config.isEnd()) { //此判断既可视为操作是否冷却也可视为持续时间是否耗尽
config.sync(r_db, r_fb); config.sync(r_db, r_fb);
release(deviceStatus, baseAddr, configVO, channel); //操作持续时间耗尽后断开所有继电器 release(deviceStatus, baseAddr, configVO, channel); //操作持续时间耗尽后断开所有继电器
@ -87,10 +87,10 @@ public class CgySwitchServiceImpl implements RealDeviceService {
private void turnToN(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO, private void turnToN(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO,
Channel channel) { Channel channel) {
boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_js());
boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc());
boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc());
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sb, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_js(), w_sb, true,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, true,
channel); channel);
@ -100,10 +100,10 @@ public class CgySwitchServiceImpl implements RealDeviceService {
private void turnToP(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO, private void turnToP(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO,
Channel channel) { Channel channel) {
boolean w_sb = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); boolean w_js = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_js());
boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc());
boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc());
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sb, true, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_js(), w_js, true,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false,
channel); channel);
@ -113,10 +113,10 @@ public class CgySwitchServiceImpl implements RealDeviceService {
private void release(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO, private void release(ByteBuf deviceStatus, int baseAddr, CgySwitchConfigVO configVO,
Channel channel) { Channel channel) {
boolean w_sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_sj()); boolean w_sj = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_js());
boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc()); boolean w_dc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_dc());
boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc()); boolean w_fc = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_fc());
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_sj(), w_sj, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_js(), w_sj, false,
channel); channel);
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false, plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_dc(), w_dc, false,
channel); channel);

View File

@ -10,119 +10,124 @@ import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import org.springframework.stereotype.Component;
@Component @Component
public class TrainTargetUpdateService { public class TrainTargetUpdateService {
public static final String Model_Name = "TrainTargetUpdate";
public static final int Rate = 5000;
public void addJobs(Simulation simulation) { public static final String Model_Name = "TrainTargetUpdate";
simulation.addJob(Model_Name, () -> this.run(simulation), Rate); public static final int Rate = 5000;
public void addJobs(Simulation simulation) {
simulation.addJob(Model_Name, () -> this.run(simulation), Rate);
}
public void run(Simulation simulation) {
SimulationDataRepository repository = simulation.getRepository();
List<VirtualRealityTrain> onlineTrain = repository.getOnlineTrainList();
for (VirtualRealityTrain train : onlineTrain) {
TrainInfo trainInfo = repository.findSupervisedTrainByGroup(train.getGroupNumber());
if (trainInfo == null) {
continue;
}
Section target = train.getTarget();
Section newTarget = this.queryArriveTarget(train, trainInfo);
if (newTarget != null && !Objects.equals(target, newTarget)) {
train.setTarget(newTarget);
}
} }
}
public void run(Simulation simulation) { private Section queryArriveTarget4Manual(VirtualRealityTrain train, TrainInfo trainInfo,
SimulationDataRepository repository = simulation.getRepository(); Section target) {
List<VirtualRealityTrain> onlineTrain = repository.getOnlineTrainList(); SectionPosition headPosition = train.getHeadPosition();
for (VirtualRealityTrain train : onlineTrain) { boolean right = train.isRight();
TrainInfo trainInfo = repository.getSupervisedTrainByGroup(train.getGroupNumber()); Section newTarget = target;
// if (!trainInfo.isManualTrain()) { Section temp = headPosition.getSection();
// continue; for (int i = 0; i < 50; i++) {
// } if (temp == null) {
Section target = train.getTarget(); break;
Section newTarget = this.queryArriveTarget(train, trainInfo);
if (newTarget != null && !Objects.equals(target, newTarget)) {
train.setTarget(newTarget);
}
} }
} if (!temp.isFunctionTrack()) {
temp = temp.findNextRunningSectionBaseRealSwitch(right);
private Section queryArriveTarget4Manual(VirtualRealityTrain train, TrainInfo trainInfo, Section target) { continue;
SectionPosition headPosition = train.getHeadPosition(); }
boolean right = train.isRight(); Signal signal = temp.getSignalOf(right);
Section newTarget = target; if (signal != null && !signal.isMainAspect()) {
Section temp = headPosition.getSection(); newTarget = temp;
for (int i = 0; i < 50; i++) { if (temp.isFunctionTrack()) {
if (temp == null) break;
break; }
if (!temp.isFunctionTrack()) { }
temp = temp.findNextRunningSectionBaseRealSwitch(right); if (temp.isNormalStandTrack() || temp.isTransferTrack()) {
continue; if (temp.isNormalStandTrack()) {
} if (temp.getStandList().stream()
Signal signal = temp.getSignalOf(right); .anyMatch(stand -> stand.isJumpStop(train.getGroupNumber()))) { //该列车应在站台跳停
if (signal != null && !signal.isMainAspect()) {
newTarget = temp;
if (temp.isFunctionTrack())
break;
}
if (temp.isNormalStandTrack() || temp.isTransferTrack()) {
if (temp.isNormalStandTrack()) {
if (temp.getStandList().stream().anyMatch(stand -> stand.isJumpStop(train.getGroupNumber()))) { //该列车应在站台跳停
temp = temp.findNextRunningSectionBaseRealSwitch(right);
continue;
}
}
if (!temp.equals(headPosition.getSection())) { //列车还未到达该区段
newTarget = temp;
break;
} else {
if (!temp.getCode().equals(trainInfo.getActualArriveStandTrack())) { //列车未在该区段停车
SectionPosition maxStopPosition = CalculateService
.calculateNextPositionByStartAndLen(temp.buildStopPointPosition(right),
right, SimulationConstants.PARK_POINT_MAX_OFFSET, false); //最远停车点
if (maxStopPosition.isAheadOf(headPosition, right)) { //该区段最远停车点在车头前方
newTarget = temp;
break;
}
}
}
}
temp = temp.findNextRunningSectionBaseRealSwitch(right); temp = temp.findNextRunningSectionBaseRealSwitch(right);
continue;
}
} }
return newTarget; if (!temp.equals(headPosition.getSection())) { //列车还未到达该区段
newTarget = temp;
break;
} else {
if (!temp.getCode().equals(trainInfo.getActualArriveStandTrack())) { //列车未在该区段停车
SectionPosition maxStopPosition = CalculateService
.calculateNextPositionByStartAndLen(temp.buildStopPointPosition(right),
right, SimulationConstants.PARK_POINT_MAX_OFFSET, false); //最远停车点
if (maxStopPosition.isAheadOf(headPosition, right)) { //该区段最远停车点在车头前方
newTarget = temp;
break;
}
}
}
}
temp = temp.findNextRunningSectionBaseRealSwitch(right);
} }
return newTarget;
}
private Section queryArriveTarget(VirtualRealityTrain train, TrainInfo trainInfo) { private Section queryArriveTarget(VirtualRealityTrain train, TrainInfo trainInfo) {
Section newTarget = null; Section newTarget = null;
MaService.Ma ma = train.getMa2(); MaService.Ma ma = train.getMa2();
if (ma == null) if (ma == null) {
return null; return null;
SectionPosition eoaPosition = ma.getEoaPosition(); }
Section eoaSection = eoaPosition.getSection(); SectionPosition eoaPosition = ma.getEoaPosition();
SectionPosition headPosition = train.getHeadPosition(); Section eoaSection = eoaPosition.getSection();
boolean right = train.isRight(); SectionPosition headPosition = train.getHeadPosition();
Section headSection = headPosition.getSection(); boolean right = train.isRight();
Section section = headSection; Section headSection = headPosition.getSection();
for (int i = 0; i < 100; i++) { Section section = headSection;
if (section.equals(eoaSection) && newTarget == null) { //已经遍历到移动授权终点区段且中途未找到功能轨 for (int i = 0; i < 100; i++) {
newTarget = section; if (section.equals(eoaSection) && newTarget == null) { //已经遍历到移动授权终点区段且中途未找到功能轨
break; newTarget = section;
} break;
if (section.isFunctionTrack()) { }
if (section.isNormalStandTrack()) { if (section.isFunctionTrack()) {
if (train.isHold()) { if (section.isNormalStandTrack()) {
newTarget = section; if (train.isHold()) {
break; newTarget = section;
} break;
if (!section.getCode().equals(trainInfo.getActualArriveStandTrack())) { //列车没有抵达该站台轨的信息 }
newTarget = section; if (!section.getCode().equals(trainInfo.getActualArriveStandTrack())) { //列车没有抵达该站台轨的信息
break; newTarget = section;
} break;
} else { }
newTarget = section; } else {
} newTarget = section;
}
section = section.findNextRunningSectionBaseRealSwitch(right);
if (section == null) {
break;
} else {
continue;
}
} }
return newTarget; }
section = section.findNextRunningSectionBaseRealSwitch(right);
if (section == null) {
break;
} else {
continue;
}
} }
return newTarget;
}
} }

View File

@ -4,6 +4,7 @@ import club.joylink.rtss.constants.ProjectCode;
import club.joylink.rtss.constants.ProjectDeviceType; import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.entity.ProjectDevice; import club.joylink.rtss.entity.ProjectDevice;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgyPslConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySectionConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySectionConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySignalConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySignalConfig;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySwitchConfig; import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy.CgySwitchConfig;
@ -175,6 +176,9 @@ public class ProjectDeviceVO {
case SECTION: case SECTION:
list.add(new CgySectionConfig(deviceVO)); list.add(new CgySectionConfig(deviceVO));
break; break;
case PSL:
list.add(new CgyPslConfig(deviceVO));
break;
} }
} }
return list; return list;

View File

@ -0,0 +1,71 @@
package club.joylink.rtss.vo.client.project.cgy;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CgyPslConfigVO extends RealConfigVO {
private String pslCode;
/**
* 开门按钮
*/
private Integer r_km_btn = 32;
/**
* 关门按钮
*/
private Integer r_gm_btn = 33;
/**
* 就地允许/禁止按钮
*/
private Integer r_yxjz_btn = 34;
/**
* 互锁解除钥匙true-互锁解除
*/
private Integer r_hsjc_key = 46;
/**
* 消音按钮不知道消的啥音
*/
private Integer r_xy_btn = 47;
/**
* 控制-开门指示灯
*/
private Integer w_km_light = 48;
/**
* 控制-关门指示灯
*/
private Integer w_gm_light = 49;
/**
* 控制-psl允许操作指示灯
*/
private Integer w_yxcz_light = 50;
/**
* 控制-关闭锁紧指示灯
*/
private Integer w_gbsj_light = 55;
public CgyPslConfigVO(String pslCode) {
this();
this.pslCode = pslCode;
}
public CgyPslConfigVO() {
super(0, 64);
}
@Override
public String findDeviceCode() {
return pslCode;
}
}

View File

@ -11,10 +11,16 @@ public class CgySectionConfigVO extends RealConfigVO {
/** /**
* 出清 * 出清
*/ */
private Integer r_occupied = 6; private Integer r_occupied;
public CgySectionConfigVO(String sectionCode, Integer r_occupied) {
this();
this.sectionCode = sectionCode;
this.r_occupied = r_occupied;
}
public CgySectionConfigVO() { public CgySectionConfigVO() {
super(0, 32); super(0, 64);
} }
@Override @Override

View File

@ -1,46 +1,62 @@
package club.joylink.rtss.vo.client.project.cgy; package club.joylink.rtss.vo.client.project.cgy;
import club.joylink.rtss.vo.client.project.RealConfigVO; import club.joylink.rtss.vo.client.project.RealConfigVO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
/**
* 红灯常亮DDJ吸起红灯灭 Lxj吸起黄灯 YxJ红黄 LXJZXJ吸起绿灯
*/
@Getter @Getter
@Setter @Setter
public class CgySignalConfigVO extends RealConfigVO { public class CgySignalConfigVO extends RealConfigVO {
private String signalCode; private String signalCode;
/** private Integer r_ddj;
*
*/ private Integer r_lxj;
private Integer r_red;
/** /**
* 绿 * 主灯丝报警
*/ */
private Integer r_green; private Integer r_dj;
private Integer r_zxj;
private Integer r_yxj;
/** /**
* * 副灯丝报警
*/ */
private Integer r_yellow; private Integer r_dj2;
private Integer w_red; private Integer w_ddj;
private Integer w_green; private Integer w_lxj;
private Integer w_yellow; private Integer w_zxj;
public CgySignalConfigVO(String signalCode, Integer r_red, private Integer w_yxj;
Integer r_green, Integer r_yellow, Integer w_red, Integer w_green, Integer w_yellow) {
super(0, 24); public CgySignalConfigVO(String signalCode, Integer r_ddj,
Integer r_lxj, Integer r_dj, Integer r_zxj, Integer r_yxj, Integer r_dj2, Integer w_ddj,
Integer w_lxj, Integer w_zxj, Integer w_yxj) {
this();
this.signalCode = signalCode; this.signalCode = signalCode;
this.r_red = r_red; this.r_ddj = r_ddj;
this.r_green = r_green; this.r_lxj = r_lxj;
this.r_yellow = r_yellow; this.r_dj = r_dj;
this.w_red = w_red; this.r_zxj = r_zxj;
this.w_green = w_green; this.r_yxj = r_yxj;
this.w_yellow = w_yellow; this.r_dj2 = r_dj2;
this.w_ddj = w_ddj;
this.w_lxj = w_lxj;
this.w_zxj = w_zxj;
this.w_yxj = w_yxj;
} }
public CgySignalConfigVO() { public CgySignalConfigVO() {

View File

@ -10,30 +10,39 @@ public class CgySwitchConfigVO extends RealConfigVO {
private String switchCode; private String switchCode;
/**
* 解锁表示
*/
private Integer r_js = 12;
/** /**
* 定表 * 定表
*/ */
private Integer r_db = 0; private Integer r_db = 13;
/** /**
* 反表 * 反表
*/ */
private Integer r_fb = 1; private Integer r_fb = 14;
/** /**
* *
*/ */
private Integer w_sj = 8; private Integer w_js = 24;
/** /**
* 定操 * 定操
*/ */
private Integer w_dc = 9; private Integer w_dc = 25;
/** /**
* 反操 * 反操
*/ */
private Integer w_fc = 10; private Integer w_fc = 26;
public CgySwitchConfigVO(String switchCode) {
this();
this.switchCode = switchCode;
}
public CgySwitchConfigVO() { public CgySwitchConfigVO() {
super(0, 32); super(0, 32);