Ejemplo n.º 1
0
 private void calcTime()
 {
     if (speed == 0)
     {
         time = 0;
     }
     else if (distance < neffdst || distance > effdst)
     {
         time = 0;
     }
     else
     {
         time = chkconst + TimeSpan.FromHours((distance - neffdst) / DataConverters.SpeedUnits(speed, spdunit, "KPH")).TotalSeconds;
     }
 }
        private void changeUnits(object sender, SelectionChangedEventArgs e)
        {
            if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
            {
                isUnitsFixed               = false;
                default_unitsBtn.Content   = "Fix Units";
                default_unitsBtn.IsEnabled = true;
            }
            switch ((sender as ComboBox).Name)
            {
            case "alt_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.alt = DataConverters.LengthUnits(param.alt, alt_units.Text, alt_units.SelectedValue.ToString());
                    }
                    performanceChart.Items.Refresh();
                }
                break;

            case "dist_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.climbdist   = DataConverters.LengthUnits(param.climbdist, dist_units.Text, dist_units.SelectedValue.ToString());
                        param.descenddist = DataConverters.LengthUnits(param.descenddist, dist_units.Text, dist_units.SelectedValue.ToString());
                    }
                    performanceChart.Items.Refresh();
                }
                break;

            case "speed_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    if (!String.IsNullOrEmpty(dataspd1.Text))
                    {
                        dataspd1.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd1.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd2.Text))
                    {
                        dataspd2.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd2.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd3.Text))
                    {
                        dataspd3.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd3.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd4.Text))
                    {
                        dataspd4.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd4.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                    if (!String.IsNullOrEmpty(dataspd5.Text))
                    {
                        dataspd5.Text = DataConverters.SpeedUnits(Convert.ToDouble(dataspd5.Text), speed_units.Text.Split('-')[1], speed_units.SelectedValue.ToString().Split('-')[1]).ToString();
                    }
                }
                break;

            case "fuel_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.climbfuel   = DataConverters.MassUnits(param.climbfuel, fuel_units.Text, fuel_units.SelectedValue.ToString());
                        param.descendfuel = DataConverters.MassUnits(param.descendfuel, fuel_units.Text, fuel_units.SelectedValue.ToString());
                    }
                    foreach (FuelStartData param in fsdata.fuelStartDatas)
                    {
                        param.startval = DataConverters.MassUnits(param.startval, fuel_units.Text, fuel_units.SelectedValue.ToString());
                    }
                    foreach (FuelReduceData param in frdata.fuelReduceDatas)
                    {
                        param.reductionval = DataConverters.MassUnits(param.reductionval, fuel_units.Text, fuel_units.SelectedValue.ToString());
                    }
                    performanceChart.Items.Refresh();
                    startFuelChart.Items.Refresh();
                    reductionFuelChart.Items.Refresh();
                }
                break;

            case "lfft_units":
                if (performanceChart != null && startFuelChart != null && reductionFuelChart != null)
                {
                    if (pdata.performanceDatas.Count != 0)
                    {
                        if (MessageBox.Show($"Changing This Unit Will Result in Resetting All the Existing {Environment.NewLine} Value Corresponding to This Unit {Environment.NewLine} {Environment.NewLine} Are you sure you want to proceed?", "Warning", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.Cancel)
                        {
                            lfft_units.SelectionChanged -= changeUnits;
                            lfft_units.SelectedValue     = lfft_units.Text;
                            lfft_units.SelectionChanged += changeUnits;
                            return;
                        }
                    }
                    foreach (PerformanceData param in pdata.performanceDatas)
                    {
                        param.spd1 = DataConverters.ConsumptionUnits(param.spd1, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd2 = DataConverters.ConsumptionUnits(param.spd2, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd3 = DataConverters.ConsumptionUnits(param.spd3, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd4 = DataConverters.ConsumptionUnits(param.spd4, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                        param.spd5 = DataConverters.ConsumptionUnits(param.spd5, lfft_units.Text.Replace(" ", String.Empty), lfft_units.SelectedValue.ToString().Replace(" ", String.Empty));
                    }
                    performanceChart.Items.Refresh();
                }
                break;

            default:
                return;
            }
        }
Ejemplo n.º 3
0
 public void calcTime()
 {
     if (type == "Starting")
     {
         if (speed == 0)
         {
             time = 0;
         }
         else if (distance < climbdist)
         {
             time = 0;
         }
         else
         {
             transition      = @"climb";
             neffectivedst   = DataConverters.LengthUnits(climbdist, baseDistunit, "KM");
             effectivedst    = DataConverters.LengthUnits(distance, baseDistunit, "KM");
             checkpointconst = climbtime - TimeSpan.FromHours(DataConverters.LengthUnits(climbdist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
             lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - climbdist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
             tocbodtime      = climbtime;
             landingtime     = 0;
             time            = tocbodtime + lvltime + landingtime;
         }
     }
     else if (type == "Origin")
     {
         time = 0;
     }
     else if (type == "Landing" || type == "Diversion")
     {
         if (speed == 0)
         {
             time = 0;
         }
         else
         {
             pullprevData();
             if (type == "Landing" && componentID == 1)
             {
                 if (distance < descenddist + climbdist)
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"climb";
                     neffectivedst   = DataConverters.LengthUnits(climbdist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM");
                     checkpointconst = climbtime + descendtime - TimeSpan.FromHours(DataConverters.LengthUnits(descenddist + climbdist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (descenddist + climbdist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = climbtime;
                     landingtime     = descendtime;
                     time            = tocbodtime + lvltime + landingtime;
                 }
                 return;
             }
             if (alt > prev_alt)
             {
                 if (distance < descenddist + (climbdist - prev_climbdist))
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"climb";
                     neffectivedst   = DataConverters.LengthUnits(climbdist - prev_climbdist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM");
                     checkpointconst = (climbtime - prev_climbtime) + descendtime - TimeSpan.FromHours(DataConverters.LengthUnits(descenddist + (climbdist - prev_climbdist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (descenddist + (climbdist - prev_climbdist)), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = (climbtime - prev_climbtime);
                     landingtime     = descendtime;
                     time            = tocbodtime + lvltime + landingtime;
                 }
             }
             else if (alt < prev_alt)
             {
                 if (distance < descenddist + (prev_descenddist - descenddist))
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"descend";
                     neffectivedst   = DataConverters.LengthUnits(prev_descenddist - descenddist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM");
                     checkpointconst = (prev_descendtime - descendtime) + descendtime - TimeSpan.FromHours(DataConverters.LengthUnits(descenddist + (prev_descenddist - descenddist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (descenddist + (prev_descenddist - descenddist)), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = (prev_descendtime - descendtime);
                     landingtime     = descendtime;
                     time            = tocbodtime + lvltime + descendtime;
                 }
             }
             else
             {
                 if (distance < descenddist)
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"flat";
                     neffectivedst   = DataConverters.LengthUnits(0, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM");
                     checkpointconst = descendtime - TimeSpan.FromHours(DataConverters.LengthUnits(descenddist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - descenddist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = 0;
                     landingtime     = descendtime;
                     time            = tocbodtime + lvltime + landingtime;
                 }
             }
         }
     }
     else
     {
         if (speed == 0)
         {
             time = 0;
         }
         else
         {
             pullprevData();
             if (alt > prev_alt)
             {
                 if (distance < climbdist - prev_climbdist)
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"climb";
                     neffectivedst   = DataConverters.LengthUnits(climbdist - prev_climbdist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance, baseDistunit, "KM");
                     checkpointconst = (climbtime - prev_climbtime) - TimeSpan.FromHours(DataConverters.LengthUnits(climbdist - prev_climbdist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (climbdist - prev_climbdist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = (climbtime - prev_climbtime);
                     landingtime     = 0;
                     time            = tocbodtime + lvltime + landingtime;
                 }
             }
             else if (alt < prev_alt)
             {
                 if (distance < prev_descenddist - descenddist)
                 {
                     time = 0;
                 }
                 else
                 {
                     transition      = @"descend";
                     neffectivedst   = DataConverters.LengthUnits(prev_descenddist - descenddist, baseDistunit, "KM");
                     effectivedst    = DataConverters.LengthUnits(distance, baseDistunit, "KM");
                     checkpointconst = (prev_descendtime - descendtime) - TimeSpan.FromHours(DataConverters.LengthUnits(prev_descenddist - descenddist, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance - (prev_descenddist - descenddist), baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                     tocbodtime      = (prev_descendtime - descendtime);
                     landingtime     = 0;
                     time            = tocbodtime + lvltime + landingtime;
                 }
             }
             else
             {
                 transition      = @"flat";
                 neffectivedst   = DataConverters.LengthUnits(0, baseDistunit, "KM");
                 effectivedst    = DataConverters.LengthUnits(distance, baseDistunit, "KM");
                 checkpointconst = 0;
                 lvltime         = TimeSpan.FromHours(DataConverters.LengthUnits(distance, baseDistunit, "KM") / DataConverters.SpeedUnits(speed, baseSpeedunit, "KPH")).TotalSeconds;
                 tocbodtime      = 0;
                 landingtime     = 0;
                 time            = tocbodtime + lvltime + landingtime;
             }
         }
     }
 }