Skip to content

Device inheritance

Vincent Michel requested to merge github/fork/vxgmichel/device-inheritance into master

Hi Tiago,

A last PR to discuss device inheritance. I've been using this code in production for quite some time and it's been working fine so far. Usage:

class Parent(Device):
    __metaclass__ = DeviceMeta

    prop = device_property(dtype=str)

    attr = attribute(dtype=int)

    @command
    def cmd(self):
        pass

class Child(Parent):
    __metaclass__ = DeviceMeta

    # Child will have a 'prop' device property

    # Override 'attr'
    attr = attribute(dtype=float)

    # Remove 'cmd' from the command list
    cmd = None

However, it might need some refactoring:

  • is_tango_object could have a cleaner implementation if command was a type.
  • inheritance_patch prevents __patch_read_method to patch the read method multiple times, but it's a dirty workaround.

Thanks

Merge request reports