de.wagner_ibw.iow.smx
Class SwitchMatrix

java.lang.Object
  |
  +--de.wagner_ibw.iow.smx.SwitchMatrix
All Implemented Interfaces:
SpecialModeFunction

public class SwitchMatrix
extends java.lang.Object
implements SpecialModeFunction

This is the implementation of the IO Warrior 40 key matrix special mode function.

(unfinished!)

Since:
0.9.4
Author:
Thomas Wagner

Nested Class Summary
(package private)  class SwitchMatrix.NotifierThread
           
 
Field Summary
private  sun.misc.Queue currentMatrixStatus
           
private  boolean doScan
           
private  AbstractIowDevcie iow
          Reference to the underlying IOW device.
private  java.util.Hashtable keyMap
           
private  java.util.Vector listeners
           
private  int[] matrix
          Current state of the switch matrix.
(package private) static java.lang.String name
          Name of this special mode function.
private  int[] oldMatrix
           
 
Fields inherited from interface de.wagner_ibw.iow.SpecialModeFunction
SMF_CPS_ID, SMF_I2C_ID, SMF_LCD_ID, SMF_LED_ID, SMF_RC5_ID, SMF_SMX_ID, SMF_SPI_ID
 
Constructor Summary
SwitchMatrix()
          Constructor
 
Method Summary
 void addSwitchMatrixChangeListener(SwitchMatrixChangeListener smcl)
           
 java.lang.String checkCompatibility(int id, int rev, int specialModes)
          Checks if it is possible to activate this special mode function.
 int[] getDisableReport()
          Returns the report that disables the special mode function.
 int[] getEnableReport()
          Returns the report that enables the special mode function.
 int[] getIowSpecialBits(int deviceIdentifier)
          Returns an array of bitmask(s) for port 0...1 or 0...3 if this special mode function runs on this iow device.
 long[] getLongValue()
           
 java.lang.String getName()
          Returns the name of the special mode function.
 int[] getReportIds()
          Returns the report id(s) which the implementation is interested in.
 int getSpecialModeFuncionId()
          Returns the special mode function for this implementation.
 boolean matchReportId(int reportId)
          Checks if this implementation is interested in this report.
 void removeSwitchMatrixChangeListener(SwitchMatrixChangeListener smcl)
           
 void reportReceived(int[] readBuffer)
          Callback method is called when a matching report was received.
 int[] scanMatrix()
           
 void setIowDevice(AbstractIowDevcie iow)
          Sets the reference to an iow device for write report operations.
private  void setMatrix(int[] readBuffer)
           
 java.lang.String toString()
          Returns Information about the switch matrix as String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

static final java.lang.String name
Name of this special mode function.

See Also:
Constant Field Values

listeners

private java.util.Vector listeners

iow

private AbstractIowDevcie iow
Reference to the underlying IOW device.


matrix

private int[] matrix
Current state of the switch matrix.


oldMatrix

private int[] oldMatrix

currentMatrixStatus

private sun.misc.Queue currentMatrixStatus

doScan

private boolean doScan

keyMap

private java.util.Hashtable keyMap
Constructor Detail

SwitchMatrix

public SwitchMatrix()
Constructor

Method Detail

addSwitchMatrixChangeListener

public void addSwitchMatrixChangeListener(SwitchMatrixChangeListener smcl)

removeSwitchMatrixChangeListener

public void removeSwitchMatrixChangeListener(SwitchMatrixChangeListener smcl)

toString

public java.lang.String toString()
Returns Information about the switch matrix as String.

Overrides:
toString in class java.lang.Object
Returns:
String representation of information about the switch matrix (row7,row6, ... row0).

getDisableReport

public int[] getDisableReport()
Description copied from interface: SpecialModeFunction
Returns the report that disables the special mode function.

Specified by:
getDisableReport in interface SpecialModeFunction
Returns:
Special mode function disable report.

getEnableReport

public int[] getEnableReport()
Description copied from interface: SpecialModeFunction
Returns the report that enables the special mode function.

Specified by:
getEnableReport in interface SpecialModeFunction
Returns:
Special mode function enable report.

getIowSpecialBits

public int[] getIowSpecialBits(int deviceIdentifier)
Description copied from interface: SpecialModeFunction
Returns an array of bitmask(s) for port 0...1 or 0...3 if this special mode function runs on this iow device. Returns a array of lenght zero if no bits used by this special mode function. 1 means this bit is dedicated by special mode function. 0 means this bit is free for normal pin io operations.

Specified by:
getIowSpecialBits in interface SpecialModeFunction
Parameters:
deviceIdentifier - Iow device identifier (AbstractIowDevcie.IOW24ID or AbstractIowDevcie.IOW40ID).
Returns:
Array of int that contains bitmask(s) for special mode function bits.

getReportIds

public int[] getReportIds()
Description copied from interface: SpecialModeFunction
Returns the report id(s) which the implementation is interested in.

Specified by:
getReportIds in interface SpecialModeFunction
Returns:
Int array of special mode function id(s).

getSpecialModeFuncionId

public int getSpecialModeFuncionId()
Description copied from interface: SpecialModeFunction
Returns the special mode function for this implementation.

Specified by:
getSpecialModeFuncionId in interface SpecialModeFunction
Returns:
Special mode function id (SMF_LCD_ID,SMF_RC5_ID,SMF_I2C_ID,SMF_CPS_ID,SMF_SPI_ID).

matchReportId

public boolean matchReportId(int reportId)
Description copied from interface: SpecialModeFunction
Checks if this implementation is interested in this report.

Specified by:
matchReportId in interface SpecialModeFunction
Parameters:
reportId - Report id of the received report.
Returns:
True if it fits or false if not.

reportReceived

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

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

setIowDevice

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

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

checkCompatibility

public java.lang.String checkCompatibility(int id,
                                           int rev,
                                           int specialModes)
Description copied from interface: SpecialModeFunction
Checks if it is possible to activate this special mode function. This depends on id and/or rev of the iow device and/or already activated special mode functions.

Specified by:
checkCompatibility in interface SpecialModeFunction
Parameters:
id - Id of the current iow device.
rev - Rev of the current iow device.
specialModes - Special modes from the current iow device.
Returns:
Error string if special mode function is not available. Returns null if special mode function is available.

getName

public java.lang.String getName()
Description copied from interface: SpecialModeFunction
Returns the name of the special mode function.

Specified by:
getName in interface SpecialModeFunction
Returns:
Name of the special mode function.

scanMatrix

public int[] scanMatrix()

getLongValue

public long[] getLongValue()

setMatrix

private void setMatrix(int[] readBuffer)