File: firework.py

package info (click to toggle)
python-simpy 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 17,300 kB
  • ctags: 2,568
  • sloc: python: 11,172; makefile: 145
file content (20 lines) | stat: -rw-r--r-- 606 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from SimPy.Simulation import Process, activate, initialize, hold, now, simulate


class Firework(Process):

    def execute(self):
        print('%s firework launched' % now())
        yield hold, self, 10.0  # wait 10.0 time units
        for i in range(10):
            yield hold, self, 1.0
            print('%s tick' % now())
        yield hold, self, 10.0  # wait another 10.0 time units
        print('%s Boom!!' % now())


initialize()
f = Firework()  # create a Firework object, and
                # activate it (with some default parameters)
activate(f, f.execute(), at=0.0)
simulate(until=100)