Пример #1
0
        private static decimal GetLineError(decimal vMax, decimal vMin, TestPoint point, int count)
        {
            var idealV = Math.Round(((vMax - vMin) / (count - 1)) * point.Index + vMin, 2);

            if (idealV <= 0.001m)
            {
                idealV = 0.001m;
            }
            return(((point.ActualV / idealV) - 1) * 100);
        }
Пример #2
0
        /// <summary>
        /// 获取相对的数据
        /// </summary>
        /// <param name="dataList"></param>
        /// <returns></returns>
        public static List <TestPoint> GetRelativePoints(List <TestPoint> dataList)
        {
            List <TestPoint> newDataList = new List <TestPoint>();

            foreach (var testPoint in dataList)
            {
                var data = new TestPoint();
                data.UpperV  = Math.Abs(testPoint.UpperV - 5);
                data.ActualV = Math.Abs(testPoint.ActualV - 5);
                data.DownV   = Math.Abs(testPoint.DownV - 5);
                data.IdealV  = Math.Abs(testPoint.IdealV - 5);
                newDataList.Add(data);
            }

            return(newDataList);
        }
Пример #3
0
        public static List <TestPoint> GetTestPointList(List <decimal> vList, decimal downAngle, decimal upperAngle,
                                                        decimal error, decimal vMax, decimal vMin, decimal upError, decimal downError)
        {
            if (vList.Count < 2)
            {
                throw new Exception("测试点数最少为2");
            }
            //采集点之间的角度间隔
            var slopeAngle = (upperAngle - downAngle) / (vList.Count - 1);
            //采集点之间的电压差
            var slopeV1 = (vMax - vMin) / (vList.Count - 1);
            //角度一直的电压差
            var slopeV            = ((decimal)(vMax - vMin)) / (upperAngle - downAngle);
            List <TestPoint> list = new List <TestPoint>();
            var angleBegin        = downAngle;
            var dataIndex         = 0;

            foreach (decimal item in vList)
            {
                var point = new TestPoint()
                {
                    Angle = Math.Round(angleBegin, 2),
                    //实际采集值
                    ActualV = item,
                    //理论采集值
                    IdealV = vMin,
                    //采集上限
                    //序号
                    Index = dataIndex++
                };
                //理想电压
                point.IdealV = Math.Round(vMin + slopeV1 * point.Index, 2);
                //上限电压
                point.UpperV = GetValue(vMin, slopeV1, upError / 100m, point.Index);
                //下线电压
                point.DownV = GetValue(vMin, slopeV1, -1 * (downError / 100m), point.Index);

                list.Add(point);
                angleBegin += slopeAngle;
            }


            return(list);
        }
Пример #4
0
        /// <summary>
        /// 查找最大的误差数据
        /// </summary>
        /// <param name="list"></param>
        public static void FindMaxErrorData(List <TestPoint> list)
        {
            decimal   interval     = 0;
            TestPoint maxErrorData = null;

            foreach (var testPoint in list)
            {
                if (Math.Abs(testPoint.ActualV - testPoint.IdealV) > interval)
                {
                    interval     = Math.Abs(testPoint.ActualV - testPoint.IdealV);
                    maxErrorData = testPoint;
                }
            }
            //如果找到了误差最大的数据,就记性标记
            if (null != maxErrorData)
            {
                maxErrorData.IsMaxError = false;
            }
        }