canonVC_C50i
Class CanonVC

java.lang.Object
  extended by canonVC_C50i.CanonVC
All Implemented Interfaces:
java.lang.Runnable, java.util.EventListener, javax.comm.SerialPortEventListener

public class CanonVC
extends java.lang.Object
implements java.lang.Runnable, javax.comm.SerialPortEventListener


Field Summary
(package private) static byte[] camResponse
           
(package private)  byte[] curComand
           
(package private)  java.lang.String defaultPort
           
(package private)  int focusMaxRange
           
(package private)  int focusMinRange
           
(package private)  double focusPosition
           
(package private) static java.io.InputStream inputStream
           
(package private) static int MAX_OPERATION_TIME
           
(package private)  boolean outputBufferEmptyFlag
           
(package private) static java.io.OutputStream outputStream
           
(package private)  int panDirection
           
(package private) static double panMax
           
(package private)  double panMaxSpeed
           
(package private)  double panMinSpeed
           
(package private)  double panRatio
           
(package private)  double panSpeed
           
(package private)  javax.comm.CommPortIdentifier portId
           
(package private)  java.util.Enumeration portList
           
(package private)  java.lang.Thread readThread
           
(package private)  javax.comm.SerialPort serialPort
           
(package private) static byte[] tempResponse
           
(package private)  int tiltDirection
           
(package private) static double tiltMax
           
(package private)  double tiltMaxSpeed
           
(package private)  double tiltMinSpeed
           
(package private)  double tiltRatio
           
(package private)  double tiltSpeed
           
(package private) static byte VC_CMD_END
           
(package private)  double xPosition
           
(package private)  double yPosition
           
(package private)  int zoomMaxRange
           
(package private)  int zoomMinRange
           
(package private)  double zoomPosition
           
 
Constructor Summary
CanonVC()
           
CanonVC(java.lang.String port)
           
 
Method Summary
static byte[] angle2ascii(double pan, int size)
           
static void AngleAssignment(double x, double y)
           
 void close()
           
static int CommandtoCam(byte[] command)
          Send a message to the camera.
(package private) static long getTime()
           
 void InitializePedestal()
           
 void run()
           
 void serialEvent(javax.comm.SerialPortEvent event)
          whenever there is a response from the camera read into tempResponse
(package private) static canonVC_C50i.VCstatus VCcameraStatus()
          Given a response from the camera, decide whether it is a good one or not.
(package private)  double VCconvertPanSpeed(double ps)
          Convert the pan speed to the actual pan speed that the camera will use.
(package private)  double VCconvertTiltSpeed(double ts)
          Convert the tilt speed to the actual tilt speed that the camera will use.
(package private)  void VCgetFocusPosition()
          Get the current focus position.
(package private)  void VCgetFocusRange()
          Get the focal range.
(package private)  void VCgetPanRatio()
          Get the pan ratio of the camera.
(package private)  void VCgetPanSpeed()
          Get the pan speed of the camera in degrees / sec.
(package private)  void VCgetPosition()
          Get the current pan and tilt angles of the camera.
(package private)  void VCgetTiltRatio()
          Get the tilt ratio of the camera.
(package private)  void VCgetTiltSpeed()
          Get the tilt speed of the camera in degrees / sec.
(package private)  void VCgetZoomPosition()
          Get the current zoom position.
(package private)  void VCgetZoomRange()
          Get the zoom range.
(package private)  byte[] VChexToAscii(short h, byte[] ascii, int size)
          Convert up to four nibbles of an short to ascii.
(package private)  void VChome()
          Point the camera to the straight ahead position.
(package private)  void VChostControl()
          Put the camera in host control mode.
(package private)  short VCpanDegreesToAscii(double degrees, byte[] ascii, int start, int size)
          Convert pan degrees to raw camera native units.
(package private) static void VCprintCommand(byte[] BUF)
          Print the current command.
(package private)  double VCrawToInt(byte[] raw, int start, int size)
          Given an ascii string of hex numbers, convert it to a binary.
