heros.capabilities¶
Classes¶
An attribute capability describes a single variable of the remote object. |
|
An event capability describes the ability of a remote object to notify upon a certain event. |
|
Functions¶
|
Transforms annotation given as types to strings. |
|
Build a capability object from a given member name and optional annotation to infer type. |
Module Contents¶
- heros.capabilities.type_to_str(annotation) str¶
Transforms annotation given as types to strings.
- Parameters:
annotation – The typing annotation.
- Returns:
Annotation as string.
- heros.capabilities.build_capability(hero_obj: heros.heros.LocalHERO, member_name: str, annotation: None | str = None) Capability | Literal[False]¶
Build a capability object from a given member name and optional annotation to infer type.
If no annotation is given the signature is inferred from the member itself by calling getattr. For callables (e.g. methods) this needs to be done, as the full signature is not inferable from the type annotation.
- Parameters:
hero_obj – host HERO object
member_name – name of the attribute/method to build as capability
annotation – optional annotation to infer signature.
- Returns:
Capabilityobject for the given member, False if no signature can be inferred from the given input.
- class heros.capabilities.Parameter¶
- name: str¶
- type: str¶
- default: str¶
- kind: inspect._ParameterKind¶
- static from_signature_parameter(p: inspect.Parameter)¶
- has_default()¶
- to_dict()¶
- static from_dict(d: dict, proto_version: float = __proto_version__)¶
- class heros.capabilities.Capability¶
- name: str¶
- flavor: ClassVar[str] = 'undefined'¶
- to_dict() dict¶
- static from_dict(d: dict, proto_version: float = __proto_version__)¶
- get_call_wrapper(hero_obj: heros.heros.LocalHERO) Callable[[zenoh.Query], None] | Literal[False]¶
Construct a callback wrapper function for the Zenoh endpoint.
- Returns:
A wrapper function which takes exactly one input, the
zenoh.Queryobject or False if the capability does not need a wrapper function.
- class heros.capabilities.AttributeCapability¶
Bases:
CapabilityAn attribute capability describes a single variable of the remote object. It is exposed under the name of the capability.
- Parameters:
name – name of the capability
type – data type. E.g. “str”, “int”, “float”, “list”, …
access – Read and/or write access. “r” for read, “w” for write, and “rw” for both
- flavor: ClassVar[str] = 'attribute'¶
- type: str¶
- access: str = 'rw'¶
- to_dict() dict¶
- static from_dict(d: dict, proto_version: float = __proto_version__) AttributeCapability¶
- get_call_wrapper(hero_obj: heros.heros.LocalHERO) Callable[[zenoh.Query], None]¶
Construct a callback wrapper function for the Zenoh endpoint.
- Returns:
A wrapper function which takes exactly one input, the
zenoh.Queryobject or False if the capability does not need a wrapper function.
- class heros.capabilities.EventCapability¶
Bases:
CapabilityAn event capability describes the ability of a remote object to notify upon a certain event.
- flavor: ClassVar[str] = 'event'¶
- static from_dict(d: dict, proto_version: float = __proto_version__) EventCapability¶
- class heros.capabilities.MethodCapability¶
Bases:
Capability- flavor: ClassVar[str] = 'method'¶
- return_type: str = 'None'¶
- static from_method(m: Callable, name: str | None = None) MethodCapability¶
- to_signature() inspect.Signature¶
- to_dict() dict¶
- get_call_wrapper(hero_obj: heros.heros.LocalHERO) Callable[[zenoh.Query], None]¶
Construct a callback wrapper function for the Zenoh endpoint.
- Returns:
A wrapper function which takes exactly one input, the
zenoh.Queryobject or False if the capability does not need a wrapper function.
- static from_dict(d: dict, proto_version: float = __proto_version__) MethodCapability¶
Generate a method capabilities object from a defining dictionary.
Args: definition of the capability according to the standard
- call_dict(*args, **kwargs) dict¶
This returns a dict that assigns the given parameter to the parameters of ourself. It takes care that positional and keyword arguments are handled correctly
Note
This function is deprecated and will be removed together with the transport protocol version 0.1
- Parameters:
*args – positional arguments
**kwargs – keyword arguments
- Returns:
dict with parameter assignments
- Return type:
dict