| 1 |
""" bank01: The single non-random Customer """ |
| 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("%2.1f %s Here I am" % (now(), self.name)) |
| 12 |
yield hold, self, timeInBank |
| 13 |
print("%2.1f %s I must leave" % (now(), self.name)) |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
maxTime = 100.0 |
| 18 |
timeInBank = 10.0 |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
initialize() |
| 23 |
c = Customer(name="Klaus") |
| 24 |
activate(c, c.visit(timeInBank), at=5.0) |
| 25 |
simulate(until=maxTime) |