class documentation

class ROS2ServiceMethod(ROS2ContainerMixin, ParentMixin[BaseMachineryItem], FinalResultDataMixin, ParameterSetMixin, BaseMethod):

Constructor: ROS2ServiceMethod(binding, runtime, context, minimum_access_level)

View In Hierarchy

The Method one ~opensmi.ros2.server.bindings.MethodBinding becomes.

Constructed by the declaring Component. A declaration may name a subclass of this class to add behaviour; the subclass is checked when the declaration is read.

Method __init__ Resolve everything about the declaration that can be wrong, before any node exists.
Async Method build_request Return the request message to send, given what a client wrote into the Parameters.
Async Method execute_method Call the service and write what answered.
Async Method read_parameters Return what the ParameterSet holds now, by variable name.
Async Method read_response Return the FinalResultData values one response message carries, by variable name.
Async Method read_results Return what the FinalResultData holds now, by variable name.
Class Variable callable_kind Undocumented
Property binding Return the declaration this Method was built from.
Property service_types Return the request and response types of the service this Method is bound to.
Async Method _call_the_service Send one request, turning the two transport failures into UA status codes.
Async Method _init Let opensmi register the Call, create the variables, and prove the defaults can be sent.
Method _require_the_service_agreed Refuse a call the service answered with no, if the declaration named the field.
Instance Variable _binding Undocumented
Instance Variable _parameters Undocumented
Instance Variable _request_context Undocumented
Instance Variable _request_plan Undocumented
Instance Variable _response_context Undocumented
Instance Variable _response_plan Undocumented
Instance Variable _results Undocumented
Instance Variable _runtime Undocumented
Instance Variable _types Undocumented
def __init__(self, *, binding: MethodBinding, runtime: RuntimeInterface, context: ProjectionContext, minimum_access_level: int = SKILL_ACCESS_LEVEL):

Resolve everything about the declaration that can be wrong, before any node exists.

A missing interface package, a pattern that matches nothing, a request that cannot be built backwards or a bad success_field fails here instead of on the first Call.

Parameters
binding:MethodBindingWhat to build.
runtime:RuntimeInterfaceWhere the request is sent. The Machine's, reached through the Component.
context:ProjectionContextThe Projection context of the Component, with nothing selected yet. The Method narrows it once per surface (request, response).
minimum_access_level:intThe level a caller needs.
Raises
MessageTypeErrorWhen the service type cannot be resolved.
FieldSelectionErrorWhen a selection pattern matches nothing.
NotInvertibleErrorWhen the request type reaches a Projection that cannot run backwards.
SuccessFieldErrorWhen success_field names a field the response does not have, or one that is not a bool.
async def build_request(self, values: Mapping[str, object]) -> Message:

Return the request message to send, given what a client wrote into the Parameters.

Override on a custom class when building the request needs the instance. The declaration's request_from is the pure-function form, and default_request_from is the default. An override must also work with the declaration's defaults, because _init calls it once with them. A Parameter a subclass adds after super()._init() does not exist yet at that point, so an override reading it must tolerate its absence.

async def execute_method(self):

Call the service and write what answered.

opensmi's only hook, called after the access level, Lock and startup checks.

Raises
UaStatusCodeErrorThe code TRANSPORT_STATUS gives a transport failure, or REFUSED_BY_THE_SERVICE when the success_field came back False (after the response has been written).
async def read_parameters(self) -> Mapping[str, object]:

Return what the ParameterSet holds now, by variable name.

async def read_response(self, response: Message) -> Mapping[str, object]:

Return the FinalResultData values one response message carries, by variable name.

Overridable like build_request; the declaration's response_to is the pure-function form and default_response_to the default.

async def read_results(self) -> Mapping[str, object]:

Return what the FinalResultData holds now, by variable name.

callable_kind: ClassVar[str] =

Undocumented

@property
binding: MethodBinding =

Return the declaration this Method was built from.

@property
service_types: ServiceTypes =

Return the request and response types of the service this Method is bound to.

async def _call_the_service(self, request: Message) -> Message:

Send one request, turning the two transport failures into UA status codes.

async def _init(self):

Let opensmi register the Call, create the variables, and prove the defaults can be sent.

Building a request from the initial Parameters must work, so a value ROS2 would abort on fails here, on the machine of whoever wrote the declaration.

def _require_the_service_agreed(self, response: Message):

Refuse a call the service answered with no, if the declaration named the field.

Read off the response message, not FinalResultData, so a selection that hides the field does not hide the refusal.

Raises
UaStatusCodeErrorWhen the named field came back False.
_binding =

Undocumented

_parameters =

Undocumented

_request_context =

Undocumented

_request_plan =

Undocumented

_response_context =

Undocumented

_response_plan =

Undocumented

_results =

Undocumented

_runtime =

Undocumented

_types: ServiceTypes =

Undocumented