Esempio n. 1
0
 public TireEditor(string title, CWheel _item)
 {
     itempt = _item;
     item   = (CWheel)itempt.Clone();
     InitializeComponent();
     this.Title = title;
 }
        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);
        }