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


Python Main.get_live_transitions方法代码示例

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


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

示例1: Server

# 需要导入模块: from main import Main [as 别名]
# 或者: from main.Main import get_live_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
开发者ID:spiewak,项目名称:petri_nets,代码行数:48,代码来源:server.py


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