| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.utils.News; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.MatDto; |
| | | import com.zy.core.Slave; |
| | |
| | | // screen = new Bx5GScreenClient("my"); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.info("led连接构造器错误 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | News.info("Led"+" - 1"+" - led连接构造器错误 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); |
| | | } |
| | | } |
| | | |
| | |
| | | @SuppressWarnings({"InfiniteLoopStatement", "unchecked"}) |
| | | public void run() { |
| | | // connect(); |
| | | // close(); |
| | | close(); |
| | | while (true) { |
| | | try { |
| | | Task task = MessageQueue.poll(SlaveType.Led, slave.getId()); |
| | |
| | | // 写数据 |
| | | case 1: |
| | | write((List<LedCommand>)task.getData()); |
| | | break; |
| | | // 写数据 |
| | | case 9: |
| | | write9((List<LedCommand>)task.getData()); |
| | | break; |
| | | // 复位 |
| | | case 2: |
| | |
| | | if(idx >= 0){ |
| | | strQty.substring(0,idx); |
| | | } |
| | | page.newLine(matDto.getMaknx() + "[数量" + strQty +"]"); |
| | | page.newLine(matDto.getMaktx() + "[数量" + strQty +"]"); |
| | | // page.newLine(matDto.getMaknx() + "【数量" + matDto.getCount() +"】"); |
| | | } |
| | | } |
| | |
| | | area.addPage(page); |
| | | pf.addArea(area); |
| | | if (pf.validate() != null) { |
| | | log.info("pf out of range"); |
| | | } else { |
| | | // 更新节目 |
| | | screen.writeProgram(pf); |
| | | // resetStatus = false; |
| | | } |
| | | close(); |
| | | } |
| | | |
| | | private void write9(List<LedCommand> list) throws Bx5GException { |
| | | if (!connect()) { |
| | | return; |
| | | } |
| | | pf = new ProgramBxFile( 0, screen.getProfile()); |
| | | pf.setFrameShow(false); |
| | | // 分别输入X,Y,width,height |
| | | area = new TextCaptionBxArea( 0,0,96,48, screen.getProfile()); |
| | | // 创建一个数据页 |
| | | TextBxPage page = new TextBxPage(); |
| | | for (LedCommand command : list) { |
| | | page.newLine(command.getTitle()); |
| | | page.newLine("\n"); |
| | | } |
| | | |
| | | // 设置字体 |
| | | 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) { |
| | | log.info("pf out of range"); |
| | | News.info("Led"+" - 2"+" - pf out of range"); |
| | | } else { |
| | | // 更新节目 |
| | | screen.writeProgram(pf); |
| | |
| | | pf.addArea(area); |
| | | // 更新节目 |
| | | if (pf.validate() != null) { |
| | | log.info("pf out of range"); |
| | | News.info("Led"+" - 3"+" - pf out of range"); |
| | | } else { |
| | | // 更新节目 |
| | | screen.writeProgram(pf); |
| | |
| | | } |
| | | close(); |
| | | } |
| | | |
| | | private void write7(List<LedCommand> list) { |
| | | commandList = list; |
| | | |
| | |
| | | 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"); |
| | | sb.append("图号:").append(matDto.getModel()).append("\n"); |
| | | } |
| | | } |
| | | sb.append("\n"); |
| | |
| | | @Override |
| | | public boolean connect() { |
| | | boolean connRes = false; |
| | | // try { |
| | | // connRes = screen.connect(slave.getIp(),slave.getPort()); |
| | | // screen.turnOn(); |
| | | // } catch (Exception ignore) { |
| | | // } |
| | | // 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()); |
| | | // } |
| | | 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 |
| | | public void close() { |
| | | // screen.disconnect(); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | // 更新节目 |
| | | if (pf.validate() != null) { |
| | | System.out.println("pf out of range"); |
| | | log.info("pf out of range"); |
| | | News.info("Led"+" - 6"+" - pf out of range"); |
| | | } else { |
| | | // 更新节目 |
| | | screen.writeProgram(pf); |
| | |
| | | // 继开与控制器之间的链接 |
| | | // screen.disconnect(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public static void main1(String[] args) throws Exception { |