自动化立体仓库 - WCS系统
##
luxiaotao1123
2020-12-29 b062ed974541cd9dcb7648c9fc9b40b617174d79
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.zy.core.thread;
 
import com.zy.core.Slave;
import com.zy.core.ThreadHandler;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
 
import java.io.IOException;
 
/**
 * 台车线程
 * Created by vincent on 2020/8/4
 */
@Data
@Slf4j
public class CarThread implements Runnable, ThreadHandler {
 
    private Slave slave;
 
    public CarThread(Slave slave) {
        this.slave = slave;
    }
 
    @Override
    @SuppressWarnings("InfiniteLoopStatement")
    public void run() {
        connect();
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
 
    @Override
    public boolean connect() {
        try {
        } catch (Exception e) {
            log.error("台车连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            return false;
        }
        return true;
    }
 
    @Override
    public void close() {
    }
 
    public void write(byte[] msg, int len) throws IOException {
    }
 
    public byte[] read(int bufferSize, int timeOut) throws IOException {
        return null;
    }
 
 
    public static void main(String[] args) throws Exception {
        CarThread barcodeThread = new CarThread(new Slave());
        barcodeThread.getSlave().setIp("192.168.2.150");
        barcodeThread.getSlave().setPort(51236);
        boolean connect = barcodeThread.connect();
        System.out.println(connect);
        barcodeThread.write("T".getBytes(), "T".length());
        byte[] read = barcodeThread.read(11, 1000);
        System.out.println(new String(read));
    }
}