jcontrol.comm
Class FT1_2

java.lang.Object
  extended by jcontrol.comm.FT1_2
All Implemented Interfaces:
Runnable

public class FT1_2
extends Object
implements Runnable


Field Summary
 int count_receive_failed
           
 int count_receive_lost
           
 int count_receive_success
           
 int count_send_failed
           
 int count_send_success
           
static int DIRECTION_A2B
           
static int DIRECTION_B2A
           
 
Constructor Summary
FT1_2()
          Default constructor.
FT1_2(int uartChannel, int direction, int baudrate, int params)
          Constructor
 
Method Summary
 void close()
          Stops the FT1.2 communicator.
protected  void finalize()
          finalize method
 byte[] getIncomingUDat()
          Blocks until any USER-DATA availabe and return it as byte-array.
 void run()
          This thread is a Event-Producer and fire events for each incoming USER-DATA (using the function 'getIncomingUDat()').
 void sendRESET()
          Sends a RESET command to peer.
 void sendUDAT(byte[] data, int offset, int length)
          Send USER-DATA to peer.
 void setCharacterGuardTime(int bits)
          Sets the character guard time, i.e. the time to wait between sending two characters over the serial port.
 void setListener(FT1_2EventListener eventlistener)
          Sets an FT1_2EventListener.
 void setTimeOut(int timeInMilliseconds)
          Sets the exchange timeout.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notifyAll, toString, wait
 

Field Detail

DIRECTION_A2B

public static final int DIRECTION_A2B
See Also:
Constant Field Values

DIRECTION_B2A

public static final int DIRECTION_B2A
See Also:
Constant Field Values

count_receive_success

public int count_receive_success

count_receive_failed

public int count_receive_failed

count_receive_lost

public int count_receive_lost

count_send_success

public int count_send_success

count_send_failed

public int count_send_failed
Constructor Detail

FT1_2

public FT1_2(int uartChannel,
             int direction,
             int baudrate,
             int params)
      throws IOException
Constructor

Throws:
IOException

FT1_2

public FT1_2()
      throws IOException
Default constructor. Uses RS422, 125000 baud, even parity and direction A2B.

Throws:
IOException
Method Detail

sendUDAT

public void sendUDAT(byte[] data,
                     int offset,
                     int length)
              throws IOException
Send USER-DATA to peer. This function blocks until data is send (positive ack) or throws an IO-Exception is something goes wrong! TODO: we need a time-out! TODO: sync m_uart (protect for close while sending)

Parameters:
data -
offset -
length -
Throws:
IOException

sendRESET

public void sendRESET()
               throws IOException
Sends a RESET command to peer. This function blocks until data is send (positive ack) or throws an IO-Exception is something goes wrong!

Throws:
IOException

setListener

public void setListener(FT1_2EventListener eventlistener)
Sets an FT1_2EventListener.

Parameters:
el - eventlistener to use (null to remove)

getIncomingUDat

public byte[] getIncomingUDat()
                       throws IOException
Blocks until any USER-DATA availabe and return it as byte-array. If 'close()' was called, this function throws an IOException.

Returns:
available user-data or null if close() was called
Throws:
IOException - if something bad happend (ft12 closed)

setTimeOut

public void setTimeOut(int timeInMilliseconds)
Sets the exchange timeout.

Parameters:
timeout - timeout in ms

setCharacterGuardTime

public void setCharacterGuardTime(int bits)
Sets the character guard time, i.e. the time to wait between sending two characters over the serial port. Note that this value does not change the timeout, so on altering the character guard time, the application has to take care of adjusting the timeout appropriately (i.e. if guard time is set to 8, the timeout must be approximately doubled, as communication speed is cut down by 50%.

Parameters:
bits - minimum bits to wait between two characters

close

public void close()
Stops the FT1.2 communicator.


finalize

protected void finalize()
finalize method


run

public void run()
This thread is a Event-Producer and fire events for each incoming USER-DATA (using the function 'getIncomingUDat()'). This Event-Producer only runs, if any Listener if exists, otherwise no thread is startet!

Specified by:
run in interface Runnable
See Also:
Thread.run()