pyh0n/pyhon/parameter/fixed.py

28 lines
843 B
Python
Raw Normal View History

2023-04-24 08:03:00 +05:30
from typing import Dict, Any
2023-04-16 05:13:37 +05:30
from pyhon.parameter.base import HonParameter
class HonParameterFixed(HonParameter):
2023-05-06 19:37:28 +05:30
def __init__(self, key: str, attributes: Dict[str, Any], group: str) -> None:
super().__init__(key, attributes, group)
2023-07-12 23:06:32 +05:30
self._value: str | float = ""
2023-07-12 03:35:27 +05:30
self._set_attributes()
2023-07-12 23:06:32 +05:30
def _set_attributes(self) -> None:
2023-07-12 03:35:27 +05:30
super()._set_attributes()
2023-07-12 23:06:32 +05:30
self._value = self._attributes.get("fixedValue", "")
2023-04-16 05:13:37 +05:30
def __repr__(self) -> str:
return f"{self.__class__} (<{self.key}> fixed)"
@property
def value(self) -> str | float:
return self._value if self._value is not None else "0"
@value.setter
2023-04-16 06:14:20 +05:30
def value(self, value: str | float) -> None:
# Fixed values seems being not so fixed as thought
self._value = value
2023-05-21 05:55:43 +05:30
self.check_trigger(value)