Beispiel #1
0
            public DatumAddress CreateAddress(int numericValue)
            {
                if (!IsValid(numericValue))
                {
                    throw new ArgumentOutOfRangeException();
                }

                var raw = ComputeAddress(numericValue);

                switch (Kind)
                {
                case DatumAddressKind.Coil:
                    return(CoilAddress.FromRawValue(raw));

                case DatumAddressKind.Input:
                    return(InputAddress.FromRawValue(raw));

                case DatumAddressKind.HoldingRegister:
                    return(HoldingRegisterAddress.FromRawValue(raw));

                case DatumAddressKind.InputRegister:
                    return(InputRegisterAddress.FromRawValue(raw));

                default:
                    throw new ApplicationException();
                }
            }
Beispiel #2
0
        private static Tuple <DatumAddress, Type, int> CreateHoldingRegister(int numericValue, int baseValue, Type type, int size)
        {
            var raw = (ushort)(baseValue + size * (numericValue - 1));

            return(Tuple.Create((DatumAddress)HoldingRegisterAddress.FromRawValue(raw), type, size));
        }