Traffic Simulator - About

The Traffic Simulator uses SystemJ to create a simple traffic simulator with a focus on traffic signals. The simulator is comprised of two parts implemented using SystemJ:

  1. A webserver and web based frontend to visualise the traffic.

  2. An environment to model cars, traffic lights and the road.

EnvironmentSmall

Figure 1. Screenshot of Traffic Simulator

Webserver:

An HTTP request sent from a web browser can be used as an input signal to the webserver SystemJ program. A custom class was created to handle the request object in Java. The SystemJ program can then use the reactive mechanisms such as: await Request; to wait for a new request, and respond accordingly.

The graphical frontend was created using the HTML5 canvas element, and is all rendered on the client. This eliminates a lot of the server load, as the only data that needs to be sent is the state of the environment. An example of the graphical frontend can be seen in Figure 1.

 

Environment:

Controlling the state of all the objects is the Environment program. SystemJ is used to create a concurrent framework between the traffic lights, cars, and road. The output from this program is a file containing a snapshot of all objects. This file is then updated at a given interval. To make the file easy to process by the web based frontend, it is in JSON format, to be parsed into a JavaScript object.

 

Traffic Light Simulator