de.wagner_ibw.iow.i2c
Class AbstractI2CDevice

java.lang.Object
  |
  +--de.wagner_ibw.iow.i2c.AbstractI2CDevice
All Implemented Interfaces:
I2CDevice
Direct Known Subclasses:
LM75, PCF8570

public abstract class AbstractI2CDevice
extends java.lang.Object
implements I2CDevice

This is the abtract implementation of the I2CDevice.java interface

Since:
0.9.4
Author:
Thomas Wagner

Field Summary
private static boolean CLASS_DEBUG
           
protected  I2CAddress devAdr
          Slave address of this i2c device.
private  int GENERATE_START
           
private  int GENERATE_STOP
           
protected  AbstractIowDevcie iow
          Reference to the underlying IOW device.
 int MAX_I2C_LENGTH
           
protected  Monitor monitor
          Reference to the i2ctransaction monitor.
private  java.lang.String name
          Device name.
protected  sun.misc.Queue readQueue
           
protected  sun.misc.Queue writeAckQueue
           
 
Constructor Summary
AbstractI2CDevice(java.lang.String name, int deviceClass, int deviceAddress)
          Constructor
 
Method Summary
private  void debug(java.lang.String msg)
           
 boolean equals(java.lang.Object o)
          Indicates whether some other LM75 object is "equal to" this one.
 I2CAddress getI2cAddress()
          Returns the i2c device slave address.
 java.lang.String getName()
          Returns the name of the i2c device.
 int hashCode()
          Returns a hash code value for this LM75 object.
 int[] readI2C(int[] in, int expected)
          Read operation from an i2c devices.
 void reportReceived(int[] readBuffer)
          Callback method is called when a matching report was received.
abstract  void setIowDevice(AbstractIowDevcie iow)
          Sets the reference to an iow device for write report operations.
 void setMonitor(Monitor monitor)
           
 java.lang.String toString()
          Returns Information about this i2c device as String.
 void writeI2C(int[] in)
          Write operation to an i2c device.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

GENERATE_START

private final int GENERATE_START
See Also:
Constant Field Values

GENERATE_STOP

private final int GENERATE_STOP
See Also:
Constant Field Values

MAX_I2C_LENGTH

public final int MAX_I2C_LENGTH
See Also:
Constant Field Values

iow

protected AbstractIowDevcie iow
Reference to the underlying IOW device.


monitor

protected Monitor monitor
Reference to the i2ctransaction monitor.


devAdr

protected I2CAddress devAdr
Slave address of this i2c device.


name

private java.lang.String name
Device name.


writeAckQueue

protected sun.misc.Queue writeAckQueue

readQueue

protected sun.misc.Queue readQueue

CLASS_DEBUG

private static final boolean CLASS_DEBUG
See Also:
Constant Field Values
Constructor Detail

AbstractI2CDevice

public AbstractI2CDevice(java.lang.String name,
                         int deviceClass,
                         int deviceAddress)
                  throws java.lang.Exception
Constructor

Parameters:
deviceClass - Group 1 part of slave address.
deviceAddress - Group 2 part of slave address (possible values 0...7).
Throws:
java.lang.Exception - If anything goes wrong.
Method Detail

writeI2C

public void writeI2C(int[] in)
              throws java.lang.Exception
Write operation to an i2c device.

Parameters:
in -
Throws:
java.lang.Exception

readI2C

public int[] readI2C(int[] in,
                     int expected)
              throws java.lang.Exception
Read operation from an i2c devices.

Parameters:
in - (max 6 bytes long!)
expected -
Returns:
Readed values from i2c device as array.
Throws:
java.lang.Exception

toString

public java.lang.String toString()
Returns Information about this i2c device as String.

Overrides:
toString in class java.lang.Object
Returns:
String representation of this i2c device.

equals

public boolean equals(java.lang.Object o)
Indicates whether some other LM75 object is "equal to" this one. Criterias are the i2c device class and i2c device address (in I2CAddress).

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

hashCode

public int hashCode()
Returns a hash code value for this LM75 object. It is derived from the i2c device class and i2c device address.

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

getI2cAddress

public I2CAddress getI2cAddress()
Description copied from interface: I2CDevice
Returns the i2c device slave address.

Specified by:
getI2cAddress in interface I2CDevice
Returns:
Slave address.

getName

public java.lang.String getName()
Description copied from interface: I2CDevice
Returns the name of the i2c device.

Specified by:
getName in interface I2CDevice
Returns:
Name of the i2c device.

reportReceived

public void reportReceived(int[] readBuffer)
Description copied from interface: I2CDevice
Callback method is called when a matching report was received.

Specified by:
reportReceived in interface I2CDevice
Parameters:
readBuffer - Read buffer from a received report.

setIowDevice

public abstract void setIowDevice(AbstractIowDevcie iow)
Description copied from interface: I2CDevice
Sets the reference to an iow device for write report operations.

Specified by:
setIowDevice in interface I2CDevice
Parameters:
iow - Instance of an iow device.

setMonitor

public void setMonitor(Monitor monitor)

debug

private void debug(java.lang.String msg)