Inheritance: ICloneable
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);
        }
        private static void SetRowData(DataGridViewRow row, ErrorLimit errorLimit )
        {
            int idx = 0;
            row.Tag = errorLimit;
            row.Cells[idx + 1].Value = Quantity.MINUS;
            if (errorLimit.MinusQuantity != null)
            {
                row.Cells[idx + 2].Value = Math.Abs(errorLimit.MinusQuantity.Value);
                if (errorLimit.MinusQuantity.Unit.HasPrefix())
                    row.Cells[idx + 3].Value = errorLimit.MinusQuantity.Unit.Prefix;
                if (errorLimit.MinusQuantity.Unit.HasUnit())
                    row.Cells[idx + 4].Value = errorLimit.MinusQuantity.Unit.Unit;
            }
            if (errorLimit.PlusQuantity != null)
            {
                row.Cells[idx + 5].Value = Quantity.PLUS;
                row.Cells[idx + 6].Value = Math.Abs(errorLimit.PlusQuantity.Value);
                if (errorLimit.PlusQuantity.Unit.HasPrefix())
                    row.Cells[idx + 7].Value = errorLimit.PlusQuantity.Unit.Prefix;
                if (errorLimit.PlusQuantity.Unit.HasUnit())
                    row.Cells[idx + 8].Value = errorLimit.PlusQuantity.Unit.Unit;
            }

            if (errorLimit.Confidence != null)
            {
                row.Cells[idx + 9].Value = errorLimit.Confidence.Value;
            }

            if (errorLimit.Resolution != null)
            {
                row.Cells[idx + 10].Value = errorLimit.Resolution.Value;
                row.Cells[idx + 11].Value = errorLimit.Resolution.Unit.Prefix;
                row.Cells[idx + 12].Value = errorLimit.Resolution.Unit.Unit;
            }
        }
Example #3
0
        public static ErrorLimit LeastRestrictiveLimit(ErrorLimit e1, ErrorLimit e2)
        {
            ErrorLimit newLimit = new ErrorLimit();

            newLimit.MinusQuantity = Quantity.Min(e1.MinusQuantity, e2.MinusQuantity);
            newLimit.PlusQuantity  = Quantity.Max(e1.PlusQuantity, e2.PlusQuantity);
            newLimit.Confidence    = Quantity.Min(e1.Confidence, e2.Confidence);
            newLimit.Resolution    = Quantity.Max(e1.Resolution, e2.Resolution);
            return(newLimit);
        }
Example #4
0
        private void CreateRange(string value, out string remainder, double magnitude)
        {
            Quantity qty1;
            Quantity qty2;

            string nextWord = remainder = value.Trim(); //Physical.NextWord(value, out remainder);

            _magnitude = magnitude;

            if (nextWord.ToLower().StartsWith("range"))
            {
                nextWord = Physical.NextWord(remainder, out remainder);
            }
            if (nextWord.ToLower().StartsWith("max"))
            {
                nextWord    = Physical.NextWord(remainder, out remainder);
                _toQuantity = new Quantity(remainder, out remainder);
            }
            else if (nextWord.ToLower().StartsWith("min"))
            {
                nextWord      = Physical.NextWord(remainder, out remainder);
                _fromQuantity = new Quantity(remainder, out remainder);
            }
            else
            {
                if (nextWord.StartsWith(Quantity.PLUSMINUS1))
                {
                    remainder = CalculateRange(magnitude, nextWord, Quantity.PLUSMINUS1.Length);
                }
                else if (nextWord.StartsWith(Quantity.PLUSMINUS2))
                {
                    remainder = CalculateRange(magnitude, nextWord, Quantity.PLUSMINUS2.Length);
                }
                else
                {
                    _fromQuantity = new UncertainQuantity(remainder, out remainder);
                    string to = Physical.NextWord(remainder, out remainder);
                    _toQuantity = new Quantity(remainder, out remainder);
                }
            }
            if (ErrorLimit.IsErrorLimit(remainder))
            {
                _errorLimit = new ErrorLimit(remainder, out remainder);
            }
        }
