hades.models.special
Class Counter

java.lang.Object
  extended byhades.simulator.SimObject
      extended byhades.models.special.Counter
All Implemented Interfaces:
java.lang.Cloneable, ContextToolTip, java.io.Serializable, Simulatable

public class Counter
extends SimObject
implements Simulatable, java.io.Serializable

Counter - a generic counter for events on SignalStdLogic1164 signals. Possible event types include 'events', 'value 0' ... 'value D', 'rising edge', 'falling edge', '0 hazards', ...

The counter offers data and clear inputs. The counter may also be cleared interactively.

You can specify the color to use at the display via the via the "Hades.Counter.DisplayColor" property in aarrggbb format.

See Also:
Serialized Form

Nested Class Summary
 class Counter.DecimalValueFormatter
           
 class Counter.TypeFormatter
           
 
Field Summary
 int _0
           
 int _0hazards
           
 int _1
           
 int _1hazards
           
 int _D
           
 int _events
           
 int _falling
           
 int _H
           
 int _L
           
 int _rising
           
 int _U
           
 int _W
           
 int _X
           
 int _Z
           
(package private)  javax.swing.JPanel buttonPanel
           
(package private)  javax.swing.JButton changeNameButton
           
(package private)  javax.swing.JButton clearAllButton
           
(package private)  javax.swing.JButton clearSelectedButton
           
(package private)  javax.swing.JButton closeButton
           
protected  java.lang.String[] counterNames
           
(package private)  javax.swing.JPanel counterPanel
           
protected  long[] counters
           
(package private)  javax.swing.JComboBox eventChoice
           
protected  Label symbolTypeLabel
           
protected  ColoredValueLabel symbolValueLabel
           
(package private)  javax.swing.JFrame topFrame
           
(package private)  javax.swing.JLabel valueField
           
 
Fields inherited from class hades.simulator.SimObject
classloader, console, debug, editor, name, parent, ports, propertySheet, simulator, symbol, versionId, visible
 
Constructor Summary
Counter()
          Counter(): simple constructor
 
Method Summary
 void buildGUI()
           
 void buildGUICallbacks()
           
 void changeName()
           
 void clearAllCounters()
           
 void clearSelectedCounter()
           
 void configure()
          create and display a 'ConfigDialog' to set the parameters for a SimObject.
 SimObject copy()
          copy(): create a clone of the current Counter, including its color
 void elaborate(java.lang.Object arg)
          elaborate(): This method is called by the simulation engine to initialize the simulation object.
 void evaluate(java.lang.Object arg)
          evaluate(): called by the simulation engine on all events that concern this object.