(package private)  double VCrawToReal(byte[] raw, int start, int size)
          Given an ascii string of hex numbers, convert it to a real number.
(package private)  void VCreset()
          Reset the camera.
(package private)  void VCsetFocusMode(int mode)
          Set the focus mode.
(package private)  void VCsetFocusPosition(int pos)
          Set the focus position.
(package private)  void VCsetPanSpeed(double ps)
          Set the pan speed of the camera.
(package private)  void VCsetTiltSpeed(double ts)
          Set the tilt speed of the camera.
(package private)  void VCsetZoom(int zoom)
          Set the zoom.
(package private)  short VCtiltDegreesToAscii(double degrees, byte[] ascii, int start, int size)
          Convert tilt degrees to raw camera native units.
(package private) static int VCtoCameraRetryBusy(byte[] command)
          Send a command to the camera.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

readThread

java.lang.Thread readThread

portList

java.util.Enumeration portList

portId

javax.comm.CommPortIdentifier portId

serialPort

javax.comm.SerialPort serialPort

outputStream

static java.io.OutputStream outputStream

outputBufferEmptyFlag

boolean outputBufferEmptyFlag

inputStream

static java.io.InputStream inputStream

defaultPort

java.lang.String defaultPort

MAX_OPERATION_TIME

static final int MAX_OPERATION_TIME
See Also:
Constant Field Values

camResponse

static byte[] camResponse

curComand

byte[] curComand

tempResponse

static byte[] tempResponse

panMax

static double panMax

tiltMax

static double tiltMax

panMinSpeed

double panMinSpeed

panMaxSpeed

double panMaxSpeed

tiltMinSpeed

double tiltMinSpeed

tiltMaxSpeed

double tiltMaxSpeed

tiltSpeed

double tiltSpeed

panSpeed

double panSpeed

xPosition

double xPosition

yPosition

double yPosition

zoomPosition

double zoomPosition

focusPosition

double focusPosition

panRatio

double panRatio

tiltRatio

double tiltRatio

focusMinRange

int focusMinRange

focusMaxRange

int focusMaxRange

zoomMinRange

int zoomMinRange

zoomMaxRange

int zoomMaxRange

panDirection

int panDirection

tiltDirection

int tiltDirection

VC_CMD_END

static final byte VC_CMD_END
See Also:
Constant Field Values
Constructor Detail

CanonVC

CanonVC()

CanonVC

CanonVC(java.lang.String port)
Method Detail

run

public void run()
Specified by:
run in interface java.lang.Runnable

getTime

static long getTime()

serialEvent

public void serialEvent(javax.comm.SerialPortEvent event)
whenever there is a response from the camera read into tempResponse

Specified by:
serialEvent in interface javax.comm.SerialPortEventListener
Parameters:
event -
See Also:

VCrawToInt

double VCrawToInt(byte[] raw,
                  int start,
                  int size)
Given an ascii string of hex numbers, convert it to a binary.

Parameters:
raw - Ascii string of hex numbers
size - Number of characters in raw.
Returns:
Int value representation of value.

VCrawToReal

double VCrawToReal(byte[] raw,
                   int start,
                   int size)
Given an ascii string of hex numbers, convert it to a real number.

Parameters:
raw - Ascii string of hex numbers
size - Number of characters in raw.
Returns:
floating point representation of value.

VChexToAscii

byte[] VChexToAscii(short h,
                    byte[] ascii,
                    int size)
Convert up to four nibbles of an short to ascii.

Parameters:
h - Integer value.
size - Number of bytes in resulting ascii.
Returns:

VCprintCommand

static void VCprintCommand(byte[] BUF)
Print the current command. This is generally used for debugging.

Parameters:
vc - Control structure.

VCpanDegreesToAscii

short VCpanDegreesToAscii(double degrees,
                          byte[] ascii,
                          int start,
                          int size)
Convert pan degrees to raw camera native units.

Parameters:
degrees - Degrees to pan (-360 to +360).
ascii - Put 4 ascii characters here.
size - Number of bytes in resulting ascii.
Returns:
Hex value of pan speed.

VCtiltDegreesToAscii

