Code Monkey home page Code Monkey logo

evlib's Introduction

EVLib

EVLib is a library for the management and the simulation of EV activities in a charging station level which makes use of a set of available energy sources. It is implemented using Java, and its main goal is to manage the charging, discharging, battery swap and parking/charging inductively functions and support their integration into a single charging station. The library supports a large number of operations to properly manage EV-related activities.

Documentation

The documentation of EVLib is included in the evlib-javadoc.jar file in the /target directory, after the build stage.

Main Functions

Charging:

There are 2 types of charging depending on the ratio, namely the fast and the slow charging. It is implemented through the ChargingEvent class. A proper execution first demands the call of preProcessing() method and then the call of execution() method.

DisCharging:

Similar to a charging event, a discharging event first demands the pre-processing phase and then the execution phase. The DisChargingEvent is responsible for creating a discharging event.

Battery Exchange:

The pre-processing phase requires for a battery with enough range to be available in the charging station. If such a battery is found, the battery is swapped into the EV. Battery exchange is implemented through ChargingEvent class.

Parking Event:

The vehicle can either simply park or charging inductively. The pre-processing phase looks for an empty parking slot. If the parking event requires energy as well, the parking slot needs to have enabled the switch for inductive charging. The next check is for energy. The waiting list is not supported in this operation. ParkingEvent class is competent for the implementation of this function.

Waiting queue:

An event is automatically inserted to a waiting list during an unsuccessful pre-processing phase. This means that no any empty charger, diacharger, battery handler or parking slot was found. The maximum waiting list is calculated before the insertion of it. If the calculated time is less than the time the vehicle can wait, then it is added to the list. The waiting queue can be managed either automatically or manually.

Extra Functions

The library also supports a number of secondary functions: The creation of a charging station, as well as the creation and integration of a charger, dis-charger, battery swapper or parking slot in the station. Additional operations are the recharging of batteries which are later to be swapped into EVs, as well as the ability to add new batteries to the storage in order seamless operation of the battery exchange process to be achieved. The total cost of the charging, discharging and battery swapping can be calculated based on a series of costs (e.g., energy cost) defined by the user. During the creation of the charging station, 4 waiting lists are created. A list for the charging events which want fast charging, a list for the charging events which want slow charging, a list for the discharging events, and a list for the vehicles waiting for battery exchange. The user has the capability to attach a pricing policy, as well.

Examples

Creation of a ChargingStation

  String[] kinds = { "slow", "fast", "fast", "slow" };
  String[] sources = { "Geothermal", "Nonrenewable", "Wind", "Wave" };
  double[][] energyAm = new double[4][5];
  for (int i = 0; i<4; i++)
      for (int j = 0; j<5; j++)
          energyAm [i][j] = 1500;

  ChargingStation station = new ChargingStation("Miami", kinds, sources, energyAm);

The charging station includes 4 Charger objects(2 slow and 2 fast), 4 energy sources(Geothermal, Nonrenewable, Wind, Wave). We also 5 energy packages for each energy sources. At each update storage one package from each energy source will be inserted to the charging station.

Integration of Discharger/ExchangeHandler/ParkingSlot

  DisCharger dsc = new DisCharger(station);
  ExchangeHandler handler = new ExchangeHandler(station);
  ParkingSlot slot = new ParkingSlot(station);

  station.addExchangeHandler(handler);
  station.addDisCharger(dsc);
  station.addParkingSlot(slot);

Charging station configuration

  station.setAutomaticUpdateMode(false);
  station.updateStorage();
  
  station.setTimeOfExchange(5000);
  station.setChargingRateFast(0.01);
  station.setDisChargingRate(0.1);
  station.setInductiveChargingRate(0.001);

  station.setUnitPrice(5);
  station.setDisUnitPrice(5);
  station.setInductivePrice(3);
  station.setExchangePrice(20);

Here, first we set the way each energy storage update is implemented using station.setAutomaticUpdateMode(false). Then, we call station.updateStorage() to update energy storage. The next lines refer to the setting of the rates and prices for each function.

Creation of drivers

  Driver a = new Driver("Tom");
  Driver b = new Driver("Ben");

Creation of electric vehicles

  ElectricVehicle vec1 = new ElectricVehicle("Honda");
  ElectricVehicle vec2 = new ElectricVehicle("Toyota");
  ElectricVehicle vec3 = new ElectricVehicle("Mitsubishi");
  ElectricVehicle vec4 = new ElectricVehicle("Fiat");

Creation of batteries

  Battery bat1 = new Battery(1500, 5000);
  Battery bat2 = new Battery(2000, 6000);
  Battery bat3 = new Battery(2500, 6000);
  Battery bat4 = new Battery(800, 3000);
  Battery bat5 = new Battery(0, 800);

Linkage of a battery with a charging station for the exchange battery function

  station.joinBattery(bat4);

Set battery and driver for each vehicle

  vec1.setDriver(a);
  vec1.setBattery(bat1);
  vec2.setDriver(a);
  vec2.setBattery(bat2);
  vec3.setDriver(a);
  vec3.setBattery(bat3);
  vec4.setDriver(b);
  vec4.setBattery(bat5);

Creation of events

  ChargingEvent ev1 = new ChargingEvent(station, vec1, 300, "fast");

  ChargingEvent ev2 = new ChargingEvent(station, vec2);

  DisChargingEvent ev3 = new DisChargingEvent(station, vec3, 500);

  ParkingEvent ev4 = new ParkingEvent(station, vec4, 20000, 200);

Setting of waiting time for each event

  ev1.setWaitingTime(500000);
  ev2.setWaitingTime(1200000);
  ev3.setWaitingTime(450000);

Pre-processing and execution for each event

  ev1.preProcessing();
  ev1.execution();

  ev2.preProcessing();
  ev2.execution();

  ev3.preProcessing();
  ev3.execution();

  ev4.preProcessing();
  ev4.execution();

Export of a report for the charging station

  station.generateReport("~/report.txt")

evlib's People

Contributors

skarapost avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

evlib's Issues

Large Class 2

Con respecto a las clases super grandes como ChargingStation que incumple con el principio SRP al tener demasiadas responsabilidades y un alto acoplamiento, se tiene como solución el uso del refactoring Extract Subclass que consiste en crear una clase macro y que hereden varias subclases de ella, haciendo esto se tiene un código más limpio y clases más cortas favoreciendo la legibilidad del programa.

Large Class

En la clase ChargingStation se puede ver que se encuentra saturada de varios atributos y métodos que hacen que la clase tenga mucho volumen, por esta razón viola el principio de responsabilidad única y como contiene gran parte de los métodos del programa hace que varias clases dependen de ella causando problemas con el acoplamiento. Como solución se tiene el refactoring Extract class que simplifica la clase en clases más pequeñas que son faciles de mantener, cumplen con el principio SRP y permite una mejor visualización del código.

Factory Method

Seria de gran ayuda utilizar el patrón de diseño Factory method considerando que varios objetos heredan de la clase EnergySource , ya que facilitaría la creación de objetos y se cumpliría el principio SOLID SRP y OCP respectivamente.

Facade

Tomando en cuenta lo complejo que puede serle al usuario comprender el funcionamiento de un sistema como el de la clase ChargingEventTest se tiene que considerar implementar una interface simple o fachada para que el usuario interactue de forma simple con las funciones del sistema, para esto se debe seguir el patrón estructural Facade.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.