苏安院屏蔽门监控逻辑修改
This commit is contained in:
parent
d844da103a
commit
bdbee678f9
@ -75,9 +75,9 @@ public class VirtualRealityScreenDoor extends ControllableVrDevice<VirtualRealit
|
||||
return false;
|
||||
switch (command) {
|
||||
case K:
|
||||
return !open2End && !isSettingOpen();
|
||||
return !open2End;
|
||||
case G:
|
||||
return !isLockAndClose() && !isSettingClose();
|
||||
return !isLockAndClose();
|
||||
default:
|
||||
throw new IllegalStateException("Unexpected value: " + command);
|
||||
}
|
||||
|
@ -29,6 +29,8 @@ public class SimulationRealDeviceThread {
|
||||
|
||||
public static final int Query_Rate = 300;
|
||||
|
||||
public static final int COLLECT_RATE = 100;
|
||||
|
||||
@Autowired
|
||||
public GroupSimulationCache groupSimulationCache;
|
||||
@Autowired
|
||||
@ -175,6 +177,6 @@ public class SimulationRealDeviceThread {
|
||||
public void addJobs(Simulation simulation) {
|
||||
simulation.addFixedRateJob(Simulation.JobName.controlDevice, () -> this.controlDevice(simulation), SimulationConstants.VRD_LOOP_RATE);
|
||||
simulation.addFixedRateJob(Simulation.JobName.queryDeviceStatus, () -> this.queryDeviceStatus(simulation), Query_Rate);
|
||||
simulation.addFixedRateJob(Simulation.JobName.UpdateDeviceStatusByCollection, () -> this.UpdateDeviceStatusByCollection(simulation), 100);
|
||||
simulation.addFixedRateJob(Simulation.JobName.UpdateDeviceStatusByCollection, () -> this.UpdateDeviceStatusByCollection(simulation), COLLECT_RATE);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.SimulationRealDeviceThread;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
|
||||
import club.joylink.rtss.util.JsonUtils;
|
||||
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
|
||||
@ -12,6 +13,25 @@ import lombok.Setter;
|
||||
public class SayPsdConfig extends RealDeviceConfig {
|
||||
private SayPsdConfigVO configVO;
|
||||
|
||||
/**
|
||||
* 使能剩余时间(屏蔽门开关门过程中需要使能位持续处于闭合状态,故设置使能位固定接通5秒)
|
||||
*/
|
||||
private int enableRemain;
|
||||
|
||||
public void enableStart() {
|
||||
enableRemain = 5000;
|
||||
}
|
||||
|
||||
public void enableRemainReduce() {
|
||||
if (isEnable()) {
|
||||
enableRemain -= SimulationRealDeviceThread.COLLECT_RATE;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEnable() {
|
||||
return enableRemain > 0;
|
||||
}
|
||||
|
||||
public SayPsdConfig(ProjectDeviceVO projectDevice) {
|
||||
super(projectDevice);
|
||||
if (projectDevice != null) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.say;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.PlcGatewayService;
|
||||
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.RealDeviceService;
|
||||
@ -9,9 +10,11 @@ import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDevice
|
||||
import club.joylink.rtss.vo.client.project.say.SayPsdConfigVO;
|
||||
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.Service;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class SayPsdServiceImpl implements RealDeviceService {
|
||||
@Autowired
|
||||
@ -42,8 +45,8 @@ public class SayPsdServiceImpl implements RealDeviceService {
|
||||
boolean w_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_km());
|
||||
boolean w_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_gm());
|
||||
boolean w_enable = RealDeviceConfig.getBitOf(deviceStatus, configVO.getW_enable());
|
||||
boolean r_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_km());
|
||||
boolean r_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_gm());
|
||||
// boolean r_km = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_km());
|
||||
// boolean r_gm = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_gm());
|
||||
|
||||
int baseAddr = plcGateway.getConfig().getAddr() + configVO.getAddr();
|
||||
Channel channel = plcGateway.getChannel();
|
||||
@ -51,29 +54,39 @@ public class SayPsdServiceImpl implements RealDeviceService {
|
||||
boolean needKm;
|
||||
boolean needGm;
|
||||
if (vrPsd.isSettingOpen()) {
|
||||
log.info("开门指令");
|
||||
needKm = true;
|
||||
needGm = false;
|
||||
} else if (vrPsd.isSettingClose()) {
|
||||
log.info("关门指令");
|
||||
needKm = false;
|
||||
needGm = true;
|
||||
} else {
|
||||
needKm = false;
|
||||
needGm = false;
|
||||
}
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_enable(), w_enable, needKm || needGm, channel);
|
||||
if (config.isEnable()) { //已经处于使能状态倒计时状态
|
||||
log.info("使能");
|
||||
config.enableRemainReduce();
|
||||
} else { //未处于使能状态
|
||||
if (needKm || needGm) { //有开关门指令待执行
|
||||
config.enableStart(); //使能开始
|
||||
}
|
||||
}
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_enable(), w_enable, config.isEnable(), channel);
|
||||
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_km(), w_km, needKm, channel);
|
||||
plcGatewayService.checkEqualAndWriteSingleCoil(baseAddr, configVO.getW_gm(), w_gm, needGm, channel);
|
||||
|
||||
if (r_km) {
|
||||
vrPsd.updateOpen2End(true);
|
||||
}
|
||||
if (r_gm) {
|
||||
vrPsd.updateLockAndClose(true, true);
|
||||
}
|
||||
|
||||
// if (vrPsd.getRemain() > 0) {
|
||||
// vrPsd.turning(SimulationModule.VRD.getRateMs());
|
||||
// if (r_km) {
|
||||
// vrPsd.updateOpen2End(true);
|
||||
// }
|
||||
// if (r_gm) {
|
||||
// vrPsd.updateLockAndClose(true, true);
|
||||
// }
|
||||
|
||||
if (vrPsd.getRemain() > 0) {
|
||||
vrPsd.turning(SimulationModule.VRD.getRateMs());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,15 +24,15 @@ public class SayPsdConfigVO extends RealConfigVO {
|
||||
*/
|
||||
private Integer w_enable = 246;
|
||||
|
||||
/**
|
||||
* 开门状态(I9.0-2)(I9.x最初没接线,所以网关配置里也就没配,所以现在配到了最后面)
|
||||
*/
|
||||
private Integer r_km = 248;
|
||||
|
||||
/**
|
||||
* 关门到位状态
|
||||
*/
|
||||
private Integer r_gm = 249;
|
||||
// /**
|
||||
// * 开门状态(I9.0-2)(I9.x最初没接线,所以网关配置里也就没配,所以现在配到了最后面)
|
||||
// */
|
||||
// private Integer r_km = 248;
|
||||
//
|
||||
// /**
|
||||
// * 关门到位状态
|
||||
// */
|
||||
// private Integer r_gm = 249;
|
||||
|
||||
public SayPsdConfigVO() {
|
||||
super(0, 256);
|
||||
|
Loading…
Reference in New Issue
Block a user