Пример #1
0
    def set_coupling_params(self, **data):
        session_stored_simulator, is_simulation_copy, is_simulation_load, is_branch = self.context.get_common_params(
        )

        if cherrypy.request.method == POST_REQUEST:
            self.context.add_last_loaded_form_url_to_session(
                SimulatorWizzardURLs.SET_SURFACE_URL)
            form = get_form_for_coupling(
                type(session_stored_simulator.coupling))()
            form.fill_from_post(data)
            form.fill_trait(session_stored_simulator.coupling)

        surface_fragment = self.algorithm_service.prepare_adapter_form(
            form_instance=SimulatorSurfaceFragment(),
            project_id=self.context.project.id)
        surface_fragment.fill_from_trait(session_stored_simulator.surface)

        rendering_rules = SimulatorFragmentRenderingRules(
            surface_fragment,
            SimulatorWizzardURLs.SET_SURFACE_URL,
            SimulatorWizzardURLs.SET_COUPLING_PARAMS_URL,
            is_simulation_copy,
            is_simulation_load,
            self.context.last_loaded_fragment_url,
            cherrypy.request.method,
            is_branch=is_branch)
        return rendering_rules.to_dict()
Пример #2
0
    def set_coupling_params(self, **data):
        session_stored_simulator = common.get_from_session(
            common.KEY_SIMULATOR_CONFIG)
        is_simulator_copy = common.get_from_session(
            common.KEY_IS_SIMULATOR_COPY)
        is_simulator_load = common.get_from_session(
            common.KEY_IS_SIMULATOR_LOAD)

        if cherrypy.request.method == 'POST':
            is_simulator_copy = False
            form = get_form_for_coupling(
                type(session_stored_simulator.coupling))()
            form.fill_from_post(data)
            form.fill_trait(session_stored_simulator.coupling)

        surface_fragment = SimulatorSurfaceFragment(
            '',
            common.get_current_project().id)
        surface_fragment.fill_from_trait(session_stored_simulator)

        dict_to_render = copy.deepcopy(self.dict_to_render)
        dict_to_render[self.FORM_KEY] = surface_fragment
        dict_to_render[self.ACTION_KEY] = '/burst/set_surface'
        dict_to_render[self.PREVIOUS_ACTION_KEY] = '/burst/set_coupling_params'
        dict_to_render[self.IS_COPY] = is_simulator_copy
        dict_to_render[self.IS_LOAD] = is_simulator_load
        return dict_to_render
Пример #3
0
    def set_connectivity(self, **data):
        session_stored_simulator, is_simulation_copy, is_simulation_load, _ = self.context.get_common_params(
        )

        if cherrypy.request.method == POST_REQUEST:
            self.context.add_last_loaded_form_url_to_session(
                SimulatorWizzardURLs.SET_COUPLING_PARAMS_URL)
            form = SimulatorAdapterForm()
            form.fill_from_post(data)
            self.simulator_service.reset_at_connectivity_change(
                is_simulation_copy, form, session_stored_simulator)
            form.fill_trait(session_stored_simulator)

        next_form = self.algorithm_service.prepare_adapter_form(
            form_instance=get_form_for_coupling(
                type(session_stored_simulator.coupling))())
        self.range_parameters.coupling_parameters = next_form.get_range_parameters(
        )
        next_form.fill_from_trait(session_stored_simulator.coupling)

        rendering_rules = SimulatorFragmentRenderingRules(
            next_form, SimulatorWizzardURLs.SET_COUPLING_PARAMS_URL,
            SimulatorWizzardURLs.SET_CONNECTIVITY_URL, is_simulation_copy,
            is_simulation_load, self.context.last_loaded_fragment_url,
            cherrypy.request.method)
        return rendering_rules.to_dict()
Пример #4
0
    def set_connectivity(self, **data):
        session_stored_simulator = common.get_from_session(
            common.KEY_SIMULATOR_CONFIG)
        is_simulator_copy = common.get_from_session(
            common.KEY_IS_SIMULATOR_COPY)
        is_simulator_load = common.get_from_session(
            common.KEY_IS_SIMULATOR_LOAD)
        form = SimulatorAdapterForm()

        if cherrypy.request.method == 'POST':
            is_simulator_copy = False
            form.fill_from_post(data)

            connectivity_index_gid = form.connectivity.value
            conduction_speed = form.conduction_speed.value
            coupling = form.coupling.value

            connectivity_index = ABCAdapter.load_entity_by_gid(
                connectivity_index_gid)
            connectivity = h5.load_from_index(connectivity_index)

            # TODO: handle this cases in a better manner
            session_stored_simulator.connectivity = connectivity
            session_stored_simulator.conduction_speed = conduction_speed
            session_stored_simulator.coupling = coupling()

        next_form = get_form_for_coupling(
            type(session_stored_simulator.coupling))()
        self.range_parameters.coupling_parameters = next_form.get_range_parameters(
        )
        next_form.fill_from_trait(session_stored_simulator.coupling)

        dict_to_render = copy.deepcopy(self.dict_to_render)
        dict_to_render[self.FORM_KEY] = next_form
        dict_to_render[self.ACTION_KEY] = '/burst/set_coupling_params'
        dict_to_render[self.PREVIOUS_ACTION_KEY] = '/burst/set_connectivity'
        dict_to_render[self.IS_COPY] = is_simulator_copy
        dict_to_render[self.IS_LOAD] = is_simulator_load
        return dict_to_render