123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- using System;
- using System.Collections.Generic;
- namespace Model
- {
- public class CruiseFuelConsumptionProvider_AC313A
- {
- public static double[] fuelData = new double[] { };
- public static double GetCruiseFuelConsumption(double temperature, double weight, double altitude)
- {
- int index = GetCruiseIndex(temperature, weight, altitude);
- if (index == -1)
- {
- throw new ArgumentException("Invalid input.");
- }
- return fuelData[index];
- }
- private static int GetCruiseIndex(double temperature, double weight, double altitude)
- {
- // 根据输入的温度、重量、高度确定索引
- if (temperature >= 30)
- {
- if (weight < 10000) return 0;
- else if (weight <= 12000) return 1;
- else return 2;
- }
- else if (temperature >= 20 && temperature < 30)
- {
- if (weight < 10000) return 3;
- else if (weight <= 12000) return 4;
- else return 5;
- }
- else if (temperature >= 10 && temperature < 20)
- {
- if (altitude <= 4000)
- {
- if (weight < 10000) return 6;
- else if (weight <= 12000) return 7;
- else return 8;
- }
- else
- {
- if (weight < 10000) return 9;
- else if (weight <= 12000) return 10;
- else return 11;
- }
- }
- else if (temperature >= 0 && temperature < 10)
- {
- if (altitude <= 4000)
- {
- if (weight < 10000) return 12;
- else if (weight <= 12000) return 13;
- else return 14;
- }
- else
- {
- if (weight < 10000) return 15;
- else if (weight <= 12000) return 16;
- else return 17;
- }
- }
- else if (temperature >= -10 && temperature < 0)
- {
- if (altitude <= 4000)
- {
- if (weight < 10000) return 18;
- else if (weight <= 12000) return 19;
- else return 20;
- }
- else
- {
- if (weight < 10000) return 21;
- else if (weight <= 12000) return 22;
- else return 23;
- }
- }
- else if (temperature >= -20 && temperature < -10)
- {
- if (altitude <= 4000)
- {
- if (weight < 10000) return 24;
- else if (weight <= 12000) return 25;
- else return 26;
- }
- else
- {
- if (weight < 10000) return 27;
- else if (weight <= 12000) return 28;
- else return 29;
- }
- }
- else if (temperature >= -30 && temperature < -20)
- {
- if (weight < 10000) return 30;
- else if (weight <= 12000) return 31;
- else return 32;
- }
- else if (temperature < -30)
- {
- if (weight < 10000) return 33;
- else if (weight <= 12000) return 34;
- else return 35;
- }
-
- return -1; // 无效输入
- }
- }
-
- public class ClimbFuelConsumptionProvider_AC313A
- {
- // TODO 查询数据库
- private static double[] ClimbFuelData = new double[] { };
- public static double GetClimbFuelConsumption(double temperature, double weight, double altitude)
- {
- int index = GetClimbFlightIndex(temperature, weight, altitude);
- if (index == -1)
- {
- throw new ArgumentException("Invalid input.");
- }
- return ClimbFuelData[index];
- }
- private static int GetClimbFlightIndex(double temperature, double weight, double altitude)
- {
- var temperatureRanges = new List<(double, double)> { (0, 20), (20, double.MaxValue), (double.MinValue, 0) };
- var weightRanges = new List<(double, double)> { (double.MinValue, 10000), (10000, 12000), (12000, double.MaxValue) };
- var altitudeRanges = new List<(double, double)> { (double.MinValue, 1000), (1000, 2000), (2000, 3000), (3000, 4000), (4000, 5000), (5000, 6000), (6000, double.MaxValue) };
- int temperatureIndex = GetIndexFromRange(temperature, temperatureRanges);
- int weightIndex = GetIndexFromRange(weight, weightRanges);
- int altitudeIndex = GetIndexFromRange(altitude, altitudeRanges);
- if (temperatureIndex == -1 || weightIndex == -1 || altitudeIndex == -1)
- {
- return -1;
- }
- return temperatureIndex * altitudeRanges.Count * weightRanges.Count + altitudeIndex * weightRanges.Count + weightIndex;
- }
- private static int GetIndexFromRange(double value, List<(double, double)> ranges)
- {
- for (int i = 0; i < ranges.Count; i++)
- {
- if (value > ranges[i].Item1 && value <= ranges[i].Item2)
- {
- return i;
- }
- }
- return -1;
- }
- }
- public class DescentFuelConsumptionProvider_AC313A
- {
- public static double GetDescentFuelConsumption(double temperature, double weight, double altitude)
- {
- double a = CruiseFuelConsumptionProvider_AC313A.GetCruiseFuelConsumption(temperature, weight, altitude);
- double b = ClimbFuelConsumptionProvider_AC313A.GetClimbFuelConsumption(temperature, weight, altitude);
- return a - (b - a);
- }
- }
- public class CruiseFuelConsumptionProvider_AG600
- {
- private static double[] CruiseFuelData = new double[] { };
- public static double GetCruiseFuelConsumption(double temperature, double weight, double altitude)
- {
- int index = GetCruiseFlightIndex(temperature, weight, altitude);
- if (index == -1)
- {
- throw new ArgumentException("Invalid input.");
- }
- return CruiseFuelData[index];
- }
- private static int GetCruiseFlightIndex(double temperature, double weight, double altitude)
- {
-
- var weightRanges = new List<(double, double)> { (0, 30000), (30000, double.MaxValue) };
- var altitudeRanges = new List<(double, double)> { (0, 3000), (3000, 6000), (6000, double.MaxValue) };
- int weightIndex = GetIndexFromRange(weight, weightRanges);
- int altitudeIndex = GetIndexFromRange(altitude, altitudeRanges);
- if ( weightIndex == -1 || altitudeIndex == -1)
- {
- return -1;
- }
- return altitudeIndex * weightRanges.Count + weightIndex;
- }
- private static int GetIndexFromRange(double value, List<(double, double)> ranges)
- {
- for (int i = 0; i < ranges.Count; i++)
- {
- if (value > ranges[i].Item1 && value <= ranges[i].Item2)
- {
- return i;
- }
- }
- return -1;
- }
- }
- public class ClimbFuelConsumptionProvider_AG600
- {
- private static double[] ClimbFuelData = new double[] { };
- public static double GetClimbFuelConsumption(double temperature, double weight, double altitude)
- {
- int index = GetClimbFlightIndex(temperature, weight, altitude);
- if (index == -1)
- {
- throw new ArgumentException("Invalid input.");
- }
- return ClimbFuelData[index];
- }
- private static int GetClimbFlightIndex(double temperature, double weight, double altitude)
- {
- var weightRanges = new List<(double, double)> { (0, 45000), (45000, 50000), (50000, 55000), (55000, 60000), (60000, double.MaxValue) };
- var altitudeRanges = new List<(double, double)> { (0, 1000), (1000, 2000), (2000, 3000), (3000, 4000), (4000, 5000), (5000, 6000), (6000, 7000), (7000, 7600), (7600, double.MaxValue) };
- int weightIndex = GetIndexFromRange(weight, weightRanges);
- int altitudeIndex = GetIndexFromRange(altitude, altitudeRanges);
- if (weightIndex == -1 || altitudeIndex == -1)
- {
- return -1;
- }
- return altitudeIndex * weightRanges.Count + weightIndex;
- }
- private static int GetIndexFromRange(double value, List<(double, double)> ranges)
- {
- for (int i = 0; i < ranges.Count; i++)
- {
- if (value > ranges[i].Item1 && value <= ranges[i].Item2)
- {
- return i;
- }
- }
- return -1;
- }
- }
- public class DescentFuelConsumptionProvider_AG600
- {
- public static double GetDescentFuelConsumption(double temperature, double weight, double altitude)
- {
- double a = CruiseFuelConsumptionProvider_AG600.GetCruiseFuelConsumption(temperature, weight, altitude);
- double b = ClimbFuelConsumptionProvider_AG600.GetClimbFuelConsumption(temperature, weight, altitude);
- return a - (b - a);
- }
- }
- public class CruiseFuelConsumptionProvider_AC352
- {
- private static double[] CruiseFuelData = new double[] { };
- public static double GetCruiseFuelConsumption(double temperature, double weight, double altitude)
- {
- int index = GetCruiseFlightIndex(temperature, weight, altitude);
- if (index == -1)
- {
- throw new ArgumentException("Invalid input.");
- }
- return CruiseFuelData[index];
- }
- private static int GetCruiseFlightIndex(double temperature, double weight, double altitude)
- {
- var temperatureRanges = new List<(double, double)> { (7.5, double.MaxValue), (-7.5, 7.5), (double.MinValue, -7.5)};
- var weightRanges = new List<(double, double)> { (0, 6000), (6000, 7000), (7000, double.MaxValue) };
- var altitudeRanges = new List<(double, double)> { (0, 2000), (2000,4000), (4000, double.MaxValue) };
- double temperature2 = temperature + 6.5 * weight - 15;//将实际温度转换为ISA
- int temperatureIndex =GetIndexFromRange(temperature2, temperatureRanges);
- int weightIndex = GetIndexFromRange(weight, weightRanges);
- int altitudeIndex = GetIndexFromRange(altitude, altitudeRanges);
- if (temperatureIndex == -1 ||weightIndex == -1 || altitudeIndex == -1)
- {
- return -1;
- }
- return temperatureIndex * altitudeRanges.Count * weightRanges.Count + altitudeIndex * weightRanges.Count + weightIndex;
- }
- private static int GetIndexFromRange(double value, List<(double, double)> ranges)
- {
- for (int i = 0; i < ranges.Count; i++)
- {
- if (value > ranges[i].Item1 && value <= ranges[i].Item2)
- {
- return i;
- }
- }
- return -1;
- }
- }
- public class ClimbFuelConsumptionProvider_AC352
- {
- private static double[] ClimbFuelData = new double[] { };
- public static double GetClimbFuelConsumption(double temperature, double weight, double altitude)
- {
- int index = GetClimbFlightIndex(temperature, weight, altitude);
- if (index == -1)
- {
- throw new ArgumentException("Invalid input.");
- }
- return ClimbFuelData[index];
- }
- private static int GetClimbFlightIndex(double temperature, double weight, double altitude)
- {
- var temperatureRanges = new List<(double, double)> { (7.5, double.MaxValue), (-7.5, 7.5), (double.MinValue, -7.5) };
- var weightRanges = new List<(double, double)> { (0, 6000), (6000, 7000), (7000, double.MaxValue) };
- var altitudeRanges = new List<(double, double)> { (0, 1000), (1000, 2000), (2000, 3000), (3000, 4000), (4000, 4500), (4500, double.MaxValue) };
- int temperatureIndex = GetIndexFromRange(temperature, temperatureRanges);
- int weightIndex = GetIndexFromRange(weight, weightRanges);
- int altitudeIndex = GetIndexFromRange(altitude, altitudeRanges);
- if (temperatureIndex == -1 || weightIndex == -1 || altitudeIndex == -1)
- {
- return -1;
- }
- return temperatureIndex * altitudeRanges.Count * weightRanges.Count + altitudeIndex * weightRanges.Count + weightIndex;
- }
- private static int GetIndexFromRange(double value, List<(double, double)> ranges)
- {
- for (int i = 0; i < ranges.Count; i++)
- {
- if (value > ranges[i].Item1 && value <= ranges[i].Item2)
- {
- return i;
- }
- }
- return -1;
- }
- }
- public class DescentFuelConsumptionProvider_AC352
- {
- public static double GetDescentFuelConsumption(double temperature, double weight, double altitude)
- {
- double a = CruiseFuelConsumptionProvider_AC352.GetCruiseFuelConsumption(temperature, weight, altitude);
- double b = ClimbFuelConsumptionProvider_AC352.GetClimbFuelConsumption(temperature, weight, altitude);
- return a - (b - a);
- }
- }
- }
|