PHEV-PHP

From HaFrWiki
Jump to: navigation, search

The PHEV-PHP implements calculations method for Plug-in Hybrid Electric Vehicles.

Introduction

The main difference between normal cars and Plug-in Hybrids is of coarse the 2-different ways of driving on Electricity and Petrol/Gas.
That means that the fill-up of the fuel and the upload of the battery does not have to be on the same time and on the same mileage.
Why is that important.
To be able to calculate the consumption and costs of fuel and electricity you need to have the same base of measurement.
And that is what missing here. And think about the consumption/cost of a single trip.

To summarize the complexity of consumption/cost/trip calculation:

  • The fuel fill-up of a PHEV will also not be as frequently as the upload of the battery.
  • The trip conditions (city, highway) influence the usage of fuel and electricity.
    • City is mainly electric.
    • Highway is mainly fuel.
  • The weather condition (warm, cold) influence the capacity of the battery and the usage of both energy sources.
    • In the Mitsubishi Outlander PHEV using the heating system will cause the car to drive on fuel.
    • Cold weather reduces the range of the car on electricity.

Designer Ideas

Reports

Major problems for reports are changes made in the Consumption tabs.

  • What kind of modifications are made?
  • Are these changes of major importance to the reports?
  • Are the report start- and until-days affected?

More difficult are changes made on existing records.

Solutions

  • Using global static vars for the first and next calls makes it possible to detect star- and until-days changes.
    • Implementation: Use JS-global and take it in the AJAX call, BackEnd-PHP can check the Database-Changes.

Development Guidelines

Cookies

There are 3 major Cookies:

  • Login/Logout managed by the Login.php webapp.
  • Language code used in many application.
  • CarId used only in the PHEV Application.

The setting for the duration for these 3 cookies:

  • Login, if the Login is refreshed login or KeywordLinks are at the moment the only apps that can change the duration.
  • Language is set in many apps.
  • Car is only set in the PHEV app.

Please note that the $awData/userData array/object contain:

  • $awData, defined constant COOKIE_DURATION.
  • userData the object variable CookieDuration.

PHP Class PHEV

The PHP-Class PHEV implements these calculations. The functions in the class are:

calcCumulation

calcCumulation
Parmeters
string $untilDate The end-date for the cumulation.
boolean $forgetFirst [Optional] If true does does not include first record for Consumption and Costs, but do include the odometer. [default true].
boolean $verbose [Optional] Extra developer help for debugging the function [default false]
return boolean false or array aCumulation with the cumulated results.
Description

Cumulates the Electricity and Fuel results from start until the given end-date, untilDate, inclusive. The first record is skipped if the forgetFirst is set (the first record includes initial fuel and electricity data).
The returned array has the structure:

PHEV_CONS_ELEC The cumulated uploaded Consumption of Electricity.
PHEV_COST_ELEC The cumulated costs of the uploaded Electricity.
PHEV_CONS_FUEL The cumulated filled-up Consumption of Fuel.
PHEV_COST_FUEL The cumulated costs of the filled-up Fuel.
PHEV_START_ODO The maximum of the Energy/Fuel Odometer reading of the first found record.
PHEV_END_ODO The maximum of the Energy/Fuel Odometer reading of the last found record.
Review

See UnitTest testCumulationUntilAugSep and testCumUntil17Sep.
The cumulation is exactly the same as the results of the monthly payment and the consumption upload/fill-ups.
The Odometer readings do not match actual trips, but give an idea of the total driven miles/kilometers.

Example

To find the consumption and costs of a period (i.e. 02 Sep 2019 until 14 Sep 2019) execute the following steps with this method calcCumulation:

  1. Calculate the total cost until the end of the period (14 Sep 2019)
  2. Calculate the total cost until the start of the period minus 1 day (01 Sep 2019).
  3. Subtract the under 2 found values from the under 1 found.

Please note to find the trip-estimate use another method.

calcReportMonth

calcReportMonth
Parmeters
string $untilDate The end-date for the cumulation or better the last or until date
string $startDate The start date.
return boolean false or array aCumulation with the cumulated results.
Description

This function wraps the method calcCumulation and derives the monthly consumption & costs. The returned array has the structure:

PHEV::CONS_ELEC Electricity consumption
PHEV::COST_ELEC Electricity costs
PHEV::CONS_FUEL Fuel consumption
PHEV::COST_FUEL Fuel costs
PHEV::COST_TOTAL Electricity + Fuel Costs.
Example

Steps, to find the consumption for a given period:

  1. Find the monthly report using
    • UntilDate 2019-09-30
    • StartDate 2019-07-12

Please note:

  • This method is the previous calculation in one step.
  • No trip calculation has been made, because it is accurate.

Reporting

The Best-Report makes the best possible estimate on the consumption of a PHEV.
The assumptions needed to create the best possible solutions are:

  • An (paid) electric charge is always made on the day of the consumption afterwards.
  • Fuel is calculated as fill-up, meaning the First Fuel load is omitted.
  • Fuel is calculated between 2 fill-ups. The odometer difference are the trip kilometers.
  • All fill-ups and charges are cumulated for one day.

So an example interval can be (plus means fill-up/load, minus means a day without fill-up/load).

↓ Type \ Days → 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20
Fuel + - - - + - + - + - - - - - - + - - - -
Elec + + + - + - + - - - + + + - + + + - - +

See also

top

Reference

top