Пример #1
0
        private static void TestUnitConversion(Parameter parameter, double retval)
        {
            double num  = 0.01;
            double num2 = double.NaN;
            string text = parameter.AsValueString();

            if (text.Contains("\"") || text.Contains("'"))
            {
                string text2 = parameter.DisplayUnitType.ToString();
                if (text2.Contains("FEET") || text2.Contains("INCHE"))
                {
                    num2 = APIObjectList.ConvertImperial(text);
                }
            }
            else
            {
                Regex  regex = new Regex("-?\\d+(\\.\\d+)?");
                string value = regex.Match(parameter.AsValueString()).Groups[0].Value;
                try
                {
                    num2 = double.Parse(value);
                }
                catch (System.Exception ex)
                {
                    Log.WriteWarning("1. RetVal={1} ValueString={0}, RegexInput={2}, DUT={3}, Exception={4}", new object[]
                    {
                        parameter.AsValueString(),
                        retval,
                        text,
                        parameter.DisplayUnitType,
                        ex.Message
                    });
                }
            }
            if (System.Math.Abs(num2 - retval) > num)
            {
                Log.WriteWarning("Unit conversion failure: RetVal={0} ApiValue={1} ValueString={2}, calculated={3}, DUT={4}, Parameter={5}", new object[]
                {
                    retval,
                    parameter.AsDouble(),
                    parameter.AsValueString(),
                    num2,
                    parameter.DisplayUnitType,
                    parameter.Definition.Name
                });
            }
        }