Java代写:SENG201 Traffic Engineering Application Part2

Introduction

交通灯的应用的第二部分的代写,这部分就是按照要求和给的示例程序来写码了。

Some simplifying assumptions

We will make a few assumptions in order to make the problem simpler.

  • All intersections involve one north-south rood meeting an east-west road.
  • Signal faces are oriented to the north, 4 south, east or west and are located at the north-west, north-east, south-west or south-east corners of intersections. No overhead signal faces need be considered.
  • Semi-actuated intersections need not be considered. If necessary, we can always add a SemiActuatedPhasePlan class later to cope with these.
  • Signal faces contain 3 lights: one of each colour and all of the same shape.
  • For “round” signal faces, green lights are always followed by yellow lights which are followed in turn by red lights in each cycle. We need not consider other sequences — such as those in countries where another yellow interval occurs between red and green.
  • Change intervals and all-red intervals are treated as separate phases.
  • Only passive detectors are used. These can report, when asked, whether they have seen any vehicles pass over them.
  • No phases are optional.

Getting started

You should be able to begin the following activities already and you will find them helpful preparation for the next part which will be available soom.

  • Make sure you read the description of the way intersections work and that you understand it fully.
  • Observe some real intersections in action. You can start this right away. Identify the signal faces, traffic streams and phases.
  • For the active phase plan, draw up a table listing the phases and the state of each stream in the phase.
  • Note which signal faces are associated with each traffic stream. Remember that signal faces might shared between streams.
  • Using Smarties TM, Pebbles TM or other tools, construct a diagram such as that
    shown in Figure 5 to show the lights displayed in the signal faces in each phase.
  • Time some phases. Do you think your intersection is unactuated or fully-actuated?
  • Do you think it has more than one phase plan? For example, is there any difference between rush hour and off peak plans?

Our toolkit

Figure 6 shows a very simple intersection monitor — an instance of IntersectionMonitor. Near the top is a panel showing the intersection’s signal faces, together with their locations and orientations.
The monitor displays a “row” for each phase — the active phase is highlighted. As well as the phase description, there is some information about each stream and a colour chip showing the state of each stream (remember that signal faces can be shared between streams) in the corresponding phase.
A transcript provides a log of the activity at the intersection. Each entry has a time stamp (traffic.misc.TimeStamp) and the transcript can be saved in a file for subsequent analysis.
Given an Intersection, an IntersectionMonitor can display information about its state. The traffic package contains classes (such as TrafficStream which can be used to assemble an intersection.
Intersections may also be constructed by reading intersection descriptions from a file. Figure 7 shows the description file corresponding to the intersection of Figure 6.

  • The file contains a number of tags, such as SignalFaces — valid tags are found in traffic.Tags.
  • Lines beginning with // are treated as comments and empty lines are ignored.
  • Within a tag body each line contains one or more fields. The fields are separated by tabs (which are shown underlined in Figure 7). Why tabs? The idea is to make it easy to use a Scanner to parse the content of the line. Using commas as separators seems appealing but ultimately the hassle of escaping commas inside field content is frustrating.

The file structure is as follows.

Intersection

Label and description for the intersection.

TrafficStreams

Label and description for each TrafficStream

PhasePlan

One or more Phase tags

Phases

Each line contains

  1. Phase label
  2. Phase description
  3. The state of each traffic stream in this phase. An X indicates that the stream is not included are R, Y and G indicate the corresponding colours.
  4. The duration (in seconds) of the phase.

SignalFaces

Each line contains

  1. The location of the corresponding SignalFace. Legal values are defined by traffic.TrafficDirection.
  2. The orientation of the corresponding SignalFace. Legal values are defined by traffic.TrafficDirection.
  3. The kind (STANDARD, LEFT_ARROW or RIGHT_ARROW) of the signal face.
  4. The labels of the streams (tab separated) that the face is associated with

Next steps

Now that you have completed the activities, you are ready to start working with intersection data.

  • Obtain a copy of the intersection monitor demonstrated in class — from the Learn assessment page where you found this document.
  • Run it and familiarise yourself with the way it displays information about elements such as phases, streams and signal faces.
  • The File menu contains an item to run a working demo, plus one to read files, such as the one in Firgure 7, in the format described.
  • The Intersection menu can be used to start and stop the intersection’s phase plan cycle. The signal faces will change to reflect the current phase.
  • Information about the changing states of the intersection appears in the transcript pane. The Transcript menu incldes an item which allows the transcript content to be saved for later analysis.
  • Wite an intersection file for each intersection you oberved as desribed and check that it is correct by loading and running it.

What to do now

Now that you understand how intersections work, and how to describe them in files, it’s time to write some Java code to implement some features of an intersection monitor.
The classes you write will be based on the description in Section 2 on page 1 and individual class specifications provided in the form of javadoc documentation as described below. Together, they should form the basis of a toolkit for traffic engineering.
You are provided with javadoc documentation for the classes that you must complete as well as for the other classes in the system.
You are also provided with skeleton/incomplete versions of the classes which you will need to complete.
You will need to implement private properties and methods in some classes,but do not change the public API of any class. If you think you need to do this then please discuss it with us.
You will find it helpful to use the analysis & modelling technoiques covered in class, and the various kinds of UML diagrams will help you firm up your designs.

  • traffic.diy.ModelIntersection.java — skeleton for the ModelIntersection class. You should complete its methods to show how a complete Intersection is made from the other provided classes (such as TrafficStream and Phase).
  • traffic.diy.MyIntersectionMonitor.java — incomplete intersection monitor. This is like the monitor you have seen already, but has several menu items (highlighted in pink) on the File menu for you to complete.
  • Save intersection — allows the Intersection being monitored to be saved in serialised form. It should be stopped before being saved.
  • Similarly, Load saved intersection — allows the an Intersection previously saved saved in serialised form to be loaded.
  • My Demo causes the monitor to display an Intersection built using a method of your ModelIntersection class.
  • Open — causes the monitor to load an intersection description from a file in the format shouwn in Figure 7 and described. You will need to complete MyIntersectionLoader to implement this feature fully.

Using the resources provided

  • You will find the javadoc in the api folder.
  • Create an Eclipse project (e.g. myassignment).
  • Create a package traffic.diy in the src directory. This is where the code you will write/modify goes.
  • Add the Java source files from the skeleton folder to the package you created. These contain the sources for classes MyIntersectionMonitor,ModelIntersection and MyIntersectionLoader.
  • In the Project — Properties dialog, add the JAR file traffic-library-1.2.jar to the build path (using the Add External JARs button).
  • You should now be able to run the application (there’s a main method in MyIntersectionMonitor.

Submission

We’ll update you on the exact details of your submission soon.