Author Topic: Ejs version of traffic control simulation  (Read 84108 times)

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Ejs version of traffic control simulation
« on: May 15, 2006, 05:27:10 pm »
Registed user can get files related to this applet for offline access.
Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
If java program did not show up, please download and install latest Java RUN TIME

This simulation is similar to the traffic light contril I have created many years ago.
But I rewrited it with ejs.

Each square represent a car. It could be painted with three different color depends on it's acceleration a.
1. a>0 (yellow): when there is no car in front of it or the car in front is far away (the distance is more than dmin) and the street light is not red.
2. a=0 (green): it will keep move with the same speed when it reach maximum speed.
3. a<0 (red): when the street light turn red or the car in front is too close (distance < dmin).

dmin= v* treaction time, where treaction time is the reaction time of the driver.

You can click the +/- sign to change the time delay between traffic lights.



acceleration=m/s2 (modify value and hit return to change acceleration)
reaction time=s


Registed user can get files related to this applet for offline access.
Problem viewing java?Add http://www.phy.ntnu.edu.tw/ to exception site list
If java program did not show up, please download and install latest Java RUN TIME

chef

  • Newbie
  • *
  • Posts: 3
topic365
« Reply #1 on: May 21, 2006, 05:45:33 am »
cool you know a lot about java

combiz

  • Newbie
  • *
  • Posts: 1
Re: Ejs version of traffic control simulation
« Reply #2 on: March 09, 2007, 11:32:59 am »
Could you please send me the source code for traffic control.
Thanks

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: Ejs version of traffic control simulation
« Reply #3 on: March 09, 2007, 03:46:01 pm »
If you click the button "load ejs as signed applet".
You can see the source code/modified it and save it to your disk. (EJS source is saved in XML format)
You will find variables defined, relations between variables ...
It is the same for all the simulations created with EJS shown in the web site.

bardha

  • Newbie
  • *
  • Posts: 1
Re: Ejs version of traffic control simulation
« Reply #4 on: April 18, 2007, 04:06:12 pm »
Can this program be considered as a real-time system application program?

Please,if it's possible send me the documentation of this application,because i don't understand it very well.

Thank you.

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: Ejs version of traffic control simulation
« Reply #5 on: April 19, 2007, 02:09:58 am »
Yes. I believe many "one way traffic light system" did implement it to control the traffic in real life.

If you want to discuss about it, please write down what you know and what you think you do not understand.

revage06

  • Newbie
  • *
  • Posts: 1
Re: Ejs version of traffic control simulation
« Reply #6 on: April 24, 2007, 09:03:13 pm »
Dear Sir,
it's cool simulation, could you please send me the source code for traffic control.
Thanks & regards

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: Ejs version of traffic control simulation
« Reply #7 on: April 28, 2007, 05:21:26 pm »
The EJS will be installed into your browser if you clieck "load ejs as signed applets" for the first time. And the applets source will be loaded into ejs as well.
You can see all the source(variables,equations...), modify it or save it(click save button).
You can even generate new simulation after you modify the code.

crazyboyrs

  • Newbie
  • *
  • Posts: 1
Re: Ejs version of traffic control simulation
« Reply #8 on: May 31, 2007, 02:32:57 am »
I've seen the previous version code.But i dun understand how to code the program in EJS.Is it simpler or more complicated?Got any sources?the EJS manual din help much

joel123

  • Newbie
  • *
  • Posts: 1
hi mr Fu-Kwun Hwang
« Reply #9 on: July 25, 2007, 04:46:21 am »
Mr Fu-Kwun Hwang i hope that you be fine, im from mexico and  im really interested in your simulation applet because im developing one simulator for my simultaion class and i think that your source code could help me to complete my project. please answer me to  my email as soon as posible thank you. ill be waiting for you answer bye

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: Ejs version of traffic control simulation
« Reply #10 on: July 25, 2007, 09:45:19 am »
The EJS will be loaded into your browser(with your permission) and you will be able to save/modify the ejs source code, if you clicked the above button (right under the simulation) labeled as "load ejs as signed applet".

Actually, it is the same for all the simulations created with EJS on our server.
So, please click the button. And you will find out how the ariables are defined, what are the relations used. You can save it if you click the save button in the EJS and you can even modify the code and generate new simulation (click green triangle).

serkan3123

  • Newbie
  • *
  • Posts: 2
Re: Ejs version of traffic control simulation
« Reply #11 on: November 11, 2007, 05:14:35 am »
Can you send me source code?

serkan3123@gmail.com

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: Ejs version of traffic control simulation
« Reply #12 on: November 11, 2007, 11:04:35 am »
You will get the EJS source code, if you clicked down ejs source link (just under the java simulation).
It is an xml file. You can open it if you install EJS or you can click load ejs as signed applet to load ejs into your browser(about 2M) and you can see the source automatically.

yeek01

  • Newbie
  • *
  • Posts: 2
Re: Ejs version of traffic control simulation
« Reply #13 on: March 18, 2009, 06:48:29 am »
Sir, i find error when i try to run it using EJS.

The following are the errors:

Warning. Syntax error or custom page updatelight:
  Parse error at line 1, column 41.  Encountered: [
Warning. Syntax error or custom page updatecar:
  Parse error at line 1, column 42.  Encountered: [
File successfully read trafficcontrol.xml

Fu-Kwun Hwang

  • Administrator
  • Hero Member
  • *****
  • Posts: 3062
    • Enjoy the fun of physics with simulations
Re: Ejs version of traffic control simulation
« Reply #14 on: March 18, 2009, 08:23:04 am »
Please download it again. It should work fine now.
The following line has been changed from
public void updatelight (double tlight[],java.lang.Object clr[],String slight[]) {
to
public void updatelight (double[] tlight,java.lang.Object[] clr,String[] slight) {