Example #5
0
        public object Clone()
        {
            var clone = new ErrorLimit();

            if (MinusQuantity != null)
            {
                clone.MinusQuantity = MinusQuantity.Clone() as Quantity;
            }
            if (PlusQuantity != null)
            {
                clone.PlusQuantity = PlusQuantity.Clone() as Quantity;
            }
            if (Resolution != null)
            {
                clone.Resolution = Resolution.Clone() as Quantity;
            }
            if (Confidence != null)
            {
                clone.Confidence = Confidence.Clone() as Quantity;
            }
            return(clone);
        }
Example #6
0
 public object Clone()
 {
     var clone = new ErrorLimit();
     if (MinusQuantity != null)
         clone.MinusQuantity = MinusQuantity.Clone() as Quantity;
     if (PlusQuantity != null)
         clone.PlusQuantity = PlusQuantity.Clone() as Quantity;
     if (Resolution != null)
         clone.Resolution = Resolution.Clone() as Quantity;
     if (Confidence != null)
         clone.Confidence = Confidence.Clone() as Quantity;
     return clone;
 }
Example #7
0
 public static ErrorLimit LeastRestrictiveLimit(ErrorLimit e1, ErrorLimit e2)
 {
     ErrorLimit newLimit = new ErrorLimit();
     newLimit.MinusQuantity = Quantity.Min(e1.MinusQuantity, e2.MinusQuantity);
     newLimit.PlusQuantity = Quantity.Max(e1.PlusQuantity, e2.PlusQuantity);
     newLimit.Confidence = Quantity.Min(e1.Confidence, e2.Confidence);
     newLimit.Resolution = Quantity.Max(e1.Resolution, e2.Resolution);
     return newLimit;
 }
Example #8
0
        private void CreateRange(string value, out string remainder, double magnitude)
        {
            Quantity qty1;
            Quantity qty2;

            string nextWord = remainder = value.Trim(); //Physical.NextWord(value, out remainder);
            _magnitude = magnitude;

            if (nextWord.ToLower().StartsWith("range"))
                nextWord = Physical.NextWord(remainder, out remainder);
            if (nextWord.ToLower().StartsWith("max"))
            {
                nextWord = Physical.NextWord(remainder, out remainder);
                _toQuantity = new Quantity(remainder, out remainder);
            }
            else if (nextWord.ToLower().StartsWith("min"))
            {
                nextWord = Physical.NextWord(remainder, out remainder);
                _fromQuantity = new Quantity(remainder, out remainder);
            }
            else
            {
                if (nextWord.StartsWith(Quantity.PLUSMINUS1))
                {
                    remainder = CalculateRange(magnitude, nextWord, Quantity.PLUSMINUS1.Length);
                }
                else if (nextWord.StartsWith(Quantity.PLUSMINUS2))
                {
                    remainder = CalculateRange(magnitude, nextWord, Quantity.PLUSMINUS2.Length);
                }
                else
                {
                    _fromQuantity = new UncertainQuantity(remainder, out remainder);
                    string to = Physical.NextWord(remainder, out remainder);
                    _toQuantity = new Quantity(remainder, out remainder);
                }
            }
            if (ErrorLimit.IsErrorLimit(remainder))
                _errorLimit = new ErrorLimit(remainder, out remainder);
        }
 protected void ControlsToData()
 {
     if (_errorLimit == null)
         _errorLimit = new ErrorLimit();
     _errorLimit.MinusQuantity = edtLLValue.Quantity;
     _errorLimit.PlusQuantity = edtULValue.Quantity;
     _errorLimit.Confidence = edtConfidence.Quantity;
     _errorLimit.Resolution = edtResolution.Quantity;
     edtErrorLimit.Text = _errorLimit.ToString();
 }
 private void quantity_ULValueChanged(object sender, EventArgs e)
 {
     if (_errorLimit == null)
         _errorLimit = new ErrorLimit();
     _errorLimit.PlusQuantity = edtULValue.Quantity;
     edtErrorLimit.Text = _errorLimit.ToString();
 }
 private void quantity_ResValueChanged(object sender, EventArgs e)
 {
     if (_errorLimit == null)
         _errorLimit = new ErrorLimit();
     _errorLimit.Resolution = edtResolution.Quantity;
     edtErrorLimit.Text = _errorLimit.ToString();
 }
 private void quantity_ConfValueChanged(object sender, EventArgs e)
 {
     if (_errorLimit == null)
         _errorLimit = new ErrorLimit();
     _errorLimit.Confidence = edtConfidence.Quantity;
     edtErrorLimit.Text = _errorLimit.ToString();
 }