pycertifspec.ArrayVar #
ArrayVar Objects #
class ArrayVar(Var, collections.MutableSequence)
Represents a SPEC array and behaves like a regular python list. Values assigned to array indices will be pushed to SPEC.
The connection to SPEC decreases performance since the array gets fetched every time it is accessed. Therefore, for expensive computations, store the .value to a different variable and use that.
You usually don’t need to instantiate this class since it is easier to just use client.var(...) which will automatically detect the variable type and return a Var or ArrayVar accordingly.
shape #
| @property
| shape() -> Tuple[int]
Shape of the array like in numpy
is_2d #
| @property
| is_2d() -> bool
True if 2D array
pycertifspec.Var #
Var Objects #
class Var()
Represents a var/property.
You usually don’t need to instantiate this class since it is easier to just use client.var(...) which will automatically detect the variable type and return a Var or ArrayVar accordingly.
__init__ #
| __init__(name: str, conn: Client, dtype: Type = str)
Create a variable object.
Arguments:
namestr - The name of the variableconnClient - An instance of Client connected to SPECdtypeType - The datatype of the variable (Only if not array)
value #
| @property
| value() -> Union[str, Exception, dict, np.ndarray]
The value of the variable
subscribe #
| subscribe(callback: Callable, nowait: bool = False, timeout: float = 1.0) -> bool
Subscribe to changes in the value.
Arguments:
callbackfunction - The function to be called when the event is receivednowaitboolean - By default the function waits for the first event after registering to see if an error occurred. To skip that set Truetimeoutfloat - The timeout to wait for a response after subscribing. Function returns False when it runs out
Returns:
True if successful, False when an error occurred or timeout reached
unsubscribe #
| unsubscribe(callback: Callable) -> bool
Unsubscribe from changes.
Arguments:
callbackfunction - The callback function
Returns:
(boolean)- True if the callback was removed, False if it didn’t exist anyways