[bug]成都工业区段联动服务没写

This commit is contained in:
thesai 2024-05-24 11:40:13 +08:00
parent cee9eda430
commit dbe197eba6
1 changed files with 43 additions and 0 deletions

View File

@ -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);
}
}