Beispiel #1
0
        public int CompareTo(object obj)
        {
            if (obj.GetType() != typeof(ModbusAddress))
            {
                throw new InvalidCastException($"Невозможно преобразовать {obj.GetType()} к типу {typeof(ModbusAddress)}.");
            }
            ModbusAddress addr   = obj != null ? obj as ModbusAddress : this;
            int           result = wordNum.CompareTo(addr.wordNum);

            if (result == 0)
            {
                result = bitNum.CompareTo(addr.bitNum);
            }
            return(result);
        }
Beispiel #2
0
 private int GetByteNum(ModbusAddress address, int startRegister)
 {
     return(address.WordNum * 2 + (address.BitNum > 7 ? 1 : 0) - startRegister * 2);
 }