From a79949e585c6853a871bc04d78ab915db9368c66 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 01 九月 2020 15:31:27 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/LedThread.java | 25 ++++++++++++++++++++++---
src/main/resources/application.yml | 7 ++++++-
src/main/java/com/zy/core/ServerBootstrap.java | 9 +++++++++
3 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/zy/core/ServerBootstrap.java b/src/main/java/com/zy/core/ServerBootstrap.java
index e995d30..57860a6 100644
--- a/src/main/java/com/zy/core/ServerBootstrap.java
+++ b/src/main/java/com/zy/core/ServerBootstrap.java
@@ -8,6 +8,7 @@
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.CrnThread;
import com.zy.core.thread.DevpThread;
+import com.zy.core.thread.LedThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
@@ -88,6 +89,14 @@
// new Thread(barcodeThread).start();
// SlaveConnection.put(SlaveType.Barcode, barcode.getId(), barcodeThread);
// }
+ // 鍒濆鍖朙ED绾跨▼
+ log.info("鍒濆鍖朙ED绾跨▼...................................................");
+ for (Slave led : slaveProperties.getLed()) {
+ LedThread ledThread = new LedThread(led);
+ new Thread(ledThread).start();
+ SlaveConnection.put(SlaveType.Led, led.getId(), ledThread);
+ }
+
}
diff --git a/src/main/java/com/zy/core/thread/LedThread.java b/src/main/java/com/zy/core/thread/LedThread.java
index 849049c..4553f5b 100644
--- a/src/main/java/com/zy/core/thread/LedThread.java
+++ b/src/main/java/com/zy/core/thread/LedThread.java
@@ -19,12 +19,21 @@
public class LedThread implements Runnable, ThreadHandler {
private Slave slave;
+ private Bx5GScreenClient screen;
public LedThread(Slave slave) {
this.slave = slave;
+ try {
+ Bx5GEnv.initial(3000);
+ screen = new Bx5GScreenClient("MyScreen");
+ } catch (Exception e) {
+ e.printStackTrace();
+ log.info("led杩炴帴鏋勯�犲櫒閿欒 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+ }
}
@Override
+ @SuppressWarnings("InfiniteLoopStatement")
public void run() {
connect();
while (true) {
@@ -41,12 +50,23 @@
@Override
public boolean connect() {
- return false;
+ boolean connRes = false;
+ try {
+ connRes = screen.connect(slave.getIp(),slave.getPort());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ if (connRes) {
+ log.info("led杩炴帴鎴愬姛 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+ } else {
+ log.error("led杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+ }
+ return connRes;
}
@Override
public void close() {
-
+ screen.disconnect();
}
@@ -56,7 +76,6 @@
Bx5GScreenClient screen = new Bx5GScreenClient("MyScreen");
// 鍒涘缓screen瀵硅薄锛岀敤浜庡鎺у埗鍣ㄨ繘琛岃闂紝涓插彛妯″紡
// Bx5GScreenRS screen = new Bx5GScreenRS("MyScreen");
-
// 鍦ㄥ鎺у埗鍣ㄤ氦浜掍箣鍓嶏紝闇�瑕佸厛涓庢帶鍒跺櫒寤虹珛杩炴帴
screen.connect("192.168.100.199",5005);
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index c7491af..163893c 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -117,11 +117,16 @@
id: 1
ip: 192.168.2.150
port: 51236
- # LED
+ # LED1
led[0]:
id: 1
ip: 192.168.1.1
port: 8888
+ # LED2
+ led[1]:
+ id: 2
+ ip: 192.168.1.1
+ port: 8888
# 纾呯О
scale[0]:
id: 1
--
Gitblit v1.9.1