using System; using System.Data; using System.IO; using System.Reflection; using System.Collections.Generic; /// /// Rf信息配置类 /// public class RfConfig { private const string CONFIG_XML_FILE = "config.xml"; private const string SYSTEM_SET_NODE = "SystemSet"; private static RfConfig _RfConfig; private static string _ServerAddress; /// /// 服务器地址 /// public string ServerAddress { get { return _ServerAddress; } } protected RfConfig() { //GetConfigInfo(); GetWmsInfo(); } public static RfConfig Create() { if (_RfConfig == null) { _RfConfig = new RfConfig(); } return _RfConfig; } private static string _PlcIp1; /// /// 服务器地址 /// public string PLCIp1 { get { return _PlcIp1; } } private string _ScanIp1=""; private string _ScanProt1 = ""; /// /// 服务器地址 /// public string ScanIp1 { get { return _ScanIp1; } } /// /// 服务器地址 /// public string ScanProt1 { get { return _ScanProt1; } } private string _ScanIp2 = ""; private string _ScanProt2 = ""; /// /// 服务器地址 /// public string ScanIp2 { get { return _ScanIp2; } } /// /// 服务器地址 /// public string ScanProt2 { get { return _ScanProt2; } } private string _ScanIp3 = ""; private string _ScanProt3 = ""; /// /// 服务器地址 /// public string ScanIp3 { get { return _ScanIp3; } } /// /// 服务器地址 /// public string ScanProt3 { get { return _ScanProt3; } } private string _ScanIp4 = ""; private string _ScanProt4 = ""; /// /// 服务器地址 /// public string ScanIp4 { get { return _ScanIp4; } } /// /// 服务器地址 /// public string ScanProt4 { get { return _ScanProt4; } } /// /// wms ip地址 /// private string _wmsSendIp = string.Empty; /// /// wms ip地址 /// public string WmsSendIP { get { return _wmsSendIp; } } private string _wmsprot = string.Empty; /// /// wms prot端口设置 /// public string WmsPort { get { return _wmsprot; } } /// /// wcs ip地址 /// private string _wcsIp = string.Empty; /// /// wcs ip地址 /// public string WcsIP { get { return _wcsIp; } } /// /// wcs 端口 /// private string _wcsPort = string.Empty; /// /// wcs端口 /// public string WcsPort { get { return _wcsPort; } } private string _requestt = string.Empty; /// /// 3请求的等待时间 /// public string Requestt { get { return _requestt; } } private string _requestNumber = string.Empty; /// /// 请求次数 /// public string RequestNumber { get { return _requestNumber; } } private string _requestBool = string.Empty; /// /// 清除数据 /// public string RequestBool { get { return _requestBool; } } private string _requestf = string.Empty; /// /// 5等待的时间 /// public string Requestf { get { return _requestf; } } private string _clearlog = string.Empty; /// /// 清除日志 /// public string Clearlog { get { return _clearlog; } } private string _clearData = string.Empty; /// /// 清除数据 /// public string ClearData { get { return _clearData; } } /// /// comm1端口 /// private string _commProt1 = string.Empty; /// /// comm1端口 /// public string CommProt1 { get { return _commProt1; } } /// /// comm2端口 /// private string _commProt2 = string.Empty; /// /// comm2端口 /// public string CommProt2 { get { return _commProt2; } } /// /// comm3端口 /// private string _commProt3 = string.Empty; /// /// comm3端口 /// public string CommProt3 { get { return _commProt3; } } /// /// comm4端口 /// private string _commProt4 = string.Empty; /// /// comm4端口 /// public string CommProt4 { get { return _commProt4; } } /// /// comm4端口 /// private string _commProt5= string.Empty; /// /// comm4端口 /// public string CommProt5 { get { return _commProt5; } } private string _baudRate1 = string.Empty; /// /// 波特率 /// public string BaudRate1 { get { return _baudRate1; } } private string _baudRate2 = string.Empty; /// /// 波特率 /// public string BaudRate2 { get { return _baudRate2; } } private string _baudRate3 = string.Empty; /// /// 波特率 /// public string BaudRate3 { get { return _baudRate3; } } private string _baudRate4 = string.Empty; /// /// 波特率 /// public string BaudRate4 { get { return _baudRate4; } } private string _baudRate5 = string.Empty; /// /// 波特率 /// public string BaudRate5 { get { return _baudRate5; } } #region 扫描消息格式 private string _heartbeat = string.Empty; /// /// 心跳 /// public string Heartbeat { get { return _heartbeat; } } #endregion public Dictionary wmsDevice = new Dictionary(); /// /// 读配置信息 /// public void GetConfigInfo() { DataSet ds = new DataSet(); string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName); ds.ReadXml(appPath + "\\" + CONFIG_XML_FILE); _wmsSendIp = ds.Tables[SYSTEM_SET_NODE].Rows[0]["wmsip"].ToString(); _wmsprot = ds.Tables[SYSTEM_SET_NODE].Rows[0]["wmsprot"].ToString(); //_wcsIp = ds.Tables[SYSTEM_SET_NODE].Rows[0]["wcsip"].ToString(); //_wcsPort = ds.Tables[SYSTEM_SET_NODE].Rows[0]["wcsprot"].ToString(); //_PlcIp1 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["plcip"].ToString(); _ScanIp1 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["scanip1"].ToString(); //_ScanProt1 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["prot1"].ToString(); _ScanIp2 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["scanip2"].ToString(); //_ScanProt2 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["prot2"].ToString(); _ScanIp3 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["scanip3"].ToString(); //_ScanProt3 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["prot3"].ToString(); _ScanIp4 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["scanip4"].ToString(); _ScanProt4 = ds.Tables[SYSTEM_SET_NODE].Rows[0]["prot4"].ToString(); } public DataSet plcds = new DataSet(); /// /// 读配置信息 /// private void GetWmsInfo() { string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName); plcds.ReadXml(appPath + "\\" + "PLCData.xml"); } public DataSet SysonPlcData = new DataSet(); private void GetSysonPlcData() { string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName); SysonPlcData.ReadXml(appPath + "\\" + "SysonPLC.xml"); } }