From 8076a2a7abb05b4f49544bd95a6083bae0048023 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 13 一月 2021 15:19:38 +0800
Subject: [PATCH] #test
---
src/main/java/com/zy/core/thread/LedThread.java | 107 +++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 79 insertions(+), 28 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/LedThread.java b/src/main/java/com/zy/core/thread/LedThread.java
index 32baf97..9c57985 100644
--- a/src/main/java/com/zy/core/thread/LedThread.java
+++ b/src/main/java/com/zy/core/thread/LedThread.java
@@ -37,17 +37,17 @@
TextCaptionBxArea area;
DisplayStyleFactory.DisplayStyle[] styles = DisplayStyleFactory.getStyles().toArray(new DisplayStyleFactory.DisplayStyle[0]);
private Set<Integer> workNos = new HashSet<>();
+ private boolean resetStatus = false; // 澶嶄綅鐘舵��
+
+ // 鏄剧ず鍣�
+ private StringBuffer stringBuffer = new StringBuffer();
public LedThread(Slave slave) {
this.slave = slave;
try {
Bx5GEnv.initial(3000);
- screen = new Bx5GScreenClient("MyScreen");
+ screen = new Bx5GScreenClient("my");
screen.turnOn();
- pf = new ProgramBxFile( 0, screen.getProfile());
- pf.setFrameShow(false);
- // 鍒嗗埆杈撳叆X锛孻锛寃idth锛宧eight
- area = new TextCaptionBxArea( 0,0,192,128,screen.getProfile());
} catch (Exception e) {
e.printStackTrace();
log.info("led杩炴帴鏋勯�犲櫒閿欒 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
@@ -57,7 +57,7 @@
@Override
@SuppressWarnings({"InfiniteLoopStatement", "unchecked"})
public void run() {
- connect();
+// connect();
while (true) {
try {
Task task = MessageQueue.poll(SlaveType.Led, slave.getId());
@@ -67,12 +67,16 @@
case 1:
write((List<LedCommand>)task.getData());
break;
+ // 澶嶄綅
+ case 2:
+ reset();
+ break;
default:
break;
}
}
- Thread.sleep(3000);
+ Thread.sleep(1000);
} catch (Exception e) {
e.printStackTrace();
}
@@ -84,8 +88,7 @@
boolean connRes = false;
try {
connRes = screen.connect(slave.getIp(),slave.getPort());
- } catch (Exception e) {
- e.printStackTrace();
+ } catch (Exception ignore) {
}
if (connRes) {
log.info("led杩炴帴鎴愬姛 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
@@ -102,29 +105,77 @@
private void write(List<LedCommand> list) throws Bx5GException {
- // 鍒涘缓涓�涓暟鎹〉
- TextBxPage page = new TextBxPage();
- for (LedCommand command : list) {
- page.newLine("鍑哄簱浠诲姟锛�"+command.getWorkNo()+")");
- page.newLine("婧愬簱浣嶏細"+command.getSourceLocNo());
- page.newLine("鐩爣绔欙細"+command.getStaNo());
- for (MatDto matDto : command.getMatDtos()) {
- page.newLine(matDto.getMaknx() + "銆愭暟閲�" + matDto.getCount() +"銆�");
- }
- page.newLine("\n");
- }
+// pf = new ProgramBxFile( 0, screen.getProfile());
+// pf.setFrameShow(false);
+// // 鍒嗗埆杈撳叆X锛孻锛寃idth锛宧eight
+// area = new TextCaptionBxArea( 0,0,192,128,screen.getProfile());
+// // 鍒涘缓涓�涓暟鎹〉
+// TextBxPage page = new TextBxPage();
+// for (LedCommand command : list) {
+// page.newLine(command.getTitle() +"锛�"+command.getWorkNo()+")");
+// page.newLine("婧愬簱浣嶏細"+command.getSourceLocNo());
+// page.newLine("鐩爣绔欙細"+command.getStaNo());
+// if (!command.isEmptyMk()) {
+// for (MatDto matDto : command.getMatDtos()) {
+// page.newLine(matDto.getMaknx() + "銆愭暟閲�" + matDto.getCount() +"銆�");
+// }
+// }
+// page.newLine("\n");
+// }
+//
+// // 璁剧疆瀛椾綋
+// page.setFont(new Font("瀹嬩綋",Font.PLAIN,12));
+// // 璁剧疆鏄剧ず鐗规妧涓哄揩閫熸墦鍑�
+// page.setDisplayStyle(styles[6]);
+// area.clearPages();
+// area.addPage(page);
+// pf.addArea(area);
+// // 鏇存柊鑺傜洰
+// screen.writeProgram(pf);
+// resetStatus = false;
- // 璁剧疆瀛椾綋
- page.setFont(new Font("瀹嬩綋",Font.PLAIN,12));
- // 璁剧疆鏄剧ず鐗规妧涓哄揩閫熸墦鍑�
- page.setDisplayStyle(styles[6]);
- area.addPage(page);
- pf.addArea(area);
- // 鏇存柊鑺傜洰
- screen.writeProgram(pf);
+ StringBuilder sb = new StringBuilder();
+ for (LedCommand command : list) {
+ sb.append(command.getTitle() +"锛�"+command.getWorkNo()+")").append("\n");
+ sb.append("婧愬簱浣嶏細"+command.getSourceLocNo()).append("\n");
+ sb.append("鐩爣绔欙細"+command.getStaNo()).append("\n");
+ if (!command.isEmptyMk()) {
+ for (MatDto matDto : command.getMatDtos()) {
+ sb.append(matDto.getMaknx() + "銆愭暟閲�" + matDto.getCount() +"銆�").append("\n");
+ }
+ }
+ sb.append("\n");
+ }
+ stringBuffer.delete(0, stringBuffer.length());
+ stringBuffer.append(sb.toString());
+ resetStatus = false;
}
+ private void reset() throws Bx5GException {
+ if (!resetStatus) {
+// pf = new ProgramBxFile( 0, screen.getProfile());
+// pf.setFrameShow(false);
+// // 鍒嗗埆杈撳叆X锛孻锛寃idth锛宧eight
+// area = new TextCaptionBxArea( 0,0,192,128,screen.getProfile());
+// // 鍒涘缓涓�涓暟鎹〉
+// TextBxPage page = new TextBxPage();
+// page.newLine("骞垮痉涓壃鐗╂祦瑁呭鏈夐檺鍏徃");
+// page.newLine("鑷姩鍖栫珛浣撲粨搴�");
+// page.newLine("娴欐睙涓壃鐗╂祦瑁呭鏈夐檺鍏徃");
+// // 璁剧疆瀛椾綋
+// page.setFont(new Font("瀹嬩綋",Font.PLAIN,12));
+// // 璁剧疆鏄剧ず鐗规妧涓哄揩閫熸墦鍑�
+// page.setDisplayStyle(styles[6]);
+// area.clearPages();
+// area.addPage(page);
+// pf.addArea(area);
+// // 鏇存柊鑺傜洰
+// screen.writeProgram(pf);
+ stringBuffer.delete(0, stringBuffer.length());
+ resetStatus = true;
+ }
+ }
public static void main(String[] args) throws Exception {
--
Gitblit v1.9.1