| | |
| | | package com.ld.igds.protocol.modbus.command; |
| | | |
| | | import com.ld.igds.common.CoreDeviceService; |
| | | import com.ld.igds.common.CoreSerService; |
| | | import com.ld.igds.constant.Constant; |
| | | import com.ld.igds.constant.DeviceStatus; |
| | | import com.ld.igds.io.RemoteControlService; |
| | |
| | | import com.ld.igds.modbus.service.HModbusService; |
| | | import com.ld.igds.models.Device; |
| | | import com.ld.igds.models.DeviceModbus; |
| | | import com.ld.igds.models.DeviceSer; |
| | | import com.ld.igds.protocol.modbus.ModbusUtil2; |
| | | import com.ld.igds.protocol.modbus.ServerUtil; |
| | | import com.ld.igds.protocol.modbus.data.ModbusTcp; |
| | |
| | | private HModbusService deviceModbusService; |
| | | @Resource |
| | | private AnalysisService analysisService; |
| | | @Resource |
| | | private CoreSerService coreSerService; |
| | | |
| | | |
| | | @Override |
| | |
| | | temp = modbusTcp.getDeviceModbus().getOpen(); |
| | | } |
| | | |
| | | //环流风机-关 |
| | | if (DeviceStatus.F_CLOSE.getCode().equals(exeDevice.getTargetStatus())) { |
| | | temp = modbusTcp.getDeviceModbus().getStop(); |
| | | } |
| | | |
| | | //环流风机-开 |
| | | if (DeviceStatus.F_OPEN.getCode().equals(exeDevice.getTargetStatus())) { |
| | | temp = modbusTcp.getDeviceModbus().getOpen(); |
| | | } |
| | | |
| | | if (StringUtils.isBlank(exeDevice.getLink()) || "null".equals(exeDevice.getLink())) { |
| | | //根据设备目标状态,调用MODBUS执行 |
| | | modbusTcp.setAddrExe(ServerUtil.getAddrExe(temp)); |
| | |
| | | modbusTcpLink.setBizCode(exeDevice.getLink()); |
| | | modbusTcpLink.setSerId(request.getSerId()); |
| | | modbusTcpLink.setCompanyId(request.getCompanyId()); |
| | | |
| | | if(StringUtils.isNotEmpty(deviceModbus.getSerId())){ |
| | | //若Modbus设备配置分机,则使用所配置分机的IP、端口 |
| | | DeviceSer deviceSer = coreSerService.getCacheSer(request.getCompanyId(), deviceModbus.getSerId()); |
| | | modbusTcpLink.setIp(deviceSer.getIp()); |
| | | modbusTcpLink.setPort(deviceSer.getPort()); |
| | | } |
| | | |
| | | //如果是开风机 |
| | | if (DeviceStatus.F_OPEN.getCode().equals(exeDevice.getTargetStatus())) { |
| | |
| | | Thread.sleep(300); |
| | | |
| | | //在关窗户 |
| | | temp = modbusTcp.getDeviceModbus().getOpen(); |
| | | temp = modbusTcp.getDeviceModbus().getClose(); |
| | | modbusTcp.setAddrExe(ServerUtil.getAddrExe(temp)); |
| | | |
| | | doWriteExe(modbusTcp, DeviceStatus.CLOSE.getCode()); |
| | |
| | | |
| | | if (Constant.YN_N.equals(modbusTcp.getDeviceModbus().getOpen())) return; |
| | | |
| | | if (Constant.YN_N.equals(modbusTcp.getDeviceModbus().getOpenEnd())) return; |
| | | int addrExe = ServerUtil.getAddrExe(modbusTcp.getDeviceModbus().getOpenEnd()); |
| | | |
| | | boolean result = ModbusUtil2.readInputStatus(modbusTcp.getIp(), modbusTcp.getPort(), addrExe); |
| | |
| | | ServerUtil.add2StatusMap(modbusTcp.getCompanyId(), modbusTcp.getSerId(), modbusTcp.getBizCode(), DeviceStatus.OPEN.getCode()); |
| | | } |
| | | |
| | | |
| | | if (Constant.YN_N.equals(modbusTcp.getDeviceModbus().getCloseEnd())) return; |
| | | addrExe = ServerUtil.getAddrExe(modbusTcp.getDeviceModbus().getCloseEnd()); |
| | | result = ModbusUtil2.readInputStatus(modbusTcp.getIp(), modbusTcp.getPort(), addrExe); |
| | | log.debug("---------读关到位状态------{}-{}-{}", modbusTcp.getBizCode(), addrExe, result); |