def setUp(self): core = Core(None, use_gui=False) core.gui_process = dummyProcess() core.gui_alive = True self.core_thread = Thread(target=core.run) self.core_thread.start() self.gui_data = DGui() # self.gui_api = Gui_api(self.gui_data, core.core_event_queue, core.gui_id) self.gui_thread = Thread(target=startGUI_TESTMOCK, args=[ core.core_event_queue, core.gui_event_queue, core.gui_id, self.gui_data ]) self.gui_thread.start() # get data and queues self.core_queue = core.core_event_queue self.gui_queue = core.gui_event_queue self.core_data = core.core_data self.gui_api = Gui_api(self.gui_data, self.core_queue, core.gui_id) time.sleep(1)
def __init__(self, core_queue, gui_queue, gui_id, TabManager, get_gui_config, set_gui_config): self.core_queue = core_queue self.gui_queue = gui_queue self.gui_data = DGui() self.gui_id = gui_id self.tab_manager = TabManager self.plugin_manager = PluginManager() self.plugin_manager.setPluginPlaces(PLUGIN_ROOT_FOLDER_LIST) self.plugin_manager.collectPlugins() self.gui_api = Gui_api(self.gui_data, self.core_queue, self.gui_id, get_gui_config_function=get_gui_config, set_gui_config_function= set_gui_config, plugin_manager=self.plugin_manager ) self.gui_event_processing = GuiEventProcessing(self.gui_data, self.core_queue, self.gui_id, self.gui_queue, self.tab_manager, self.plugin_manager )
def __init__(self, gui_data, core_queue, gui_id, PLUGIN_API_IDENTIFIER, tabManager = None): super(Plugin_api, self).__init__() self.__default_api = Gui_api(gui_data, core_queue, gui_id, PLUGIN_API_IDENTIFIER, TabManager=tabManager)
class Plugin_api(QtCore.QObject): # resize_gui = QtCore.Signal(int, int) def __init__(self, gui_data, core_queue, gui_id, PLUGIN_API_IDENTIFIER, tabManager = None): super(Plugin_api, self).__init__() self.__default_api = Gui_api(gui_data, core_queue, gui_id, PLUGIN_API_IDENTIFIER, TabManager=tabManager) def do_create_plugin(self, plugin_identifier, uname, config={}, autostart = True): """ Something like a callback function for gui triggered events e.a. when a user wants to create a new plugin. :param plugin_identifier: plugin to create :type plugin_identifier: basestring :param uname: uniqe name to set for new plugin :type uname: basestring :param config: additional configuration for creation :type config: :return: """ self.__default_api.do_create_plugin(plugin_identifier,uname,config,autostart) def do_subscribe_uname(self,subscriber_uname,source_uname,block_name, signals=None, sub_alias = None): """ Something like a callback function for gui triggered events. In this case, user wants one plugin to subscribe another :param subscriber_uname: Plugin uname of plugin which should get the data :type subscriber_uname: basestring :param source_uname: plugin uname of plugin that should send the data :type source_uname: basestring :param block_name: name of block to subscribe :type block_name: basestring :return: """ self.__default_api.do_subscribe_uname(subscriber_uname, source_uname, block_name, signals, sub_alias) def do_set_parameter_uname(self, plugin_uname, parameter_name, value): """ Something like a callback function for gui triggered events. User wants to change a parameter of a plugin :param plugin_uname: name of plugin which owns the parameter :type plugin_uname: basestring :param parameter_name: name of parameter to change :type parameter_name: basestring :param value: new parameter value to set :type value: """ self.__default_api.do_set_parameter_uname(plugin_uname, parameter_name, value) def do_load_xml(self, path): self.__default_api.do_load_xml(path) def do_delete_plugin_uname(self, uname): """ Delete plugin with given uname. :param uname: Plugin uname to delete :type uname: basestring :return: """ self.__default_api.do_delete_plugin_uname(uname) def do_set_parameter(self, plugin_id, parameter_name, value): """ Something like a callback function for gui triggered events. User wants to change a parameter of a plugin :param plugin_id: id of plugin which owns the parameter :type plugin_id: int :param parameter_name: name of parameter to change :type parameter_name: basestring :param value: new parameter value to set :type value: """ self.__default_api.do_set_parameter(plugin_id,parameter_name,value) def do_update_parameter(self, plugin_id, parameter_name, value): """ Something like a callback function for gui triggered events. User wants to update a parameter in the gui. Used by a owner of a plugin to inform the gui that a parameter was internally changed. :param plugin_id: id of plugin which owns the parameter :type plugin_id: int :param parameter_name: name of parameter to change :type parameter_name: basestring :param value: new parameter value to set :type value: """ self.__default_api.do_set_parameter(plugin_id,parameter_name,value, only_db_update=True) def do_resume_plugin_by_uname(self, plugin_uname): """ Something like a callback function for gui triggered events. User wants to resume a plugin, so this method will send an event to core. :param plugin_uname: uname of plugin to resume :type plugin_uname: basestring """ self.__default_api.do_resume_plugin_by_uname(plugin_uname) def do_pause_plugin_by_uname(self, plugin_uname): """ Something like a callback function for gui triggered events. User wants to pause a plugin, so this method will send an event to core. :param plugin_uname: uname of plugin to pause :type plugin_uname: basestring """ self.__default_api.do_pause_plugin_by_uname(plugin_uname) def do_set_tab_active_by_name(self, tabName): self.__default_api.do_set_tab_active_by_name(tabName) def get_all_plugins(self): return self.__default_api.gui_data.get_all_plugins() def get_dplugin_by_uname(self, name): return self.__default_api.gui_data.get_dplugin_by_uname(name) def get_dparameter_of_plugin_from_data(self, plugin_uname): if plugin_uname is not None and plugin_uname != '': dplugin = self.__default_api.gui_data.get_dplugin_by_uname(plugin_uname) if dplugin is not None: return dplugin.get_parameters() return None def do_change_string_to_be_uname(self, name): return self.__default_api.do_change_string_to_be_uname(name) def change_uname_to_uniqe(self, name): return self.__default_api.change_uname_to_uniqe(name) def do_test_name_to_be_unique(self, name): return self.__default_api.do_test_name_to_be_unique(name)