Symbol

abb_rws_client_python_rw6.highlevel.symbol

High-level RAPID symbol introspection for ABB RWS RobotWare 6.

Author: Clement RACINET

Composed operations built exclusively from atomic rws/ functions. No HTTP calls are made directly in this module.

All functions are async and require an open RWSClient instance.

SymbolProperties dataclass

Parsed RAPID symbol properties from GET /rw/rapid/symbol/properties.

Parameters:
  • symbolurl (str) –

    Symbol URL, e.g. "RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools".

  • symtyp (str) –

    Symbol type, e.g. "per" (persistent), "var", "con".

  • dattyp (str) –

    RAPID data type name, e.g. "trajCenterTool".

  • ndim (int) –

    Number of array dimensions. 0 means a scalar symbol.

  • dim (tuple[int, ...]) –

    Array dimension sizes, one entry per dimension. Empty when ndim == 0.

  • local (bool) –

    False for a global module persistent.

  • readonly (bool) –

    True if the persistent is read-only.

Example
>>> props = SymbolProperties(
...     symbolurl="RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools",
...     symtyp="per",
...     dattyp="trajCenterTool",
...     ndim=1,
...     dim=(2,),
...     local=False,
...     readonly=False,
... )
>>> props.dim[0]
2
Source code in abb_rws_client_python_rw6/highlevel/symbol.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
@dataclass(frozen=True)
class SymbolProperties:
    """Parsed RAPID symbol properties from ``GET /rw/rapid/symbol/properties``.

    Args:
        symbolurl: Symbol URL, e.g. ``"RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools"``.
        symtyp: Symbol type, e.g. ``"per"`` (persistent), ``"var"``, ``"con"``.
        dattyp: RAPID data type name, e.g. ``"trajCenterTool"``.
        ndim: Number of array dimensions. ``0`` means a scalar symbol.
        dim: Array dimension sizes, one entry per dimension. Empty when
            ``ndim == 0``.
        local: ``False`` for a global module persistent.
        readonly: ``True`` if the persistent is read-only.

    Example:
        ```python
        >>> props = SymbolProperties(
        ...     symbolurl="RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools",
        ...     symtyp="per",
        ...     dattyp="trajCenterTool",
        ...     ndim=1,
        ...     dim=(2,),
        ...     local=False,
        ...     readonly=False,
        ... )
        >>> props.dim[0]
        2
        ```
    """

    symbolurl: str
    symtyp: str
    dattyp: str
    ndim: int
    dim: tuple[int, ...]
    local: bool
    readonly: bool

get_array_length(client, *, symbolurl, dimension=0) async

Read the size of one dimension of a RAPID array symbol.

Convenience wrapper over get_symbol_properties for the common case of discovering a one-based array's usable upper bound at runtime (e.g. trajTools{N} where N is cell-dependent).

Route (delegated): GET /rw/rapid/symbol/properties/{symbolurl}

ABB constraints
  • The symbol must be declared as an array (ndim >= 1).
  • RAPID arrays are one-based; the returned length is the number of valid indexes 1..length.
Parameters:
  • client (RWSClient) –

    Open RWSClient instance.

  • symbolurl (str) –

    Full RAPID symbol path of the array variable, e.g. "RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools".

  • dimension (int, default: 0 ) –

    Zero-based index into SymbolProperties.dim for multi-dimensional arrays. Defaults to 0 (first dimension).

Returns:
  • int –

    Size of the requested dimension.

Raises:
Example
async with RWSClient(host="192.168.125.1") as client:
    n = await get_array_length(
        client,
        symbolurl="RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools",
    )
    print("trajTools has", n, "entries")
