You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.0 KiB
C#

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