## RealTimeFireworks.py
from __future__ import generators
from SimPy.SimulationRT  import *
from random import *
import time
class Launcher(Process):
    def launch(self):
        while True:
            print "Launch at %.1f; wallclock: %s"%(now(),time.clock()-startTime)
            yield hold,self,uniform(1,maxFlightTime)
            print "Boom!!! Aaaah!! at %.1f; wallclock: %s"%(now(),time.clock()-startTime)
def model():
    initialize()
    for i in range(nrLaunchers):
        lau=Launcher()
        activate(lau,lau.launch())
    simulate(real_time=True,rel_speed=1,until=20) ##unit sim time = 1 sec clock
nrLaunchers=2
maxFlightTime=5.0 ##seconds
startTime=time.clock()
model()
