Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## avrora.sim.clock
Class MainClock

    java.lang.Object
      avrora.sim.clock.Clock
          avrora.sim.clock.MainClock

public class MainClock
extends Clock

The `MainClock` class represents a clock that has an associated delta queue. This clock is meant as the main, or driving clock. Clocks that are derived from this class are kept in synch through the event queue. The `MainClock` is advanced by the interpreter for a node.

Field Summary
`protected DeltaQueue` | `eventQueue` The `eventQueue` field stores a reference to the event queue for this node.

Fields inherited from class avrora.sim.clock.Clock
`hz, name`

Constructor Summary
`MainClock(java.lang.String n, long hz)` The `MainClock()` method creates a main clock with the specified name and frequency.

Method Summary
`void` | `advance(long cycles)` The `advance()` method advances the time of the clock by the number of cycles.
`long` | `getCount()` The `getCount()` method returns the number of clock cycles (ticks) that have elapsed for this clock.
`long` | `getFirstEventDelta()` The `getFirstEventDelta()` method returns the number of clock cycles until the first event in the event queue will fire.
`void` | `insertEvent(Simulator.Event e, long cycles)` 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.
`void` | `skipAhead()` The `skipAhead()` method skips ahead to the next event in the queue and fires it.

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

### eventQueue

    protected final DeltaQueue eventQueue

  The `eventQueue` field stores a reference to the event queue for this node.

Constructor Detail

### MainClock

    public MainClock(java.lang.String n,
                     long hz)

  The `MainClock()` method creates a main clock with the specified name and frequency.

Parameters:
  `n` - the name of this clock
  `hz` - the number of cycles per second for this clock

Method Detail

### getCount

    public long getCount()

  The `getCount()` method returns the number of clock cycles (ticks) that have elapsed for this clock.

  Specified by:
    `getCount` in class `Clock`
  Returns:
    the number of elapsed time ticks in clock cycles

### insertEvent

    public void insertEvent(Simulator.Event e,
                            long cycles)

  The `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.

  Specified by:
    `insertEvent` in class `Clock`
  Parameters:
    `e` - the event to be inserted
    `cycles` - the number of cycles in the future at which to fire

### removeEvent

    public void removeEvent(Simulator.Event e)

  The `removeEvent()` method removes an event from the event queue of the clock. The comparison used is reference equality, not `.equals()`.

  Specified by:
    `removeEvent` in class `Clock`
  Parameters:
    `e` - the event to remove

### advance

    public void advance(long cycles)

  The `advance()` method advances the time of the clock by the number of cycles. This may happen as the result of executing an instruction, sleeping for a time, delaying, etc. This method is only intended for use by the agent driving the clock; e.g. the simulator, and not a monitor or probe.

  Parameters:
    `cycles` - the number of cycles to advance the clock

### getFirstEventDelta

    public long getFirstEventDelta()

  The `getFirstEventDelta()` method returns the number of clock cycles until the first event in the event queue will fire. This method will return -1 if there are no events in the queue.

  Returns:
    the delta in clock cycles of the first event in the queue; -1 if there are no events in the queue

### skipAhead

    public void skipAhead()

  The `skipAhead()` method skips ahead to the next event in the queue and fires it.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD