package com.mes.common;
|
|
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
|
import java.io.IOException;
|
|
import static com.mes.common.InitUtil.readAndUpdateWordValues;
|
|
public class PLCAutoMes extends Thread {
|
|
private static final Logger log = LoggerFactory.getLogger(PLCAutoMes.class);
|
private static InitUtil initUtil;
|
|
// 单例实例
|
private static PLCAutoMes instance;
|
private static String PlcAlbania;
|
|
|
|
public static PlcParameterObject PlcMesObject;
|
|
// 私有构造函数
|
public PLCAutoMes() throws IOException {
|
PlcAlbania="D:\\SQL\\PlcCacheGlass.json";
|
// PlcAlbania=PLCAutoMes.class.getResource("/JsonFile/PlcCacheGlass.json").getPath();
|
//log.info(PLCAutoMes.class.getResource("").getPath());
|
PlcMesObject = InitUtil.initword(PlcAlbania);
|
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);
|
|
|
}
|
}
|
}
|