本文整理汇总了Python中fysom.Fysom.produce_strawberry方法的典型用法代码示例。如果您正苦于以下问题:Python Fysom.produce_strawberry方法的具体用法?Python Fysom.produce_strawberry怎么用?Python Fysom.produce_strawberry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fysom.Fysom
的用法示例。
在下文中一共展示了Fysom.produce_strawberry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from fysom import Fysom [as 别名]
# 或者: from fysom.Fysom import produce_strawberry [as 别名]
class Micro:
def __init__(self, macro, cookie, callback=None):
self.callback = callback
self.macro = macro
self.cookie = cookie
self._fsm = Fysom(
initial='waiting',
events=[('load', 'waiting', 'loaded'),
('produce_strawberry', 'loaded', 'produced_strawberry'),
('produce_chocolate', 'produced_strawberry', 'produced_chocolate'),
('present', 'produced_chocolate', 'waiting')],
callbacks=[('onload', self._load),
('onproduce_strawberry', self._produce_strawberry),
('onproduce_chocolate', self._produce_chocolate),
('onpresent', self._present)])
@property
def status(self):
return self._fsm.current
def start(self):
self._fsm.load()
def produce_chocolate(self, job):
self._fsm.produce_chocolate()
def present(self, job):
self._fsm.present()
def _load(self, e):
logging.info('loading cookie')
self.macro.track.to_load()
self._fsm.produce_strawberry()
def _produce_strawberry(self, e):
logging.info('producing strawberry')
job = StrawberryJob(self.macro.strawberry_factory,
forward=self.cookie.properties[0],
quantity=self.cookie.properties[1],
callback=self.produce_chocolate)
self.macro.track.to_strawberry()
job.start()
def _produce_chocolate(self, e):
logging.info('producing chocolate')
job = ChocolateJob(self.macro.chocolate_factory,
rounds=self.cookie.properties[2],
velocity=self.cookie.properties[3],
callback=self.present)
self.macro.track.to_chocolate()
job.start()
def _present(self, e):
logging.info('presenting cookie')
self.macro.track.to_present()
if self.callback:
self.callback()