示例#1
0
    def launch_simulation(self):
        """ DEPRECATED """
        
        component_registry = registry.Registry()

        environment = component_registry.get_component_class(self.configuration["environment"])
        institution = component_registry.get_component_class(self.configuration["institution"])
        agents = []
        for agent_d in self.configuration["agents"]:
            agent_class = component_registry.get_component_class(agent_d["agent_name"])
            agent_count = agent_d["number"]
            agents.append((agent_class, agent_count))

        container = Container()
        properties = None
        if "properties" in self.configuration.keys():
            properties = self.configuration["properties"]
        container.create_root_environment(environment, properties)
        container.setup_environment_institution(institution)
        for agent in agents:
            container.setup_environment_agents(agent[0], agent[1])

        start_message = Message()
        start_message.set_sender("experimenter")
        start_message.set_directive("start_environment")
        container.send_root_environment_message(start_message)
示例#2
0
    def __init__(self):
        self.environment = None
        self.actor_system = None
        self.root_environment = None
        self.component_registry = registry.Registry()

        self.create_actor_system()
        atexit.register(self.actor_system_cleanup)
示例#3
0
        def __init__(self):
            self.actor_system = None

            self.component_registry = registry.Registry()
            self.container = None
            self.component_registry.register_server(self)
            #self.multi_simulation = multi_simulation
            self.container = None
            self.configuration = None
示例#4
0
    def __init__(self):
        print("doing stuff")
        #  print("initializing " * 20)


        self.async_mode = 'eventlet'  # None
        self.app = Server()
        #self.app.config['SECRET_KEY'] = 'secret!'

        #self.app.config['EXPLAIN_TEMPLATE_LOADING'] = True

        thread = None
        #self.socketio = SocketIO(self.app) #, async_mode=self.async_mode)
        self.component_registry = registry.Registry()
        self.component_registry.register_server(self)
示例#5
0
def directive_enabled_class(cls):
    functions = [
        attr for attr in vars(cls).values() if isinstance(attr, FunctionType)
    ]
    component_registry = registry.Registry()

    cls._enabled_directives = {}
    cls._enabled_functions_to_directives = {}
    cls._enabled_directives_schemas = {}
    cls._mtree_properties = {}
    cls._message_sources = {}
    cls._enabled_directives_state_monitors = {}
    for func in functions:
        if getattr(func, "message_directive", False):
            cls._enabled_directives[getattr(func, "message_directive")] = func
            cls._enabled_functions_to_directives[func.__name__] = getattr(
                func, "message_directive")
        if getattr(func, "state_properties", False):
            cls._enabled_directives_state_monitors[func.__name__] = getattr(
                func, "state_properties")
        if getattr(func, "message_source", False):
            cls._message_sources[getattr(func, "message_source")] = getattr(
                func, "mtree_properties")
        if getattr(func, "mtree_properties", False):
            for property_name in getattr(func, "mtree_properties").keys():
                cls._mtree_properties[property_name] = getattr(
                    func, "mtree_properties")[property_name]
        if getattr(func, "schema", False):
            cls._enabled_directives_schemas[getattr(
                func, "message_directive")] = getattr(func, "schema")

    # now we register directives from the base class
    for base in cls.__bases__:
        functions = [
            attr for attr in vars(base).values()
            if isinstance(attr, FunctionType)
        ]
        for func in functions:
            if getattr(func, "message_directive", False):
                cls._enabled_directives[getattr(func,
                                                "message_directive")] = func
            if getattr(func, "schema", False):
                cls._enabled_directives_schemas[getattr(
                    func, "message_directive")] = getattr(func, "schema")
    component_registry.add_class(cls)

    return cls
示例#6
0
    def __init__(self):
        if ActorSystemConnector.__instance is None:
            self.actor_system = None
            self.component_registry = registry.Registry()
            self.container = None
            self.component_registry.register_server(self)
            #self.multi_simulation = multi_simulation
            self.container = None
            self.configuration = None
            # self.capabilities = dict([('Admin Port', 19000)])
            # self.actor_system = ActorSystem('multiprocTCPBase', capabilities=self.capabilities, logDefs=logcfg)
            # self.capabilities = dict([('Admin Port', 19000)])
            self.actor_system = ActorSystem('multiprocTCPBase') #, logDefs=logcfg)

            ActorSystemConnector.__instance = self
            self.dispatchers = []
            self.source_hashes = []
示例#7
0
 def __init__(self, namespace=None):
     self.admin_sid = None
     self.component_registry = registry.Registry()
     self.subject_pool = SubjectPool()
     self.configuration_scanner = ConfigurationScanner()
     super(Namespace, self).__init__(namespace)
示例#8
0
 def __init__(self):
     self.actor_system = None
     self.dispatcher = None
     self.log_actor = None
     self.component_registry = registry.Registry()
     self.create_actor_system()
示例#9
0
文件: admin.py 项目: gmucsn/mTree
def components(page):
    #try:
    component_registry = registry.Registry()

    return render_template('component_view.html', registry=component_registry)
示例#10
0
def show(page):
    #try:
    component_registry = registry.Registry()

    return render_template('subject_base.html', registry=component_registry)