zhoushihao
2024-05-09 c0505074f5149b7f0c7fe26822e793eac18319f3
hangzhoumesParent/moduleService/LoadGlassModule/src/main/java/com/mes/common/S7object.java
@@ -8,29 +8,29 @@
 * @Date: 2024/4/9 15:13
 * @Description:
 */
public class S7object {
    public S7control plccontrol; // PLC通讯类实例
    private EPlcType plcType = EPlcType.S1500; // 西门子PLC类型
    private String ip = "192.168.10.1"; // plc ip地址
    private int port = 102; // plc 端口号
    private static volatile S7object instance = null;
    private S7object() {
        if (plccontrol == null) {
            plccontrol = new S7control(plcType, ip, port, 0, 0);
        }
    }
    // 单例模式 获取类的唯一实例
    public static S7object getinstance() {
        if (instance == null) {
            synchronized (S7object.class) {
                if (instance == null) {
                    instance = new S7object();
                }
            }
        }
        return instance;
    }
}
//public class S7object {
//    public S7control plccontrol; // PLC通讯类实例
//    private EPlcType plcType = EPlcType.S1500; // 西门子PLC类型
//    private String ip = "192.168.10.1"; // plc ip地址
//    private int port = 102; // plc 端口号
//
//    private static volatile S7object instance = null;
//
//    private S7object() {
//        if (plccontrol == null) {
//            plccontrol = new S7control(plcType, ip, port, 0, 0);
//        }
//    }
//
//    // 单例模式 获取类的唯一实例
//    public static S7object getinstance() {
//        if (instance == null) {
//            synchronized (S7object.class) {
//                if (instance == null) {
//                    instance = new S7object();
//                }
//            }
//        }
//        return instance;
//    }
//}