pyhOn/pyhon/parameter/fixed.py

28 lines
837 B
Python
Raw Normal View History

2023-04-23 20:33:00 -06:00
from typing import Dict, Any
2023-04-15 17:43:37 -06:00
from pyhon.parameter.base import HonParameter
class HonParameterFixed(HonParameter):
2023-05-06 08:07:28 -06:00
def __init__(self, key: str, attributes: Dict[str, Any], group: str) -> None:
super().__init__(key, attributes, group)
2023-07-12 11:36:32 -06:00
self._value: str | float = ""
2023-07-11 16:05:27 -06:00
self._set_attributes()
2023-07-12 11:36:32 -06:00
def _set_attributes(self) -> None:
2023-07-11 16:05:27 -06:00
super()._set_attributes()
2023-07-12 11:36:32 -06:00
self._value = self._attributes.get("fixedValue", "")
2023-04-15 17:43:37 -06:00
def __repr__(self) -> str:
return f"{self.__class__} (<{self.key}> fixed)"
@property
def value(self) -> str | float:
2023-10-05 17:28:47 -06:00
return self._value if self._value != "" else "0"
2023-04-15 17:43:37 -06:00
@value.setter
2023-04-15 18:44:20 -06:00
def value(self, value: str | float) -> None:
# Fixed values seems being not so fixed as thought
self._value = value
2023-05-20 18:25:43 -06:00
self.check_trigger(value)