class documentation
class UaVariable(UaObject, ParentMixin[
Constructor: UaVariable(initial_value, unit, range, minimum_access_level, ...)
OPC UA Variable for use in ParameterSet, Monitoring, FinalResultData, etc.
Abstracts raw OPC UA/asyncua away and provides a simple, high-level interface.
| Method | __init__ |
Cooperative constructor for a new variable instance. |
| Async Method | add |
Add a reference to the given target UaObject, i.e. a Resource. |
| Method | check |
Check whether the given value is within the range. |
| Method | clone |
Clone the variable configuration. It must be initialized before using it. |
| Method | initial |
Undocumented |
| Async Method | read |
Read current value from variable. |
| Async Method | read |
Read current value from variable. Might be None. |
| Async Method | remove |
Remove the existing reference to the given target UaObject. |
| Async Method | reset |
Reset variable to initial value. |
| Async Method | set |
Set the variable to historize. |
| Async Method | set |
Set the variable to writable externally. Internally, a variable is always writable. |
| Async Method | write |
Write given value to this variable. |
| Method | write |
Check whether given value can be written to this variable. |
| Instance Variable | optional |
Undocumented |
| Instance Variable | ua |
Undocumented |
| Property | initial |
Initial value of the variable. |
| Method | _extract |
Undocumented |
| Async Method | _get |
Undocumented |
| Async Method | _init |
Undocumented |
| Method | _repr |
Undocumented |
| Async Method | _ua |
Undocumented |
| Async Method | _ua |
Undocumented |
| Instance Variable | _historize |
Undocumented |
| Instance Variable | _initial |
Undocumented |
| Instance Variable | _initial |
Undocumented |
| Instance Variable | _range |
Undocumented |
| Instance Variable | _references |
Undocumented |
| Instance Variable | _unit |
Undocumented |
| Instance Variable | _variant |
Undocumented |
| Instance Variable | _writable |
Undocumented |
def __init__(self, initial_value:
_VariableType | None, *, unit: Unit | str | int | ua.EUInformation | None = None, range: tuple[ float | int, float | int] | ua.Range | None = None, minimum_access_level: int | None = None, writable: bool = False, historize: bool = False, bypass_lock: bool = False, variable_type: type[ _VariableType] | None = None, optional_ok: bool = False, name: str | None = None, **kwargs):
¶
Cooperative constructor for a new variable instance.
| Parameters | |
initial_VariableType | None | The initial value of the variable. This should not be None for both correct type hints and correctly guessed OPC UA data type of the corresponding OPC UA variable node. |
unit:Unit | str | int | ua.EUInformation | None | The engineering unit of the variable. Can either be an Unit, an integer
(= OPC UA ua.EUInformation.UnitId, e.g. 4410708), or a string (symbol = OPC UA display name, e.g. "cm").
If provided, the range range_ parameter is mandatory! |
range:tuple[ | Tuple containing the minimum and maximum values of the variable. |
minimumint | None | Minimum access level required to write to the variable (externally via OPC UA). |
writable:bool | Whether the variable is writable externally or not. Always writable internally. |
historize:bool | Whether to keep a history of past values of this variable. |
bypassbool | Whether the variable can be written to without ownership of corresponding lock. |
variabletype[ | The Python type of the variable. Is only required if type cannot be determined from initial_value, i.e. when None is provided. |
optionalbool | Undocumented |
name:str | None | Undocumented |
| **kwargs | Undocumented |
Check whether the given value is within the range.
| Returns | |
bool | True if the given value is within the range (or there is no range specified), False otherwise. |
Clone the variable configuration. It must be initialized before using it.
| Parameters | |
name:str | The name of the variable. |
writable:bool | None | Override writable configuration in clone if not None. |
| Returns | |
UaVariable[ | Undocumented |
Read current value from variable.
| Raises | |
PyUaRuntimeError | If reading an UaObject based variable type would result in None due to
Null Node ID. |
async def set_historize(self, historize: days=7), count:
bool, *, period: timedelta = timedelta(int = 1000):
¶
Set the variable to historize.
| Parameters | |
historize:bool | Whether the variable should be historized or not. The other parameters are ignored when False. |
period:timedelta | data older than this will be deleted from the history. By default, keep the last 7 days. |
count:int | max. number of value changes to keep in the history. 0 = no count limit |
Write given value to this variable.
Note: None is only valid for a small set of variable types:
str and UaObject based (internally OPC UA nodes)
| Raises | |
OutOfRangeError | if value is not within the range of the variable. |
Check whether given value can be written to this variable.
| Raises | |
OutOfRangeError | if value is not within the range of the variable. |