From 0cefcbdbd1bcd8db3f4048926adaca7a0bc9e1bf Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <xltys1995>
Date: 星期日, 27 九月 2020 16:24:34 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/BarcodeThread.java | 13 ++++++++++++-
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 6 ++++++
src/main/resources/application.yml | 2 +-
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
index cde91e2..14e9a7c 100644
--- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -107,6 +107,9 @@
// 鑾峰彇鏉$爜鎵弿浠俊鎭�
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
String barcode = barcodeThread.getBarcode();
+ if(!Cools.isEmpty(barcode)) {
+ System.err.println(barcode);
+ }
// 鑾峰彇鍏ュ簱绔欎俊鎭�
DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()).clone();
@@ -178,6 +181,7 @@
// 鍛戒护涓嬪彂鍖� --------------------------------------------------------------------------
+
// 鏇存柊绔欑偣淇℃伅 涓� 涓嬪彂plc鍛戒护
barcodeThread.setBarcode("");
staProtocol.setWorkNo((short) workNo);
@@ -188,6 +192,8 @@
throw new CoolException("鏇存柊plc绔欑偣淇℃伅澶辫触");
}
+
+
} catch (Exception e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
}
diff --git a/src/main/java/com/zy/core/thread/BarcodeThread.java b/src/main/java/com/zy/core/thread/BarcodeThread.java
index 4bc67d7..7c613d7 100644
--- a/src/main/java/com/zy/core/thread/BarcodeThread.java
+++ b/src/main/java/com/zy/core/thread/BarcodeThread.java
@@ -1,5 +1,6 @@
package com.zy.core.thread;
+import com.core.common.Cools;
import com.zy.core.Slave;
import com.zy.core.ThreadHandler;
import lombok.Data;
@@ -41,7 +42,7 @@
if (null != read) {
barcode = new String(read);
}
- Thread.sleep(1000);
+ Thread.sleep(100);
} catch (Exception e) {
e.printStackTrace();
}
@@ -124,6 +125,16 @@
return true;
}
+ public String getBarcode() {
+ if (Cools.isEmpty(barcode)) {
+ return null;
+ } else if("NG".endsWith(barcode)) {
+ return null;
+ } else {
+ return barcode.trim();
+ }
+ }
+
public static void main(String[] args) throws Exception {
BarcodeThread barcodeThread = new BarcodeThread(new Slave());
barcodeThread.getSlave().setIp("192.168.2.150");
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 02fa732..63b7175 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -85,7 +85,7 @@
# 鏉$爜鎵弿浠�
barcode[0]:
id: 1
- ip: 192.168.10.150
+ ip: 192.168.6.150
port: 51236
# 鍙拌溅
car[0]:
--
Gitblit v1.9.1