def do_unsubscribe(self, subscriber_id, source_id, block_name, signal_index=None): """ Something like a callback function for gui triggered events. User wants one plugin to do not get any more data from another plugin :param subscriber_id: plugin id which wants to lose a data source :type subscriber_id: int :param source_id: plugin id of data source :type source_id: int :param block_name: name of block to unsubscribe :type block_name: basestring :return: """ # create optional data with source id and block_name opt = DOptionalData() opt.source_ID = source_id opt.block_name = block_name opt.signals = signal_index # sent event to Core with origin subscriber_id event = Event.instruction.Unsubscribe(subscriber_id, 0, opt) self.core_queue.put(event)
def do_subscribe(self, subscriber_id, source_id, 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_id: Plugin id of plugin which should get the data :type subscriber_id: int :param source_id: plugin uname of plugin that should send the data :type source_id: int :param block_name: name of block to subscribe :type block_name: basestring :return: """ # build optional data object and add id and block name to it opt = DOptionalData() opt.source_ID = source_id opt.block_name = block_name opt.signals = signals opt.subscription_alias = sub_alias # send event with subscriber id as the origin to CORE event = Event.instruction.Subscribe(subscriber_id, 0, opt) self.core_queue.put(event)
def _send_parameter_change(self, data, block): """ Internal function, should be not directly used anymore. :param data: :param block: :return: """ opt = DOptionalData(DATA=data) opt.data_source_id = self.__id__ opt.is_parameter = True if isinstance(block, DBlock) is False and isinstance(block, str) is False: raise pe.WrongType("block", [DBlock, str]) if isinstance(block, DBlock): opt.block_name = block.name if isinstance(block, str): opt.block_name = block event = Event.data.NewData(self.__id__, 0, opt, None) self._Core_event_queue__.put(event)
def do_set_parameter(self, plugin_id, parameter_name, value, only_db_update=False): """ 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: :param only_db_update: do_set_parameter of the target plugin will not be called. Updates only the internal database. :type boolean: """ # get plugin from DGUI dplug = self.gui_data.get_dplugin_by_id(plugin_id) # check for existance if dplug is not None: # it exists # get its parameter list parameters = dplug.get_parameters() # check if there are any parameter if parameters is not None: # there is a parameter list # get the parameter with parameter_name if parameter_name in parameters: p = parameters[parameter_name] # check if this specific parameter exists if p is not None: # parameter with name parameter_name exists # build an event to send this information to Core opt = DOptionalData() opt.data = value opt.is_parameter = True opt.parameter_alias = parameter_name opt.block_name = None if only_db_update: e = Event.instruction.UpdateParameter( self.gui_id, dplug.id, opt) else: e = Event.instruction.SetParameter( self.gui_id, dplug.id, opt) self.core_queue.put(e)
def do_set_parameter(self, plugin_id, parameter_name, value, only_db_update = False): """ 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: :param only_db_update: do_set_parameter of the target plugin will not be called. Updates only the internal database. :type boolean: """ # get plugin from DGUI dplug = self.gui_data.get_dplugin_by_id(plugin_id) # check for existance if dplug is not None: # it exists # get its parameter list parameters = dplug.get_parameters() # check if there are any parameter if parameters is not None: # there is a parameter list # get the parameter with parameter_name if parameter_name in parameters: p = parameters[parameter_name] # check if this specific parameter exists if p is not None: # parameter with name parameter_name exists # build an event to send this information to Core opt = DOptionalData() opt.data = value opt.is_parameter = True opt.parameter_alias = parameter_name opt.block_name = None if only_db_update: e = Event.instruction.UpdateParameter(self.gui_id, dplug.id, opt) else: e = Event.instruction.SetParameter(self.gui_id, dplug.id, opt) self.core_queue.put(e)
def pl_send_new_data(self, block_name, time_line, data): """ This function is called by plugins to send new data for a single block. :param block_name: Name of the block :param time_line: A time vector :param data: Data containing the values in a hash array of signal names as key. :return: """ if not isinstance(time_line, list): raise pe.WrongType("time", list) if not isinstance(data, dict): raise pe.WrongType("data", dict) dataHash = data dataHash[CORE_TIME_SIGNAL] = time_line opt = DOptionalData(DATA=dataHash) opt.data_source_id = self.__id__ opt.block_name = block_name event = Event.data.NewData(self.__id__, 0, opt, None) self._Core_event_queue__.put(event)
def pl_send_new_data(self, block_name, time_line, data): """ This function is called by plugins to send new data for a single block. :param block_name: Name of the block :param time_line: A time vector :param data: Data containing the values in a hash array of signal names as key. :return: """ if not isinstance(time_line, list): raise pe.WrongType("time", list) if not isinstance(data, dict): raise pe.WrongType("data", dict) dataHash = data dataHash[CORE_TIME_SIGNAL] = time_line opt = DOptionalData(DATA = dataHash) opt.data_source_id = self.__id__ opt.block_name = block_name event = Event.data.NewData(self.__id__, 0, opt, None) self._Core_event_queue__.put(event)
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: """ # id = self.do_get_plugin_id_from_uname(plugin_uname) # if id is not None: # self.do_set_parameter(id, parameter_name, value) # print(parameter_name, value) opt = DOptionalData() opt.data = value opt.is_parameter = True opt.parameter_alias = parameter_name opt.block_name = None e = Event.instruction.SetParameterByUname(self.gui_id,plugin_uname, opt) self.core_queue.put(e)
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: """ # id = self.do_get_plugin_id_from_uname(plugin_uname) # if id is not None: # self.do_set_parameter(id, parameter_name, value) # print(parameter_name, value) opt = DOptionalData() opt.data = value opt.is_parameter = True opt.parameter_alias = parameter_name opt.block_name = None e = Event.instruction.SetParameterByUname(self.gui_id, plugin_uname, opt) self.core_queue.put(e)