| | |
| | | package com.zy.core.thread; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools; |
| | | import com.zy.common.entity.Parameter; |
| | | import com.zy.common.model.MatDto; |
| | | import com.zy.core.Slave; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.ErrMsg; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.LedCommand; |
| | | import lombok.Data; |
| | |
| | | import onbon.bx05.utils.DisplayStyleFactory; |
| | | |
| | | import java.awt.*; |
| | | import java.util.HashSet; |
| | | import java.util.*; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/9/1 |
| | |
| | | private StringBuffer stringBuffer = new StringBuffer(); |
| | | private List<LedCommand> commandList; |
| | | |
| | | private StringBuffer errorMsg = new StringBuffer(); |
| | | // private StringBuffer errorMsg = new StringBuffer(); |
| | | private List<ErrMsg> errorMsg = new ArrayList<>(); |
| | | |
| | | 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()); |
| | |
| | | @Override |
| | | @SuppressWarnings({"InfiniteLoopStatement", "unchecked"}) |
| | | public void run() { |
| | | connect(); |
| | | // connect(); |
| | | close(); |
| | | while (true) { |
| | | try { |
| | |
| | | reset7(); |
| | | break; |
| | | case 5: |
| | | error((String) task.getData()); |
| | | error((ErrMsg)task.getData()); |
| | | break; |
| | | case 6: |
| | | errorReset(); |
| | |
| | | } |
| | | |
| | | |
| | | private void error(String msg) { |
| | | errorMsg.delete(0, errorMsg.length()); |
| | | errorMsg.append(msg); |
| | | private void error(ErrMsg errMsg) { |
| | | // errorMsg.clear(); |
| | | ErrMsg errMsOld = null; |
| | | for (ErrMsg errMsg1 : errorMsg){ |
| | | if (errMsg1.getId()==1){ |
| | | errMsOld = errMsg1; |
| | | } |
| | | errMsg1.setId(errMsg1.getId()-1); |
| | | } |
| | | if (errMsOld != null){ |
| | | errorMsg.remove(errMsOld); |
| | | } |
| | | errMsg.setId(errMsg.getIdCode()); |
| | | errorMsg.add(errMsg); |
| | | } |
| | | |
| | | public void errorReset() { |
| | | this.errorMsg.delete(0, errorMsg.length()); |
| | | this.errorMsg.clear(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void close() { |
| | | screen.disconnect(); |
| | | // screen.disconnect(); |
| | | } |
| | | |
| | | |