de.wagner_ibw.iow
Class AbstractIowDevcie

java.lang.Object
  |
  +--de.wagner_ibw.iow.AbstractIowDevcie
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
Iow24, Iow40

public abstract class AbstractIowDevcie
extends java.lang.Object
implements java.lang.Runnable

This class represents the iow 40 device.

Author:
Thomas Wagner

Nested Class Summary
 class AbstractIowDevcie.SpecialModeReadThread
          Read thread for special mode functions.
 
Field Summary
protected  boolean autonomous
           
protected  sun.misc.Queue currentPinStatus
          Queue for receiving the current pin status report
protected  long handle
          Device handle of this iow device.
protected  int id
          Device identifier of this iow device.
static long IOW24ID
          A constant for iow 24 device id.
static java.lang.String IOW24NAME
          A constant for iow 24 device name.
static long IOW40ID
          A constant for iow 40 device id.
static java.lang.String IOW40NAME
          A constant for iow 40 device name.
protected  Monitor monitor
          Queue for receiving the current pin status report
protected  int portCount
           
protected  IowPort[] ports
          The ports.
protected  int rev
          Revision identifier of this iow device.
protected  java.lang.String serial
          Serial number of this iow device.
protected  java.util.Vector smfImplementations
          Vector of special mode implementations.
protected  int specialMode
          Flag for all special mode functions.
 
Constructor Summary
AbstractIowDevcie()
          Contructor.
 
Method Summary
 void addSpecialModeFunctionImpl(SpecialModeFunction impl)
           
 void autonomous(boolean status)
          Sets the autonomous mode either on or off.
protected  void checkPort(int port)
           
 void clearBit(int port, int bit)
          Clear the given bit froma the given port.
 void close()
          Close this iow device (Used by subclasses Iow40 and Iow24 only.)
abstract  boolean equals(java.lang.Object o)
          Indicates whether some other Iow40 object is "equal to" this one.
protected  int[] getCurrentPinStatus()
          Gets the current pin status.
 long getHandle()
          Implementation for IowInterface method getHandle.
 int getId()
          Implementation for IowInterface method getId.
 Monitor getMonitor()
           
abstract  java.lang.String getName()
           
 IowPort getPort(int port)
           
 int getRev()
          Implementation for IowInterface method getRev.
 java.lang.String getSerial()
          Implementation for IowInterface method getSerial.
 SpecialModeFunction getSpecialModeFunctionImpl(java.lang.String smfName)
          Returns the desired special mode function implementation.
 int hashCode()
          Returns a hash code value for this Iow40 object.
abstract  long readIOPorts()
           
abstract  long readIOPortsImmediate()
           
 int[] readReport(int pipe)
          Implementation for IowInterface method readReport.
 void removeSpecialModeFunctionImpl(SpecialModeFunction impl)
           
 void run()
           
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 Iow40 object.
abstract  void writeIOPorts()
           
 long writeReport(int pipe, int[] wbuf)
          Implementation for IowInterface method writeReport.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IOW40ID

public static final long IOW40ID
A constant for iow 40 device id. (decimal 5376)

See Also:
Constant Field Values

IOW24ID

public static final long IOW24ID
A constant for iow 24 device id. (decimal 5377)

See Also:
Constant Field Values

IOW40NAME

public static final java.lang.String IOW40NAME
A constant for iow 40 device name.

See Also:
Constant Field Values

IOW24NAME

public static final java.lang.String IOW24NAME
A constant for iow 24 device name.

See Also:
Constant Field Values

handle

protected long handle
Device handle of this iow device.


id

protected int id
Device identifier of this iow device.


rev

protected int rev
Revision identifier of this iow device.


serial

protected java.lang.String serial
Serial number of this iow device.


ports

protected IowPort[] ports
The ports.


currentPinStatus

protected sun.misc.Queue currentPinStatus
Queue for receiving the current pin status report

Since:
0.9.3

monitor

protected Monitor monitor
Queue for receiving the current pin status report

Since:
0.9.4

specialMode

protected int specialMode
Flag for all special mode functions. Each bit stands for one enabled or disbaled special mode function. See SpecialModeFunction constants.

See Also:
de.wagner_ibw.iow.SpecialModeFuntion

smfImplementations

protected java.util.Vector smfImplementations
Vector of special mode implementations.


autonomous

protected boolean autonomous

portCount

protected int portCount
Constructor Detail

AbstractIowDevcie

public AbstractIowDevcie()
Contructor.

Method Detail

addSpecialModeFunctionImpl

public void addSpecialModeFunctionImpl(SpecialModeFunction impl)
                                throws java.lang.UnsupportedOperationException,
                                       java.lang.IllegalArgumentException
Parameters:
impl -
java.lang.UnsupportedOperationException
java.lang.IllegalArgumentException

removeSpecialModeFunctionImpl

public void removeSpecialModeFunctionImpl(SpecialModeFunction impl)
Parameters:
impl -

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 already added.
Since:
0.9.4

getHandle

public long getHandle()
Implementation for IowInterface method getHandle.

Returns:
Returns the handle of this iow device.

getSerial

public java.lang.String getSerial()
Implementation for IowInterface method getSerial.

Returns:
The serial number of this iow device.

getId

public int getId()
Implementation for IowInterface method getId.

Returns:
Returns the device id of this device.

getRev

public int getRev()
Implementation for IowInterface method getRev.

Returns:
Returns the revision id of this device.
Since:
0.9.3

close

public void close()
Close this iow device (Used by subclasses Iow40 and Iow24 only.)


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

readReport

public int[] readReport(int pipe)
Implementation for IowInterface method readReport.

Parameters:
pipe -
Returns:
Array of int.

writeReport

public long writeReport(int pipe,
                        int[] wbuf)
Implementation for IowInterface method writeReport.

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

readIOPorts

public abstract long readIOPorts()
Since:
0.9.3 with long return value

readIOPortsImmediate

public abstract long readIOPortsImmediate()
Since:
0.9.3 with long return value

scanPorts

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

Returns:
Count of written bytes to iow device.
java.lang.UnsupportedOperationException
Since:
0.9.3

getCurrentPinStatus

protected int[] getCurrentPinStatus()
                             throws java.lang.UnsupportedOperationException
Gets the current pin status.

Returns:
Array of int.
java.lang.UnsupportedOperationException
Since:
0.9.3

writeIOPorts

public abstract void writeIOPorts()

run

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

autonomous

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

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

getName

public abstract java.lang.String getName()

getPort

public IowPort getPort(int port)
                throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException

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...3).
bit - Bit number (0...7).
java.lang.IllegalArgumentException

clearBit

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

Parameters:
port - Port number (0...3).
bit - Bit number (0...7).
java.lang.IllegalArgumentException

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).
java.lang.IllegalArgumentException

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
java.lang.IllegalArgumentException
Since:
0.9.3

getMonitor

public Monitor getMonitor()

checkPort

protected void checkPort(int port)
                  throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException

hashCode

public int hashCode()
Returns a hash code value for this Iow40 object. It is derived from the 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 Iow40 object. It contains information about device handle, id , revision, serial number and the status of port 0 ... port 3.

Overrides:
toString in class java.lang.Object

equals

public abstract boolean equals(java.lang.Object o)
Indicates whether some other Iow40 object is "equal to" this one. 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