using FestoDebugger.Service; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FestoDebugger.Beckoff { public class BeckhoffModuleIOManager : Singleton { #region 内部变量 private BeckhoffModuleIOCfg _cfg; /// /// 模块IO字典(key-模块名称,value-beckhoff 变量名称) /// private Dictionary _moduleNameIODic = new Dictionary(); /// /// Beckhoff (IO-模块名称字典) /// private Dictionary _ioModuleNameDic = new Dictionary(); #endregion /// /// 初始化 /// /// public void Initialize(string xmlPath) { _cfg = CustomXmlSerializer.Deserialize(new FileInfo(xmlPath)); if (_cfg != null) { foreach (BeckhoffModule item in _cfg.Modules) { foreach (BeckhoffModuleIOInfo io in item.IOs) { _moduleNameIODic[io.Name] = io.IOName; _ioModuleNameDic[io.IOName] = io.Name; } } } } /// /// 通过获取模块名称获取IO名称 /// /// /// public string GetIoNameByInnerModuleName(string key) { return _moduleNameIODic.ContainsKey(key) ? _moduleNameIODic[key] : ""; } /// /// 通过IO名称获取模块名称 /// /// /// public string GetInnerModuleNameByIOName(string key) { return _ioModuleNameDic.ContainsKey(key) ? _ioModuleNameDic[key] : ""; } } }