cl
2024-01-19 e0fac38b26845f25de479783e0c76cf12a5311e0
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package cn.stylefeng.guns.plcserver.tool;
 
import java.io.IOException;
import java.util.Properties;
 
public class ResourceUtil {
 
 
    //是否开启上层MES接口
    public static String MES_TERMINATED;
    //是否开启PLC采集
    public static String PLC_TERMINATED;
 
 
    //消费者变量
    public static String CONSUMER_ZOOKEEPER_CONNECT;
    public static String CONSUMER_SERVERS;
    public static String CONSUMER_ENABLE_AUTO_COMMIT;
    public static String CONSUMER_SESSION_TIMEOUT;
    public static String CONSUMER_AUTO_COMMIT_INTERVAL;
    public static String CONSUMER_AUTO_OFFSET_RESET;
    public static String CONSUMER_GROUP_ID;
    public static String CONSUMER_CONCURRENCY;
 
    //生产者变量
    public static String PRODUCER_SERVERS;
    public static String PRODUCER_RETRIES;
    public static String PRODUCER_BATCH_SIZE;
    public static String PRODUCER_LINGER;
    public static String PRODUCER_BUFFER_MEMORY;
 
    //定义接收频率
    public static int  RECEIVE_WORK_ORDER_TIME;
    public static int  RECEIVE_PRODUCTION_LINE_CMD_TIME;
 
    //定义发送频率
    public static int  SEND_PRODUCTION_REPORT_TIME;
    public static int  SEND_PRODUCTION_RESULT_TIME;
    public static int  SEND_PRODUCTION_LINE_STATUS_TIME;
    public static int  SEND_PRODUCTION_LINE_CMD_RES_TIME;
    public static int  SEND_EQUIPMENT_STATUS_TIME;
    public static int  SEND_EQUIPMENT_ALARM_TIME;
    public static int  SEND_TAKT_TIME_TIME;
 
 
    public void readFile(){
        try{
            Properties prop = new Properties();
            prop.load(this.getClass().getResourceAsStream("/kafka.properties"));
 
            //是否开启上层MES接口
            MES_TERMINATED = prop.getProperty("kafka.mes.terminated");
            //是否开启PLC采集
            PLC_TERMINATED = prop.getProperty("plc.terminated");
 
            //消费者变量
            CONSUMER_ZOOKEEPER_CONNECT = prop.getProperty("kafka.consumer.zookeeper.connect");
            CONSUMER_SERVERS = prop.getProperty("kafka.consumer.servers");
            CONSUMER_ENABLE_AUTO_COMMIT = prop.getProperty("kafka.consumer.enable.auto.commit");
            CONSUMER_SESSION_TIMEOUT = prop.getProperty("kafka.consumer.session.timeout");
            CONSUMER_AUTO_COMMIT_INTERVAL = prop.getProperty("kafka.consumer.auto.commit.interval");
            CONSUMER_AUTO_OFFSET_RESET = prop.getProperty("kafka.consumer.auto.offset.reset");
            CONSUMER_GROUP_ID = prop.getProperty("kafka.consumer.group.id");
            CONSUMER_CONCURRENCY = prop.getProperty("kafka.consumer.concurrency");
 
            //生产者变量
            PRODUCER_SERVERS = prop.getProperty("kafka.producer.servers");
            PRODUCER_RETRIES = prop.getProperty("kafka.producer.retries");
            PRODUCER_BATCH_SIZE = prop.getProperty("kafka.producer.batch.size");
            PRODUCER_LINGER = prop.getProperty("kafka.producer.linger");
            PRODUCER_BUFFER_MEMORY = prop.getProperty("kafka.producer.buffer.memory");
 
            //接收时间
            RECEIVE_WORK_ORDER_TIME = Integer.parseInt(prop.getProperty("receive.work.order.time"));
            RECEIVE_PRODUCTION_LINE_CMD_TIME = Integer.parseInt(prop.getProperty("receive.production.line.cmd.time"));
 
            //发送时间
            SEND_PRODUCTION_REPORT_TIME = Integer.parseInt(prop.getProperty("send.production.report.time"));
            SEND_PRODUCTION_RESULT_TIME = Integer.parseInt(prop.getProperty("send.production.result.time"));
            SEND_PRODUCTION_LINE_STATUS_TIME = Integer.parseInt(prop.getProperty("send.production.line.status.time"));
            SEND_PRODUCTION_LINE_CMD_RES_TIME = Integer.parseInt(prop.getProperty("send.production.line.cmd.res.time"));
            SEND_EQUIPMENT_STATUS_TIME = Integer.parseInt(prop.getProperty("send.equipment.status.time"));
            SEND_EQUIPMENT_ALARM_TIME = Integer.parseInt(prop.getProperty("send.equipment.alarm.time"));
            SEND_TAKT_TIME_TIME = Integer.parseInt(prop.getProperty("send.takt.time.time"));
 
            System.out.println("成功读取配置文件!");
        }catch (IOException e){
            e.printStackTrace();
        }
 
    }
}