its.backbone.domain.tms
Class TmsLoop

java.lang.Object
  extended byits.backbone.domain.SensorData
      extended byits.backbone.domain.tms.TmsData
          extended byits.backbone.domain.tms.TmsLoop
All Implemented Interfaces:
java.io.Serializable

public class TmsLoop
extends TmsData

Encapsulates a TMS loop sensor in packed format, plus other fields necessary to support SDD. This is an immutable class which may only be initialized from a TMS data block.

Should this be extended to include (a) a ref to the TmsSensor, (b) the sensor ID, (c) the timestamp, (d) a ref to the TmsData? Or should there maybe be another type which includes all this stuff through aggregation? Last change: NSF 3 Feb 98 9:15 am

See Also:
Serialized Form

Field Summary
static int BAD_LOOP
          flag value indicating the loop is bad.
static int CHATTER
          flag value indicating chatter (> 3 counts / second)
static int DATA_GOOD
          flag value indicating data is good.
static int DISABLED
          flag value indicating the the loop was disable by the operator.
static int OUTSIDE_ENVELOPE
          flag value indicating that the values from the sensor are outside an externally defined volume/occupancy envelope.
static int SHORT_PULSE
          flag value indicating short pulse (< 1/15 sec)
 
Fields inherited from class its.backbone.domain.tms.TmsData
INCIDENT_CONTINUING, INCIDENT_NONE, INCIDENT_OCCURRED, INCIDENT_TENTATIVE
 
Fields inherited from class its.backbone.domain.SensorData
dataBlock, MASK_EIGHT_BIT, MASK_FIVE_BIT, MASK_FOUR_BIT, MASK_ONE_BIT, MASK_SEVEN_BIT, MASK_SIX_BIT, MASK_THREE_BIT, MASK_TWO_BIT, rawData
 
Constructor Summary
TmsLoop(DataBlock dataBlock)
          Constructs a TmsLoop object using the 3 bytes of data at offset in dataBlock.
 
Method Summary
 int getFlag()
           
 int getIncidentDetect()
           
 java.lang.String getName()
           
 int getNLoops()
           
 float getOccupancy()
           
 int getPackedSize()
           
 int getRawVolume()
           
 int getScanCount()
           
 TmsTimestamp getTimestamp()
           
 int getVolume()
           
 boolean isValid()
          Checks to see if data meets validity constraints.
 java.lang.String[] processSensor(int offset, java.lang.String sensor_id)
          processes an instance of a sensor
protected  void read(int offset)
          reads values for a TmsLoop object from the 3 bytes of data at offset in dataBlock.
 
Methods inherited from class its.backbone.domain.tms.TmsData
checkOffsetBounds
 
Methods inherited from class its.backbone.domain.SensorData
setRawData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATA_GOOD

public static final int DATA_GOOD
flag value indicating data is good. Any other value may mean the data is bad.

See Also:
Constant Field Values

SHORT_PULSE

public static final int SHORT_PULSE
flag value indicating short pulse (< 1/15 sec)

See Also:
Constant Field Values

CHATTER

public static final int CHATTER
flag value indicating chatter (> 3 counts / second)

See Also:
Constant Field Values

OUTSIDE_ENVELOPE

public static final int OUTSIDE_ENVELOPE
flag value indicating that the values from the sensor are outside an externally defined volume/occupancy envelope. The algorithm used to determine this envelope is experimental.

See Also:
Constant Field Values

DISABLED

public static final int DISABLED
flag value indicating the the loop was disable by the operator.

See Also:
Constant Field Values

BAD_LOOP

public static final int BAD_LOOP
flag value indicating the loop is bad.

See Also:
Constant Field Values
Constructor Detail

TmsLoop

public TmsLoop(DataBlock dataBlock)
        throws java.lang.IllegalArgumentException
Constructs a TmsLoop object using the 3 bytes of data at offset in dataBlock.

Parameters:
dataBlock - byte array containing data
Throws:
BadOffsetException - if offset is less than the header size or greater than the data block size
java.lang.IllegalArgumentException
Method Detail

read

protected void read(int offset)
             throws BadOffsetException
reads values for a TmsLoop object from the 3 bytes of data at offset in dataBlock.

Specified by:
read in class TmsData
Parameters:
offset - offset within dataBlock
Throws:
BadOffsetException - if offset is less than the header size or greater than the data block size

processSensor

public java.lang.String[] processSensor(int offset,
                                        java.lang.String sensor_id)
                                 throws java.lang.IllegalArgumentException,
                                        BadOffsetException
Description copied from class: SensorData
processes an instance of a sensor

Specified by:
processSensor in class SensorData
Parameters:
offset - the offset into the blob
sensor_id - the sensor id
Returns:
array of strings containing variable values of SQL command
Throws:
java.lang.IllegalArgumentException - thrown if bad sensor id
BadOffsetException - thrown if offset is bad

getTimestamp

public TmsTimestamp getTimestamp()
Specified by:
getTimestamp in class TmsData
Returns:
timestamp

getIncidentDetect

public int getIncidentDetect()
Returns:
incidentDetect value (values are enumerated in TmsData).

getNLoops

public int getNLoops()
Returns:
number of loops reporting, this should be 1

getFlag

public int getFlag()
Returns:
data validity flag sent by TMS

getScanCount

public final int getScanCount()
Returns:
number of scans (60 per second for 20 seconds) in which was occupied.

getRawVolume

public int getRawVolume()
Returns:
raw volume, which is a 20-second vehicle count. This should be between 0 and 17.

getOccupancy

public float getOccupancy()
Returns:
occupancy as percent, calculated from scanCount

getVolume

public int getVolume()
Returns:
volume rescaled to vehicles per hour

getPackedSize

public int getPackedSize()
Overrides:
getPackedSize in class SensorData
Returns:
the size of the packed data (3 bytes)

getName

public java.lang.String getName()
Specified by:
getName in class TmsData
Returns:
printable name "Loop".

isValid

public boolean isValid()
Checks to see if data meets validity constraints. This is an external test performed by TmsLoop, it is not sent by the TMS.

Specified by:
isValid in class TmsData
Returns:
true if data is valid, as determined by tests:
  • flag == DATA_GOOD
  • scanCount <= MAX_SCAN_COUNT
  • volume <= MAX_VOLUME
  • nLoops <= MAX_LOOPS