Пример #1
0
 public Pv2RttFieldDesc(byte id, string name, string description, string units, string formatString,
                        Pv2RttFieldFlags flags, object defaultValue, Pv2RttRecordDesc group)
 {
     Id           = id;
     Name         = name;
     Description  = description;
     Units        = units;
     FormatString = formatString;
     Flags        = flags;
     GroupId      = group.Id;
     GroupName    = group.Name;
     // ReSharper disable once VirtualMemberCallInConstructor
     ValidateValue(defaultValue);
     DefaultValue = defaultValue;
     ValidateSize();
 }
Пример #2
0
        public Pv2RttFixedPointDesc(byte id, string name, string description, string units, string formatString,
                                    Pv2RttFieldFlags flags, BitSizeEnum bitSize, double offset, double fraction, double defaultValue,
                                    Pv2RttRecordDesc group) : base(id, name, description, units, formatString, flags, defaultValue, group)
        {
            BitSize  = bitSize;
            Offset   = offset;
            Fraction = fraction;
            try
            {
                FormatString.FormatWith(defaultValue);
            }
            catch (Exception e)
            {
                throw new Exception($"RTT field {name}[{id}] has wrong format string '{formatString}':{e.Message}");
            }

            if (Enum.GetValues(typeof(BitSizeEnum)).Cast <BitSizeEnum>().Contains(bitSize) == false)
            {
                throw new ArgumentOutOfRangeException(nameof(bitSize), bitSize,
                                                      $"Unknwon value of enum {nameof(BitSizeEnum)}");
            }
        }