Yasin DEMİR

#herseypaylasmakicin

————————————————-

DASH BOARD CONTROL UNIT

————————————————-

Project Definitions:  Dashboard is the consol of car that gives information’s about:

  • Current Speed
  • Current Gear
  • Engine Temperature
  • Average Fuel Consumption ( lt / 100km)
  • Engine’s RPM (Round per Minute)
  • Outside Temperature

Users should be able to

  • Start – Stop Engine
  • Increase/ Decrease the speed
  • Break
  • Change the Gear

Implement a Java Applications so that it performs the given tasks regarding to user inputs. You should submit both the documentation and source code.

.

PRESENTATION OF DASH BOARD CONTROL UNIT (WITH GUI)

Step1: Main Menu to Dash Board Control Unit. All thread in this program is stopped when program is debugging.

Step2: When we press start button; Firstly start button text changes pause and all threads start in this program. All textboxes (gear, rpm, speed, engine temperature, outside temperature, average fuel.) are initialized.

Step3: When gear is zero and we presses to speed button that for increasing speed only rpm textbox value is changed.

Step4: When we press on gear button and press on speed button, speed, rpm, engine temperature are increasing.

Step5: When we changed value of gear (2), speed increases over 35 and increases engine temperature, average fuel degreases faster than less speed.

Step6: When we changed value of gear (3), speed increases above 69 and increases engine temperature, average fuel degreases faster than less speed.

Step7: Until the program is working when we press the pause button, every value in textboxes is sticked. Pause button text turned start.

Step8: When we press brake button speed of car degreases speedy.

.

DESCRIPTION THE WRITTEN CODES AND DASH BOARD CONTROL UNIT DEFINATIONS

.

1. Main Class

.

public ClassSpeed classSpeed=new ClassSpeed(taSpeed,tfFuolOil,pictureSpeed,tfOutSidetemp);

public classRPM classRpm=classRpm=new classRPM(tfRpm,pictureSpeed);

public classEngineTemperature classEngineTemp=new classEngineTemperature(tfEngineTmp);

public classEngineTemperature classEngineTemp2=new classEngineTemperature(tfEngineTmp);

We created our thread class used this code globally and started those threads in mouse listener.

Table 1: Create thread classes

