hades.models.io
Class DiodeSwitch

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

public class DiodeSwitch
extends GenericGate
implements Wakeable, Assignable

DiodeSwitch - a simple subclass of GenericGate that models a switch in series with a diode. This type of switch is typically used for a switch matrix, e.g. a pocket calculator keypad.

Clicking on the switch will close the switch As usual, this switch is configured to be active low.

See Also:
Serialized Form

Field Summary
protected  double delay
           
protected  PortStdLogic1164 port_A
           
protected  PortStdLogic1164 port_Y
           
protected  ColoredCircle showOnOff
           
protected  StdLogic1164 startValue
           
protected  int state
           
 
Fields inherited from class hades.models.gates.GenericGate
t_delay
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
DiodeSwitch()
          DiodeSwitch(): simple constructor
 
Method Summary
 void assign(java.lang.String value, double simTime)
          assign: set a new state for this switch at the specified time, also update the graphical symbol (if visible) via a WakeupEvent.
 void configure()
          configure: display a dialog to specify instance name, initial output value, and switch propagation delay.
 void elaborate(java.lang.Object arg)
          elaborate: set the selected inital state, show that state on the symbol, and generate a corresponding SimEvent on the Y output port.
 void evaluate(java.lang.Object arg)
          evaluate: This is only called when this switch is used as a hierarchy connector.
 double getDelay()
           
 java.lang.String getStartValue()
           
protected  void initDisplay()
           
 boolean initialize(java.lang.String s)
          initialize an DiodeSwitch from a String, which contains the integer version id, and optionally the initial start value (StdLogic1164.getChar) if the DiodeSwitch should start in the '0' state instead of the 'U' state.
 void mousePressed(java.awt.event.MouseEvent me)
          react to a MouseEvent.
 void setDelay(java.lang.String s)
           
 void setStartState()
           
 void setStartValue(java.lang.String s)
           
 void setSymbol(Symbol s)
           
 void showState()
           
 void wakeup(java.lang.Object arg)
          wakeup: this method is currently used to handle "external" events on this DiodeSwitch via the assign call, which schedules a Wakeup event to update our symbol at the correct simulation time.
 void write(java.io.PrintWriter ps)
          write the versionID and the initial start value of this switch, e.g.
 
Methods inherited from class hades.models.gates.GenericGate
copy, getToolTip, scheduleEvent, scheduleEventAfter, scheduleOutputValue, scheduleOutputValueAfter, setDelay
 
Methods inherited from class hades.simulator.SimObject
constructDynamicSymbol, getBindkey, getClassLoader, getDebug, getEditor, getExternalResources, getFullName, getName, getParent, getPort, getPorts, getPropertySheet, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, keyPressed, message, needsDynamicSymbol, needsExternalResources, setClassLoader, setConsole, setDebug, setEditor, setName, setParent, setPorts, setSimulator, setVersionId, setVisible, tearDown, toString
 
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

port_A

protected PortStdLogic1164 port_A

port_Y

protected PortStdLogic1164 port_Y

startValue

protected StdLogic1164 startValue

delay

protected double delay

state

protected int state

showOnOff

protected ColoredCircle showOnOff
Constructor Detail

DiodeSwitch

public DiodeSwitch()
DiodeSwitch(): simple constructor

Method Detail

getDelay

public double getDelay()
Overrides:
getDelay in class GenericGate

setDelay

public void setDelay(java.lang.String s)
Overrides:
setDelay in class GenericGate

getStartValue

public java.lang.String getStartValue()

setStartValue

public void setStartValue(java.lang.String s)

initialize

public boolean initialize(java.lang.String s)
initialize an DiodeSwitch from a String, which contains the integer version id, and optionally the initial start value (StdLogic1164.getChar) if the DiodeSwitch should start in the '0' state instead of the 'U' state.

Overrides:
initialize in class GenericGate

write

public void write(java.io.PrintWriter ps)
write the versionID and the initial start value of this switch, e.g. "1001 U"

Overrides:
write in class GenericGate

setSymbol

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

initDisplay

protected void initDisplay()

setStartState

public void setStartState()

showState

public void showState()

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
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

elaborate

public void elaborate(java.lang.Object arg)
elaborate: set the selected inital state, show that state on the symbol, and generate a corresponding SimEvent on the Y output port.

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

evaluate

public void evaluate(java.lang.Object arg)
evaluate: This is only called when this switch is used as a hierarchy connector. Propagate the top-level input value to our output port after delay.

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

assign

public void assign(java.lang.String value,
                   double simTime)
assign: set a new state for this switch at the specified time, also update the graphical symbol (if visible) via a WakeupEvent. Valid input "value"s are "0" (switch open), "1" (switch closed) and "U" or "X" (switch undefined).

Specified by:
assign in interface Assignable

wakeup

public void wakeup(java.lang.Object arg)
wakeup: this method is currently used to handle "external" events on this DiodeSwitch via the assign call, which schedules a Wakeup event to update our symbol at the correct simulation time. To this end, the "arg" argument is expected to hold a WakeupEvent whose arg member is a StdLogic1164 object.

Specified by:
wakeup in interface Wakeable

configure

public void configure()
configure: display a dialog to specify instance name, initial output value, and switch propagation delay.

Overrides:
configure in class GenericGate