package com.example.springboot.component;
|
|
import com.example.springboot.entity.device.PlcBitObject;
|
import com.example.springboot.entity.device.PlcParameterObject;
|
|
import java.io.IOException;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import static com.example.springboot.component.InitUtil.readAndUpdateBitValues;
|
import static com.example.springboot.component.InitUtil.readAndUpdateWordValues;
|
|
public class PLCAutoMes extends Thread {
|
|
// 用于存储应用程序的配置信息
|
|
private static InitUtil initUtil;
|
// public static PlcParameterObject PlcMesObject;
|
// public static PlcParameterObject PlcReadObject;
|
// public static PlcParameterObject PlcframeObject;
|
|
// 创建一个自定义的 S7 控制器消息处理器对象
|
MessageHandler customS7Control = new MessageHandler();
|
|
// 单例实例
|
private static PLCAutoMes instance;
|
private static String PlcAlbania ="D:/Code/Albania_Mes/PlcAlbania.json";
|
// PLCAutoMes.class.getResource("/JsonFile/PlcAlbania.json").getPath();
|
public static PlcParameterObject PlcMesObject = initUtil.initword(PlcAlbania);
|
|
// 私有构造函数
|
public PLCAutoMes() throws IOException {
|
//config = new Configuration("config.properties");
|
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();
|
}
|
//List<Short> ss=S7control.getinstance().ReadWord("DB14.0", 1);
|
readAndUpdateWordValues(PlcMesObject);
|
|
}
|
}
|
}
|