ZengTao
2024-04-29 91e4ba507f9806c975a4273154d79f1a43b836c4
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
package com.mes.common;
 
 
import java.io.IOException;
 
import static com.mes.common.InitUtil.readAndUpdateWordValues;
 
public class PLCAutoMes extends Thread {
 
    private static InitUtil initUtil;
 
    // 单例实例
    private static PLCAutoMes instance;
    private static String PlcAlbania = PLCAutoMes.class.getResource("/JsonFile/PlcAlbania.json").getPath();
 
 
 
    public static PlcParameterObject PlcMesObject = InitUtil.initword(PlcAlbania);
 
    // 私有构造函数
    public PLCAutoMes() throws IOException {
        initUtil = new InitUtil();
    }
 
    // 获取单例实例
    public static synchronized PLCAutoMes getInstance() throws IOException {
        if (instance == null) {
            instance = new PLCAutoMes();
        }
        return instance;
    }
 
    @Override
    public void run() {
        while (this != null) {
            try {
                Thread.sleep(100);
 
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
 
            readAndUpdateWordValues(PlcMesObject);
 
 
        }
    }
}