de.wagner_ibw.iow.i2c
Class AbstractI2CDevice

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

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

This is the abtract implementation of the I2CDevice interface.

Since:
0.9.4
Author:
Thomas Wagner

Field Summary
 int MAX_I2C_LENGTH
           
 
Constructor Summary
AbstractI2CDevice(java.lang.String name, int deviceClass, int deviceAddress)
          Constructor
 
Method Summary
 boolean equals(java.lang.Object o)
          Indicates whether some other i2c device 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 i2c device 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(AbstractIowDevice iow)
          Sets the reference to an IO-Warrior device for write report operations.
 void setMonitor(Monitor monitor)
          Sets the reference to an i2c transaction 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
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_I2C_LENGTH

public final int MAX_I2C_LENGTH
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 - Array of int, data to write.
Throws:
java.lang.Exception - If any error occured.

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

setMonitor

public void setMonitor(Monitor monitor)
Sets the reference to an i2c transaction monitor.

Parameters:
monitor - Instance of an i2c transaction monitor.

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 i2c device 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 i2c device 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(AbstractIowDevice iow)
Description copied from interface: I2CDevice
Sets the reference to an IO-Warrior device for write report operations.

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