Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## PER.rover.control
Class ReceiveThread

    java.lang.Object
      java.lang.Thread
          PER.rover.control.ReceiveThread

All Implemented Interfaces:
  java.lang.Runnable

public class ReceiveThread
extends java.lang.Thread

Contains the thread class for receiving and parsing information returned by the rover during color tracking, mean color detection, and motion detection as well as pictures taken during turnTo and driveTo commands. Also contains public variables and methods for accessing this data

Field Summary
`int` | `maxX` When tracking, this is the maximum x-coordinate where the object was detected
`int` | `maxY` When tracking, this is the maximum y-coordinate where the object was detected
`static int` | `MEAN_RECEIVE` use this variable in the [un]registerObject functions to be notified of new mean color data
`int` | `meanU` Updated by getMean, this is the average U value.
`int` | `meanV` Updated by getMean, this is the average V value.
`int` | `meanY` Updated by getMean, this is the average Y value.
`int` | `minX` When tracking, this is the minimum x-coordinate where the object was detected
`int` | `minY` When tracking, this is the minimum y-coordinate where the object was detected
`int[]` | `motion` This array stores the difference in intensity between frames.
`static int` | `MOTION_RECEIVE` use this variable in the [un]registerObject functions to be notified of new motion data
`static int` | `PICTURE_RECEIVE` use this variable in the [un]registerObject functions to be notified of new pictures
`int` | `pixels` When tracking, this is the total number of pixels tracked
`static int` | `TRACK_RECEIVE` use this variable in the [un]registerObject functions to be notified of new tracking data
`int` | `x` When tracking, this is the mean x-coordinate where the object was detected
`int` | `y` When tracking, this is the mean y-coordinate where the object was detected

Fields inherited from class java.lang.Thread
`MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY`

Constructor Summary
`ReceiveThread(Reliagram reliagram, RoverState State)` Creates a new instance of ReceiveThread

Method Summary
`long` | `getImageUpdateTime()` Lets you know when the last image came back from the rover.
`long` | `getMeanUpdateTime()` Lets you know when the last packet containing mean color data came back from the rover.
`long` | `getMotionUpdateTime()` Lets you know when the last packet containing motion data came back from the rover.
`java.awt.image.BufferedImage` | `getRecentImage()` Gets the most recent image taken on the stargate.
`long` | `getTrackUpdateTime()` Lets you know when the last packet containing tracking data came back from the rover.
`void` | `quit()` Do not call this function.
`boolean` | `registerObject(java.lang.Object o, int type)` Registers an object to be notified when new data arrives that you are interested in.
`void` | `run()`
`boolean` | `unregisterObject(java.lang.Object o, int type)` Unregisters an object that was registered with the registerObject() function.

Methods inherited from class java.lang.Thread
`activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### PICTURE_RECEIVE

    public static final int PICTURE_RECEIVE

  use this variable in the [un]registerObject functions to be notified of new pictures

  See Also:
    Constant Field Values

### TRACK_RECEIVE

    public static final int TRACK_RECEIVE

  use this variable in the [un]registerObject functions to be notified of new tracking data

  See Also:
    Constant Field Values

### MEAN_RECEIVE

    public static final int MEAN_RECEIVE

  use this variable in the [un]registerObject functions to be notified of new mean color data

  See Also:
    Constant Field Values

### MOTION_RECEIVE

    public static final int MOTION_RECEIVE

  use this variable in the [un]registerObject functions to be notified of new motion data

  See Also:
    Constant Field Values

### minX

    public int minX

  When tracking, this is the minimum x-coordinate where the object was detected

### minY

    public int minY

  When tracking, this is the minimum y-coordinate where the object was detected

### maxX

    public int maxX

  When tracking, this is the maximum x-coordinate where the object was detected

### maxY

    public int maxY

  When tracking, this is the maximum y-coordinate where the object was detected

### x

    public int x

  When tracking, this is the mean x-coordinate where the object was detected

### y

    public int y

  When tracking, this is the mean y-coordinate where the object was detected

### pixels

    public int pixels

  When tracking, this is the total number of pixels tracked

### meanY

    public int meanY

  Updated by getMean, this is the average Y value. The Y-channel corresponds to intensity.

### meanU

    public int meanU

  Updated by getMean, this is the average U value. The U-channel roughly corresponds to how blue the object is.

### meanV

    public int meanV

  Updated by getMean, this is the average V value. The V-channel roughly corresponds to how red the object is.

### motion

    public int[] motion

  This array stores the difference in intensity between frames. It is 99 elements in size. Each element in the array represents the average intensity difference for a 16 by 16 block of pixels. A single frame is 11 blocks wide and 9 blocks high (176x144 pixels). The data is stored row-wise, starting from the upper-left block. Check `getMotionUpdateTime()` to see when it was last updated.

Constructor Detail

### ReceiveThread

    public ReceiveThread(Reliagram reliagram,
                         RoverState State)

  Creates a new instance of ReceiveThread

Method Detail

### run

    public void run()

### quit

    public void quit()

  Do not call this function. It stops the thread running for this class. This function should only be called when closing the communication in RoverController.

### getRecentImage

    public java.awt.image.BufferedImage getRecentImage()

  Gets the most recent image taken on the stargate.

  Returns:
    the most recent picture the stargate has send back.

### getImageUpdateTime

    public long getImageUpdateTime()

  Lets you know when the last image came back from the rover.

  Returns:
    the system time in ms when the last image came back from the rover.

### getTrackUpdateTime

    public long getTrackUpdateTime()

  Lets you know when the last packet containing tracking data came back from the rover.

  Returns:
    the system time in ms when the last tracking data came back from the rover.

### getMeanUpdateTime

    public long getMeanUpdateTime()

  Lets you know when the last packet containing mean color data came back from the rover.

  Returns:
    the system time in ms when the last mean color data came back from the rover.

### getMotionUpdateTime

    public long getMotionUpdateTime()

  Lets you know when the last packet containing motion data came back from the rover.

  Returns:
    the system time in ms when the last motion data came back from the rover.

### registerObject

    public boolean registerObject(java.lang.Object o,
                                  int type)

  Registers an object to be notified when new data arrives that you are interested in. When new data comes of the type you specify, a lock will be acquired on that object and then `notify()` will be called. See PER.rover.DetectMotionAction for an example of this function used.

  Make sure to call unregisterObject when you are done. This will free up the resources associated with notifying.

  Parameters:
    `o` - The object to be registered.
    `type` - The type of data you want to be notified for. See the *_RECEIVE constants from this class: PICTURE_RECEIVE, TRACK_RECEIVE, MEAN_RECEIVE, and MOTION_RECEIVE.
  Returns:
    This function will return false if either the type is invalid or you try to register the same object twice for the same type. Otherwise, it returns true.

### unregisterObject

    public boolean unregisterObject(java.lang.Object o,
                                    int type)

  Unregisters an object that was registered with the registerObject() function. Calling this function will free up the resources associated with notifying.

  Parameters:
    `o` - The object to be unregistered.
    `type` - The type of data you want to be notified for. See the *_RECEIVE constants from this class: PICTURE_RECEIVE, TRACK_RECEIVE, MEAN_RECEIVE, and MOTION_RECEIVE.
  Returns:
    This function will return true only if the object was successfully unregistered.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD