From 95fdea913ed121e48bd6e51b84e7bb58404da176 Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期六, 04 十一月 2023 13:27:00 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/LedThread.java | 72 +++++++---------------------------- 1 files changed, 15 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/zy/core/thread/LedThread.java b/src/main/java/com/zy/core/thread/LedThread.java index 9b2d11e..b3d35a7 100644 --- a/src/main/java/com/zy/core/thread/LedThread.java +++ b/src/main/java/com/zy/core/thread/LedThread.java @@ -1,7 +1,6 @@ package com.zy.core.thread; import com.zy.common.model.MatDto; -import com.zy.common.utils.News; import com.zy.core.Slave; import com.zy.core.ThreadHandler; import com.zy.core.cache.MessageQueue; @@ -11,7 +10,6 @@ import lombok.Data; import lombok.extern.slf4j.Slf4j; import onbon.bx05.Bx5GEnv; -import onbon.bx05.Bx5GException; import onbon.bx05.Bx5GScreenClient; import onbon.bx05.area.TextCaptionBxArea; import onbon.bx05.area.page.TextBxPage; @@ -30,10 +28,6 @@ @Slf4j public class LedThread implements Runnable, ThreadHandler { - private Bx5GScreenClient screen; - private ProgramBxFile pf; - private TextCaptionBxArea area; - DisplayStyleFactory.DisplayStyle[] styles = DisplayStyleFactory.getStyles().toArray(new DisplayStyleFactory.DisplayStyle[0]); private Slave slave; private Set<Integer> workNos = new HashSet<>(); private boolean ledMk = false; @@ -83,53 +77,28 @@ } } - private void write(List<LedCommand> list) throws Bx5GException { - if (!connect()) { - return; - } + private void write(List<LedCommand> list) { + commandList = list; - pf = new ProgramBxFile( 0, screen.getProfile()); - pf.setFrameShow(false); - // 鍒嗗埆杈撳叆X锛孻锛寃idth锛宧eight - area = new TextCaptionBxArea( 0,0,96,48, screen.getProfile()); - // 鍒涘缓涓�涓暟鎹〉 - TextBxPage page = new TextBxPage(); + StringBuilder sb = new StringBuilder(); for (LedCommand command : list) { - page.newLine(command.getTitle() +"锛�"+command.getWorkNo()+")"); - page.newLine("搴撲綅锛�"+ (command.getIoType() < 100 ? command.getLocNo() : command.getSourceLocNo())); - page.newLine("鐩爣绔欙細"+command.getStaNo()); + sb.append(command.getTitle()).append("锛�").append(command.getWorkNo()).append(")").append("\n"); + sb.append("婧愬簱浣嶏細").append(command.getSourceLocNo()).append("\n"); + sb.append("鐩爣绔欙細").append(command.getStaNo()).append("\n"); if (!command.isEmptyMk()) { for (MatDto matDto : command.getMatDtos()) { - //鍘绘帀灏忔暟鐐� - String strQty = matDto.getCount().toString(); - int idx = strQty.lastIndexOf("."); - if(idx >= 0){ - strQty.substring(0,idx); - } - page.newLine(matDto.getMaknx() + "[鏁伴噺" + strQty +"]"); -// page.newLine(matDto.getMaknx() + "銆愭暟閲�" + matDto.getCount() +"銆�"); + sb.append("鐗╂枡缂栫爜锛�").append(matDto.getMatnr()).append("\n"); + sb.append("鍚嶇О锛�").append(matDto.getMaknx()).append("\n"); + sb.append("鏁伴噺锛�").append(matDto.getCount()).append("\n"); + sb.append("瑙勬牸锛�").append(matDto.getSpecs()).append("\n"); } } - page.newLine("\n"); + sb.append("\n"); } + stringBuffer.delete(0, stringBuffer.length()); + stringBuffer.append(sb.toString()); - // 璁剧疆瀛椾綋 - page.setFont(new Font("瀹嬩綋",Font.PLAIN,12)); - // 璁剧疆鏂囨湰棰滆壊 - page.setForeground(Color.red); - // 璁剧疆鏄剧ず鐗规妧涓哄揩閫熸墦鍑� - page.setDisplayStyle(styles[6]); - area.clearPages(); - area.addPage(page); - pf.addArea(area); - if (pf.validate() != null) { - News.info("Led"+" - 2"+" - pf out of range"); - } else { - // 鏇存柊鑺傜洰 - screen.writeProgram(pf); -// resetStatus = false; - } - close(); + errorReset(); } @@ -151,18 +120,7 @@ @Override public boolean connect() { - boolean connRes = false; - try { - connRes = screen.connect(slave.getIp(),slave.getPort()); - screen.turnOn(); - } catch (Exception ignore) { - } - if (connRes) { - News.info("Led"+" - 4"+" - led杩炴帴鎴愬姛 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); - } else { - News.error("Led"+" - 5"+" - led杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); - } - return connRes; + return true; } @Override -- Gitblit v1.9.1