de.wagner_ibw.iow
Class AbstractIowDevice

java.lang.Object
  |
  +--de.wagner_ibw.iow.AbstractIowDevice
Direct Known Subclasses:
Iow24, Iow40, Iow56

public abstract class AbstractIowDevice
extends java.lang.Object

This class provides default implementation for the IO-Warrior devices.

Author:
Thomas Wagner

Field Summary
static int IOW24_SMF_REPORT_LENGTH
          Constant for IO-Warrior 24 device special mode funtions's record length: '8'.
static long IOW24ID
          Constant for IO-Warrior 24 device id: '0x1501'.
static java.lang.String IOW24NAME
          Constant for IO-Warrior 24 device name: 'IOW24'.
static int IOW40_SMF_REPORT_LENGTH
          Constant for IO-Warrior 40 device special mode funtions's record length: '8'.
static long IOW40ID
          Constant for IO-Warrior 40 device id: '0x1500'.
static java.lang.String IOW40NAME
          Constant for IO-Warrior 40 device name: 'IOW40'.
static int IOW56_SMF_REPORT_LENGTH
          Constant for IO-Warrior 56 device special mode funtions's record length: '64'.
static long IOW56ID
          Constant for IO-Warrior 56 device id: '0x1503'.
static java.lang.String IOW56NAME
          Constant for IO-Warrior 56 device name: 'IOW56'.
 
Constructor Summary
AbstractIowDevice()
          Constructor, called from sub class only.
 
Method Summary
 void addIowChangeListener(IowChangeListener icl)
          Adds an IowChangeListener to the internal list.
 void addSpecialModeFunctionImpl(SpecialModeFunction impl)
          Adds given special mode function implementation to this IO-Warrior device.
 void autonomous(boolean status)
          Sets the autonomous mode either on or off.
 void clearBit(int port, int bit)
          Clear the given bit from a the given port.
 void close()
          Close this IO-Warrior device.
abstract  boolean equals(java.lang.Object o)
          Indicates whether some other IO-Warrior 24, IO-Warrior 40 or IO-Warrior 65 object is "equal to" this object.
 long getHandle()
          Returns the handle of this IO-Warrior device.
 int getId()
          Returns the device id of this IO-Warrior device.
 Monitor getMonitor()
          Returns the Monitor reference (for internal I2C control purpose only).
abstract  java.lang.String getName()
          Returns the name of this IO-Warrior device.
 IowPort getPort(int port)
          Returns the desired port of this IO-Warrior device.
 int getPortCount()
          Returns the number of ports of this IO-Warrior device.
 int getRev()
          Returns the revision of this IO-Warrior device.
 java.lang.String getSerial()
          Returns the serial of this IO-Warrior device.
 int getSmfReportLength()
          Returns the length of the special mode function report of this IO-Warrior device.
 SpecialModeFunction getSpecialModeFunctionImpl(java.lang.String smfName)
          Returns the desired special mode function implementation.
 int hashCode()
          Returns a hash code value for this Iow object.
 long readIOPorts()
          Reads the iow ports and store them in the internal port array.
abstract  long readIOPortsImmediate()
          Reads the iow ports and store them in the internal port array (none blocking).
 long readIOPortsNonBlocking()
          Reads the iow ports non blocking and store them in the internal port array.
 void removeIowChangeListener(IowChangeListener icl)
          Removes given IowChangeListener from the internal list.
 void removeSpecialModeFunctionImpl(SpecialModeFunction impl)
          Removes given special mode function implementation from this IO-Warrior device.
abstract  long scanPorts()
          Gets the current pin status.
 void setBit(int port, int bit)
          Set the given bit from the given port.
 void setDirection(int port, int direction)
          Set the direction mask to the given port.
 void setPort(int port, int in)
          Set the pattern to the given port.
 void setTimeout(long timeout)
          Set timeout for read operations.
 void setWriteTimeout(long timeout)
          Set timeout for write operations.
abstract  java.lang.String toString()
          Returns a String object representing this Iow object.
abstract  void writeIOPorts()
          Writes the presetted ports to this IO-Warrior device.
abstract  void writeIOPorts(long value)
          Writes the value to this IO-Warrior device's ports.
 long writeReport(int pipe, int[] wbuf)
          Writes a report to this IO-Warrior device.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IOW40ID

