本文整理汇总了Python中SimPy.Simulation.reactivate方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.reactivate方法的具体用法?Python Simulation.reactivate怎么用?Python Simulation.reactivate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimPy.Simulation
的用法示例。
在下文中一共展示了Simulation.reactivate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: operate
# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import reactivate [as 别名]
def operate(self, repairduration, triplength):
"""Travel until the trip is finished.
The bus may break down down several times during the trip.
Parameters:
repairduration -- time to recover from a breakdown and continue
triplength -- duration of the trip
"""
tripleft = triplength
# "tripleft"is the driving time to finish trip
# if there are no further breakdowns
while tripleft > 0:
yield sim.hold, self, tripleft # try to finish the trip
# if a breakdown intervenes
if self.interrupted():
print self.interruptCause.name, 'at %s' % sim.now()
tripleft = self.interruptLeft
# update driving time to finish
# the trip if no more breakdowns
self.interruptReset()
# end self interrupted state
#update next breakdown time
sim.reactivate(br, delay=repairduration)
#impose delay for repairs on self
yield sim.hold, self, repairduration
print 'Bus repaired at %s' % sim.now()
else: # no breakdowns intervened, so bus finished trip
break
print 'Bus has arrived at %s' % sim.now()