using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Serialization; namespace Rs.Motion.GugaoPulse { public class IIOCard { [XmlElement] public List DIn { get; set; } = new List(); [XmlElement] public List DOut { get; set; } = new List(); /// /// 0glink 1总线 /// public int CardType { get; set; } = 0; public string Name { get; set; } = "本地IO"; /// /// 厂家 /// public string Vender { get; set; } = "Gugao"; /// /// 是否采用EtherCat通信 /// public bool IsEtherCat { get; set; } = true; public virtual void Init(ushort inCount, ushort outCount, ushort slaveNo) { } } /// /// 总线卡 /// [Serializable] [XmlInclude(typeof(IO))] public class ECatIOCard: IIOCard { public ECatIOCard() { } public override void Init(ushort inCount, ushort outCount, ushort slaveNo) { ushort i = 0; for (; i < outCount; i++) { IO io = new IO(); io.SlaveNo = slaveNo; io.Offset = 0; io.Index = i; io.Name = "Out" + i+"_"+slaveNo; DOut.Add(io); } for (; i < outCount + inCount; i++) { IO io = new IO(); io.SlaveNo = slaveNo; io.Offset = 0; io.Index = i; io.Name = "In" + i + "_" + slaveNo; DIn.Add(io); } } } /// /// GLink卡 /// [XmlInclude(typeof(GLinkIO))] public class GLinkIOCard: IIOCard { public override void Init(ushort inCount, ushort outCount, ushort slaveNo) { for (ushort i = 0; i < outCount; i++) { GLinkIO io = new GLinkIO(); io.Name = "Out" + i+ "_"+ slaveNo; io.Index = i; DOut.Add(io); } for (ushort i = 0; i < inCount; i++) { GLinkIO io = new GLinkIO(); io.Name = "In" + i + "_" + slaveNo; io.Index = i; DIn.Add(io); } } } public class IIO { public ushort Index { get; set; } public string Name { get; set; } public bool IsReverse { get; set; } = false; [XmlIgnore] public IIOCard Card { get; set; } } public class GLinkIO:IIO { } public class IO:IIO { [XmlElement] public short Core { get; set; } = 1; [XmlElement] public ushort SlaveNo { get; set; } [XmlElement] public ushort Offset { get; set; } } }