Debian Codegraph @

docs/SManual/source/programs/carT.py

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