本文整理汇总了Python中main.Main.run_selected_transitions方法的典型用法代码示例。如果您正苦于以下问题:Python Main.run_selected_transitions方法的具体用法?Python Main.run_selected_transitions怎么用?Python Main.run_selected_transitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类main.Main
的用法示例。
在下文中一共展示了Main.run_selected_transitions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Server
# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import run_selected_transitions [as 别名]
class Server(tornado.websocket.WebSocketHandler):
def open(self):
self.write_message(json.dumps({"message": "Petri net simulation"}))
def on_message(self, message):
message_dict = ast.literal_eval(message)
return self.__do_action(message_dict)
def __do_action(self, message_dict):
action_type = message_dict["type"]
receive_data = message_dict["data"]
if action_type is RequestType.START:
parsed_objects = JsonToObjectParser()
parsed_objects.create_graph_structure(receive_data)
self.main = Main(parsed_objects.places, parsed_objects.transitions, parsed_objects.links)
return self.write_message(self.main.start_simulation())
elif action_type is RequestType.SIMULATE:
try:
return self.write_message(self.main.simulate())
except AttributeError:
return self.write_message(json.dumps({'error': 'Network is empty. Please send network parameters first.'}))
elif action_type is RequestType.GRAPH_FEATURES:
try:
return self.write_message(self.main.get_graph_features())
except AttributeError:
return self.write_message(json.dumps({'error': 'Network is empty. Please send network parameters first.'}))
elif action_type is RequestType.VECTOR_NETWORK_CONSERVATIVE:
try:
return self.write_message(self.main.is_network_vector_conservative(ast.literal_eval(receive_data)))
except AttributeError:
return self.write_message(json.dumps({'error': 'Network is empty. Please send network parameters first.'}))
elif action_type is RequestType.LIVE_TRANSITIONS:
try:
return self.write_message(self.main.get_live_transitions())
except AttributeError:
return self.write_message(json.dumps({'error': 'Network is empty. Please send network parameters first.'}))
elif action_type is RequestType.RUN_SELECTED_TRANSITION:
try:
return self.write_message(self.main.run_selected_transitions(receive_data))
except AttributeError:
return self.write_message(json.dumps({'error': 'Network is empty. Please send network parameters first.'}))
def on_close(self):
pass