hades.models.io
Class HexSwitch

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.io.HexSwitch
All Implemented Interfaces:
Assignable, java.lang.Cloneable, ContextToolTip, java.io.Serializable, Simulatable, Wakeable

public class HexSwitch
extends SimObject
implements Wakeable, Assignable

HexSwitch: a 16-valued (4 bit) hex input switch. Signals are expected to be of type SignalStdLogic1164.

If the HexSwitch is visible, the currently selected value is indicated by a small Rectangle under the corresponding number. The value may be changed by clicking on a field, or by calling the setIndex() method.

See Also:
Serialized Form

Field Summary
protected  java.lang.String bindkey
           
static int FIELD_SIZE
           
protected  int index
           
static java.awt.Point offset
           
protected  Rectangle rect
           
protected  int startIndex
           
protected  StdLogic1164 value_0
           
protected  StdLogic1164 value_1
           
protected  StdLogic1164 value_U
           
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
HexSwitch()
          HexSwitch(): create a HexSwitch simulation component
 
Method Summary
 void assign(java.lang.String hex, double simTime)
          assign: called by scripts or the StimuliGenerator to assign a new value for this HexSwitch at the given simulation time.
 void configure()
          configure: display a dialog to specify the instance name, and bindkey
 void elaborate(java.lang.Object arg)
          elaborate: initialize the switch symbol to the value 0.
 void evaluate(java.lang.Object arg)
          evaluate: called by setIndex() as a reaction to interactive user events.
 java.lang.String getBindkey()
          return the bindkey as a String.
 int getIndex()
           
 int getStartIndex()
           
 java.lang.String getToolTip(java.awt.Point position, long millis)
          construct a (short) tool tip message for a SimObject.
 void initGraphics()
           
 boolean initialize(java.lang.String s)
          initialize versionID, startIndex (default 0), and bindkey (default null).
 void keyPressed(java.awt.event.KeyEvent evt)
          react to a KeyEvent.
 void mousePressed(java.awt.event.MouseEvent evt)
          react to a MouseEvent.
 void scheduleOutputs(int index, double time)
           
 void setBindkey(java.lang.String s)
           
 void setIndex(int index)
           
 void setStartIndex(int i)
           
 void setStartIndex(java.lang.String s)
           
 void setSymbol(Symbol s)
           
 java.lang.String toString()
          generate a String with class name, instance name, and value.
 void updateDisplay()
          update the HexSwitch graphical symbol.
 void wakeup(java.lang.Object arg)
          wakeup: extract the Integer argument from the WakeupEvent, and use the resulting integer value as the index value for updating the graphical symbol of this HexSwitch (if visible).
 void write(java.io.PrintWriter ps)
          write the versionID, startIndex, and bindkey.
 
Methods inherited from class hades.simulator.SimObject
constructDynamicSymbol, copy, getClassLoader, getDebug, getEditor, getExternalResources, getFullName, getName, getParent, getPort, getPorts, getPropertySheet, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, message, needsDynamicSymbol, needsExternalResources, setClassLoader, setConsole, setDebug, setEditor, setName, setParent, setPorts, setSimulator, setVersionId, setVisible, tearDown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface hades.simulator.Simulatable
message
 

Field Detail

index

protected int index

startIndex

protected int startIndex

value_0

protected StdLogic1164 value_0

value_1

protected StdLogic1164 value_1

value_U

protected StdLogic1164 value_U

rect

protected Rectangle rect

bindkey

protected java.lang.String bindkey

FIELD_SIZE

public static final int FIELD_SIZE
See Also:
Constant Field Values

offset

public static final java.awt.Point offset
Constructor Detail

HexSwitch

public HexSwitch()
HexSwitch(): create a HexSwitch simulation component

Method Detail

setSymbol

public void setSymbol(Symbol s)
Overrides:
setSymbol in class SimObject

initGraphics

public void initGraphics()

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Description copied from class: SimObject
react to a MouseEvent. The base SimObject ignores MouseEvents.

