src/main/java/com/zy/core/thread/JarThread.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/thread/SiemensDevpThread.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/thread/SteThread.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/core/thread/JarThread.java
@@ -40,6 +40,8 @@ private JarSlave slave; private JarProtocol jarProtocol; private short heartBeatVal = 1; private boolean connectJar = false; public JarThread(JarSlave slave) { this.slave = slave; @@ -48,7 +50,33 @@ @Override @SuppressWarnings("InfiniteLoopStatement") public void run() { this.connect(); connectJar = this.connect(); while(!connectJar){ try { connectJar = this.connect(); Thread.sleep(100); } catch (Exception e){ } } // 启动线程自动重连 new Thread(this::jarConnect).start(); // 启动读数据线程 new Thread(this::readStatusJar).start(); // 启动任务下发线程 new Thread(this::taskIssued).start(); } /** * 任务下发 */ private void taskIssued() { while (true) { try { int step = 1; @@ -59,7 +87,7 @@ switch (step) { // 读数据 case 1: readStatus(); // readStatus(); break; // 写数据 ID+目标站 case 2: @@ -70,14 +98,55 @@ } // 心跳 // heartbeat(); Thread.sleep(500); Thread.sleep(200); } catch (Exception e) { e.printStackTrace(); log.error("JAR写线程异常"+e.getMessage()); // e.printStackTrace(); } } } private void jarConnect() { while (true) { try { Thread.sleep(1000); if(!connectJar){ try { connectJar = this.connect(); Thread.sleep(100); } catch (Exception e){ } } } catch (Exception e) { log.error("rgv连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); initSte(); // e.printStackTrace(); } } } private void readStatusJar() { while (true) { try { Thread.sleep(50); // System.out.println("读线程"+ slave.getId()); readStatus(); } catch (Exception e) { log.error("RGV数据读取线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); initSte(); // e.printStackTrace(); } } } /** * 初始化堆垛机状态 */ src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -300,7 +300,8 @@ } catch (Exception e) { // e.printStackTrace(); try{ log.error(e.getMessage()); log.error("dev写线程异常"+e.getMessage()); } catch (Exception e1){ } src/main/java/com/zy/core/thread/SteThread.java
@@ -44,6 +44,7 @@ private SteProtocol steProtocol; private short heartBeatVal = 1; private boolean resetFlag = false; private boolean connectSte = false; public SteThread(SteSlave slave) { this.slave = slave; @@ -52,7 +53,31 @@ @Override @SuppressWarnings("InfiniteLoopStatement") public void run() { this.connect(); connectSte = this.connect(); while(!connectSte){ try { connectSte = this.connect(); Thread.sleep(100); } catch (Exception e){ } } // 启动线程自动重连 new Thread(this::steConnect).start(); // 启动读数据线程 new Thread(this::readStatusSte).start(); // 启动任务下发线程 new Thread(this::taskIssued).start(); } /** * 任务下发 */ private void taskIssued() { while (true) { try { int step = 1; @@ -63,7 +88,7 @@ switch (step) { // 读数据 case 1: readStatus(); // readStatus(); break; // 写入数据 case 2: @@ -74,14 +99,55 @@ } // 心跳 // heartbeat(); Thread.sleep(500); Thread.sleep(200); } catch (Exception e) { e.printStackTrace(); log.error("STE写线程异常"+e.getMessage()); // e.printStackTrace(); } } } private void steConnect() { while (true) { try { Thread.sleep(1000); if(!connectSte){ try { connectSte = this.connect(); Thread.sleep(100); } catch (Exception e){ } } } catch (Exception e) { log.error("ste连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); initSte(); // e.printStackTrace(); } } } private void readStatusSte() { while (true) { try { Thread.sleep(50); // System.out.println("读线程"+ slave.getId()); readStatus(); } catch (Exception e) { log.error("RGV数据读取线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); initSte(); // e.printStackTrace(); } } } /** * 初始化堆垛机状态 */