| 1 |
""" bank02: More Customers """ |
| 2 |
from SimPy.Simulation import * |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
class Customer(Process): |
| 8 |
""" Customer arrives, looks around and leaves """ |
| 9 |
|
| 10 |
def visit(self, timeInBank): |
| 11 |
print("%7.4f %s: Here I am" % (now(), self.name)) |
| 12 |
yield hold, self, timeInBank |
| 13 |
print("%7.4f %s: I must leave" % (now(), self.name)) |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
maxTime = 400.0 |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
initialize() |
| 22 |
|
| 23 |
c1 = Customer(name="Klaus") |
| 24 |
activate(c1, c1.visit(timeInBank=10.0), at=5.0) |
| 25 |
c2 = Customer(name="Tony") |
| 26 |
activate(c2, c2.visit(timeInBank=7.0), at=2.0) |
| 27 |
c3 = Customer(name="Evelyn") |
| 28 |
activate(c3, c3.visit(timeInBank=20.0), at=12.0) |
| 29 |
|
| 30 |
simulate(until=maxTime) |