package com.mes.common.PlcTools;
|
|
import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType;
|
import com.github.xingshuangs.iot.protocol.s7.service.S7PLC;
|
|
public class S7object2 {
|
public S7control plccontrol; // PLC通讯类实例
|
private EPlcType plcType = EPlcType.S1500; // 西门子PLC类型
|
private String ip = "192.168.10.2"; // plc ip地址
|
private int port = 102; // plc 端口号
|
|
private static volatile S7object2 instance = null;
|
|
private S7object2() {
|
if (plccontrol == null)
|
plccontrol = new S7control(plcType, ip, port,0,0);
|
}
|
|
// 单例模式 获取类的唯一实例
|
public static S7object2 getinstance() {
|
if (instance == null) {
|
synchronized (S7object2.class) {
|
if (instance == null)
|
instance = new S7object2();
|
}
|
}
|
return instance;
|
}
|
}
|