using System; using System.Collections.Generic; using TwinCAT.Ads; using Aitex.Core.RT.Log; namespace Aitex.Core.RT.PLC { // public class ADSDevice :IDataDevice // { // private TcAdsClient client = null; // private int port = 811; // private bool isOpened = false; // private int hInput; // private int hOutput; // public bool IsOpened { get { return isOpened; } } // public ADSDevice() // { // client = new TcAdsClient(); // } // public bool Open() // { // try // { // isOpened = false; // client.Connect(port); // if ( !client.IsConnected) // { // //add log // return false; // } // //获取PLC句柄 // hInput = client.CreateVariableHandle(".CSharp_Input"); // hOutput = client.CreateVariableHandle(".CSharp_Output"); // } // catch(Exception ex) // { //// LOG.Error(String.Format("与PLC的Ads连接失败."), ex); // return false; // } // isOpened = true; // return true; // } // public void Close() // { // try // { // if (client != null) // client.Dispose(); // } // catch (Exception ex) // { // // Console.WriteLine("ADS Close exception {0}", ex); // } // } // public object Read() // { // try // { // return client.ReadAny(hInput, typeof(T)); // } // catch(Exception ex) // { // // LOG.Error(String.Format("Entity terminate has exception."), ex); // } // return null; // } // public bool Write(T buffer) // { // try // { // client.WriteAny(hOutput, buffer); // return true; // } // catch (Exception ex) // { // // LOG.Error(String.Format("Entity terminate has exception."), ex); // return false; // } // } // public object Read(string type) // { // throw new NotImplementedException(); // } // public bool Write(string type, T buffer) // { // throw new NotImplementedException(); // } // public bool SyncData() // { // throw new NotImplementedException(); // } // public List GetTypes() // { // throw new NotImplementedException(); // } // } }