From 98d2aecd3899b1b8419aca65a4f899b9dc9c5b3a Mon Sep 17 00:00:00 2001 From: 野心家 <1051256694@qq.com> Date: 星期六, 04 十一月 2023 10:02:17 +0800 Subject: [PATCH] 显示器显示拣料全板信息 --- src/main/java/com/zy/core/thread/LedThread.java | 72 ++++++++++++++++++++++++++++------- 1 files changed, 57 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/zy/core/thread/LedThread.java b/src/main/java/com/zy/core/thread/LedThread.java index b3d35a7..9b2d11e 100644 --- a/src/main/java/com/zy/core/thread/LedThread.java +++ b/src/main/java/com/zy/core/thread/LedThread.java @@ -1,6 +1,7 @@ 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; @@ -10,6 +11,7 @@ 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; @@ -28,6 +30,10 @@ @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; @@ -77,28 +83,53 @@ } } - private void write(List<LedCommand> list) { - commandList = list; + private void write(List<LedCommand> list) throws Bx5GException { + if (!connect()) { + return; + } - StringBuilder sb = new StringBuilder(); + 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(); for (LedCommand command : list) { - 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"); + page.newLine(command.getTitle() +"锛�"+command.getWorkNo()+")"); + page.newLine("搴撲綅锛�"+ (command.getIoType() < 100 ? command.getLocNo() : command.getSourceLocNo())); + page.newLine("鐩爣绔欙細"+command.getStaNo()); if (!command.isEmptyMk()) { for (MatDto matDto : command.getMatDtos()) { - 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"); + //鍘绘帀灏忔暟鐐� + 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("\n"); + page.newLine("\n"); } - stringBuffer.delete(0, stringBuffer.length()); - stringBuffer.append(sb.toString()); - errorReset(); + // 璁剧疆瀛椾綋 + 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(); } @@ -120,7 +151,18 @@ @Override public boolean connect() { - return true; + 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; } @Override -- Gitblit v1.9.1