public static final long IOW40ID
Constant for IO-Warrior 40 device id: '0x1500'. (decimal 5376)

See Also:
Constant Field Values

IOW24ID

public static final long IOW24ID
Constant for IO-Warrior 24 device id: '0x1501'. (decimal 5377)

See Also:
Constant Field Values

IOW56ID

public static final long IOW56ID
Constant for IO-Warrior 56 device id: '0x1503'. (decimal 5379)

See Also:
Constant Field Values

IOW40NAME

public static final java.lang.String IOW40NAME
Constant for IO-Warrior 40 device name: 'IOW40'.

See Also:
Constant Field Values

IOW24NAME

public static final java.lang.String IOW24NAME
Constant for IO-Warrior 24 device name: 'IOW24'.

See Also:
Constant Field Values

IOW56NAME

public static final java.lang.String IOW56NAME
Constant for IO-Warrior 56 device name: 'IOW56'.

See Also:
Constant Field Values

IOW24_SMF_REPORT_LENGTH

public static final int IOW24_SMF_REPORT_LENGTH
Constant for IO-Warrior 24 device special mode funtions's record length: '8'.

See Also:
Constant Field Values

IOW40_SMF_REPORT_LENGTH

public static final int IOW40_SMF_REPORT_LENGTH
Constant for IO-Warrior 40 device special mode funtions's record length: '8'.

See Also:
Constant Field Values

IOW56_SMF_REPORT_LENGTH

public static final int IOW56_SMF_REPORT_LENGTH
Constant for IO-Warrior 56 device special mode funtions's record length: '64'.

See Also:
Constant Field Values
Constructor Detail

AbstractIowDevice

public AbstractIowDevice()
Constructor, called from sub class only.

Method Detail

addSpecialModeFunctionImpl

public void addSpecialModeFunctionImpl(SpecialModeFunction impl)
                                throws java.lang.UnsupportedOperationException,
                                       java.lang.IllegalArgumentException
Adds given special mode function implementation to this IO-Warrior device.

Parameters:
impl - Special mode function implementation to add.
Throws:
java.lang.UnsupportedOperationException - if this IO-Warrior device does not support the given special mode function
java.lang.IllegalArgumentException - if the special mode function implementation is already added

removeSpecialModeFunctionImpl

public void removeSpecialModeFunctionImpl(SpecialModeFunction impl)
Removes given special mode function implementation from this IO-Warrior device.

Parameters:
impl - Special mode function implementation to remove.

getSpecialModeFunctionImpl

public SpecialModeFunction getSpecialModeFunctionImpl(java.lang.String smfName)
                                               throws java.util.NoSuchElementException
Returns the desired special mode function implementation.

Parameters:
smfName - Name of the desired function.
Returns:
Instance of the desired special mode function implementation.
Throws:
java.util.NoSuchElementException - if the desired function was not added.
Since:
0.9.4

getHandle

public long getHandle()
Returns the handle of this IO-Warrior device.

Returns:
Returns the handle of this IO-Warrior device.

getSerial

public java.lang.String getSerial()
Returns the serial of this IO-Warrior device.

Returns:
The serial number of this IO-Warrior device.

getId

public int getId()
Returns the device id of this IO-Warrior device.

Returns:
Returns the device id of this IO-Warrior device.

getSmfReportLength

public int getSmfReportLength()
Returns the length of the special mode function report of this IO-Warrior device.

Returns:
Returns the special mode record length of this IO-Warrior device.
Since:
0.9.5

getRev

public int getRev()
Returns the revision of this IO-Warrior device.

Returns:
Returns the revision id of this IO-Warrior device.
Since:
0.9.3

getPortCount

public int getPortCount()
Returns the number of ports of this IO-Warrior device.

Returns:
Returns the number of ports (IO-Warrior 24: 2, IO-Warrior 40: 4, IO-Warrior 56: 7).
Since:
0.9.5

close

public void close()
Close this IO-Warrior device. Stops the special mode function read thread and if necessary the pin io read thread.


setTimeout

public void setTimeout(long timeout)
Set timeout for read operations.

Parameters:
timeout - Timeout value in ms.

setWriteTimeout

public void setWriteTimeout(long timeout)
Set timeout for write operations.

Parameters:
timeout - Timeout value in ms.
Since:
0.9.3

writeReport

