| 1 |
""" bank01_OO: The single non-random Customer """ |
| 2 |
from SimPy.Simulation import Simulation, Process, hold |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
class Customer(Process): |
| 7 |
""" Customer arrives, looks around and leaves """ |
| 8 |
|
| 9 |
def visit(self, timeInBank): |
| 10 |
print("%2.1f %s Here I am" % (self.sim.now(), self.name)) |
| 11 |
yield hold, self, timeInBank |
| 12 |
print("%2.1f %s I must leave" % (self.sim.now(), self.name)) |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
class BankModel(Simulation): |
| 17 |
def run(self): |
| 18 |
""" PEM """ |
| 19 |
c = Customer(name="Klaus", sim=self) |
| 20 |
self.activate(c, c.visit(timeInBank), at=tArrival) |
| 21 |
self.simulate(until=maxTime) |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
maxTime = 100.0 |
| 26 |
timeInBank = 10.0 |
| 27 |
tArrival = 5.0 |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
mymodel = BankModel() |
| 32 |
mymodel.run() |