From dbe197eba64968ba9aef0f5f7f9c27874eda9e0b Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Fri, 24 May 2024 11:40:13 +0800 Subject: [PATCH] =?UTF-8?q?[bug]=E6=88=90=E9=83=BD=E5=B7=A5=E4=B8=9A?= =?UTF-8?q?=E5=8C=BA=E6=AE=B5=E8=81=94=E5=8A=A8=E6=9C=8D=E5=8A=A1=E6=B2=A1?= =?UTF-8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modbustcp/cgy/CgySectionServiceImpl.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySectionServiceImpl.java diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySectionServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySectionServiceImpl.java new file mode 100644 index 000000000..4de0669e1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/device/real/modbustcp/cgy/CgySectionServiceImpl.java @@ -0,0 +1,43 @@ +package club.joylink.rtss.simulation.cbtc.device.real.modbustcp.cgy; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter; +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.CgySectionConfigVO; +import io.netty.buffer.ByteBuf; +import org.springframework.stereotype.Service; + +@Service +public class CgySectionServiceImpl implements RealDeviceService { + + @Override + public boolean canHandle(RealDeviceConfig deviceConfig) { + return deviceConfig instanceof CgySectionConfig; + } + + @Override + public void init(Simulation simulation, RealDeviceConfig deviceConfig) { + + } + + @Override + public void handle(Simulation simulation, RealDeviceConfig deviceConfig, ByteBuf byteBuf) { + PlcGateway plcGateway = simulation.queryPlcGatewayDevice(); + if (plcGateway == null) { + return; + } + CgySectionConfig config = (CgySectionConfig) deviceConfig; + VirtualRealitySectionAxleCounter vrAxleCounter = (VirtualRealitySectionAxleCounter) config.getMapElement(); + if (vrAxleCounter == null) { + return; + } + CgySectionConfigVO configVO = config.getConfigVO(); + ByteBuf deviceStatus = RealDeviceConfig.getDeviceCoilStatus(byteBuf, configVO.getAddr(), + configVO.getQuantity()); + + boolean r_occupied = RealDeviceConfig.getBitOf(deviceStatus, configVO.getR_occupied()); + vrAxleCounter.setOccupy(r_occupied); + } +}