hw6
Class TrafficReceiver

java.lang.Object
  |
  +--its.backbone.frame.ItsFrameReceiver
        |
        +--its.backbone.sdd.SddReceiver
              |
              +--hw6.TrafficReceiver
All Implemented Interfaces:
java.lang.Runnable

public class TrafficReceiver
extends its.backbone.sdd.SddReceiver

This class reads a network socket to get updates indicating where the buses in the King County Metro bus system are. Any object that wants to hear about changes in the state of the various transit buses must implement TransitBusListener and register as a listener with the TrafficSource object.


Field Summary
 
Fields inherited from class its.backbone.frame.ItsFrameReceiver
ignoreStreamTimeout
 
Constructor Summary
TrafficReceiver(java.lang.String hostname, int port)
          Create a TrafficReceiver object to read data from the specified source.
 
Method Summary
 void addTransitBusListener(hw6.TransitBusListener ear)
          Add an object that wants to be notified of TransitBusEvents.
 void extractedDataReceived(java.util.Hashtable ht, java.lang.String serialNum)
          This method is called when a data frame arrives from the transmitter and has been pre-processed into a hashtable with one ContentsData object for each table in the data frame.
protected  void fireTransitBusEvent(java.lang.String tv, int vin, double lat, double lon, int route)
          Notify all listeners that have registered interest for notification on TransitBusEvents that a new data record has arrived.
 void removeTransitBusListener(hw6.TransitBusListener ear)
          Remove an object that no longer wants to be notified of TransitBusEvents.
 
Methods inherited from class its.backbone.sdd.SddReceiver
contentsReceived, dataReceived, extractorReceived, frameReceived, schemaReceived
 
Methods inherited from class its.backbone.frame.ItsFrameReceiver
getFrameQueue, getInputBuffer, run, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TrafficReceiver

public TrafficReceiver(java.lang.String hostname,
                       int port)
                throws java.io.IOException
Create a TrafficReceiver object to read data from the specified source.

Parameters:
hostname - the network host that is supplying the data
port - the port that the data is being read from
Method Detail

extractedDataReceived

public void extractedDataReceived(java.util.Hashtable ht,
                                  java.lang.String serialNum)
This method is called when a data frame arrives from the transmitter and has been pre-processed into a hashtable with one ContentsData object for each table in the data frame.

Overrides:
extractedDataReceived in class its.backbone.sdd.SddReceiver
Parameters:
ht - the hash table containing the tables
serialNum - the serial number for this data frame

addTransitBusListener

public void addTransitBusListener(hw6.TransitBusListener ear)
Add an object that wants to be notified of TransitBusEvents.

Parameters:
ear - the object that wants to listen for TransitBusEvents

removeTransitBusListener

public void removeTransitBusListener(hw6.TransitBusListener ear)
Remove an object that no longer wants to be notified of TransitBusEvents.

Parameters:
ear - the object that no longer wants to listen for TransitBusEvents

fireTransitBusEvent

protected void fireTransitBusEvent(java.lang.String tv,
                                   int vin,
                                   double lat,
                                   double lon,
                                   int route)
Notify all listeners that have registered interest for notification on TransitBusEvents that a new data record has arrived.

Parameters:
tv - the time value String associated with this update
vin - the Vehicle ID number for this bus
lat - the latitude for this bus
lon - the longitude for this bus
route - the route number for this bus