Breaking News

TRAFFIC CONTROL

TRAFFIC CONTROL


INTRODUCTION TO JAVA

 Java is a programming language created by James Gosling from Sun Microsystems (Sun) in 1991. The target of Java is to write a program once and then run this program on multiple operating systems. The first publicly available version of Java (Java 1.0) was released in 1995. Sun Microsystems was acquired by the Oracle Corporation in 2010. Oracle has now the steermanship for Java. In 2006 Sun started to make Java available under the GNU General Public License (GPL). Oracle continues this project called OpenJDK.
Over time new enhanced versions of Java have been released. The current version of Java is Java 1.8 which is also known as Java 8.
Java is defined by a specification and consists of a programming language, a compiler, core libraries and a runtime (Java virtual machine) The Java runtime allows software developers to write program code in other languages than the Java programming language which still runs on the Java virtual machine. The Java platform is usually associated with the Java virtual machineand the Java core libraries.

FEATURES OF JAVA
·Compiled and Interpreted
·Platform- Independent and Portable
·Object -Oriented
·Robust and Secure
·Distributed
·Familiar, Simple and Small
·Multithreaded and Interactive
·High Performance
·Dynamic and Extensible

ADVANTAGES OF JAVA
The advantages of Java are as follows:
·Java is easy to learn.
Java was designed to be easy to use and is therefore easy to write, compile, debug, and learn than other programming languages.
·Java is object-oriented.
This allows you to create modular programs and reusable code.
·Java is platform-independent.
One of the most significant advantages of Java is its ability to move easily from one computer system to another. The ability to run the same program on many different systems is crucial to World Wide Web software, and Java succeeds at this by being platform-independent at both the source and binary levels.
Because of Java's robustness, ease of use, cross-platform capabilities and security features, it has become a language of choice for providing worldwide Internet solutions
.
INTRODUCTION TO TRAFFIC CONTROL
In 1985, the Federal Highway Administration published the second edition of the Traffic Control Systems Handbook to present basic technology used in planning, designing, and implementing traffic monitoring and control systems for urban street and freeway applications. That publication presented a compendium of applicable technology, concepts, and practices in the traffic control field. It proved useful in:
·Fostering understanding and acceptance of such systems, and
·Implementing proven advances in traffic monitoring and control.
This handbook was updated in 1996. In addition to describing signal system improvements since 1985, the 1996 edition provided considerable information on freeway management techniques and equipment.
The current edition updates signal system technology and broadens it into other methods for achieving surface street traffic management. Much of the freeway related material has been removed or abridged as the material is currently covered in the newly revised Freeway Management and Operations Handbook (FMOH) (1).
This updated version of the Traffic Control Systems Handbook maintains the following major objectives:
·Provide a compendium of existing traffic control system technology,
·Aid understanding of the basic elements of traffic control systems,
·Broaden the viewpoint of the traffic management field,
·Serve as a basic reference for the practicing traffic engineer in planning, designing, and implementing new and effective traffic control systems, and
·Serve as a training aid in the field of traffic control systems.
The Handbook targets a wide range of potential users - administrators, roadway designers, and traffic operations engineers, both experienced and newly assigned.
FEATURES
 This guide describes Traffic Control and how to configure it. This new Traffic Control feature replaces the existing feature called Traffic Shaping. Traffic Control (often referred to as Quality of Service or QoS) optimizes the service provided to users when interfaces become oversubscribed.
 This means creating policies that:
 * identify which traffic belongs to which services
* apply different control parameters to the traffic belonging to different services These control parameters are applied to traffic to optimize the services and can be applied in a variety of combinations:
 * prioritization
 * bandwidth limiting
* marking
* egress scheduling This document explains each of the component aspects of Traffic Control including relevant commands and example configurations.
 The components covered are:
 * Policies
 * Classifying traffic using rules
 * Traffic classes and queues
 * Scheduling algorithms
 * Bandwidth limiting
Implementation of traffic control
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
public class TrafficLight extends JFrame implements ActionListener {
 JButton b1, b2, b3;
 Signal green = new Signal(Color.green); Signal yellow = new Signal(Color.yellow);Signal red = new Signal(Color.red);
 public TrafficLight(){
 super("Traffic Light");
getContentPane().setLayout(new GridLayout(2, 1));b1 = new JButton("Red");
b2 = new JButton("Yellow");
b3 = new JButton("Green");
b1.addActionListener(this);
 b2.addActionListener(this);
b3.addActionListener(this);
 green.turnOn(false);
 yellow.turnOn(false);
 red.turnOn(true);
 JPanel p1 = new JPanel(new GridLayout(3,1));
 p1.add(red);
 p1.add(yellow);
 p1.add(green);
 JPanel p2 = new JPanel(new FlowLayout());
 p2.add(b1);
 p2.add(b2);
 p2.add(b3);
 getContentPane().add(p1);
 getContentPane().add(p2);
 pack();
}
 public static void main(String[] args){
 TrafficLight tl = new TrafficLight();
 tl.setVisible(true);
}
public void actionPerformed(ActionEvent e){
 if (e.getSource() == b1){
 green.turnOn(false);
yellow.turnOn(false);
red.turnOn(true);
} else if (e.getSource() == b2){ yellow.turnOn(true);
 green.turnOn(false);
 red.turnOn(false);
} else if (e.getSource() == b3){ red.turnOn(false);
 yellow.turnOn(false);
 green.turnOn(true);
}
}
} 
class Signal extends JPanel{
Color on;
int radius = 40;
int border = 10;
boolean change;
Signal(Color color){
 on = color;
 change = true;
}
public void turnOn(boolean a){
 change = a;
 repaint();
}
public Dimension getPreferredSize(){
 int size = (radius+border)*2;
 return new Dimension( size, size );
 }
 public void paintComponent(Graphics g){
 g.setColor( Color.black );
 g.fillRect(0,0,getWidth(),getHeight());
 if (change){
 g.setColor( on );
} else {
 g.setColor( on.darker().darker().darker() );
 }
 g.fillOval( border,border,2*radius,2*radius );
 }
}


OUTPUT













No comments