class ophyd.device.FormattedComponent(cls, suffix=None, *, lazy=False, trigger_value=None, add_prefix=None, doc=None, kind=<Kind.normal: 1>, **kwargs)

A Component which takes a dynamic format string

This differs from Component in that the parent prefix is not automatically added onto the Component suffix. Additionally, str.format() style strings are accepted, allowing access to Device instance attributes:

>>> from ophyd import (Component as Cpt, FormattedComponent as FCpt)
>>> class MyDevice(Device):
...     # A normal component, where 'suffix' is added to prefix verbatim
...     cpt = Cpt(EpicsSignal, 'suffix')
...     # A formatted component, where 'self' refers to the Device instance
...     ch = FCpt(EpicsSignal, '{self.prefix}{self._ch_name}')
...     # A formatted component, where 'self' is assumed
...     ch = FCpt(EpicsSignal, '{prefix}{_ch_name}')
...     def __init__(self, prefix, ch_name=None, **kwargs):
...         self._ch_name = ch_name
...         super().__init__(prefix, **kwargs)
>>> dev = MyDevice('prefix:', ch_name='some_channel', name='dev')
>>> print(dev.cpt.pvname)
>>> print(dev.ch.pvname)

For additional documentation, refer to Component.

__init__(self, cls, suffix=None, *, lazy=False, trigger_value=None, add_prefix=None, doc=None, kind=<Kind.normal: 1>, **kwargs)


__init__(self, cls[, suffix, lazy, …])
create_component(self, instance) Instantiate the object described by this Component for a Device
make_docstring(self, parent_class) Create a docstring for the Component
maybe_add_prefix(self, instance, kw, suffix)
sub_default(self, func) Default subscription decorator
sub_meta(self, func) Metadata subscription decorator
sub_value(self, func) Value subscription decorator
subscriptions(self, event_type) (Decorator) Specify subscriptions callbacks in the Device definition