short VCtiltDegreesToAscii(double degrees,
                           byte[] ascii,
                           int start,
                           int size)
Convert tilt degrees to raw camera native units.

Parameters:
degrees - Degrees to tilt (-360 to +360).
ascii - Put 4 ascii characters here.
size - Number of bytes in resulting ascii.
Returns:
Hex value of tilt speed.

VCcameraStatus

static canonVC_C50i.VCstatus VCcameraStatus()
Given a response from the camera, decide whether it is a good one or not. If not, describe what the problem is.

Parameters:
vc - Control structure.
response - Message from camera to computer.
Returns:
Zero if good message from camera, error code if there is a problem.

CommandtoCam

public static int CommandtoCam(byte[] command)
                        throws canonVC_C50i.CanonVC_Exception
Send a message to the camera. The command must be terminated with VC_CMD_END, which will be used as the cmomand terminator. It is assumed that commands are short (less than 100 bytes). After the command is sent, the response will be read from the camera. If a good response is received, then a good status will be returned. If the camera does not respond or responds with an error, then an exception will be thrown.

Parameters:
vc - Control structure.
command - Command bytes to send to the camera, terminated with VC_CMD_END.
resp - If this is not null and the camera gives a good response, then put the resonse here. Caller must ensure that the buffer is big enough.
Returns:
Zero on success, throws error on fail.
Throws:
canonVC_C50i.CanonVC_Exception

VCtoCameraRetryBusy

static int VCtoCameraRetryBusy(byte[] command)
                        throws canonVC_C50i.CanonVC_Exception
Send a command to the camera. If the camera is busy, keep retrying it until it either succeeds, fails for another reason, or the operation times out

Parameters:
command - Command to send to camera.
Returns:
Zero on success, throws error on failure.
Throws:
canonVC_C50i.CanonVC_Exception

angle2ascii

public static byte[] angle2ascii(double pan,
                                 int size)

AngleAssignment

public static void AngleAssignment(double x,
                                   double y)

VChostControl

void VChostControl()
             throws canonVC_C50i.CanonVC_Exception
Put the camera in host control mode. This must be done before issuing any other commands. This mode means that the camera is controlled by the computer and not by the infra-red remote.

Parameters:
vc - Control structure.
Throws:
canonVC_C50i.CanonVC_Exception

VCgetPosition

void VCgetPosition()
             throws canonVC_C50i.CanonVC_Exception
Get the current pan and tilt angles of the camera. The results are put in the vc struct.

Parameters:
vc - Control structure.
Throws:
canonVC_C50i.CanonVC_Exception

VCgetPanRatio

void VCgetPanRatio()
             throws canonVC_C50i.CanonVC_Exception
Get the pan ratio of the camera.

Parameters:
vc - Control structure.
ps - Pan ratio (returned).
Throws:
canonVC_C50i.CanonVC_Exception

VCgetTiltRatio

void VCgetTiltRatio()
              throws canonVC_C50i.CanonVC_Exception
Get the tilt ratio of the camera.

Parameters:
vc - Control structure.
ps - Tilt ratio (returned).
Throws:
canonVC_C50i.CanonVC_Exception

VCsetPanSpeed

void VCsetPanSpeed(double ps)
             throws canonVC_C50i.CanonVC_Exception
Set the pan speed of the camera. If the speed is too fast or slow, then set it to the corresponding high or low speed limit.

Parameters:
vc - Control structure.
ps - Pan speed in degrees/sec.
Throws:
canonVC_C50i.CanonVC_Exception

VCsetTiltSpeed

void VCsetTiltSpeed(double ts)
              throws canonVC_C50i.CanonVC_Exception
Set the tilt speed of the camera. If the speed is too fast or slow, then set it to the corresponding high or low speed limit.

Parameters:
vc - Control structure.
ts - Tilt speed in degrees/sec.
Throws:
canonVC_C50i.CanonVC_Exception

VCgetPanSpeed

void VCgetPanSpeed()
             throws canonVC_C50i.CanonVC_Exception
Get the pan speed of the camera in degrees / sec.

