ln.ethercat/ln.ethercat/PDO.cs

32 lines
734 B
C#

using System;
using System.ComponentModel.DataAnnotations;
namespace ln.ethercat
{
public class PDO
{
readonly ECMaster ECMaster;
public SDO SDO { get; }
public SDOAddr Address => SDO.Address;
public int AddressOffset { get; set; }
public int AddressBit { get; set; }
public int BitLength { get; set; }
public int ByteLength {
get => (BitLength + 7) / 8;
set => BitLength = value * 8;
}
public PDO(ECMaster ecMaster, UInt16 slave, UInt16 index, byte subIndex)
{
ECMaster = ecMaster;
ECMaster.GetSDO(new SDOAddr(slave, index, subIndex), out SDO sdo);
SDO = sdo;
}
}
}