Note that the HADES schematic editor will also deliver jfig.canvas.FigCanvasEvent object, which also include the world-coordinates of the Event.

Overrides:
mousePressed in class SimObject

keyPressed

public void keyPressed(java.awt.event.KeyEvent evt)
Description copied from class: SimObject
react to a KeyEvent. The base SimObject ignores all KeyEvents. this method is currently only used by a few classes in hades.models.io, e.g. IpinWithBindkey.

At the moment this is actually called from KeyHandler.keyTyped(), but this naming mismatch is not considered critical...

Overrides:
keyPressed in class SimObject

updateDisplay

public void updateDisplay()
update the HexSwitch graphical symbol. This basically sets the small indicator rectangle to the position corresponding to the current "index" value (0 .. 15).


configure

public void configure()
configure: display a dialog to specify the instance name, and bindkey

Overrides:
configure in class SimObject

getIndex

public int getIndex()

setIndex

public void setIndex(int index)

getStartIndex

public int getStartIndex()

setStartIndex

public void setStartIndex(int i)

setStartIndex

public void setStartIndex(java.lang.String s)

getBindkey

public java.lang.String getBindkey()
Description copied from class: SimObject
return the bindkey as a String.

Returns the lowercase bindkey character as a String; this key is used by KeyHandler to check whether this SimObject should be activated (via keyPressed()) in view-mode. We return null here. Should be overridden by SimObject's that want to be notified by and react to global key-events on the main editor canvas.

If you plan to enable a bindkey for your SimObject, please: override getBindkey(), implement setBindkey() - e.g. via NameMangler.getBindkey(), change write() to write the bindkey string, change initialize() to parse the bindkey string, modify getToolTip() to print the bindkey, and change configure() to allow setting the bindkey.

Overrides:
getBindkey in class SimObject

setBindkey

public void setBindkey(java.lang.String s)

elaborate

public void elaborate(java.lang.Object arg)
elaborate: initialize the switch symbol to the value 0.

Specified by:
elaborate in interface Simulatable
Overrides:
elaborate in class SimObject

evaluate

public void evaluate(java.lang.Object arg)
evaluate: called by setIndex() as a reaction to interactive user events. Generate the selected output value.

Specified by:
evaluate in interface Simulatable
Overrides:
evaluate in class SimObject
Parameters:
arg - an arbitrary object argument

scheduleOutputs

public void scheduleOutputs(int index,
                            double time)

wakeup

public void wakeup(java.lang.Object arg)
wakeup: extract the Integer argument from the WakeupEvent, and use the resulting integer value as the index value for updating the graphical symbol of this HexSwitch (if visible). This method is currently only called in reaction to WakeupEvents generated by a previous call to assign().

Specified by:
wakeup in interface Wakeable

assign

public void assign(java.lang.String hex,
                   double simTime)
assign: called by scripts or the StimuliGenerator to assign a new value for this HexSwitch at the given simulation time. The value string is expected to contain a single hex digit char, namely "0" .. "9" "a" .. "f" or "A" .. "F" for the values 0 .. 15. For example, hexswitch.assign( "C", 0.3 );

Note that this method also tries to update the graphical symbol of this HexSwitch (if visible), by scheduling a WakeupEvent.

Specified by:
assign in interface Assignable

write

public void write(java.io.PrintWriter ps)
write the versionID, startIndex, and bindkey.

Overrides:
write in class SimObject

initialize

public boolean initialize(java.lang.String s)
initialize versionID, startIndex (default 0), and bindkey (default null).

Overrides:
initialize in class SimObject

getToolTip

public java.lang.String getToolTip(java.awt.Point position,
                                   long millis)
Description copied from class: SimObject
construct a (short) tool tip message for a SimObject. This method should be overridden as needed.

Specified by:
getToolTip in interface ContextToolTip
Overrides:
getToolTip in class SimObject

toString

public java.lang.String toString()
generate a String with class name, instance name, and value.

Overrides:
toString in class SimObject