================================================ How to implement a dynamic attribute from signal ================================================ :ref:`how-to-event-driven` describes how to use :class:`.attribute_from_signal` to implement an event driven Tango device with a static set of attributes using a static set of signals. The signal bus mechanism also supports a more dynamically generated signal names and working with dynamic attributes. When using dynamic signal names, we cannot use the signal data descriptors and must use :meth:`.BusProtocol.emit` ourselves. Dynamic attributes can be used with signal data descriptors, provided the signal name is known statically. For example, the following device dynamically adds an attribute using a random signal name which is updated randomly every time the :func:`!MyCmd` command is called: .. code :: python class MyDevice(stb.software_bus.SignalBusMixin, stb.SKADevice): def init_device(self) -> None: super().init_device() self.signal = randomise_signal_name() self.add_attribute( stb.software_bus.attribute_from_signal( self.signal, name="myDynAttr", dtype=int ) ) @tango.server.command def MyCmd(self) -> None: self.shared_bus.emit(self.signal, randomise_value())