[openrtm-users 01607] Re: knowing the LifeCycleState of service provider

Ando Noriaki n-ando @ aist.go.jp
2011年 2月 24日 (木) 22:27:10 JST


Dear Matthieu-san

> Dear Sirs,
>
> I'd like to know how to get the lifecycle state of a service provider
> component from one of its consumer.
>
> I've got the following issue : One of my component, during his onExecuted
> function, calls a service from another component. During the activation of
> the complete set of components, if this component is activated before the
> service provider, the service call will fail, setting the component in a
> error state. I'd like to avoid any order in the component's activation, thus
> I'd like to check 1-if a service provider is connected (done using
> getObject) and 2-then also check if it has been activated (LifeCycleState ==
> ACTIVE).
>
> Could you explain me how to handle this issue ?

Currently we are not providing easy way to get status of other end of
RTC on the port.
But if you already have the RTC 's reference on the port
you might get the status in the following code.

const char* stateName[] = {
 "CREATED_STATE", "INACTIVE_STATE", "ACTIVE_STATE", "ERROR_STATE" };
RTC::ExecutionContextList_var ec = rtc->get_owned_contexts();
for (CORBA::ULong i(0); i < ec.length(); ++i)
{
  LifeCycleState state = ec[i]->get_component_state(rtc);
  std::cout << "State on EC" << i << " is " << stateName[state] << std::endl;
}

See the following IDL reference
http://www.openrtm.org/OpenRTM-aist/documents/IDLReference-en/namespaces.html

I would like to discuss to provide such kind of operation in the next
version of OpenRTM.
e.g. PortBase::getConnectedRtcs(), getConnectedRtcsState(), etc...


But the easiest way would be just calling the service and catching
the exception. If you want to avoid the side effect of operation call,
you can call CORBA::Object::_non_existent() operation.
But this method cannot distinguish whether the other RTC is
dead and whether it is just inactive state.

Best regards,
Noriaki Ando


>
>
> Thank you very much,
> Best regards,
>
> Matthieu
>
>
>



-- 
Noriaki Ando, Ph.D.
    Senior Research Scientist, RT-Synthesis R.G., ISRI, AIST
    AIST Tsukuba Central 2, Tsukuba, Ibaraki 305-8568 JAPAN
    e-mail: n-ando @ aist.go.jp, web: http://staff.aist.go.jp/n-ando
    OpenRTM-aist: http://www.openrtm.org




openrtm-users メーリングリストの案内