优化固高总线卡的IO操作

master
lhiven 1 year ago
parent 132b54bcc5
commit d755eba894

@ -1,4 +1,6 @@
using Rs.Motion.Base; using Rs.Framework;
using Rs.Motion.Base;
using Rs.Motion.GugaoPulse;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -44,6 +46,13 @@ namespace Rs.Motion.GugaoEcat
io.Name = "In" + i + "_" + slaveNo; io.Name = "In" + i + "_" + slaveNo;
DIn.Add(io); DIn.Add(io);
} }
}
public override void Save()
{
string filename = $"config/motion/io/gugao_ecat{CardID}.xml";
XmlSerializerHelper.Instance.Serialize<ECatIOCard>(filename, this);
} }
} }
} }

@ -206,8 +206,17 @@ namespace Rs.Motion
ECatIO eio = (ECatIO)io; ECatIO eio = (ECatIO)io;
apiResult = mc_ecat.GTN_EcatIOBitReadOutput(eio.Core, eio.SlaveNo, eio.Offset, eio.Index, out byte pValue); apiResult = mc_ecat.GTN_EcatIOBitReadOutput(eio.Core, eio.SlaveNo, eio.Offset, eio.Index, out byte pValue);
if (apiResult == 0) if (apiResult == 0)
{
if (io.IsReverse)
{
return (short)((~pValue) & 0x01);
}
else
{
return pValue; return pValue;
} }
}
}
else else
{ {
ECatIO eio = (ECatIO)io; ECatIO eio = (ECatIO)io;
@ -215,8 +224,16 @@ namespace Rs.Motion
if (apiResult == 0) if (apiResult == 0)
{ {
byte pValue = (byte)(~(value >> eio.Index) & 0x01); byte pValue = (byte)(~(value >> eio.Index) & 0x01);
if(io.IsReverse)
{
return (short)((~pValue) & 0x01);
}
else
{
return pValue; return pValue;
} }
}
} }
} }
else if (io.Card.Vender == "GugaoPulse") else if (io.Card.Vender == "GugaoPulse")

Loading…
Cancel
Save