Skip to content

hololinked.td.interaction_affordance.PropertyAffordance

Bases: DataSchema, InteractionAffordance

Implements property affordance schema from Property descriptor object.

Schema
UML Diagram

Source code in hololinked/hololinked/td/interaction_affordance.py
class PropertyAffordance(DataSchema, InteractionAffordance):
    """
    Implements property affordance schema from `Property` descriptor object.

    [Schema](https://www.w3.org/TR/wot-thing-description11/#propertyaffordance) <br>
    [UML Diagram](https://docs.hololinked.dev/UML/PDF/InteractionAffordance.pdf) <br>
    """

    # [Supported Fields]() <br>
    observable: Optional[bool] = None

    def __init__(self):
        super().__init__()

    @property
    def what(self) -> Enum:
        return ResourceTypes.PROPERTY

    def build(self) -> None:
        property = self.objekt
        self.ds_build_from_property(property)
        if property.observable:
            self.observable = property.observable

    @classmethod
    def generate(cls, property, owner=None):
        if not isinstance(property, Property):
            raise TypeError(f"property must be instance of Property, given type {type(property)}")
        affordance = PropertyAffordance()
        affordance.owner = owner
        affordance.objekt = property
        affordance.build()
        affordance.build_non_compliant_metadata()
        return affordance

TD Supported Fields

Apart from the fields supported InteractionAffordance and DataSchema, the following is supported

field supported meaning default usage
observable ✔️ true if Property pushes change events Property.observable value