野心家
2025-05-08 b427e1d0102d4b3b4263c7c6e572f29f9c50bef9
src/main/java/com/zy/core/thread/LedThread.java
@@ -2,6 +2,7 @@
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;
@@ -52,18 +53,18 @@
    public LedThread(Slave slave) {
        this.slave = slave;
        try {
            Bx5GEnv.initial(3000);
            screen = new Bx5GScreenClient("my");
//            Bx5GEnv.initial(3000);
//            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());
        }
    }
    @Override
    @SuppressWarnings({"InfiniteLoopStatement", "unchecked"})
    public void run() {
        connect();
//        connect();
        close();
        while (true) {
            try {
@@ -126,7 +127,7 @@
                    if(idx >= 0){
                        strQty.substring(0,idx);
                    }
                    page.newLine(matDto.getMaknx() + "[数量" + strQty +"]");
                    page.newLine(matDto.getMaktx() + "[数量" + strQty +"]");
//                    page.newLine(matDto.getMaknx() + "【数量" + matDto.getCount() +"】");
                }
            }
@@ -143,7 +144,7 @@
        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);
@@ -193,7 +194,7 @@
        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);
@@ -201,6 +202,7 @@
        }
        close();
    }
    private void write7(List<LedCommand> list) {
        commandList = list;
@@ -211,8 +213,9 @@
            sb.append("目标站:").append(command.getStaNo()).append("\n");
            if (!command.isEmptyMk()) {
                for (MatDto matDto : command.getMatDtos()) {
                    sb.append("物料编码:").append(matDto.getMatNo()).append("\n");
                    sb.append("物料编码:").append(matDto.getMatnr()).append("\n");
                    sb.append("数量:").append(matDto.getCount()).append("\n");
                    sb.append("规格:").append(matDto.getSpecs()).append("\n");
                }
            }
            sb.append("\n");
@@ -249,16 +252,16 @@
        } catch (Exception ignore) {
        }
        if (connRes) {
            log.info("led连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.info("Led"+" - 4"+" - led连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
        } else {
            log.error("led连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.error("Led"+" - 5"+" - led连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
        }
        return connRes;
    }
    @Override
    public void close() {
        screen.disconnect();
    }
@@ -308,7 +311,7 @@
            // 更新节目
            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);
@@ -318,36 +321,6 @@
        // 继开与控制器之间的链接
//        screen.disconnect();
    }
    public static void main1(String[] args) throws Exception {