Debian Codegraph @

docs/SManual/source/programs/car.py

raw symbols SCIP
1 from SimPy.Simulation import Process, activate, hold, initialize, now, simulate
2
3
4 class Car(Process):
5 def __init__(self, name, cc):
6 Process.__init__(self, name=name)
7 self.cc = cc
8
9 def go(self):
10 print('%s %s %s' % (now(), self.name, 'Starting'))
11 yield hold, self, 100.0
12 print('%s %s %s' % (now(), self.name, 'Arrived'))
13
14
15 initialize()
16 c1 = Car('Car1', 2000) # a new car
17 activate(c1, c1.go(), at=6.0) # activate at time 6.0
18 c2 = Car('Car2', 1600) # another new car
19 activate(c2, c2.go()) # activate at time 0
20 simulate(until=200)
21 print('Current time is %s' % now()) # will print 106.0