tiqi-group / pydase

A flexible and robust Python library for creating, managing, and interacting with data services, with built-in support for web and RPC servers, and customizable features for diverse use cases.
MIT License
0 stars 1 forks source link

Optionally call getter after setter #85

Closed marti-m closed 1 month ago

marti-m commented 6 months ago

With certain devices it would be nice to call the getter after the setter. A decorator to indicate which setters should call the getter afterwards would be nice.

mosmuell commented 1 month ago

Something like this should do:

import pydase
from pydase.utils.decorators import validate_set

class Service(pydase.DataService):
    def __init__(self) -> None:
        super().__init__()
        self._value = 0.0

    @property
    def value(self) -> float:
        return self._value

    @value.setter
    @validate_set(timeout=0.2, precision=1e-3)
    def value(self, value: float) -> None:
        self._value = value