| | |
| | | |
| | | 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.Task; |
| | | import com.zy.core.model.command.LedCommand; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import onbon.bx05.Bx5GEnv; |
| | |
| | | import onbon.bx05.utils.DisplayStyleFactory; |
| | | |
| | | import java.awt.*; |
| | | import java.util.HashSet; |
| | | import java.util.List; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/9/1 |
| | |
| | | |
| | | private Slave slave; |
| | | private Bx5GScreenClient screen; |
| | | private Set<Integer> workNos = new HashSet<>(); |
| | | |
| | | public LedThread(Slave slave) { |
| | | this.slave = slave; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @SuppressWarnings("InfiniteLoopStatement") |
| | | @SuppressWarnings({"InfiniteLoopStatement", "unchecked"}) |
| | | public void run() { |
| | | connect(); |
| | | while (true) { |
| | | try { |
| | | Task task = MessageQueue.poll(SlaveType.Led, slave.getId()); |
| | | if (task != null) { |
| | | switch (task.getStep()) { |
| | | // 写数据 |
| | | case 1: |
| | | write((List<LedCommand>)task.getData()); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | Thread.sleep(500); |
| | | Thread.sleep(3000); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | private void write(List<LedCommand> list) { |
| | | |
| | | for (LedCommand command : list) { |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | public static void main(String[] args) throws Exception { |