Source code in abb_rws_client_python_rw6/highlevel/symbol.py
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
async def get_array_length(
    client: RWSClient,
    *,
    symbolurl: str,
    dimension: int = 0,
) -> int:
    """Read the size of one dimension of a RAPID array symbol.

    Convenience wrapper over ``get_symbol_properties`` for the common case
    of discovering a one-based array's usable upper bound at runtime
    (e.g. ``trajTools{N}`` where ``N`` is cell-dependent).

    Route (delegated): ``GET /rw/rapid/symbol/properties/{symbolurl}``

    ABB constraints:
        - The symbol must be declared as an array (``ndim >= 1``).
        - RAPID arrays are one-based; the returned length is the number of
          valid indexes ``1..length``.

    Args:
        client: Open ``RWSClient`` instance.
        symbolurl: Full RAPID symbol path of the array variable, e.g.
            ``"RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools"``.
        dimension: Zero-based index into ``SymbolProperties.dim`` for
            multi-dimensional arrays. Defaults to ``0`` (first dimension).

    Returns:
        Size of the requested dimension.

    Raises:
        RWSAuthenticationError: On HTTP 401.
        RWSNotFoundError: On HTTP 404.
        RWSHTTPError: On any other HTTP >= 400.
        ValueError: If the symbol is not an array (``ndim == 0``), or if
            ``dimension`` is out of range for the symbol's declared
            dimensions.

    Example:
        ```python
        async with RWSClient(host="192.168.125.1") as client:
            n = await get_array_length(
                client,
                symbolurl="RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools",
            )
            print("trajTools has", n, "entries")
        ```
    """
    props = await get_symbol_properties(client, symbolurl=symbolurl)

    if props.ndim == 0:
        raise ValueError(f"Symbol {symbolurl!r} is not an array (ndim=0)")

    if dimension < 0 or dimension >= len(props.dim):
        raise ValueError(
            f"dimension={dimension} out of range for symbol {symbolurl!r} with dim={props.dim!r}"
        )

    length = props.dim[dimension]
    logger.debug("Array %s dimension %d length = %d", symbolurl, dimension, length)
    return length

get_symbol_properties(client, *, symbolurl) async

Read and parse the properties of a RAPID symbol.

Wraps get_rapid_symbol_properties and parses the ABB XML response into a typed SymbolProperties.

Route (delegated): GET /rw/rapid/symbol/properties/{symbolurl}

ABB constraints
  • Not supported in bootserver mode.
  • No mastership required for reads.
Parameters:
  • client (RWSClient) –

    Open RWSClient instance.

  • symbolurl (str) –

    Full RAPID symbol path, e.g. "RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools".

Returns:
Raises:
Example
async with RWSClient(host="192.168.125.1") as client:
    props = await get_symbol_properties(
        client,
        symbolurl="RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools",
    )
    print(props.ndim, props.dim)
Source code in abb_rws_client_python_rw6/highlevel/symbol.py
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
async def get_symbol_properties(
    client: RWSClient,
    *,
    symbolurl: str,
) -> SymbolProperties:
    """Read and parse the properties of a RAPID symbol.

    Wraps ``get_rapid_symbol_properties`` and parses the ABB XML response
    into a typed ``SymbolProperties``.

    Route (delegated): ``GET /rw/rapid/symbol/properties/{symbolurl}``

    ABB constraints:
        - Not supported in bootserver mode.
        - No mastership required for reads.

    Args:
        client: Open ``RWSClient`` instance.
        symbolurl: Full RAPID symbol path, e.g.
            ``"RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools"``.

    Returns:
        Parsed symbol properties, including array dimensions.

    Raises:
        RWSAuthenticationError: On HTTP 401.
        RWSNotFoundError: On HTTP 404.
        RWSHTTPError: On any other HTTP >= 400.
        ValueError: If the response body cannot be parsed.

    Example:
        ```python
        async with RWSClient(host="192.168.125.1") as client:
            props = await get_symbol_properties(
                client,
                symbolurl="RAPID/T_ROB1/TRAJCENTER_CellConfig/trajTools",
            )
            print(props.ndim, props.dim)
        ```
    """
    response = await get_rapid_symbol_properties(client, symbolurl=symbolurl)
    return _parse_symbol_properties(response, symbolurl)