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();
|
}
|
|
}
|
}
|