Parameters:
vc - Control structure.
Throws:
canonVC_C50i.CanonVC_Exception

VCgetTiltSpeed

void VCgetTiltSpeed()
              throws canonVC_C50i.CanonVC_Exception
Get the tilt speed of the camera in degrees / sec.

Parameters:
vc - Control structure.
ps - Tilt speed (returned).
Throws:
canonVC_C50i.CanonVC_Exception

VCconvertPanSpeed

double VCconvertPanSpeed(double ps)
Convert the pan speed to the actual pan speed that the camera will use. This accounts for the fact that the speed setting has a granularity. For example, if the camera is given a pan speed of 3.0000 degrees/sec, then it will actually set it to 3.0375 degress/sec. Setting a value of 0 to stop panning will not work, although the conversion does.

Parameters:
vc - Control structure.
ps - Pan speed.
Returns:
Converted value.

VCconvertTiltSpeed

double VCconvertTiltSpeed(double ts)
Convert the tilt speed to the actual tilt speed that the camera will use. This accounts for the fact that the speed setting has a granularity. For example, if the camera is given a tilt speed of 24.0000 degrees/sec, then it will actually set it to 23.96250 degress/sec. Note that some work out exactly, such as 9, 18, and 27 degrees. Setting a value of 0 to stop tilting will not work, although the conversion does.

Parameters:
vc - Control structure.
ts - Tilt speed.
Returns:
Converted value.

VCreset

void VCreset()
       throws canonVC_C50i.CanonVC_Exception
Reset the camera.

Parameters:
vc - Control structure.
Throws:
canonVC_C50i.CanonVC_Exception

VCsetFocusMode

void VCsetFocusMode(int mode)
              throws canonVC_C50i.CanonVC_Exception
Set the focus mode.

Parameters:
vc - Control structure.
mode - Focus mode.
Throws:
canonVC_C50i.CanonVC_Exception

VCsetFocusPosition

void VCsetFocusPosition(int pos)
                  throws canonVC_C50i.CanonVC_Exception
Set the focus position.

Parameters:
vc - Control structure.
pos - Position of focus.
Throws:
canonVC_C50i.CanonVC_Exception

VCgetFocusRange

void VCgetFocusRange()
               throws canonVC_C50i.CanonVC_Exception
Get the focal range.

Parameters:
vc - Control structure.
minFocus - Minimum focus range.
maxFocus - Maximum focus range.
Throws:
canonVC_C50i.CanonVC_Exception

VCgetFocusPosition

void VCgetFocusPosition()
                  throws canonVC_C50i.CanonVC_Exception
Get the current focus position.

Parameters:
vc - Control structure.
pos - Focus position (returned).
Throws:
canonVC_C50i.CanonVC_Exception

VCgetZoomRange

void VCgetZoomRange()
              throws canonVC_C50i.CanonVC_Exception
Get the zoom range.

Parameters:
vc - Control structure.
minFocus - Minimum focus range.
maxFocus - Maximum focus range.
Throws:
canonVC_C50i.CanonVC_Exception

VCsetZoom

void VCsetZoom(int zoom)
         throws canonVC_C50i.CanonVC_Exception
Set the zoom. This uses zoom position 2.

Parameters:
zoom - Amount to zoom. The larger the value, the more the image is magnified.
Throws:
canonVC_C50i.CanonVC_Exception

VCgetZoomPosition

void VCgetZoomPosition()
                 throws canonVC_C50i.CanonVC_Exception
Get the current zoom position. Use zoom position 2.

Parameters:
vc - Control structure.
pos - Zoom position (returned).
Throws:
canonVC_C50i.CanonVC_Exception

VChome

void VChome()
      throws canonVC_C50i.CanonVC_Exception
Point the camera to the straight ahead position.

Parameters:
vc - Control structure.
Throws:
canonVC_C50i.CanonVC_Exception

close

public void close()

InitializePedestal

public void InitializePedestal()
                        throws canonVC_C50i.CanonVC_Exception
Throws:
canonVC_C50i.CanonVC_Exception