hades.styx
Class Waveform

java.lang.Object
  extended byhades.styx.Waveform
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
WaveInteger, WaveStdLogic1164, WaveStdLogicVector, WaveString

public class Waveform
extends java.lang.Object
implements java.io.Serializable

Waveform: the base class to represent waveform data in the Hades waveform viewer. This class should be extended for specific signal types like integer or StdLogic1164 type signals.

At the moment, a Waveform does *not* keep a reference to the Signal whose events it records. It just stores the Signal name, full name, and the event data in form of pairs. This design is intentional, as it allows us to write and read-back waveform data without having to re-create the full Hades design.

See Also:
Serialized Form

Field Summary
static boolean debug
           
protected  java.lang.Object[] events
           
protected  int fill
           
protected  java.lang.String fullName
           
(package private)  int in
           
protected  java.lang.String name
           
protected  int pos
           
(package private)  boolean search_direction
           
(package private)  double search_time0
           
(package private)  java.lang.Object searchfrom
           
(package private)  java.lang.Object searchto
           
protected  int SIZE
           
protected  double[] times
           
protected  Transformation trafo
           
(package private)  WaveCanvas WC
           
 
Constructor Summary
Waveform()
          create a new (empty) waveform object.
 
Method Summary
 void addValue(java.lang.Object evt, double t)
          adds new event to array, and reallocates to a new array of double size, if necessary.
 void clearData()
           
 double findEvent(double time, boolean forward)
          search and return the event time of the next/previous event after/before 'time'.
 void findSpecialEvent(java.lang.Object event1, java.lang.Object event2, double Time, boolean direction)
           
 java.lang.String getFullName()
          get the full (hierarchical) name of this waveform
 java.lang.String getLabel(int index)
           
 double getMaxTime()
          return the maximum events time in this waveform
 java.lang.String getName()
          get the (short) name of this waveform
 int getPos()
          get the position (i.e.
 Transformation getTrafo()
           
 java.lang.Object getValue(double time)
          find and return the value of the waveform at time 'time'.
 java.lang.String getValueAsString(double time)
           
 int gototime(double time)
          return an index into the times/events array, whose data corresponds to the value at simulation time 'time'.
static void msg(java.lang.String msg)
           
 void paint(java.awt.Graphics g)
          method template for the graphical representation of this waveform.
 void reallocate()
          try to reallocate new times[] and events[] array of double the current size.
 void searchevent(double Time, boolean direction)
           
 void searchMenu(double time, boolean direction)
          method template for a search menu on this waveform.
 void setFullName(java.lang.String s)
          set the full (hierarchical) name of this waveform
 void setName(java.lang.String n)
          set the (short, flat) name of this waveform
 void setPos(int p)
          set the position (index, counted from top) for this Waveform when displaying in WaveCanvas
 void setTrafo(Transformation _trafo)
           
 void setWaveCanvas(WaveCanvas w)
          set the WaveCanvas this Waveform is displayed in
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SIZE

protected int SIZE

times

protected double[] times

events

protected java.lang.Object[] events

fill

protected int fill

pos

protected int pos

trafo

protected Transformation trafo

name

protected java.lang.String name

fullName

protected java.lang.String fullName

WC

transient WaveCanvas WC

searchfrom

transient java.lang.Object searchfrom

searchto

transient java.lang.Object searchto

search_time0

transient double search_time0

search_direction

transient boolean search_direction

in

int in

debug

public static boolean debug
Constructor Detail

Waveform

public Waveform()
create a new (empty) waveform object. Note that you *must* call setTrafo( Tranformation ) before you can really use the waveform.

Method Detail

setTrafo

public void setTrafo(Transformation _trafo)

getTrafo

public Transformation getTrafo()

setName

public void setName(java.lang.String n)
set the (short, flat) name of this waveform


getName

public java.lang.String getName()
get the (short) name of this waveform


setFullName

public void setFullName(java.lang.String s)
set the full (hierarchical) name of this waveform


getFullName

public java.lang.String getFullName()
get the full (hierarchical) name of this waveform


setPos

public void setPos(int p)
set the position (index, counted from top) for this Waveform when displaying in WaveCanvas


getPos

public int getPos()
get the position (i.e. index) for displaying in WaveCanvas


setWaveCanvas

public void setWaveCanvas(WaveCanvas w)
set the WaveCanvas this Waveform is displayed in


clearData

public void clearData()

gototime

public int gototime(double time)
return an index into the times/events array, whose data corresponds to the value at simulation time 'time'. Return the current 'fill' value if 'time' is bigger than the largest event time in this array.


addValue

public void addValue(java.lang.Object evt,
                     double t)
adds new event to array, and reallocates to a new array of double size, if necessary.

At any moment, the 'fill' variable counts the number of events in this Waveform. Note that the times[] and events[] arrays are initialized with times[0] = 0.0 (seconds) and events[0] = "" (the empty String), as placeholders for an undefined value. Therefore, the first call to addValue() puts the arguments into times[1] and events[1], the second call into times[2] and events[2], etc.

Subsequent calls to addValue() should use increasing time values to keep the data representation consistent.


reallocate

public void reallocate()
try to reallocate new times[] and events[] array of double the current size. If that fails due to an OutOfMemoryError, we overwrite the older half of existing events, in order to make some room for new events. To avoid synchronisation overhead, this method is not synchronized.


getValue

public java.lang.Object getValue(double time)
find and return the value of the waveform at time 'time'. This method returns an object.


getValueAsString

public java.lang.String getValueAsString(double time)

getLabel

public java.lang.String getLabel(int index)

findEvent

public double findEvent(double time,
                        boolean forward)
search and return the event time of the next/previous event after/before 'time'.


searchevent

public void searchevent(double Time,
                        boolean direction)

findSpecialEvent

public void findSpecialEvent(java.lang.Object event1,
                             java.lang.Object event2,
                             double Time,
                             boolean direction)

getMaxTime

public double getMaxTime()
return the maximum events time in this waveform


searchMenu

public void searchMenu(double time,
                       boolean direction)
method template for a search menu on this waveform.


paint

public void paint(java.awt.Graphics g)
method template for the graphical representation of this waveform. Subclass as needed.


msg

public static void msg(java.lang.String msg)