public void Calculate()
        {
            if (!ready)
            {
                return;
            }
            pm.Axes[0].MinorStep = double.NaN;
            pm.Axes[0].MajorStep = double.NaN;
            CGear  frtemp = frnow;
            CGear  bktemp = bknow;
            CGear  intemp = innow;
            CWheel whtemp = (CWheel)whnow.Clone();

            whtemp.Lenth = Whlength;

            list.Items.Clear();

            lineSeriesCurrent.Points.Clear();
            double toothratemax = 0;
            double toothratemin = 0;

            int num = 1;

            NaNNumber.Clear();
            for (int i = 0; i < frtemp.Speeds; i++)
            {
                for (int k = 0; k < intemp.Speeds; k++)
                {
                    for (int j = 0; j < bktemp.Speeds; j++)
                    {
                        CResult resulttemp = new CResult();
                        resulttemp.No1 = num;
                        num++;
                        resulttemp.Gear1  = "";
                        resulttemp.GearT1 = "";
                        if (frtemp.Speeds != 1)
                        {
                            resulttemp.Gear1  += (i + 1).ToString();
                            resulttemp.GearT1 += frtemp.teeth[i].teeth.ToString() + "T";
                        }
                        if (bktemp.Speeds != 1)
                        {
                            if (resulttemp.Gear1 != "")
                            {
                                resulttemp.Gear1  += "x";
                                resulttemp.GearT1 += "x";
                            }
                            resulttemp.Gear1  += (j + 1).ToString();
                            resulttemp.GearT1 += bktemp.teeth[j].teeth.ToString() + "T";
                        }
                        if (intemp.Speeds != 1)
                        {
                            if (resulttemp.Gear1 != "")
                            {
                                resulttemp.Gear1  += "x";
                                resulttemp.GearT1 += "x";
                            }
                            resulttemp.Gear1  += (k + 1).ToString();
                            resulttemp.GearT1 += intemp.teeth[k].Teeth.ToString("0.00");
                        }
                        double toothrateout = (double)frtemp.teeth[i].teeth / (double)bktemp.teeth[j].teeth;
                        double toothrate    = toothrateout * intemp.teeth[k].teeth;

                        if (toothratemin == 0)
                        {
                            toothratemin = toothrate;
                        }
                        if (toothratemax == 0)
                        {
                            toothratemax = toothrate;
                        }
                        if (toothrate < toothratemin)
                        {
                            toothratemin = toothrate;
                        }
                        if (toothrate > toothratemax)
                        {
                            toothratemax = toothrate;
                        }

                        resulttemp.GearRatio1  = toothrate;
                        resulttemp.SpeedRatio1 = toothrate * whtemp.Lenth / 3.1415926535 / 25.4;

                        if (IsSpd)
                        {
                            if (IsMPH)
                            {
                                resulttemp.Speed1 = Cad * 1.609344 / 2.0 * 1000000.0 / 60.0 / whtemp.Lenth / toothrate;
                            }
                            else
                            {
                                resulttemp.Speed1 = Cad / 2.0 * 1000000.0 / 60.0 / whtemp.Lenth / toothrate;
                            }
                        }
                        else
                        {
                            if (IsMPH)
                            {
                                resulttemp.Speed1 = toothrate * Cad * whtemp.Lenth * 60 / 1000000.0 * 0.6213712;
                            }
                            else
                            {
                                resulttemp.Speed1 = toothrate * Cad * whtemp.Lenth * 60 / 1000000.0;
                            }
                        }

                        if (num >= 3)
                        {
                            resulttemp.Increment1 = toothrate / toothrateold - 1.0;
                        }
                        toothrateold = toothrate;

                        resulttemp.Remark1 = "";
                        if (frtemp.Speeds != 1 && bktemp.Speeds != 1)
                        {
                            if (i == frtemp.Speeds - 1 && j == 0)
                            {
                                resulttemp.Remark1 += Properties.Resources.StringLFLB;
                            }
                            if (i == 0 && j == bktemp.Speeds - 1)
                            {
                                resulttemp.Remark1 += Properties.Resources.StringSFSB;
                            }
                        }

                        if (intemp.Speeds != 1)
                        {
                            if (toothrateout < 1.5)
                            {
                                resulttemp.Remark1 += Properties.Resources.StringTorque;
                            }
                        }
                        results.Add(resulttemp);
                        list.Items.Add(resulttemp);


                        double tempx = 0;
                        double tempy = 0;
                        switch (CurveX)
                        {
                        case 0:    //不分支
                            tempx = num - 1;
                            break;

                        case 1:    //按牙盘
                            tempx = bktemp.Speeds * k + j + 1;
                            break;

                        case 2:    //按飞轮
                            tempx = i * frtemp.Speeds + k + 1;
                            break;

                        case 3:    //按内变速
                            tempx = i * bktemp.Speeds + j + 1;
                            break;
                        }


                        switch (CurveY)
                        {
                        case 1:    //走距速比
                            tempy = toothrate * whtemp.Lenth / 1000.0;
                            break;

                        case 2:    //GI速比
                            tempy = toothrate * whtemp.Lenth / 3.1415926535 / 25.4;
                            break;

                        case 3:    //齿比
                            tempy = toothrate;
                            break;

                        case 4:    //车速踏频
                            tempy = resulttemp.Speed1;
                            break;
                        }
                        if (lineSeriesCurrent.Points.Count >= 2)
                        {
                            if (lineSeriesCurrent.Points[lineSeriesCurrent.Points.Count - 2].X != double.NaN)
                            {
                                if (tempx - lineSeriesCurrent.Points[lineSeriesCurrent.Points.Count - 2].X <= 0)
                                {
                                    lineSeriesCurrent.Points.Add(new DataPoint(double.NaN, double.NaN));
                                    NaNNumber.Add(num - 1);
                                }
                            }
                        }
                        lineSeriesCurrent.Points.Add(new DataPoint(tempx, tempy));
                    }
                }
            }

            switch (CurveX)
            {
            case 0:    //不分支
                pm.Axes[0].Title = Properties.Resources.StringGear + " No.";
                break;

            case 1:    //按牙盘
                pm.Axes[0].Title = Properties.Resources.StringGear + " No. (" + Properties.Resources.StringBranchfr + ")";
                break;

            case 2:    //按飞轮
                pm.Axes[0].Title = Properties.Resources.StringGear + " No. (" + Properties.Resources.StringBranchbk + ")";
                break;

            case 3:    //按内变速
                pm.Axes[0].Title = Properties.Resources.StringGear + " No. (" + Properties.Resources.StringBranchin + ")";
                break;
            }


            switch (CurveY)
            {
            case 1:    //走距速比
                pm.Axes[1].Title = Properties.Resources.StringSpdRatio;
                break;

            case 2:    //GI速比
                pm.Axes[1].Title = Properties.Resources.StringGI;
                break;

            case 3:    //齿比
                pm.Axes[1].Title = Properties.Resources.StringGearRatio;
                break;

            case 4:    //车速踏频
                pm.Axes[1].Title = (IsSpd ? Properties.Resources.StringCAD + "(rpm)" : (Properties.Resources.StringSpeed + (IsMPH ? "(mph)" : "(km/h)")));
                break;
            }


            label0.Content = Properties.Resources.StringTotaldiff + ": " +
                             (Convert.ToDouble(toothratemax / toothratemin * 100.0)).ToString("F0") +
                             "%";
            label1.Content = Properties.Resources.StringTotalCap + ": " +
                             (frtemp.teeth[frtemp.Speeds - 1].teeth - frtemp.teeth[0].teeth - bktemp.teeth[bktemp.Speeds - 1].teeth + bktemp.teeth[0].teeth).ToString() + "T";



            chart.ResetAllAxes();
            chart.InvalidatePlot(true);
            pm.Axes[1].Minimum = 0;
            //if (pm.Axes[0].ActualMinorStep < 0.9 && pm.Axes[0].MinorStep == double.NaN) pm.Axes[0].MinorStep = 1;
            //if (pm.Axes[0].ActualMajorStep < 0.9 && pm.Axes[0].MajorStep == double.NaN) pm.Axes[0].MajorStep = 1;
            //Chart1.InvalidatePlot(true);
        }
