using System; using System.ComponentModel.DataAnnotations; namespace ln.ethercat { public class PDO { readonly ECMaster ECMaster; public SDOValue SDOValue{ get; } 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; if (!ECMaster.GetSDOValue(slave, index, subIndex, out SDOValue sdoValue)) throw new Exception(String.Format("PDO: could not retrieve SDOValue {0}:{1:X4}.{2}", slave, index, subIndex)); SDOValue = sdoValue; } } }