From 433040dfff973bc8e502a00b2f1bee2e929fdf70 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期六, 16 一月 2021 16:01:10 +0800 Subject: [PATCH] #堆垛机异常 --- src/main/java/com/zy/core/thread/LedThread.java | 102 ++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 77 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/zy/core/thread/LedThread.java b/src/main/java/com/zy/core/thread/LedThread.java index 0384e64..9c57985 100644 --- a/src/main/java/com/zy/core/thread/LedThread.java +++ b/src/main/java/com/zy/core/thread/LedThread.java @@ -37,6 +37,10 @@ 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; @@ -44,10 +48,6 @@ Bx5GEnv.initial(3000); 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(); } @@ -101,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