|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthades.simulator.SimObject
hades.models.io.SevenSegmentMultiplexed
SevenSegmentMultiplexed - model a multiplexed seven-segment display
This component allows to visualize the behaviour of a multiplexed 7-segment LED display. To this end, it maintains an internal data structure that keeps track of the 'on period' of each LED segment during a predefined time interval (specified by the t_sample variable). Typically, this time interval will be the as the repaint interval of the GUI (e.g. one second or 1/10th second).
The simulation model is driven by two threads. The first, simulation thread is responsible to set the LED input values and to update the 'on period' statistics of each LED segment. After t_sample has elapsed, the statistics is evaluated and the LED colors are calculated. Note that this implies that the display shows the values 'late', namely corresponding to the previous t_sample time interval.
The second, 'repaint' thread evaluates the 'on period' statistics and decides whether to paint a segment as active (red color) or inactive (dark gray color).
Nested Class Summary | |
(package private) class |
SevenSegmentMultiplexed.DynSymbol
|
Field Summary | |
static int |
CATHODE_ACTIVE
|
static int |
CATHODE_INACTIVE
|
static int |
CATHODE_UX
|
(package private) java.awt.Color |
COLOR_OFF
|
(package private) java.awt.Color |
COLOR_ON
|
(package private) java.awt.Color |
COLOR_UX
|
protected java.awt.Color |
dark_gray
|
protected FigCompound |
display
|
protected boolean |
hasNewEvents
|
static int |
LED_OFF
|
static int |
LED_ON
|
static int |
LED_UX
|
protected int[] |
ledValues
|
protected java.awt.Color |
medium_gray
|
protected int |
n_cycles
|
(package private) static char[] |
names
|
protected int[] |
portValues
|
protected ColoredPolyline[] |
segments
|
protected double |
t_delta
|
protected double[] |
t_lastUpdate
|
protected double[] |
t_off
|
protected double[] |
t_on
|
protected double |
t_sample
|
protected double |
t_threshold
|
protected double[] |
t_total
|
protected double[] |
t_ux
|
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 | |
SevenSegmentMultiplexed()
SevenSegmentMultiplexed(): simple constructor |
Method Summary | |
void |
configure()
create and display a 'ConfigDialog' to set the parameters for a SimObject. |
void |
constructDynamicSymbol()
|
void |
elaborate(java.lang.Object arg)
elaborate(): This method is called by the simulation engine to initialize the simulation object. |
(package private) void |
evalStatistics()
evaluate the statistics of one t_sample period, calculate the corresponding LED on/off/X states, and store these int ledValues[i]. |
void |
evaluate(java.lang.Object arg)
evaluate(): called by the simulation engine on all events that concern this object. |
double |
getT_sample()
|
double |
getT_threshold()
|
java.lang.String |
getToolTip(java.awt.Point position,
long millis)
construct a tool tip message (with the timing parameters) |
boolean |
initialize(java.lang.String s)
initialize a SevenSegmentMultiplexed display from a String, which contains its integer version id, and the double values for sample period and on-threshold (in seconds), e.g. |
(package private) void |
initLedValues()
|
(package private) void |
initPortValues()
|
(package private) void |
initStatistics()
|
boolean |
needsDynamicSymbol()
we want to construct our own Symbol! |
(package private) void |
repaint()
|
(package private) void |
resetStatistics()
|
void |
setSymbol(Symbol s)
|
void |
setT_sample(java.lang.String s)
|
void |
setT_threshold(java.lang.String s)
|
java.lang.String |
toString()
toString() - the usual info method |
(package private) void |
updateAllSegmentStatistics(double time)
called whenever the common cathode port (port[8]) changes. |
(package private) void |
updateSegmentStatistics(double time,
int i)
update the on/off/x statistics for segment i (A=0, B=1, ..P=7) from the current value in portValues[i], portValues[cathode=8], and the current simulation time. |
void |
wakeup(java.lang.Object arg)
one sample period has elapsed. |
void |
write(java.io.PrintWriter ps)
|
Methods inherited from class hades.simulator.SimObject |
copy, getBindkey, getClassLoader, getDebug, getEditor, getExternalResources, getFullName, getName, getParent, getPort, getPorts, getPropertySheet, getResourceAsStream, getSimulator, getSymbol, getSymbolResourceName, getVersionId, isVisible, keyPressed, message, mousePressed, 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 |
public static final int LED_UX
public static final int LED_OFF
public static final int LED_ON
public static final int CATHODE_UX
public static final int CATHODE_ACTIVE
public static final int CATHODE_INACTIVE
protected ColoredPolyline[] segments
protected FigCompound display
protected java.awt.Color dark_gray
protected java.awt.Color medium_gray
protected StdLogic1164 value_U
protected int[] portValues
protected int[] ledValues
protected double[] t_on
protected double[] t_off
protected double[] t_ux
protected double[] t_lastUpdate
protected double[] t_total
protected double t_delta
protected double t_sample
protected double t_threshold
protected int n_cycles
protected boolean hasNewEvents
java.awt.Color COLOR_UX
java.awt.Color COLOR_ON
java.awt.Color COLOR_OFF
static char[] names
Constructor Detail |
public SevenSegmentMultiplexed()
Method Detail |
public void setSymbol(Symbol s)
setSymbol
in class SimObject
public boolean needsDynamicSymbol()
needsDynamicSymbol
in class SimObject
public void constructDynamicSymbol()
constructDynamicSymbol
in class SimObject
public void elaborate(java.lang.Object arg)
elaborate
in interface Simulatable
elaborate
in class SimObject
arg
- This parameter is ignored by SevenSegmentMultiplexedpublic void wakeup(java.lang.Object arg)
wakeup
in interface Wakeable
arg
- a WakeupEvent whose details are not usedpublic void evaluate(java.lang.Object arg)
evaluate
in interface Simulatable
evaluate
in class SimObject
arg
- An arbitrary and unused objectvoid repaint()
void updateSegmentStatistics(double time, int i)
void updateAllSegmentStatistics(double time)
void initPortValues()
void initLedValues()
void initStatistics()
void resetStatistics()
void evalStatistics()
public boolean initialize(java.lang.String s)
initialize
in class SimObject
public void write(java.io.PrintWriter ps)
write
in class SimObject
public void configure()
SimObject
configure
in class SimObject
public double getT_sample()
public double getT_threshold()
public void setT_sample(java.lang.String s)
public void setT_threshold(java.lang.String s)
public java.lang.String getToolTip(java.awt.Point position, long millis)
getToolTip
in interface ContextToolTip
getToolTip
in class SimObject
public java.lang.String toString()
toString
in class SimObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |