Пример #1
0
        private object GetChannelValue(ChannelHistoryRecord channel)
        {
            double?value = null;

            if (channel.DisplayValue != null)
            {
                if (channel.Value != null && IsTimeSpan(channel))
                {
                    return(TimeSpan.FromSeconds(channel.Value.Value));
                }

                if (IsValueLookup(channel.DisplayValue))
                {
                    return(channel.DisplayValue);
                }

                var space = channel.DisplayValue.IndexOf(' ');

                var valueStr = channel.DisplayValue;

                if (space > 0)
                {
                    valueStr = channel.DisplayValue.Substring(0, space);
                }

                if (valueStr == "<1")
                {
                    valueStr = "0";
                }
                else if (valueStr == ">99")
                {
                    valueStr = "100";
                }
                else if (valueStr == "<" || valueStr == ">")
                {
                    var first  = channel.DisplayValue.IndexOf(' ') + 1;
                    var second = channel.DisplayValue.IndexOf(' ', first);

                    valueStr = channel.DisplayValue.Substring(first, second - first);
                }

                value = ConvertUtilities.ToDynamicDouble(valueStr, channel.Value);
            }

            return(value);
        }
Пример #2
0
        private void TestDouble(string s, double d, double expected)
        {
            var result = ConvertUtilities.ToDynamicDouble(s, d);

            Assert.AreEqual(expected, result);
        }