Example #1
0
        public RangingInformation GetMergedRange()
        {
            RangingInformation newRange = new RangingInformation();

            foreach (RangingInformation rangingInformation in _ranges)
            {
                Quantity from = rangingInformation.FromQuantity;
                Quantity to   = rangingInformation.ToQuantity;
                if (newRange.FromQuantity == null || from < newRange.FromQuantity)
                {
                    newRange.FromQuantity = from;
                }
                if (newRange.ToQuantity == null || to > newRange.ToQuantity)
                {
                    newRange.ToQuantity = to;
                }
                if (rangingInformation.ErrorLimit != null)
                {
                    newRange.ErrorLimit = newRange.ErrorLimit == null
                                              ? rangingInformation.ErrorLimit
                                              : ErrorLimit.LeastRestrictiveLimit(rangingInformation.ErrorLimit,
                                                                                 newRange.ErrorLimit);
                }
            }
            return(newRange);
        }
Example #2
0
        public object Clone()
        {
            var clone = new RangingInformation();

            clone._fromQuantity = _fromQuantity.Clone() as Quantity;
            clone._toQuantity   = _toQuantity.Clone() as Quantity;
            clone.ErrorLimit    = _errorLimit.Clone() as ErrorLimit;
            clone.Magnitude     = _magnitude;
            return(clone);
        }
        protected void ControlsToData()
        {
            if (_rangingInformation == null)
                _rangingInformation = new RangingInformation();
            _rangingInformation.FromQuantity = edtLLValue.Quantity;
            _rangingInformation.ToQuantity = edtULValue.Quantity;

            if (_rangingInformation.FromQuantity.Unit.HasPrefix())
                cbLLPrefix.SelectedValue = _rangingInformation.FromQuantity.Unit.Prefix;
            else
                cbLLPrefix.SelectedIndex = -1;

            if (_rangingInformation.FromQuantity.Unit.HasUnit())
                cbLLUnit.SelectedValue = _rangingInformation.FromQuantity.Unit.Unit;
            else
                cbLLUnit.SelectedIndex = -1;
        }
Example #4
0
        public Physical(string value)
        {
            Value = value;
            var rgx = new Regex(PHYSICAL_PATTERN);

            if (!rgx.Match(value).Success)
            {
                throw new Exception(string.Format("Invalid Physical Expression - {0}", value));
            }
            if (value.Contains(" to ") && !value.Contains("range"))
            {
                throw new Exception(string.Format("Invalid Physical Range - {0}, please prefix a range of values with \"range \"", value));
            }
            string remainder = value;
            string word      = NextWord(remainder, out remainder);

            while (!string.IsNullOrWhiteSpace(word))
            {
                if (IsNumericExpression(word) || IsQualifier(word))
                {
                    _magnitude = new QualifiedQuantity(word + " " + remainder, out remainder);
                    AddQuantity(_magnitude);
                }
                else if (IsRange(word))
                {
                    var range = new RangingInformation(remainder, out remainder,
                                                       _magnitude == null ? 0d : _magnitude.Magnitude);
                    Ranges.Add(range);
                }
                else if (IsErrorLimit(word))
                {
                    ErrorLimits.Add(new ErrorLimit(remainder, out remainder));
                }
                else if (IsResolution(word))
                {
                    Resolutions.Add(new Quantity(remainder, out remainder));
                }
                else if (IsConfidence(word))
                {
                }
                else if (IsLoad(word))
                {
                }
                word = NextWord(remainder, out remainder);
            }
        }
Example #5
0
        public RangingInformation GetMergedRange()
        {
            RangingInformation newRange = new RangingInformation();

            foreach (RangingInformation rangingInformation in _ranges)
            {
                Quantity from = rangingInformation.FromQuantity;
                Quantity to = rangingInformation.ToQuantity;
                if (newRange.FromQuantity == null || from < newRange.FromQuantity)
                    newRange.FromQuantity = from;
                if (newRange.ToQuantity == null || to > newRange.ToQuantity)
                    newRange.ToQuantity = to;
                if (rangingInformation.ErrorLimit != null)
                    newRange.ErrorLimit = newRange.ErrorLimit == null
                                              ? rangingInformation.ErrorLimit
                                              : ErrorLimit.LeastRestrictiveLimit( rangingInformation.ErrorLimit,
                                                                                  newRange.ErrorLimit );

            }
            return newRange;
        }
Example #6
0
 public void AddRange(RangingInformation range)
 {
     Ranges.Add(range);
 }
Example #7
0
 public Physical(string value)
 {
     Value = value;
     var rgx = new Regex(PHYSICAL_PATTERN);
     if (!rgx.Match(value).Success)
         throw new Exception(string.Format("Invalid Physical Expression - {0}", value));
     if( value.Contains( " to " ) && !value.Contains( "range" ))
         throw new Exception(string.Format("Invalid Physical Range - {0}, please prefix a range of values with \"range \"", value));
     string remainder = value;
     string word = NextWord(remainder, out remainder);
     while (!string.IsNullOrWhiteSpace(word))
     {
         if (IsNumericExpression(word) || IsQualifier(word))
         {
             _magnitude = new QualifiedQuantity(word + " " + remainder, out remainder);
             AddQuantity(_magnitude);
         }
         else if (IsRange(word))
         {
             var range = new RangingInformation(remainder, out remainder,
                 _magnitude == null ? 0d : _magnitude.Magnitude);
             Ranges.Add(range);
         }
         else if (IsErrorLimit(word))
         {
             ErrorLimits.Add(new ErrorLimit(remainder, out remainder));
         }
         else if (IsResolution(word))
         {
             Resolutions.Add(new Quantity(remainder, out remainder));
         }
         else if (IsConfidence(word))
         {
         }
         else if (IsLoad(word))
         {
         }
         word = NextWord(remainder, out remainder);
     }
 }
Example #8
0
 public object Clone()
 {
     var clone = new RangingInformation();
     clone._fromQuantity = _fromQuantity.Clone() as Quantity;
     clone._toQuantity = _toQuantity.Clone() as Quantity;
     clone.ErrorLimit = _errorLimit.Clone() as ErrorLimit;
     clone.Magnitude = _magnitude;
     return clone;
 }
 private void quantity_ValueChanged(object sender, EventArgs e)
 {
     if (_rangingInformation != null)
     {
         var originalErrorLimit = _rangingInformation.Clone() as ErrorLimit;
         if (originalErrorLimit != null)
         {
             ControlsToData();
             edtErrorLimit.Text = _rangingInformation.ToString();
             _rangingInformation = originalErrorLimit.Clone() as RangingInformation;
         }
     }
 }
Example #10
0
 public void AddRange(RangingInformation range)
 {
     Ranges.Add(range);
 }