File: firework.py

package info (click to toggle)
python-simpy 2.3.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,864 kB
  • sloc: python: 11,171; makefile: 143
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)