当前位置: 首页>>代码示例>>Python>>正文


Python Simulation.reactivate方法代码示例

本文整理汇总了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()
开发者ID:buguen,项目名称:wsnpy,代码行数:33,代码来源:sim_bus.py


注:本文中的SimPy.Simulation.reactivate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。