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.
132 lines
3.3 KiB
C#
132 lines
3.3 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,short cardID=0)
|
|
{
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 总线卡
|
|
/// </summary>
|
|
[Serializable]
|
|
[XmlInclude(typeof(ECatIO))]
|
|
public class ECatIOCard: IIOCard
|
|
{
|
|
|
|
public ECatIOCard()
|
|
{
|
|
|
|
}
|
|
|
|
public override void Init(ushort inCount, ushort outCount, ushort slaveNo, short cardID = 0)
|
|
{
|
|
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,short cardID=0)
|
|
{
|
|
for (ushort i = 0; i < outCount; i++)
|
|
{
|
|
GLinkIO io = new GLinkIO();
|
|
io.Name = "Out" + i+ "_"+ slaveNo;
|
|
io.Index = i;
|
|
io.CardID = cardID;
|
|
DOut.Add(io);
|
|
}
|
|
for (ushort i = 0; i < inCount; i++)
|
|
{
|
|
GLinkIO io = new GLinkIO();
|
|
io.Name = "In" + i + "_" + slaveNo;
|
|
io.Index = i;
|
|
io.CardID = cardID;
|
|
DIn.Add(io);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
public class IIO
|
|
{
|
|
public short CardID { get; set; } = 0;
|
|
|
|
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
|
|
{
|
|
[XmlElement]
|
|
public short CardID { get; set; } = 0;
|
|
}
|
|
|
|
public class ECatIO:IIO
|
|
{
|
|
[XmlElement]
|
|
public short Core { get; set; } = 1;
|
|
[XmlElement]
|
|
public ushort SlaveNo { get; set; }
|
|
[XmlElement]
|
|
public ushort Offset { get; set; }
|
|
|
|
}
|
|
}
|