modhelxs.simulation
Class PeriodicRTClock

java.lang.Object
  extended by tesl.Clock<T>
      extended by modhelxs.simulation.DrivingClock<java.lang.Long>
          extended by modhelxs.simulation.PeriodicRTClock

public class PeriodicRTClock
extends DrivingClock<java.lang.Long>

A driving clock that ticks periodically on real time.

Author:
boulange

Nested Class Summary
private  class PeriodicRTClock.ClockBackup
           
private  class PeriodicRTClock.PeriodicRTThread
          The thread used to notify the execution engine when a tick is produced on the clock.
 
Field Summary
private  PeriodicRTClock.PeriodicRTThread mythread_
           
private  long next_tick_time_
          The time for the next tick.
private  long offset_
          the offset between the system time and this clock.
private  long period_
          The period of the clock, in milliseconds.
 
Fields inherited from class modhelxs.simulation.DrivingClock
listener_
 
Constructor Summary
PeriodicRTClock(java.lang.String name, long milliseconds, long initialTag)
           
 
Method Summary
 void activate()
          Activate the clock: make it ready to produce a tick and notify the engine.
 ClockBackupInterface<java.lang.Long> backup()
           
 void cancel()
          Cancel the clock: stop waiting for the driving event.
 long getNextTime()
          Compute the time for the next tick.
 Tick<java.lang.Long> newTick()
          This clock should have only one tick, so we can't add new ones.
 void removeTick(int i)
          This clock should always have a tick, so we cannot remove its tick.
 void removeTick(Tick<java.lang.Long> tick)
          This clock should always have a tick, so we cannot remove its tick.
 void resetClock()
          This clock should always have a tick, so we cannot remove its tick.
 void restore(ClockBackupInterface<java.lang.Long> backup)
          This clock should have only one tick, so it cannot be restored.
 void wrapup()
          Release the ressources used by the clock, called at the end of the simulation.
 
Methods inherited from class modhelxs.simulation.DrivingClock
getDrivingClocks, setListener
 
Methods inherited from class tesl.Clock
affineTags, cleanUp, createMasterImplication, createSlaveImplication, filteredImplies, getClockSet, getFirstTaggedTick, getFloatingTick, getName, getNowTick, getNumberOfTicks, getTag, getTagCalculus, getTagValue, getTick, getTick, getTick, getTicks, hasFloatingTick, hasTaggedTick, hasTickNow, hasTicks, implies, impliesThroughFilter, impliesWithDelay, impliesWithDelay, isGreedy, isNow, newTick, sameTags, setClockSet, setGreedy, setNow, setTag, setTagValue, sustains, sustains, tagDifference, tagProduct, tagQuotient, tagSum, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mythread_

private PeriodicRTClock.PeriodicRTThread mythread_

period_

private long period_
The period of the clock, in milliseconds.


offset_

private long offset_
the offset between the system time and this clock.


next_tick_time_

private long next_tick_time_
The time for the next tick.

Constructor Detail

PeriodicRTClock

public PeriodicRTClock(java.lang.String name,
                       long milliseconds,
                       long initialTag)
Method Detail

getNextTime

public long getNextTime()
Compute the time for the next tick. If this time is is the past, add as many periods as necessary to bring it in the future.


activate

public void activate()
Description copied from class: DrivingClock
Activate the clock: make it ready to produce a tick and notify the engine.

Specified by:
activate in class DrivingClock<java.lang.Long>

cancel

public void cancel()
Description copied from class: DrivingClock
Cancel the clock: stop waiting for the driving event.

Specified by:
cancel in class DrivingClock<java.lang.Long>

newTick

public Tick<java.lang.Long> newTick()
This clock should have only one tick, so we can't add new ones.

Overrides:
newTick in class Clock<java.lang.Long>

backup

public ClockBackupInterface<java.lang.Long> backup()
Overrides:
backup in class Clock<java.lang.Long>

restore

public void restore(ClockBackupInterface<java.lang.Long> backup)
This clock should have only one tick, so it cannot be restored.

Overrides:
restore in class Clock<java.lang.Long>

removeTick

public void removeTick(Tick<java.lang.Long> tick)
This clock should always have a tick, so we cannot remove its tick.

Overrides:
removeTick in class Clock<java.lang.Long>

removeTick

public void removeTick(int i)
This clock should always have a tick, so we cannot remove its tick.

Overrides:
removeTick in class Clock<java.lang.Long>

resetClock

public void resetClock()
This clock should always have a tick, so we cannot remove its tick.

Overrides:
resetClock in class Clock<java.lang.Long>

wrapup

public void wrapup()
Description copied from class: DrivingClock
Release the ressources used by the clock, called at the end of the simulation.

Specified by:
wrapup in class DrivingClock<java.lang.Long>