/// <summary> /// Consturctor of FuelTripCalculator. /// </summary> /// <param name="option">Calculation option.</param> /// <param name="calculationMethod">Calclation method</param> public FuelTripCalculator(FuelTripCalculatorOption option, FuelCalculationMethod calculationMethod) { this.calculatorOption = option; this.calculationMethod = calculationMethod; totalTripFuel = new TripFuelContent(); sectElapsed = 0; sectStoreMax = 60; sectSpan = 60 * 1000; sectTripFuelTemporary = new TripFuelContent(); sectTripFuelQueue = new Queue <TripFuelContent>(); sectTripFuelLatest = new TripFuelContent(); saveElapsedTime = 0; //Set data folder and file path. folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); filePath = Path.Combine(folderPath, "." + "FUELTRIP_Logger"); loadTripFuel(); stopWatch = new Stopwatch(); stopWatch.Reset(); }
/// <summary> /// Calculate fuel consumption by mass air flow. /// </summary> /// <param name="elapsedMillisecond">Elapsed time</param> /// <param name="massAirFlow">Mass air flow</param> /// <param name="calculatorOption">Calculator option<</param> /// <returns></returns> public static double FuelCalcByMassAir(double elapsedMillisecond, double massAirFlow, FuelTripCalculatorOption calculatorOption) { return(FuelCalcByAFAndMassAir(elapsedMillisecond, massAirFlow, DefaultAFRatio, calculatorOption)); }
/// <summary> /// Calulate fuel consumption by mass air flow and AF ratio. /// </summary> /// <param name="elapsedMillisecond">Elapsed time</param> /// <param name="massAirFlow">Mass air flow (g/s)</param> /// <param name="AFRatio">AF ratio(lambda, Set 1 on stoichiometric mixture(Gas(gram):Air(gram)=14.7:1))</param> /// <param name="calculatorOption">Calculator option</param> /// <returns></returns> public static double FuelCalcByAFAndMassAir(double elapsedMillisecond, double massAirFlow, double AFRatio, FuelTripCalculatorOption calculatorOption) { double GasConsumptionCoefficient = calculatorOption.FuelCorrectionFactor; double momentaryFuelConsumption = massAirFlow / (AFRatio * 14.7) / DensityOfFuel / 1000; return(momentaryFuelConsumption * GasConsumptionCoefficient * elapsedMillisecond / 1000); }
/// <summary> /// Calculate and return momentary fuel consumption by rev and injection pulse width method. /// </summary> /// <param name="elaspedMillisecond">Elapsed time in millisecond.</param> /// <param name="engineRev">Engine rpm.</param> /// <param name="injetctioPulseWidth">Injection pulse width</param> /// <param name="calculatorOption">Calculator option</param> /// <returns></returns> public static double FuelCalcByRevInjPW(double elaspedMillisecond, double engineRev, double injectionPulseWidth, FuelTripCalculatorOption calculatorOption) { double GasConsumptionCoefficient = calculatorOption.FuelCorrectionFactor; int NumCylinder = calculatorOption.NumCylinder; double InjectorCapacity = calculatorOption.InjectorCapacity; double InjectionLatency = calculatorOption.InjectionLatency; double momentaryFuelConsumption; if (engineRev > 500) //Calculate fuel consumption only if the rev is over idling rev. { momentaryFuelConsumption = GasConsumptionCoefficient * (double)NumCylinder * (double)engineRev * InjectorCapacity * (injectionPulseWidth - InjectionLatency) / (7.2E9) * elaspedMillisecond / 1000; } else { momentaryFuelConsumption = 0; } //If the calculated momentary fuel consumption is negative, override by zero. if (momentaryFuelConsumption < 0) { momentaryFuelConsumption = 0; } return(momentaryFuelConsumption); }
private double getMomentaryTrip(long elasped_millisecond, double currentVehicleSpeed, FuelTripCalculatorOption calculatorOption) { double TripCoefficient = calculatorOption.TripCorrectionFactor; double monentary_trip = TripCoefficient * (currentVehicleSpeed) / 3600 / 1000 * elasped_millisecond; return(monentary_trip); }