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
Class Clock

    java.lang.Object
      avrora.sim.Clock

Direct Known Subclasses:
  ClockPrescaler, DerivedClock

public abstract class Clock
extends java.lang.Object

The `Clock` class represents a clock within the simulation. There is one main clock for the Simulator itself, and all other clocks, even if they are not physically derived off the same clock signal, are simulated by inserting events into the main clock.

Field Summary
`protected long` | `hz` The `hz` field stores the rate of this clock in cycles per second.
`protected java.lang.String` | `name` The `name` field stores the name of this clock as a string.

Constructor Summary
`protected` | `Clock(java.lang.String n, long hz)`

Method Summary
`abstract long` | `getCount()` The `getCount()` method returns the number of clock cycles (ticks) that have elapsed for this clock.
`long` | `getHZ()` The `getHZ()` method returns the number of cycles per second at which this clock runs.
`java.lang.String` | `getName()` The `getName()` method returns the name of this clock source.
`abstract 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.
`abstract void` | `removeEvent(Simulator.Event e)` The `removeEvent()` method removes an event from the event queue of the clock.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### hz

    protected final long hz

  The `hz` field stores the rate of this clock in cycles per second.

### name

    protected final java.lang.String name

  The `name` field stores the name of this clock as a string.

Constructor Detail

### Clock

    protected Clock(java.lang.String n,
                    long hz)

Method Detail

### getHZ

    public long getHZ()

  The `getHZ()` method returns the number of cycles per second at which this clock runs.

  Returns:
    the number of cycles per second on this clock

### getName

    public java.lang.String getName()

  The `getName()` method returns the name of this clock source. Each clock has a name, so that they can be indexed in the simulator.

  Returns:
    the name of the clock as a string

### getCount

    public abstract long getCount()

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

  Returns:
    the number of elapsed time ticks in clock cycles

### insertEvent

    public abstract 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.

  Parameters:
    `e` - the event to be inserted
    `cycles` - the number of cycles in the future at which to fire

### removeEvent

    public abstract 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()`.

  Parameters:
    `e` - the event to remove

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