| | |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.Date; |
| | |
| | | @SuppressWarnings("InfiniteLoopStatement") |
| | | public void run() { |
| | | this.connect(); |
| | | // try { |
| | | // Thread.sleep(2000); |
| | | // } catch (InterruptedException e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | while (true) { |
| | | try { |
| | | int step = 1; |
| | |
| | | log.error("堆垛机plc连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | initCrn(); |
| | | } |
| | | melsecMcNet.ConnectClose(); |
| | | // melsecMcNet.ConnectClose(); |
| | | return result; |
| | | } |
| | | |
| | |
| | | */ |
| | | private void readStatus(){ |
| | | try { |
| | | if (this.slave.getId() == 1) { |
| | | System.out.println("==="); |
| | | } |
| | | // if (this.slave.getId() == 1 && flag1.equals(0)) { |
| | | // Thread.sleep(3000); |
| | | // flag1=1; |
| | | // System.out.println("==="); |
| | | // } |
| | | OperateResultExOne<byte[]> result = melsecMcNet.Read("D20", (short) 70); |
| | | if (result.IsSuccess) { |
| | | if (null == crnProtocol) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 根据实时信息更新数据库 |
| | | BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class); |
| | | BasCrnp basCrnp = new BasCrnp(); |