Example #2
0
        public void Calculate()
        {
            if (!ready)
            {
                return;
            }
            pm.Series.Clear();
            //pm.Axes[0].MinorStep = double.NaN;
            //pm.Axes[0].MajorStep = double.NaN;
            //CHub hubtemp = frnow;
            CHub hubtemp = hubnow;
            CRim rimtemp = rimnow;

            if (Spokes <= 3)
            {
                return;
            }


            ///////////////左侧///////////////////////
            //花鼓孔
            var hubhole = new ScatterSeries();

            hubhole.MarkerType = MarkerType.Circle;
            hubhole.MarkerSize = 3;
            hubhole.Title      = Properties.Resources.StringHubHoleL;
            for (int i = 0; i < Spokes / 2; i++)
            {
                double       theta        = 2.0 * Math.PI / (Spokes / 2.0) * i;
                double       x            = Math.Sin(theta) * hubtemp.LeftFlange / 2.0;
                double       y            = Math.Cos(theta) * hubtemp.LeftFlange / 2.0;
                ScatterPoint scatterPoint = new ScatterPoint(x, y);
                hubhole.Points.Add(scatterPoint);
            }
            //轮圈孔
            var rimhole = new ScatterSeries();

            rimhole.MarkerType = MarkerType.Circle;
            rimhole.MarkerSize = 3;
            for (int i = 0; i < Spokes / 2; i++)
            {
                double       theta        = 2.0 * Math.PI / (Spokes / 2.0) * i;
                double       x            = Math.Sin(theta) * rimtemp.ERD / 2.0;
                double       y            = Math.Cos(theta) * rimtemp.ERD / 2.0;
                ScatterPoint scatterPoint = new ScatterPoint(x, y);
                rimhole.Points.Add(scatterPoint);
            }
            //轮圈线
            var rimline = new LineSeries();

            rimline.StrokeThickness = 2;
            for (int i = 0; i < 101; i++)
            {
                double theta = 2.0 * Math.PI / 100.0 * i;
                double x     = Math.Sin(theta) * rimtemp.ERD / 2.0;
                double y     = Math.Cos(theta) * rimtemp.ERD / 2.0;
                rimline.Points.Add(new DataPoint(x, y));
            }
            //花鼓线
            var hubline = new LineSeries();

            hubline.StrokeThickness = 2;
            for (int i = 0; i < 101; i++)
            {
                double theta = 2.0 * Math.PI / 100.0 * i;
                double x     = Math.Sin(theta) * hubtemp.LeftFlange / 2.0 * 1.2;
                double y     = Math.Cos(theta) * hubtemp.LeftFlange / 2.0 * 1.2;
                hubline.Points.Add(new DataPoint(x, y));
            }
            hubline.Points.Add(new DataPoint(double.NaN, double.NaN));
            for (int i = 0; i < 101; i++)
            {
                double theta = 2.0 * Math.PI / 100.0 * i;
                double x     = Math.Sin(theta) * 7.0;
                double y     = Math.Cos(theta) * 7.0;
                hubline.Points.Add(new DataPoint(x, y));
            }
            //辐条
            var spokesline = new LineSeries();

            spokesline.Title           = Properties.Resources.StringSpokeL;
            spokesline.StrokeThickness = 1;
            double spokeslenthraw = 0;

            for (int i = 0; i < Spokes / 2; i++)
            {
                DataPoint p1 = new DataPoint(hubhole.Points[i].X, hubhole.Points[i].Y);
                int       j  = 0;
                if (i % 2 == 0)
                {
                    j = i + CrossesL;
                }
                else
                {
                    j = i - CrossesL;
                }
                while (j < 0)
                {
                    j += Spokes / 2;
                }
                j = j % (Spokes / 2);

                DataPoint p2 = new DataPoint(rimhole.Points[j].X, rimhole.Points[j].Y);
                if (spokeslenthraw == 0)
                {
                    spokeslenthraw = (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);
                }
                spokesline.Points.Add(p1);
                spokesline.Points.Add(p2);
                spokesline.Points.Add(new DataPoint(double.NaN, double.NaN));
            }


            /////////////////////右侧///////////////////////
            //花鼓孔
            var hubholer = new ScatterSeries();

            hubholer.MarkerSize = 3;
            hubholer.Title      = Properties.Resources.StringHubHoleR;
            hubholer.MarkerType = MarkerType.Circle;
            for (int i = 0; i < Spokes / 2; i++)
            {
                double       theta        = 2.0 * Math.PI / (Spokes / 2.0) * (i + 0.5);
                double       x            = Math.Sin(theta) * hubtemp.RightFlange / 2.0;
                double       y            = Math.Cos(theta) * hubtemp.RightFlange / 2.0;
                ScatterPoint scatterPoint = new ScatterPoint(x, y);
                hubholer.Points.Add(scatterPoint);
            }
            //轮圈孔
            var rimholer = new ScatterSeries();

            rimholer.MarkerSize = 3;
            rimholer.MarkerType = MarkerType.Circle;
            for (int i = 0; i < Spokes / 2; i++)
            {
                double       theta        = 2.0 * Math.PI / (Spokes / 2.0) * (i + 0.5);
                double       x            = Math.Sin(theta) * rimtemp.ERD / 2.0;
                double       y            = Math.Cos(theta) * rimtemp.ERD / 2.0;
                ScatterPoint scatterPoint = new ScatterPoint(x, y);
                rimholer.Points.Add(scatterPoint);
            }
            //辐条
            var spokesliner = new LineSeries();

            spokesliner.Title           = Properties.Resources.StringSpokeR;
            spokesliner.StrokeThickness = 1;
            double spokeslenthrawr = 0;

            for (int i = 0; i < Spokes / 2; i++)
            {
                DataPoint p1 = new DataPoint(hubholer.Points[i].X, hubholer.Points[i].Y);
                int       j  = 0;
                if (i % 2 == 0)
                {
                    j = i + CrossesR;
                }
                else
                {
                    j = i - CrossesR;
                }
                while (j < 0)
                {
                    j += Spokes / 2;
                }
                j = j % (Spokes / 2);

                DataPoint p2 = new DataPoint(rimholer.Points[j].X, rimholer.Points[j].Y);
                if (spokeslenthrawr == 0)
                {
                    spokeslenthrawr = (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);
                }
                spokesliner.Points.Add(p1);
                spokesliner.Points.Add(p2);
                spokesliner.Points.Add(new DataPoint(double.NaN, double.NaN));
            }

            if (disrimline)
            {
                pm.Series.Add(rimline);
            }
            if (dishubline)
            {
                pm.Series.Add(hubline);
            }
            if (disrightside && dishubhole)
            {
                pm.Series.Add(hubholer);
            }
            if (disleftside && dishubhole)
            {
                pm.Series.Add(hubhole);
            }
            if (disrightside && disrimhole)
            {
                pm.Series.Add(rimholer);
            }
            if (disleftside && disrimhole)
            {
                pm.Series.Add(rimhole);
            }
            if (disrightside && disspokesline)
            {
                pm.Series.Add(spokesliner);
            }
            if (disleftside && disspokesline)
            {
                pm.Series.Add(spokesline);
            }
            chart.ResetAllAxes();
            chart.InvalidatePlot(true);


            list.Items.Clear();

            for (int i = 0; i < 6; i++)
            {
                DataPoint p1 = new DataPoint(hubhole.Points[0].X, hubhole.Points[0].Y);
                while (i < 0)
                {
                    i += Spokes / 2;
                }
                int       j  = i % (Spokes / 2);
                DataPoint p2 = new DataPoint(rimhole.Points[j].X, rimhole.Points[j].Y);
                spokeslenthraw = (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);

                p1 = new DataPoint(hubhole.Points[0].X, hubhole.Points[0].Y);
                while (i < 0)
                {
                    i += Spokes / 2;
                }
                j  = i % (Spokes / 2);
                p2 = new DataPoint(rimhole.Points[j].X, rimhole.Points[j].Y);
                spokeslenthrawr = (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);


                CSpokeResult resulttemp = new CSpokeResult();
                resulttemp.Crosses = i;
                double offsetl = hubtemp.CenterToLeft - rimtemp.OSB;
                double offsetr = hubtemp.CenterToRight + rimtemp.OSB;
                resulttemp.Lenthleft  = Math.Sqrt(spokeslenthraw + offsetl * offsetl) - hubtemp.SpokeHole / 2.0;
                resulttemp.Lenthright = Math.Sqrt(spokeslenthrawr + offsetr * offsetr) - hubtemp.SpokeHole / 2.0;;

                double sinphyl = offsetl / Math.Sqrt(spokeslenthraw);
                double sinphyr = offsetr / Math.Sqrt(spokeslenthrawr);
                resulttemp.Tensionratio = sinphyr / sinphyl;
                resulttemp.Remark       = "";
                list.Items.Add(resulttemp);
            }
            if (CrossesL > 5)
            {
                int       i  = CrossesL;
                DataPoint p1 = new DataPoint(hubhole.Points[0].X, hubhole.Points[0].Y);
                while (i < 0)
                {
                    i += Spokes / 2;
                }
                int j = i % (Spokes / 2);

                DataPoint p2 = new DataPoint(rimhole.Points[j].X, rimhole.Points[j].Y);
                spokeslenthraw = (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);

                p1 = new DataPoint(hubhole.Points[0].X, hubhole.Points[0].Y);
                while (i < 0)
                {
                    i += Spokes / 2;
                }
                j  = i % (Spokes / 2);
                p2 = new DataPoint(rimhole.Points[j].X, rimhole.Points[j].Y);
                spokeslenthrawr = (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);


                CSpokeResult resulttemp = new CSpokeResult();
                resulttemp.Crosses = i;
                double offsetl = hubtemp.CenterToLeft - rimtemp.OSB;
                double offsetr = hubtemp.CenterToRight + rimtemp.OSB;
                resulttemp.Lenthleft  = Math.Sqrt(spokeslenthraw + offsetl * offsetl) - hubtemp.SpokeHole / 2.0;
                resulttemp.Lenthright = Math.Sqrt(spokeslenthrawr + offsetr * offsetr) - hubtemp.SpokeHole / 2.0;;

                double sinphyl = offsetl / Math.Sqrt(spokeslenthraw);
                double sinphyr = offsetr / Math.Sqrt(spokeslenthrawr);
                resulttemp.Tensionratio = sinphyr / sinphyl;
                resulttemp.Remark       = "";
                list.Items.Add(resulttemp);
            }
            if (CrossesR > 5 && CrossesR != CrossesL)
            {
                int       i  = CrossesR;
                DataPoint p1 = new DataPoint(hubhole.Points[0].X, hubhole.Points[0].Y);
                while (i < 0)
                {
                    i += Spokes / 2;
                }
                int j = i % (Spokes / 2);

                DataPoint p2 = new DataPoint(rimhole.Points[j].X, rimhole.Points[j].Y);
                spokeslenthraw = (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);

                p1 = new DataPoint(hubhole.Points[0].X, hubhole.Points[0].Y);
                while (i < 0)
                {
                    i += Spokes / 2;
                }
                j  = i % (Spokes / 2);
                p2 = new DataPoint(rimhole.Points[j].X, rimhole.Points[j].Y);
                spokeslenthrawr = (p1.X - p2.X) * (p1.X - p2.X) + (p1.Y - p2.Y) * (p1.Y - p2.Y);


                CSpokeResult resulttemp = new CSpokeResult();
                resulttemp.Crosses = i;
                double offsetl = hubtemp.CenterToLeft - rimtemp.OSB;
                double offsetr = hubtemp.CenterToRight + rimtemp.OSB;
                resulttemp.Lenthleft  = Math.Sqrt(spokeslenthraw + offsetl * offsetl) - hubtemp.SpokeHole / 2.0;
                resulttemp.Lenthright = Math.Sqrt(spokeslenthrawr + offsetr * offsetr) - hubtemp.SpokeHole / 2.0;;

                double sinphyl = offsetl / Math.Sqrt(spokeslenthraw);
                double sinphyr = offsetr / Math.Sqrt(spokeslenthrawr);
                resulttemp.Tensionratio = sinphyr / sinphyl;
                resulttemp.Remark       = "";
                list.Items.Add(resulttemp);
            }
        }