懒羊羊
2024-01-11 be26d5065b4a07123638c220c0792e9250a458e6
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package cn.stylefeng.guns.plcserver.opc.conf;
 
import org.openscada.opc.lib.common.ConnectionInformation;
 
public final class OPCConfiguration {
 
    private final static ConnectionInformation ci;
    private static String HOST = "172.20.1.10";
    //private static String HOST = "192.168.1.100";
    private static String USER = "OPCServer";
    private static String PASSWORD = "admin@123";
    private static String CLSID= "7BC0CC8E-482C-47CA-ABDC-0FE7F9C6E729";
    private static String PROGID = "";
 
    /*public final static String CONFIG_USERNAME = "username";
    public final static String CONFIG_PASSWORD = "password";
    public final static String CONFIG_HOST = "host";
    public final static String CONFIG_DOMAIN = "domain";
    public final static String CONFIG_CLSID = "clsid";
    public final static String CONFIG_PROGID = "progid";
    private final static String CONFIG_FILE_NAME = "opc.properties";*/
    /**
     * 加载配置文件
     */
    static {
        ci = new ConnectionInformation();
        /*prop = new Properties();
        try {
            prop.load(OPCConfiguration.class.getClassLoader().getResourceAsStream(CONFIG_FILE_NAME));
        } catch (IOException e) {
            e.printStackTrace();
        }*/
    }
    /**
     * 通过名字获得配置的值
     */
    /*public static String getEntryValue(String name) {
        return prop.getProperty(name);
    }*/
    /**
     * 获得包含ClsId的连接信息
     */
    public static ConnectionInformation getCLSIDConnectionInfomation() {
        ci.setProgId(null);
        getConnectionInfomation();
        ci.setClsid(CLSID);
        return ci;
    }
    /**
     * 获得包含ProgId的连接信息
     */
    public static ConnectionInformation getPROGIDConnectionInfomation() {
        ci.setClsid(null);
        getConnectionInfomation();
        ci.setProgId(PROGID);
        return ci;
    }
    /**
     * 获得基础的连接信息
     */
    private static void getConnectionInfomation() {
        ci.setHost(HOST);
        ci.setDomain("");
        ci.setUser(USER);
        ci.setPassword(PASSWORD);
    }
}