|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object avrora.sim.clock.Clock avrora.sim.clock.DerivedClock
The DerivedClock
class represents a clock that is derived from another clock; i.e. the derived
clock runs slower but is synchronized with the clock that it is derived from. An example is the 32khz real
time clock on the Mica2--it runs independently of the main clock, but in the simulation, it uses the
main clock signal to synchronize its execution to the execution of the program.
Field Summary | |
protected double |
divider
The divider stores a the ration between the clockspeed of the drive clock and the
clockspeed of this clock. |
protected Clock |
driveClock
The driveClock field stores a reference to the clock that is underlying this derived
clock. |
Fields inherited from class avrora.sim.clock.Clock |
hz, name |
Constructor Summary | |
DerivedClock(java.lang.String n,
Clock driver,
long hz)
The constructor of the DerivedClock creates a new clock with the specified name, driven by
the specified clock, with the specified clockrate. |
Method Summary | |
long |
getCount()
The getCount() method returns the total count of clock ticks that have happened for this
clock. |
void |
insertEvent(Simulator.Event e,
long delta)
The insertEvent() method inserts an event into the event queue of the clock with the
specified delay in clock cycles. |
void |
removeEvent(Simulator.Event e)
The removeEvent() method removes an event from the event queue of the clock. |
Methods inherited from class avrora.sim.clock.Clock |
getHZ, getName |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected final Clock driveClock
driveClock
field stores a reference to the clock that is underlying this derived
clock.
protected final double divider
divider
stores a the ration between the clockspeed of the drive clock and the
clockspeed of this clock.
Constructor Detail |
public DerivedClock(java.lang.String n, Clock driver, long hz)
DerivedClock
creates a new clock with the specified name, driven by
the specified clock, with the specified clockrate. The derived clock can have any speed that is slower
than the clock that it is derived from. Roundoff errors will happen when the rates are not an integer
multiple of each other, but are guaranteed never to exceed 1 cycle of the underlying clock.
n
- the name of the clockdriver
- the clock source from which this clock is derivedhz
- the number of cycles per second of this clockMethod Detail |
public long getCount()
getCount()
method returns the total count of clock ticks that have happened for this
clock. Since this clock is a derived clock, it computes the number of clock cycles that have happened
based on the number of clock cycles that have happened for the underlying clock from which it is
derived.
getCount
in class Clock
public void insertEvent(Simulator.Event e, long delta)
insertEvent()
method inserts an event into the event queue of the clock with the
specified delay in clock cycles. The event will then be executed at the future time specified.
insertEvent
in class Clock
e
- the event to be inserteddelta
- the number of cycles in the future at which to eventpublic void removeEvent(Simulator.Event e)
removeEvent()
method removes an event from the event queue of the clock. The
comparison used is reference equality, not .equals()
.
removeEvent
in class Clock
e
- the event to remove
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |