jAER project on SourceForge

net.sf.jaer.biasgen
Class Pot

java.lang.Object
  extended by java.util.Observable
      extended by net.sf.jaer.biasgen.Pot
All Implemented Interfaces:
java.util.EventListener, java.util.prefs.PreferenceChangeListener
Direct Known Subclasses:
IPot, VPot

public abstract class Pot
extends java.util.Observable
implements java.util.prefs.PreferenceChangeListener

Describes an general bias (pot=potentiometer), This Pot can either be on or off chip. On chip pots are current DACs from Tobi's bias generator design kit, programmed over an SPI interface. Off-chip pots are voltage DACs programmed over SPI.

This class extends Observer so observers can add themselves to be notified when the pot value changes.

Author:
tobi

Nested Class Summary
static class Pot.Sex
          the transistor type for bias, N or P or not available (na)
static class Pot.Type
          an enum for the type of bias, NORMAL or CASCODE or REFERENCE
 
Field Summary
protected  int bitValue
          the current value of the ipot in bits loaded into the shift register
 float CHANGE_FRACTION
          fraction that pot current changes for increment or decrement
protected  Chip chip
          The Chip for this Pot
protected  int chipNumber
          the chip that this ipot sits on in the chain of chips; zero based
protected  int displayPosition
          the display position within a group
protected  java.lang.String group
          the 'group' of this IPot, used for grouping related pots
protected static java.util.logging.Logger log
           
 Masterbias masterbias
          the Masterbias supplying reference current to this IPot
protected  java.lang.String name
          the name of the ipot bias
protected  int numBits
          the number of bits of resolution for this bias.
protected  int numBytes
          the number for bytes of 8 bits for this ipot
protected  int pinNumber
           
protected  java.util.prefs.Preferences prefs
          Preferences fot this Pot.
protected  Pot.Sex sex
          n or p type
protected  java.lang.String tooltipString
          A tooltip to show users
protected  Pot.Type type
          type of bias, e.g.
 
Constructor Summary
Pot(Chip chip)
          Constructs a new instance of Pot which adds itself as a preference change listener.
 
Method Summary
 void addObserver(java.util.Observer o)
           
 void decrementBitValue()
          decrement pot value by one count
abstract  byte[] getBinaryRepresentation()
          Computes and returns a new array of bytes representing the bias to be sent over hardware interface to the device.
 int getBitValue()
          Returns the value of the bias current or voltage in binary form, i.e.
 int getChipNumber()
           
 int getDisplayPosition()
           
 java.lang.String getGroup()
           
 int getMaxBitValue()
          return the max value representing all stages of current splitter enabled
 int getMinBitValue()
          no current: zero
 java.lang.String getName()
           
 int getNumBits()
          returns the number of shift register/current splitter/DAC bits for the bias value.
 int getNumBytes()
          bytes for this bias.
abstract  float getPhysicalValue()
          returns physical value of bias, e.g.
abstract  java.lang.String getPhysicalValueUnits()
          return units (e.g.
 int getPinNumber()
           
 int getPreferedBitValue()
          returns the preference value bit value using prefsKey as the key
 Pot.Sex getSex()
           
 java.lang.String getTooltipString()
           
 Pot.Type getType()
           
 void incrementBitValue()
          increment pot value by one count
 void loadPreferences()
          loads and makes active the preference value.
abstract  javax.swing.JComponent makeGUIPotControl()
          Contructs the UI control for this Pot.
 void preferenceChange(java.util.prefs.PreferenceChangeEvent e)
          called when there is a preference change for this Preferences node (the Biasgen package node).
protected  java.lang.String prefsKey()
          Returns the String key by which this pot is known in the Preferences: Pot..
 void resume()
          restore suspend value (0 if not suspended before
 void setBitValue(int value)
          set the bit value.
 void setDisplayPosition(int displayPosition)
           
 void setGroup(java.lang.String group)
           
 void setName(java.lang.String name)
          sets the pot name.
 void setNumBits(int n)
          Sets the number of bits representing this bias.
 void setNumBytes(int numBytes)
          sets the number of bytes that represent this bias
abstract  void setPhysicalValue(float value)
          sets physical value of bias
 void setPinNumber(int pinNumber)
           
 void setSex(Pot.Sex sex)
           
 void setTooltipString(java.lang.String tooltipString)
           
 void setType(Pot.Type type)
           
 void storePreferences()
          stores as a preference the bit value
 void suspend()
          set suspend value (zero current), saving old value for resume
 java.lang.String toBitPatternString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.util.Observable
clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static java.util.logging.Logger log

chip

protected Chip chip
The Chip for this Pot


prefs

protected java.util.prefs.Preferences prefs
Preferences fot this Pot. prefs is assigned in the constructor to the Preferences node for the Chip for this Pot.


type

protected Pot.Type type
type of bias, e.g. normal single FET, or cascode


sex

protected Pot.Sex sex
n or p type


pinNumber

protected int pinNumber

tooltipString

protected java.lang.String tooltipString
A tooltip to show users


name

protected java.lang.String name
the name of the ipot bias


bitValue

protected int bitValue
the current value of the ipot in bits loaded into the shift register


chipNumber

protected int chipNumber
the chip that this ipot sits on in the chain of chips; zero based


group

protected java.lang.String group
the 'group' of this IPot, used for grouping related pots


displayPosition

protected int displayPosition
the display position within a group


masterbias

public transient Masterbias masterbias
the Masterbias supplying reference current to this IPot


numBytes

protected int numBytes
the number for bytes of 8 bits for this ipot


numBits

protected int numBits
the number of bits of resolution for this bias. This number is used to compute the max bit value and also for computing the number of bits or bytes to send to a device


CHANGE_FRACTION

public final float CHANGE_FRACTION
fraction that pot current changes for increment or decrement

See Also:
Constant Field Values
Constructor Detail

Pot

public Pot(Chip chip)
Constructs a new instance of Pot which adds itself as a preference change listener. This Pot adds itself as a PreferenceChangeListener to the Preference object for this preference node (the Biasgen package node), so that preference changes call the method preferenceChange.

Parameters:
chip - the chip for this Pot
Method Detail

preferenceChange

public void preferenceChange(java.util.prefs.PreferenceChangeEvent e)
called when there is a preference change for this Preferences node (the Biasgen package node). If the key of the PreferenceChangeEvent matches our own preference key, then the bit value is set

Specified by:
preferenceChange in interface java.util.prefs.PreferenceChangeListener
Parameters:
e - the PreferenceChangeEvent, issued when new Preferences are loaded

getNumBits

public int getNumBits()
returns the number of shift register/current splitter/DAC bits for the bias value. The total number of bits may be larger if the bias has other configuration bits, e.g. for buffer bias, type of bias, etc.

Returns:
the number of bits
See Also:
ConfigurableIPot

setNumBits

public void setNumBits(int n)
Sets the number of bits representing this bias.

Parameters:
n - the number of bits

getName

public java.lang.String getName()

setName

public void setName(java.lang.String name)
sets the pot name.

Parameters:
name - the string name that is used for the preferences key

getNumBytes

public int getNumBytes()
bytes for this bias. This is numBits/8.


setNumBytes

public void setNumBytes(int numBytes)
sets the number of bytes that represent this bias

Parameters:
numBytes - number of bytes

getBitValue

public int getBitValue()
Returns the value of the bias current or voltage in binary form, i.e. this value will scale the actual value by the reference value. For an on-chip bias current generator the minimum current is about 0, and the maximum is the master current. For an off-chip voltage DAC, the limits are set the by the DAC references.

Returns:
the binary value of the bias
See Also:
getBinaryRepresentation()

setBitValue

public void setBitValue(int value)
set the bit value. Observers are notified if value changes. Value is clipped to hard limits. Every change to bias value must flow through this method.

Parameters:
value - the new bitValue

getChipNumber

public int getChipNumber()

getMaxBitValue

public int getMaxBitValue()
return the max value representing all stages of current splitter enabled


getMinBitValue

public int getMinBitValue()
no current: zero


incrementBitValue

public void incrementBitValue()
increment pot value by one count


decrementBitValue

public void decrementBitValue()
decrement pot value by one count


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toBitPatternString

public java.lang.String toBitPatternString()
Returns:
string of bits for this ipot shift register

storePreferences

public void storePreferences()
stores as a preference the bit value


loadPreferences

public void loadPreferences()
loads and makes active the preference value. The name should be set before this is called.


getPreferedBitValue

public int getPreferedBitValue()
returns the preference value bit value using prefsKey as the key


prefsKey

protected java.lang.String prefsKey()
Returns the String key by which this pot is known in the Preferences: Pot.. Subclasses, e.g. IPot, sometimes override prefsKey to associate the preferences key with a specific chip.

Returns:
preferences key string

suspend

public void suspend()
set suspend value (zero current), saving old value for resume

See Also:
resume()

resume

public void resume()
restore suspend value (0 if not suspended before

See Also:
suspend()

getGroup

public java.lang.String getGroup()

setGroup

public void setGroup(java.lang.String group)

getPinNumber

public int getPinNumber()

setPinNumber

public void setPinNumber(int pinNumber)

getDisplayPosition

public int getDisplayPosition()

setDisplayPosition

public void setDisplayPosition(int displayPosition)

getTooltipString

public java.lang.String getTooltipString()

setTooltipString

public void setTooltipString(java.lang.String tooltipString)

makeGUIPotControl

public abstract javax.swing.JComponent makeGUIPotControl()
Contructs the UI control for this Pot.

Returns:
the UI component that user uses to control the Pot

getType

public Pot.Type getType()

setType

public void setType(Pot.Type type)

getSex

public Pot.Sex getSex()

setSex

public void setSex(Pot.Sex sex)

getPhysicalValue

public abstract float getPhysicalValue()
returns physical value of bias, e.g. in current amps or voltage volts

Returns:
physical value

setPhysicalValue

public abstract void setPhysicalValue(float value)
sets physical value of bias

Parameters:
value - the physical value, e.g. in amps or volts

getPhysicalValueUnits

public abstract java.lang.String getPhysicalValueUnits()
return units (e.g. A, mV) of physical value of bias


addObserver

public void addObserver(java.util.Observer o)
Overrides:
addObserver in class java.util.Observable

getBinaryRepresentation

public abstract byte[] getBinaryRepresentation()
Computes and returns a new array of bytes representing the bias to be sent over hardware interface to the device.

Returns:
array of bytes to be sent, by convention values are ordered in big endian format so that byte 0 is the most significant byte and is sent first to the hardware

jAER project on SourceForge