public void mousePressed(MouseEvent arg0) {if(arg0.getSource()==btnSpeedIncreasing){if(Gear==0){classRpm.RpmGear=Gear;classRpm.sleep=50;                classEngineTemp.EngineGear=Gear;               classEngineTemp.sleep=700;}

if(Gear==1){

classSpeed.sleep = 100;                  classRpm.RpmGear=Gear;

classRpm.sleep=50;                classEngineTemp.EngineGear=Gear;

classEngineTemp.sleep=800;

classSpeed.Gear=Gear;

classSpeed.limit=35;

}

.

.

.

if(Gear==5){

classSpeed.sleep = 360;

classSpeed.Gear=Gear;

classRpm.RpmGear=Gear;

classRpm.sleep=200;

classEngineTemp.EngineGear=Gear;

classEngineTemp.sleep=1500;

classSpeed.limit=159;

}

}

When the user presses btnSpeedIncreasing button and press a time. taSpeed (speed value shower) show numbers increasing.When gear is increases one by one variable of classes changed and limitation of speed increases.We use: className.changedValue for changing class value for threads.

Table 2: Mouse pressed action

if(arg0.getSource()==btnStartStop){if(comp==0){classSpeed.start();classRpm.start();classEngineTemp.start();tfGear.setText(“”+0);

btnStartStop.setText(“pause”);

} else if(1==comp%2){

classSpeed.pleaseWait=true;

classRpm.pleaseWait=true;

classEngineTemp.pleaseWait=true;

btnStartStop.setText(“pause”);

}else if(0==comp%2){

synchronized (classSpeed){

classSpeed.pleaseWait=false;

classSpeed.notify();

}

synchronized (classRpm){

classRpm.pleaseWait=false;

classRpm.notify();

}

synchronized (classEngineTemp){

classEngineTemp.pleaseWait=false;

classEngineTemp.notify();

}

btnStartStop.setText(“start”);

}

comp++;

}

The global values that counter are in the event of only zero mean all threads are started.This code section used one time until program terminated.When we press btnStartStop button secondly all thread is pause and btnStartStop button text changed “pause”.We started all threads when user press btnStartStop button thirdly, all thread must be synchronized. That why’s, we used synchronized(className) for all classes.

Table3: Start-Stop and Break action

public void mouseReleased(MouseEvent arg0) {classEngineTemp.sleep=1500;classSpeed.temp=false;classRpm.temp=false;classSpeed.sleep = 300;classSpeed.Gear=7;

classRpm.RpmGear=7;

classRpm.sleep=50;

}

We use mouse released action for degreasing speed when user increases gear value.

Table4: Mouse Released action

2. Speed Class

public synchronized void run() {tfOutSidetemp.setText(“”+OutsideTemp+” C Degree”);tfFuil.setText(“”+oil+”LT”);while(true){try {sleep(sleep);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

if(Gear==1){

if(speed <= limit){

tfSpeed.setText(“”+speed);

speed++;

count++;

pictureSpeed=speed;

}

}

if(Gear==2){

if(speed <= limit){

pictureSpeed=speed;

tfSpeed.setText(“”+speed);

speed++;

count+=2;

}

.

.

.

if(Gear==7){

tfSpeed.setText(“”+speed);

speed–;

pictureSpeed=speed;

if(speed<=0)

speed=0;

}

This thread class is controlled speed, average fuel, engine temperature and outside temperature.This part uses, value (gear) that taking from main class and uses them for decreases and increase speed values.

Table5: Controlling run method of speed class

if(count>=100){OutsideTemp–;                           tfOutSidetemp.setText(“”+OutsideTemp+” C Degree”);           tfOutSidetemp.setText(“”+OutsideTemp+” C Degree”);           oil–;tfFuil.setText(“”+oil+”LT”);count=0;km++;}

if(count==30&&count==43){

OutsideTemp++;                           tfOutSidetemp.setText(“”+OutsideTemp+” C Degree”);

}

synchronized(this){

while( pleaseWait ){

try{

this.wait();

} catch( InterruptedException e ){ };

}

}

We created count global variable for calculate kilometer when car going.When the count over 100 oil of car decreases 1 liter and kilometer increases 1 km.When the pleaseWait control Boolean value changed in main class speed class thread pause until pleaseWait value changed false. So, thread class started again.

Table6: Control unit of kilometer and pause run method with wait parameter.

3. Rpm Class

public synchronized void run() {while(true){try {sleep(sleep);} catch (InterruptedException e) {e.printStackTrace();

}

if(RpmGear==0){

if(RpmSpeed<=8.0){

RpmSpeed +=0.1;

tfRpm.setText(“”+RpmSpeed);

}

}

if(RpmGear==1){

if(RpmSpeed<=5.5){

RpmSpeed +=0.1;

tfRpm.setText(“”+RpmSpeed);

}

if(RpmSpeed>=5.5 && RpmSpeed<=8.0){

try {

sleep(100);

} catch (InterruptedException e) {

e.printStackTrace();

}

RpmSpeed +=0.1;

tfRpm.setText(“”+RpmSpeed);

}

.

.

.

if(RpmGear==7){

tfRpm.setText(“”+RpmSpeed);

RpmSpeed -=0.1;

if(RpmSpeed<=0.0)

RpmSpeed=0;

}

synchronized(this){

while( pleaseWait ){

try{

this.wait();

} catch( InterruptedException e ){ };

}

}

}

This thread class is controlled rpm.This part uses, value (gear) that taking from main class and uses them for decreases and increase rpm values.Rpm gear value 7 that is used for control rpm valueWhen the pleaseWait control Boolean value changed in main class speed class thread pause until pleaseWait value changed false. So, thread class started again.

Table7: Controlling run method of rpm class

4. Engine Class

public synchronized void run() {while(true){try {sleep(sleep);} catch (InterruptedException e) {e.printStackTrace();

}

if(EngineGear==0){

if(EngineSpeed<=10){

EngineSpeed ++;                                             tfEngineTemp.setText(“”+EngineSpeed);

}

}

if(EngineGear==1){

if(EngineSpeed<=30){

EngineSpeed ++;

tfEngineTemp.setText(“”+EngineSpeed);

}

.

.

.

if(EngineGear==7){

tfEngineTemp.setText(“”+EngineSpeed);

EngineSpeed –;

if(EngineSpeed<=0)

EngineSpeed=0;

}

synchronized(this){

while( pleaseWait ){

try{

this.wait();

} catch( InterruptedException e ){ };

}}

This thread class is controlled engine temperature.This part uses, value (gear) that taking from main class and uses them for decreases and increase engine values.Engine gear value 7 that is used for control rpm valueWhen the pleaseWait control Boolean value changed in main class speed class thread pause until pleaseWait value changed false. So, thread class started again.

Table8: Controlling run method of engine class

.

 

Download: Full Source Code and project details

 

Bir cevap yazın

E-posta hesabınız yayımlanmayacak.