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.util
Class GlobalClock

    java.lang.Object
      avrora.sim.util.GlobalClock

Direct Known Subclasses:
  FreeSpaceAir.RadioClock, SimpleAir.RadioClock

public class GlobalClock
extends java.lang.Object

The `GlobalClock` class implements a global timer among multiple simulators by inserting periodic timers into each simulator. It is an alternate version of the `GlobalClock` class that was developed for use with the synchronization policy used in the CC1000 - SimpleAir radio implementation.

A verbose printer for this class can be accessed through "sim.global".

Nested Class Summary
`static class` | `GlobalClock.InterruptedException` How sad.
`static class` | `GlobalClock.LocalMeet`
`static class` | `GlobalClock.Ticker` The `Ticker` class is an event that fires in the local queues of participating threads.

Field Summary
`protected Verbose.Printer` | `gqPrinter`
`long` | `period` `cycles` is the number of cycles on a member local clock per cycle on the global clock.
`protected java.util.HashMap` | `threadMap`
`GlobalClock.Ticker` | `ticker`

Constructor Summary
`` | `GlobalClock(long p)`
`protected` | `GlobalClock(long p, GlobalClock.Ticker t)`

Method Summary
`void` | `add(SimulatorThread t)`
`void` | `addLocalMeet(GlobalClock.LocalMeet m, long delay)` Adds a `LocalMeet` event to the event queue of every simulator participating in the global clock.
`long` | `getCount()`
`int` | `getNumberOfThreads()`
`long` | `globalTime()`
`void` | `insertEvent(Simulator.Event event, long ticks)` Adds an `Event` to this global event queue.
`void` | `remove(SimulatorThread t)`
`void` | `removeEvent(Simulator.Event event)`

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

Field Detail

### period

    public final long period

  `cycles` is the number of cycles on a member local clock per cycle on the global clock. Some re-coding must be done if microcontrollers running at difference speeds are to be accurately simulated.

### threadMap

    protected final java.util.HashMap threadMap

### ticker

    public final GlobalClock.Ticker ticker

### gqPrinter

    protected final Verbose.Printer gqPrinter

Constructor Detail

### GlobalClock

    public GlobalClock(long p)

### GlobalClock

    protected GlobalClock(long p,
                          GlobalClock.Ticker t)

Method Detail

### add

    public void add(SimulatorThread t)

### remove

    public void remove(SimulatorThread t)

### insertEvent

    public void insertEvent(Simulator.Event event,
                            long ticks)

  Adds an `Event` to this global event queue. It is important to note that this method adds an event executed once at the appropriate global time. It does not execute once in each thread participating in the clock. For such functionality, see `LocalMeet`. Note that the event, when fired, may run in any one of the threads participating in the global clock, and not necessarily the same thread each time.

### removeEvent

    public void removeEvent(Simulator.Event event)

### addLocalMeet

    public void addLocalMeet(GlobalClock.LocalMeet m,
                             long delay)

  Adds a `LocalMeet` event to the event queue of every simulator participating in the global clock.

### getCount

    public long getCount()

### globalTime

    public long globalTime()

### getNumberOfThreads

    public int getNumberOfThreads()

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