using System; namespace ln.ethercat { public class SDOAddr { public UInt16 Slave { get; private set; } public UInt16 Index { get; private set; } public byte SubIndex { get; private set; } public long Linear => ((long)(ulong)Slave << 32) | ((long)Index << 16) | (long)SubIndex; public int Compact => ((Slave << 24) | (Index << 8) | SubIndex); public SDOAddr(){} public SDOAddr(UInt16 slave, UInt16 index) : this(slave, index, 0) { } public SDOAddr(UInt16 slave, UInt16 index, byte subindex) { Slave = slave; Index = index; SubIndex = subindex; } public override bool Equals(object obj) => (obj is SDOAddr other) && (Linear == other.Linear); public override int GetHashCode() => Compact; public override string ToString() { return string.Format("[SDOAddr Slave={0} Index={1:X4}.{2} ]", Slave, Index, SubIndex); } } }