static java.lang.String formatPaddedLong(long value, int n_chars)
           
 long getCounterValue(int index)
           
 int getMaxCounterIndex()
           
 java.awt.Component getPropertySheet()
          return a reference to the 'property sheet' or configuration window for this SimObject.
 java.lang.String getToolTip(java.awt.Point position, long millis)
          construct a (short) tool tip message for a SimObject.
 boolean initialize(java.lang.String s)
          read the versionID (currently ignored) and the index of the active counter (_event ...
static void main(java.lang.String[] argv)
          main(): simple selftest of the Counter's GUI
 void mousePressed(java.awt.event.MouseEvent evt)
          mousePressed: currently, the Counter defines two mouse click reactions.
 void setCounterValue(int index, long value)
           
 void setSymbol(Symbol s)
           
 void showSelectedCounter()
           
 java.lang.String toString()
          toString() - the usual info method
 void write(java.io.PrintWriter ps)
          write the versionID and the currently active counter
 
Methods inherited from class hades.simulator.SimObject
constructDynamicSymbol, getBindkey, getClassLoader, getDebug, getEditor, getExternalResources, getFullName, getName, getParent, getPort, getPorts, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, keyPressed, 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

_events

public final int _events
See Also:
Constant Field Values

_rising

public final int _rising
See Also:
Constant Field Values

_falling

public final int _falling
See Also:
Constant Field Values

_U

public final int _U
See Also:
Constant Field Values

_X

public final int _X
See Also:
Constant Field Values

_0

public final int _0
See Also:
Constant Field Values

_1

public final int _1
See Also:
Constant Field Values

_Z

public final int _Z
See Also:
Constant Field Values

_L

public final int _L
See Also:
Constant Field Values

_H

public final int _H
See Also:
Constant Field Values

_W

public final int _W
See Also:
Constant Field Values

_D

public final int _D
See Also:
Constant Field Values

_0hazards

public final int _0hazards
See Also:
Constant Field Values

_1hazards

public final int _1hazards
See Also:
Constant Field Values

counterNames

protected java.lang.String[] counterNames

counters

protected long[] counters

symbolTypeLabel

protected Label symbolTypeLabel

symbolValueLabel

protected ColoredValueLabel symbolValueLabel

topFrame

javax.swing.JFrame topFrame

counterPanel

javax.swing.JPanel counterPanel

buttonPanel

javax.swing.JPanel buttonPanel

valueField

javax.swing.JLabel valueField

eventChoice

javax.swing.JComboBox eventChoice

clearAllButton

javax.swing.JButton clearAllButton

clearSelectedButton

javax.swing.JButton clearSelectedButton

closeButton

javax.swing.JButton closeButton

changeNameButton

javax.swing.JButton changeNameButton
Constructor Detail

Counter

public Counter()
Counter(): simple constructor

Method Detail

setSymbol

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

buildGUI

public void buildGUI()

buildGUICallbacks

public void buildGUICallbacks()

clearAllCounters

public void clearAllCounters()

clearSelectedCounter

public void clearSelectedCounter()

showSelectedCounter

public void showSelectedCounter()

getCounterValue

public long getCounterValue(int index)

setCounterValue

public void setCounterValue(int index,
                            long value)

getMaxCounterIndex

public int getMaxCounterIndex()

changeName

public void changeName()

write

public void write(java.io.PrintWriter ps)
write the versionID and the currently active counter

Overrides:
write in class SimObject

initialize

public boolean initialize(java.lang.String s)
read the versionID (currently ignored) and the index of the active counter (_event ... _0 ... _D ...)

Overrides:
initialize in class SimObject

configure

public void configure()
Description copied from class: SimObject
create and display a 'ConfigDialog' to set the parameters for a SimObject. The default ConfigDialog for the base class (SimObject) itself is empty except for the 'instance name' of the SimObject.

Overrides:
configure in class SimObject

getPropertySheet

public java.awt.Component getPropertySheet()
Description copied from class: SimObject
return a reference to the 'property sheet' or configuration window for this SimObject. We cast the return value to an AWT Component, but typically you can expect either a hades.gui.PropertySheet or an java.awt.Window (Dialog or Frame).

Overrides:
getPropertySheet in class SimObject

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
mousePressed: currently, the Counter defines two mouse click reactions. If clicked in the lower left corner (1200 < y < 2400, 0 < 1500 < x), the counter is cleared. If clicked in the upper left corner, the counter mode is toggled.

Overrides:
mousePressed in class SimObject

elaborate

public void elaborate(java.lang.Object arg)
elaborate(): This method is called by the simulation engine to initialize the simulation object.

Specified by:
elaborate in interface Simulatable
Overrides:
elaborate in class SimObject
Parameters:
arg - This parameter is ignored by Counter

evaluate

public void evaluate(java.lang.Object arg)
evaluate(): called by the simulation engine on all events that concern this object. The object is responsible for updating its internal state and for scheduling all pending output events.

Specified by:
evaluate in interface Simulatable
Overrides:
evaluate in class SimObject
Parameters:
arg - An arbitrary and unused object

formatPaddedLong

public static java.lang.String formatPaddedLong(long value,
                                                int n_chars)

copy

public SimObject copy()
copy(): create a clone of the current Counter, including its color

Overrides:
copy 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()
toString() - the usual info method

Overrides:
toString in class SimObject

main

public static void main(java.lang.String[] argv)
main(): simple selftest of the Counter's GUI