avrora.sim.util
Class PeriodicTrigger

java.lang.Object
  extended byavrora.sim.util.PeriodicTrigger
All Implemented Interfaces:
Simulator.Trigger

public class PeriodicTrigger
extends java.lang.Object
implements Simulator.Trigger

The PeriodicTrigger class is a utility that allows a Trigger to be inserted into the simulator that will fire with a specified period of clock cycles. It works by automatically adding itself back into the timer queue at each firing.

See Also:
Simulator.Trigger

Field Summary
 long period
          This field stores the period (in clock cycles) that the trigger will be fired.
 Simulator simulator
          This field stores the simulator in which the trigger will continually be reinserted.
 Simulator.Trigger trigger
          This field stores the trigger that will be fired after each period.
 
Constructor Summary
PeriodicTrigger(Simulator s, Simulator.Trigger t, long p)
          The constructor for the PeriodicTrigger class creates a new periodic trigger with the specified period.
 
Method Summary
 void fire()
          The fire() method is called by the simulator when the timer event occurs.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

simulator

public final Simulator simulator
This field stores the simulator in which the trigger will continually be reinserted.


trigger

public final Simulator.Trigger trigger
This field stores the trigger that will be fired after each period.


period

public final long period
This field stores the period (in clock cycles) that the trigger will be fired.

Constructor Detail

PeriodicTrigger

public PeriodicTrigger(Simulator s,
                       Simulator.Trigger t,
                       long p)
The constructor for the PeriodicTrigger class creates a new periodic trigger with the specified period. Each time the trigger fires, it will be added again back into the simulator's timer event queue with the same delta. The result is the specified trigger fires with the precise period specified.

Creating the PeriodicTrigger does not insert it into the simulator. It is important that these instances of Simulator match--this probe will always reinsert itself into the instance passed in the constructor.

Parameters:
s - the simulator in which to reinsert the trigger each time
t - the trigger to fire after each period
p - the period in clock cycles
Method Detail

fire

public void fire()
The fire() method is called by the simulator when the timer event occurs. In this implementation, the periodic trigger is reinserted into the timer queue, and then the fire() method of the trigger is called.

Specified by:
fire in interface Simulator.Trigger