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


Python Simulator.setVerbose方法代码示例

本文整理汇总了Python中simulator.Simulator.setVerbose方法的典型用法代码示例。如果您正苦于以下问题:Python Simulator.setVerbose方法的具体用法?Python Simulator.setVerbose怎么用?Python Simulator.setVerbose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simulator.Simulator的用法示例。


在下文中一共展示了Simulator.setVerbose方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: terminate_whenStateIsReached

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import setVerbose [as 别名]
#    every simulation step, making it possible to check for certain states
#    being reached.
#    It should return True to stop simulation, or Falso to continue.
def terminate_whenStateIsReached(clock, model):
    return model.trafficLight.state.get() == "manual"
sim.setTerminationCondition(terminate_whenStateIsReached)

#    A termination time is prefered over a termination condition,
#    as it is much simpler to use.
#    e.g. to simulate until simulation time 100.0 is reached
sim.setTerminationTime(300.0)

# B. Set the use of a tracer to show what happened during the simulation run
#    Both writing to stdout or file is possible:
#    pass None for stdout, or a filename for writing to that file
sim.setVerbose(None)

# C. Use Classic DEVS instead of Parallel DEVS
#    If your model uses Classic DEVS, this configuration MUST be set as
#    otherwise errors are guaranteed to happen.
#    Without this option, events will be remapped and the select function
#    will never be called.
sim.setClassicDEVS()

#    ======================================================================

# 4. Simulate the model
sim.simulate()

#    ======================================================================
开发者ID:capocchi,项目名称:DEVSimPy,代码行数:32,代码来源:trafficLightExperiment_classic.py

示例2: intTransition

# 需要导入模块: from simulator import Simulator [as 别名]
# 或者: from simulator.Simulator import setVerbose [as 别名]
      return {self.outport: [self.state]}

  def intTransition(self):
      self.state = None
      return self.state

  def extTransition(self, inputs):
      self.state = inputs[self.inport][0]
      return self.state

class CQueue(CoupledDEVS):
    def __init__(self):
        CoupledDEVS.__init__(self, "CQueue")
        self.generator = self.addSubModel(Generator())
        self.queue = self.addSubModel(Queue())
        self.connectPorts(self.generator.outport, self.queue.inport)

class DQueue(CoupledDEVS):
    def __init__(self):
        CoupledDEVS.__init__(self, "DQueue")
        self.generator = self.addSubModel(Generator())
        self.queue1 = self.addSubModel(Queue())
        self.queue2 = self.addSubModel(Queue())
        self.connectPorts(self.generator.outport, self.queue1.inport)
        self.connectPorts(self.generator.outport, self.queue2.inport)

model = CQueue()
sim = Simulator(model)
sim.setVerbose()
sim.simulate()
开发者ID:AsmaDhanePersonal,项目名称:DEVSimPy,代码行数:32,代码来源:queue_example.py


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