public long writeReport(int pipe,
                        int[] wbuf)
Writes a report to this IO-Warrior device.

Parameters:
pipe - number of pipe.
wbuf - Write buffer.
Returns:
Count of written bytes.

readIOPorts

public long readIOPorts()
Reads the iow ports and store them in the internal port array. Attention! this method blocks until a io pin is changed.

Returns:
Port status in long representation.
Since:
0.9.3 with long return value

readIOPortsNonBlocking

public long readIOPortsNonBlocking()
Reads the iow ports non blocking and store them in the internal port array.

Returns:
Port status in long representation.
Since:
0.9.5

readIOPortsImmediate

public abstract long readIOPortsImmediate()
Reads the iow ports and store them in the internal port array (none blocking).

Returns:
Port status in long representation.
Since:
0.9.3 with long return value

scanPorts

public abstract long scanPorts()
                        throws java.lang.UnsupportedOperationException
Gets the current pin status.

Returns:
Port status in long representation.
Throws:
java.lang.UnsupportedOperationException - if this IO-Warrior device does not support the get curent pin status special mode function.
Since:
0.9.3

writeIOPorts

public abstract void writeIOPorts()
Writes the presetted ports to this IO-Warrior device.


writeIOPorts

public abstract void writeIOPorts(long value)
Writes the value to this IO-Warrior device's ports.

Parameters:
value - output pattern
Since:
0.9.5

autonomous

public void autonomous(boolean status)
Sets the autonomous mode either on or off. Autonomous mode means, that class uses readIOPorts() in a loop and in a thread.

Parameters:
status - true switches the mode on, false switches the mode off.

addIowChangeListener

public void addIowChangeListener(IowChangeListener icl)
Adds an IowChangeListener to the internal list.

Since:
0.9.5

removeIowChangeListener

public void removeIowChangeListener(IowChangeListener icl)
Removes given IowChangeListener from the internal list.

Since:
0.9.5

getName

public abstract java.lang.String getName()
Returns the name of this IO-Warrior device.

Returns:
Returns the name of this IO-Warrior device.

getPort

public IowPort getPort(int port)
                throws java.lang.IllegalArgumentException
Returns the desired port of this IO-Warrior device.

Parameters:
port - desired port number.
Returns:
IowPort instance of the desired port.
Throws:
java.lang.IllegalArgumentException - if the port number is out of range.

setBit

public void setBit(int port,
                   int bit)
            throws java.lang.IllegalArgumentException
Set the given bit from the given port.

Parameters:
port - Port number (0...1 or 0...3).
bit - Bit number (0...7).
Throws:
java.lang.IllegalArgumentException - if the port number is out of range.

clearBit

public void clearBit(int port,
                     int bit)
              throws java.lang.IllegalArgumentException
Clear the given bit from a the given port.

Parameters:
port - Port number (0...1 or 0...3).
bit - Bit number (0...7).
Throws:
java.lang.IllegalArgumentException - if the port number is out of range.

setPort

public void setPort(int port,
                    int in)
             throws java.lang.IllegalArgumentException
Set the pattern to the given port.

Parameters:
port - Port number (0...3).
Throws:
java.lang.IllegalArgumentException - if the port number is out of range.

setDirection

public void setDirection(int port,
                         int direction)
                  throws java.lang.IllegalArgumentException
Set the direction mask to the given port.

Parameters:
port - Port number (0...3 or 0...1).
direction - 0-output, 1-input
Throws:
java.lang.IllegalArgumentException - if the port number is out of range.
Since:
0.9.3

getMonitor

public Monitor getMonitor()
Returns the Monitor reference (for internal I2C control purpose only).

Returns:
Monitor reference

hashCode

public int hashCode()
Returns a hash code value for this Iow object. It is derived from the device id and serial number.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.
Since:
0.9.4

toString

public abstract java.lang.String toString()
Returns a String object representing this Iow object. It contains information about device handle, id , revision, serial number and the status of ports.

Overrides:
toString in class java.lang.Object

equals

public abstract boolean equals(java.lang.Object o)
Indicates whether some other IO-Warrior 24, IO-Warrior 40 or IO-Warrior 65 object is "equal to" this object. Criteria is the serial number.

Overrides:
equals in class java.lang.Object
Returns:
True if this object is the same as the obj argument; false otherwise.
Since:
0.9.4