src/main/java/com/zy/core/MainProcess.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/core/thread/SiemensDevpThread.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/core/MainProcess.java
@@ -1,5 +1,6 @@ package com.zy.core; import com.core.common.SpringUtils; import com.zy.asrs.service.impl.MainServiceImpl; import com.zy.core.properties.SystemProperties; import lombok.Data; @@ -24,6 +25,7 @@ private MainServiceImpl mainService; // 所属线程 private Thread thread; private Thread thread2; // 频率 private int i = 0; private int j = 0; @@ -34,18 +36,19 @@ * =====>> 开始工作 */ public void start(){ thread = new Thread(() -> { thread = new Thread(this::cenAndDevRun); thread.start(); thread2 = new Thread(this::jarRun); thread2.start(); } private void cenAndDevRun() { while (!Thread.currentThread().isInterrupted()) { try { i++; if (i>5) i=0; j++; if (j>5) j=0; k++; if (k>5) { k=0; l++; if (l>=3) l=0; } // 间隔 Thread.sleep(1000); @@ -54,15 +57,6 @@ if (!SystemProperties.WCS_RUNNING_STATUS.get()) { continue; } //初始化RGV地图 // mainService.initRgvMap(); //刷新RGV地图 // mainService.refreshRgvMap(); // 演示 // mainService.crnDemoOfLocMove1(); // 入出库模式切换函数 // mainService.ioConvert(); // 入库 ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档 mainService.generateStoreWrkFile(); // 组托 @@ -89,7 +83,6 @@ mainService.storeFinishedTwo(); } // // 异常信息记录 // mainService.recErr(); // 入库 ===>> 空栈板初始化入库 @@ -103,6 +96,23 @@ // 其他 ===>> LED显示器复位,显示默认信息 mainService.ledReset(); mainService.signTrunBig(); } catch (Exception e) { e.printStackTrace(); } } } private void jarRun() { while (!Thread.currentThread().isInterrupted()) { try { k++; if (k>5) { k=0; l++; if (l>=3) l=0; } /************************************JAR调度************************************/ mainService.stackingCompletionDriveTray();//分配硫化罐 mainService.stackingCompletionDriveTray2();//分配硫化罐 @@ -123,21 +133,16 @@ mainService.jarChargeGenerate(); /************************************JAR调度************************************/ mainService.signTrunBig(); } catch (Exception e) { e.printStackTrace(); } } }); thread.start(); } @PreDestroy public void shutDown(){ if (thread != null) thread.interrupt(); if (thread2 != null) thread2.interrupt(); } } src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -134,6 +134,9 @@ add(696);add(697);add(698);add(699); }}; private boolean connectDev = false; /** * 条码数量 */ @@ -167,10 +170,85 @@ } } /** * 初始化站点状态 */ private void initSite() { try{ ArrayList<Integer> staNos = getStaNo(); // 站点编号 for (Integer siteId : staNos) { StaProtocol staProtocol = station.get(siteId); if (null == staProtocol) { staProtocol = new StaProtocol(); staProtocol.setSiteId(siteId); station.put(siteId, staProtocol); } staProtocol.setSiteId(siteId); staProtocol.setWorkNo(0); // ID staProtocol.setAutoing(false); // 自动 staProtocol.setLoading(false); // 有物 staProtocol.setInEnable(false); // 可入 staProtocol.setOutEnable(false); // 可出 staProtocol.setEmptyMk(false); // 空板信号 staProtocol.setStaNo(0); // 目标站 if (!staProtocol.isPakMk() && !staProtocol.isLoading()) { staProtocol.setPakMk(true); } } } catch (Exception e){ try{ log.error(e.getMessage()); } catch (Exception e1){ } log.error("初始化站点状态异常"); } } @Override @SuppressWarnings("InfiniteLoopStatement") public void run() { connect(); connectDev = connect(); while(!connectDev){ try { connectDev = this.connect(); Thread.sleep(100); } catch (Exception e){ } } // 启动线程自动重连 new Thread(this::devConnect).start(); new Thread(this::readStatusDev).start(); new Thread(this::writeStatusDev).start(); } private void devConnect() { while (true) { try { Thread.sleep(1000); if(!connectDev){ try { connectDev = this.connect(); Thread.sleep(100); } catch (Exception e){ } } } catch (Exception e) { log.info("dev连接失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); initSite(); // e.printStackTrace(); } } } private void writeStatusDev() { while (true) { try { int step = 1; @@ -181,7 +259,7 @@ switch (step) { // 读数据 case 1: read(); // read(); break; // 写数据 ID+目标站 case 2: @@ -220,10 +298,33 @@ // heartbeat(); Thread.sleep(400); } catch (Exception e) { e.printStackTrace(); // e.printStackTrace(); try{ log.error(e.getMessage()); } catch (Exception e1){ } log.error("DEV数据写入线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); } } } private void readStatusDev() { while (true) { try { Thread.sleep(50); read(); } catch (Exception e) { log.error("Dev数据读取线程异常!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); initSite(); } } } @Override