|
|
/****************************************************************************
|
|
|
** File name : HTConfig.h
|
|
|
** Description : config parameter
|
|
|
** Create date : 2018.09.01
|
|
|
** Auther by : Liuyx
|
|
|
** Version info : V1.0.01
|
|
|
** Copyright (C) 2002-2018 xi'an huatek, Inc Co., Ltd
|
|
|
** Update record:
|
|
|
** DATE AUTHER DESC
|
|
|
** -------------------------------------------------------------------------
|
|
|
** 2018.09.01 Liuyx first build
|
|
|
****************************************************************************/
|
|
|
#ifndef __HT_CONFIG_H
|
|
|
#define __HT_CONFIG_H
|
|
|
#include <stdio.h>
|
|
|
#include <stdlib.h>
|
|
|
#include <string.h>
|
|
|
#include <list>
|
|
|
// 配置文件路径
|
|
|
#ifdef _WIN32
|
|
|
static const char HT_CONFIG_FILE[] = ".\\etc\\htiecsvr.conf";
|
|
|
#else
|
|
|
static const char HT_CONFIG_FILE[] = "../etc/htiecsvr.conf" ;
|
|
|
#endif
|
|
|
#pragma pack (push ,1)
|
|
|
#define HT_MAX_IED_COUNT 8 // 最大IED数量
|
|
|
typedef struct
|
|
|
{
|
|
|
char IedAddr[32];
|
|
|
int port;
|
|
|
}ST_IED_ADDR;
|
|
|
#pragma pack (pop)
|
|
|
|
|
|
class TConfig
|
|
|
{
|
|
|
public:
|
|
|
TConfig();
|
|
|
virtual ~TConfig();
|
|
|
|
|
|
static TConfig *getInstance();
|
|
|
|
|
|
// 读取配置文件参数
|
|
|
bool getIniConfig();
|
|
|
void showConfig();
|
|
|
|
|
|
// 设置本地服务器IP
|
|
|
void setLocalAddr(char *pszAddr);
|
|
|
|
|
|
// 获取本地服务器IP
|
|
|
char *getLocalAddr();
|
|
|
|
|
|
// 设置本地服务器端口
|
|
|
void setLocalPort(unsigned short iPort);
|
|
|
|
|
|
// 获取本地服务器端口
|
|
|
unsigned short getLocalPort();
|
|
|
|
|
|
|
|
|
// 设置远程服务器IP
|
|
|
void setRemoteAddr(char *pszAddr);
|
|
|
|
|
|
// 获取远程服务器IP
|
|
|
char *getRemoteAddr();
|
|
|
|
|
|
// 设置远程服务器端口
|
|
|
void setRemotePort(unsigned short iPort);
|
|
|
|
|
|
// 获取远程服务器端口
|
|
|
unsigned short getRemotePort();
|
|
|
|
|
|
|
|
|
void setRecvThreadNumber(unsigned int n) ; // 接收线程数
|
|
|
void setParseThreadNumber(unsigned int n) ; // 解析104线程数
|
|
|
void setOprationThreadNumber(unsigned int n) ; // 入库线程数
|
|
|
void setResponeThreadNumber(unsigned int n) ; // 应答线程数
|
|
|
|
|
|
unsigned int getRecvThreadNumber() ; // 接收线程数
|
|
|
unsigned int getParseThreadNumber() ; // 解析104线程数
|
|
|
unsigned int getOprationThreadNumber() ; // 入库线程数
|
|
|
unsigned int getResponeThreadNumber() ; // 应答线程数
|
|
|
|
|
|
|
|
|
// 配置数据库配置参数接口
|
|
|
unsigned int getdbPort() ;
|
|
|
unsigned int getdbMaxConnect();
|
|
|
unsigned int getdbMinConnect() ;
|
|
|
char *getdbHostIP() ;
|
|
|
char *getdbName() ;
|
|
|
char *getdbUserName() ;
|
|
|
char *getdbUserPass() ;
|
|
|
|
|
|
void setdbPort(unsigned int port);
|
|
|
void setdbMaxConnect(unsigned int max);
|
|
|
void setdbMinConnect(unsigned int min);
|
|
|
void setdbHostIP(char *pszDBHostIP);
|
|
|
void setdbName(char *pszDBName);
|
|
|
void setdbUserName(char *pszDBUserName);
|
|
|
void setdbUserPass(char *pszDBUserPass);
|
|
|
|
|
|
|
|
|
// socket 相关属性参数配置
|
|
|
void setFdLimit(unsigned int iCount);
|
|
|
unsigned int getFdLimit();
|
|
|
|
|
|
void setTimeout0(unsigned int t);
|
|
|
void setTimeout1(unsigned int t);
|
|
|
void setTimeout2(unsigned int t);
|
|
|
void setTimeout3(unsigned int t);
|
|
|
unsigned int getTimeout0();
|
|
|
unsigned int getTimeout1();
|
|
|
unsigned int getTimeout2();
|
|
|
unsigned int getTimeout3();
|
|
|
|
|
|
void setK(unsigned int k);
|
|
|
unsigned int getK();
|
|
|
|
|
|
void setW(unsigned int w);
|
|
|
unsigned int getW();
|
|
|
|
|
|
void setLogDebug(char yes);
|
|
|
void setLogError(char yes);
|
|
|
void setLogWarning(char yes);
|
|
|
void setLogPack(char yes);
|
|
|
void setLogConsole(char yes);
|
|
|
void setLogMessage(char yes);
|
|
|
char isLogDebug(void);
|
|
|
char isLogError(void);
|
|
|
char isLogWarning(void);
|
|
|
char isLogPack(void);
|
|
|
char isLogConsole(void);
|
|
|
char isLogMessage(void);
|
|
|
|
|
|
// version infomation functios
|
|
|
void setServerVersion(char *pver) ;
|
|
|
char *getServerVersion();
|
|
|
|
|
|
void setMonitor(bool bMonitor);
|
|
|
bool getMonitor();
|
|
|
// 读取配置文件函数
|
|
|
int iniGetString(const char *pszSection, const char *pszEntry, char *pszRetBuf, unsigned int uiBufLen);
|
|
|
|
|
|
// 通信协议使能
|
|
|
void setCommProtocol(int protocol);
|
|
|
int getCommProtocol();
|
|
|
|
|
|
// modbus functions
|
|
|
void setModbusMode(char *mode);
|
|
|
char *getModbusMode();
|
|
|
|
|
|
void setModbusTcpAddr(char *addr);
|
|
|
char *getModbusTcpAddr();
|
|
|
|
|
|
void setModbusRtuPort(char *port);
|
|
|
char *getModbusRtuPort();
|
|
|
|
|
|
void setModbusTcpPort(int port);
|
|
|
int getModbusTcpPort();
|
|
|
|
|
|
void setModbusBaud(int baud);
|
|
|
int getModbusBaud();
|
|
|
|
|
|
void setModbusParity(char parity);
|
|
|
char getModbusParity();
|
|
|
|
|
|
void setModbusDataBit(int bit);
|
|
|
int getModbusDataBit();
|
|
|
|
|
|
void setModbusStopBit(int sbit);
|
|
|
int getModbusStopBit();
|
|
|
|
|
|
void setWifiPasswd(char *passwd);
|
|
|
char* getWifiPasswd();
|
|
|
|
|
|
// iec61850 config
|
|
|
void setIEDCount(int c);
|
|
|
int getIEDCount();
|
|
|
|
|
|
void setIEDAddress(int idx, ST_IED_ADDR paddr);
|
|
|
ST_IED_ADDR *getIEDAddrsss(int idx);
|
|
|
|
|
|
void setIEDModelConfigFile(char *ied_file_name);
|
|
|
char *getIEDModelConfigFile();
|
|
|
|
|
|
void setComtradePath(char *path);
|
|
|
char *getComtradePath();
|
|
|
void setComtradeBakPath(char *path);
|
|
|
char *getComtradeBakPath();
|
|
|
|
|
|
void setIEDComtradePath(char *path);
|
|
|
char *getIEDComtradePath();
|
|
|
|
|
|
void setIEDComtradeRemove(bool isRemove);
|
|
|
bool getIEDComtradeRemove();
|
|
|
private:
|
|
|
static TConfig *p_TConfig;
|
|
|
|
|
|
|
|
|
bool b_monitor_enable ; // 监控标志 true:启用 false: 不启用
|
|
|
|
|
|
// server version infomations
|
|
|
char m_version[32+1]; // format 2013.00.100
|
|
|
|
|
|
// database config parameter
|
|
|
char m_dbHostIP[16];
|
|
|
char m_dbName[16];
|
|
|
char m_dbUserName[16];
|
|
|
char m_dbUserPass[16];
|
|
|
|
|
|
unsigned int m_dbMaxConnect;
|
|
|
unsigned int m_dbMinConnect;
|
|
|
unsigned int m_dbPort;
|
|
|
|
|
|
char m_local_addr[16];
|
|
|
unsigned int m_local_port;
|
|
|
char m_remote_addr[16] ;
|
|
|
unsigned int m_remote_port ;
|
|
|
// socket config
|
|
|
unsigned int m_fd_limit;
|
|
|
unsigned int t0,t1,t2,t3,uK,uW;
|
|
|
|
|
|
|
|
|
unsigned int m_recv_num;
|
|
|
unsigned int m_parse_num;
|
|
|
unsigned int m_opration_num;
|
|
|
unsigned int m_respone_num;
|
|
|
|
|
|
|
|
|
// logger
|
|
|
char m_logdebug; // debug logger
|
|
|
char m_logwarning; // warning logger
|
|
|
char m_logerror; // error logger
|
|
|
char m_logpack; // package print logger
|
|
|
char m_logconsole; // console print
|
|
|
char m_logmessage; // message print
|
|
|
|
|
|
// Modbus Protocol Configure
|
|
|
int m_comm_protocol; // 1:modbus 2: iec61850
|
|
|
char m_mbus_mode[16]; // Modbus 通信模式 TCP|RTU|ASC|IEC61850
|
|
|
char m_mbus_tcp_addr[32]; // 通信地址, IP or COM1...
|
|
|
int m_mbus_tcp_port; // 通信端口 for TCP
|
|
|
char m_mbus_rtu_port[128]; // 串口号 for RTU
|
|
|
int m_mbus_baud; // 波特率
|
|
|
char m_mbus_parity; // 校验位
|
|
|
int m_mbus_data_bit; // 数据位
|
|
|
int m_mbus_stop_bit; // 停止位
|
|
|
char m_mbus_wifi_pass[128]; // wifi password
|
|
|
|
|
|
// IEC61850 Configuration
|
|
|
int m_ied_count; // IED count
|
|
|
ST_IED_ADDR m_ied_addr[HT_MAX_IED_COUNT]; // IED address list
|
|
|
char m_ied_comtrade_path[256]; // 服务器IED录播文件存放路径
|
|
|
bool b_ied_comtrade_remove; // # 服务器录播文件下载后是否删除 true:删除,false : 保留
|
|
|
char m_ied_model_config_file[MAX_PATH]; // IEC61850配置文件名称
|
|
|
char m_comtrade_path[MAX_PATH]; // 录播文件存放路径
|
|
|
char m_comtrade_bak_path[MAX_PATH]; // 录播文件备份路径
|
|
|
};
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|