org.vigia.client.communications
Class ControlCommunicator

java.lang.Object
  extended by org.vigia.client.communications.ControlCommunicator

public class ControlCommunicator
extends java.lang.Object

Implements the client control communication.

Author:
jrios

Nested Class Summary
protected  class ControlCommunicator.ControlCommunicatorReader
          This class reads from the socket and sends the commands to the listeners.
 
Field Summary
protected  java.util.Set<LogListener> logListeners
          The registered listeners.
protected  java.net.Socket socket
          The socket to connect with the server.
 
Constructor Summary
ControlCommunicator(java.lang.String host, int controlPort)
          Connects to the remote camera data port.
 
Method Summary
 void addLogListener(LogListener logListener)
          Adds a listener to obtain control messages from the remote camera.
 void close()
          Closes the control communicator.
 void init(int dataPort)
          Initializes the remote camera properly and starts the video transmission.
 boolean isClosed()
          Check if the communications are closed.
 void move(int pan, int tilt, int zoom)
          Send to the remote camera a move command in an absolute way.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

socket

protected java.net.Socket socket
The socket to connect with the server.


logListeners

protected java.util.Set<LogListener> logListeners
The registered listeners.

Constructor Detail

ControlCommunicator

public ControlCommunicator(java.lang.String host,
                           int controlPort)
                    throws java.net.UnknownHostException,
                           java.io.IOException
Connects to the remote camera data port.

Parameters:
host - The remote host.
controlPort - The remote port.
Throws:
java.io.IOException - Error with the IO.
java.net.UnknownHostException - Host not found.
Method Detail

addLogListener

public void addLogListener(LogListener logListener)
Adds a listener to obtain control messages from the remote camera.

Parameters:
logListener - an implementation of the control listener.

init

public void init(int dataPort)
          throws java.io.IOException
Initializes the remote camera properly and starts the video transmission.

Parameters:
dataPort - the client data port.
Throws:
java.io.IOException - Error sending the command.

move

public void move(int pan,
                 int tilt,
                 int zoom)
          throws java.io.IOException
Send to the remote camera a move command in an absolute way.

Parameters:
pan - pan position.
tilt - tilt position.
zoom - zoom position.
Throws:
java.io.IOException - Error sending the command.

close

public void close()
           throws java.io.IOException
Closes the control communicator.

Throws:
java.io.IOException - Error closing the socket.

isClosed

public boolean isClosed()
Check if the communications are closed.

Returns:
Is it's closed.