Ejemplo n.º 1
0
 def subscribe(self, form, callback):
     """
     Tango event subscription.
     The 'form' argument is an instance of TangoEventSubscriptionForm
     Throws in case of error
     """
     dev_proxy = DeviceProxy(form.dev)
     fq_attr_name = event_source_str("{}/{}".format(dev_proxy.dev_name(),
                                                    form.attr))
     if (fq_attr_name, form.evt_type) in self._subscriptions:
         try:
             self.unsubscribe(fq_attr_name, form.evt_type)
         except Exception as e:
             self.logger.error(e)
             raise
     tango_evt = TangoEventInfo(
         attr=form.attr,
         dev_proxy=dev_proxy,
         evt_type=form.evt_type,
         message_id=form.message_id,
         user_data=form.user_data,
     )
     pre_subscription_action(form, dev_proxy)
     self._subscriptions[(fq_attr_name, form.evt_type)] = tango_evt
     try:
         tango_evt.subscribe(callback)
     except:
         del self._subscriptions[(fq_attr_name, form.evt_type)]
         raise
Ejemplo n.º 2
0
 def get_device_commands(self, with_context=True):
     """ Get device proxy commands"""
     ### TBD - Why use DeviceProxy?
     ### Can this not be known through self which is a Device
     commands = []
     device_proxy = DeviceProxy(self.get_name())
     cmd_config_list = device_proxy.command_list_query()
     for device_cmd_config in cmd_config_list:
         commands.append(get_dp_command(
             device_proxy.dev_name(), device_cmd_config, with_context))
     return commands