Ejemplo n.º 1
0
        public void SetOriginalPoints(I_V_Point[] oriPointArray, bool evalAll)
        {
            OldoriPointArray = oriPointArray;

            //#region 2013-06-03 曲线异常Bug修改,如果倒数第二个点靠近最后一个点,则移除
            I_V_Point[] pointArray = null;
            //if (oriPointArray != null)
            //{
            //    int oriLen = oriPointArray.Length;
            //    if (oriPointArray[oriLen - 2].Current < 0.5)
            //    {
            //        pointArray = new I_V_Point[oriLen - 1];
            //        Array.Copy(oriPointArray, pointArray, oriLen - 1);
            //        pointArray[oriLen - 2].Current = oriPointArray[oriLen - 1].Current;
            //        pointArray[oriLen - 2].Voltage = oriPointArray[oriLen - 1].Voltage;
            //    }
            //    else
            //    {
            //        pointArray = oriPointArray;
            //    }
            //}
            //#endregion

            _OriPointList = new List <Point>();

            _CurvasPointList = new List <Point>();
            _PowerPointList  = new List <Point>();// add by genhong.hu On 2016-06-02 增加功率曲线
            if (oriPointArray == null)
            {
                CleanSpine();
                return;
            }
            if (oriPointArray.Length != 3)
            {
                //MessageBox.Show("RFID标签数据异常,无法显示曲线。");
                //return;
                if (oriPointArray != null)
                {
                    int oriLen = oriPointArray.Length;
                    if (oriPointArray[oriLen - 2].Current < 0.5)
                    {
                        pointArray = new I_V_Point[oriLen - 1];
                        Array.Copy(oriPointArray, pointArray, oriLen - 1);
                        pointArray[oriLen - 2].Current = oriPointArray[oriLen - 1].Current;
                        pointArray[oriLen - 2].Voltage = oriPointArray[oriLen - 1].Voltage;
                    }
                    else
                    {
                        pointArray = oriPointArray;
                    }
                }
            }
            else
            {
                #region ======================================================
                int    PointCount = 100;
                double Voc        = oriPointArray[2].Voltage;
                double Isc        = oriPointArray[0].Current;
                double Vpm        = oriPointArray[1].Voltage;
                double Ipm        = oriPointArray[1].Current;
                pointArray = new I_V_Point[PointCount + 3];
                I_V_Point s1 = new I_V_Point();
                s1.Voltage    = 0;
                s1.Current    = Isc;
                pointArray[0] = s1;


                for (int i = 1; i < PointCount + 1; i++)
                {
                    I_V_Point s2 = new I_V_Point();
                    s2.Voltage    = 0 + (Vpm - 0) / (PointCount + 1) * i;
                    s2.Current    = Isc - (Isc - Ipm) / (PointCount + 1) * i;
                    pointArray[i] = s2;
                }



                I_V_Point s4 = new I_V_Point();
                s4.Voltage = Vpm;
                s4.Current = Ipm;
                I_V_Point s5 = new I_V_Point();
                s5.Voltage = Voc;
                s5.Current = 0;

                pointArray[PointCount + 1] = s4;
                pointArray[PointCount + 2] = s5;
                #endregion
            }
            foreach (I_V_Point oriPoint in pointArray)
            {
                _OriPointList.Add(GetPointByOriginal(oriPoint));
            }
            if (evalAll)
            {
                I_V_Point[] points = MySpline.Spline(pointArray);
                if (points == null)
                {
                    MessageBox.Show("RFID标签数据异常,无法显示曲线。");
                    return;
                }
                foreach (I_V_Point oriPoint in points)
                {
                    _CurvasPointList.Add(GetPointByOriginal(oriPoint));

                    // add by genhong.hu On 2016-06-02 增加功率曲线
                    P_V_Point pmaxpoint = new P_V_Point();
                    pmaxpoint.Pmax    = oriPoint.Current * oriPoint.Voltage;
                    pmaxpoint.Voltage = oriPoint.Voltage;
                    _PowerPointList.Add(GetPowerPointByOriginal(pmaxpoint));
                }
                #region   计算
                //  _CurvasPointList = _OriPointList;
                #endregion

                //2014-03-30 曲线画到电流为0
                Point lastPointToZero = new Point();
                lastPointToZero.X = _CurvasPointList[_CurvasPointList.Count - 1].X;
                lastPointToZero.Y = _CvsRect.Top + _CvsRect.Height;
                _CurvasPointList.Add(lastPointToZero);

                _PowerPointList.Add(lastPointToZero);// add by genhong.hu On 2016-06-02 增加功率曲线
            }
            this.Invalidate();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 设置真实的数据点,并根据需要计算插值
        /// </summary>
        /// <param name="oriPointArray">真实的数据点</param>
        /// <param name="evalAll">是否需要计算所有数据点</param>
        public void SetOriginalPoints_0(I_V_Point[] oriPointArray, bool evalAll)
        {
            #region 2013-06-03 曲线异常Bug修改,如果倒数第二个点靠近最后一个点,则移除
            I_V_Point[] pointArray = null;
            if (oriPointArray != null)
            {
                int oriLen = oriPointArray.Length;
                if (oriPointArray[oriLen - 2].Current < 0.5)
                {
                    pointArray = new I_V_Point[oriLen - 1];
                    Array.Copy(oriPointArray, pointArray, oriLen - 1);
                    pointArray[oriLen - 2].Current = oriPointArray[oriLen - 1].Current;
                    pointArray[oriLen - 2].Voltage = oriPointArray[oriLen - 1].Voltage;
                }
                else
                {
                    pointArray = oriPointArray;
                }
            }
            #endregion

            _OriPointList = new List <Point>();

            _CurvasPointList = new List <Point>();
            _PowerPointList  = new List <Point>();// add by genhong.hu On 2016-06-02 增加功率曲线
            if (pointArray == null)
            {
                return;
            }
            foreach (I_V_Point oriPoint in pointArray)
            {
                _OriPointList.Add(GetPointByOriginal(oriPoint));
            }
            if (evalAll)
            {
                I_V_Point[] points = MySpline.Spline(pointArray);
                if (points == null)
                {
                    MessageBox.Show("RFID标签数据异常,无法显示曲线。");
                    return;
                }
                foreach (I_V_Point oriPoint in points)
                {
                    _CurvasPointList.Add(GetPointByOriginal(oriPoint));

                    // add by genhong.hu On 2016-06-02 增加功率曲线
                    P_V_Point pmaxpoint = new P_V_Point();
                    pmaxpoint.Pmax    = oriPoint.Current * oriPoint.Voltage;
                    pmaxpoint.Voltage = oriPoint.Voltage;
                    _PowerPointList.Add(GetPowerPointByOriginal(pmaxpoint));
                }
                //2014-03-30 曲线画到电流为0
                Point lastPointToZero = new Point();
                lastPointToZero.X = _CurvasPointList[_CurvasPointList.Count - 1].X;
                lastPointToZero.Y = _CvsRect.Top + _CvsRect.Height;
                _CurvasPointList.Add(lastPointToZero);

                _PowerPointList.Add(lastPointToZero);// add by genhong.hu On 2016-06-02 增加功率曲线
            }
            this.Invalidate();
        }