| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 | 
							- using Aitex.Core.RT.Log;
 
- using Aitex.Core.Util;
 
- using MECF.Framework.Common.Beckhoff.IOAxis;
 
- using System;
 
- using System.Collections.Generic;
 
- using System.Linq;
 
- using System.Text;
 
- using System.Threading.Tasks;
 
- namespace MECF.Framework.Common.TwinCat
 
- {
 
-     public class TwincatCoeManager : Singleton<TwincatCoeManager>
 
-     {
 
-         #region 内部变量
 
-         /// <summary>
 
-         /// 模块COE字典(key-模块名称,key-TwincatCoe接口对象)
 
-         /// </summary>
 
-         private Dictionary<string, TwincatCoeInterface> _moduleCoeInterfaceDic = new Dictionary<string, TwincatCoeInterface>();
 
-         /// <summary>
 
-         /// 地址COE字典(key-NetId:Port,key-TwincatCoe接口对象)
 
-         /// </summary>
 
-         private Dictionary<string, TwincatCoeInterface> _addressInterfaceDic = new Dictionary<string, TwincatCoeInterface>();
 
-         #endregion
 
-         /// <summary>
 
-         /// 初始化
 
-         /// </summary>
 
-         /// <param name="moduleName"></param>
 
-         /// <param name="beckhoffAxis"></param>
 
-         public void Initialize(BeckhoffAxis beckhoffAxis)
 
-         {
 
-             string address = $"{beckhoffAxis.COEAddress}.{beckhoffAxis.COEPort}";
 
-             if (!_addressInterfaceDic.ContainsKey(address))
 
-             {
 
-                 TwincatCoeInterface coeInterface = new TwincatCoeInterface(beckhoffAxis);
 
-                 _moduleCoeInterfaceDic[beckhoffAxis.Name] = coeInterface;
 
-                 _addressInterfaceDic[address] = coeInterface;
 
-                 coeInterface.Connect();
 
-             }
 
-             else
 
-             {
 
-                 _moduleCoeInterfaceDic[beckhoffAxis.Name] = _addressInterfaceDic[address];
 
-             }
 
-             _addressInterfaceDic[address].InnitialInputAndOutputVariable(beckhoffAxis);
 
-         }
 
-         /// <summary>
 
-         /// 启动读取输入变量
 
-         /// </summary>
 
-         public void StartReadInput()
 
-         {
 
-             string[] strAry=_addressInterfaceDic.Keys.ToArray();
 
-             foreach (string item in strAry)
 
-             {
 
-                 _addressInterfaceDic[item].StartReadInputDataThread();
 
-             }
 
-         }
 
-         /// <summary>
 
-         /// 写变量数值
 
-         /// </summary>
 
-         /// <param name="variableName"></param>
 
-         /// <param name="value"></param>
 
-         /// <returns></returns>
 
-         public bool WriteVariableValue(string moduleName,string variableName,object value)
 
-         {
 
-             if(_moduleCoeInterfaceDic.ContainsKey(moduleName))
 
-             {
 
-                 return _moduleCoeInterfaceDic[moduleName].WriteModuleCoeData(moduleName,variableName, value);
 
-             }
 
-             else
 
-             {
 
-                 LOG.WriteLog(eEvent.ERR_TWINCAT, moduleName, $"Twincat Coe variables doesnot have [{moduleName}] module");
 
-                 return false;
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |