Dear Ando-san,<div><br></div><div>thank you for your very detailed answer!</div><div>I've tried out the methods you suggested and successfully solved my problem by using "_non_existent()" function, based on your example!</div>

<div><br></div><div>Best regards,</div><div><br></div><div><div>
<font>György Persa</font><br><font size="1"><i>Software engineer</i><br>Institute for Computer Science and Control<br>Hungarian Academy of Sciences<br>3D Internet-based Control and Communications Research Laboratory / 3DICC<br>

<i>Project VirCA</i> (<a href="http://www.virca.hu" target="_blank">www.virca.hu</a>)</font>
<font size="1"></font></div></div>
<br><br><div class="gmail_quote">On Wed, Jun 26, 2013 at 5:37 AM, Ando Noriaki <span dir="ltr"><<a href="mailto:n-ando@aist.go.jp" target="_blank">n-ando@aist.go.jp</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hello,<br>
<br>
At first, basic three states (inactive, active and error) belong<br>
to ExecutionContext.  It means that an RTC A can be in Inactive<br>
state on an ExecutionContext X while the RTC A might be in Active<br>
state on an ExecutionContext Y.<br>
<br>
But usually an RTC is associated with only one its own<br>
ExecutionContext with ec_id=0.<br>
<br>
If you can get the object reference of an RTC, you also can get<br>
its ExecutionContextService object(s).  So an operation<br>
RTC::ExecutionContext::get_component_state(in LightweightRTObject<br>
comp ) is available.<br>
<br>
<a href="http://www.openrtm.org/OpenRTM-aist/documents/IDLReference-en/interfaceRTC_1_1ExecutionContext.html#51a0396327ec0bab96f06a246032fc84" target="_blank">http://www.openrtm.org/OpenRTM-aist/documents/IDLReference-en/interfaceRTC_1_1ExecutionContext.html#51a0396327ec0bab96f06a246032fc84</a><br>


<br>
This is an example code.<br>
<br>
 // -*- C++ -*-<br>
 RTC::RTObject_var rtobj = obtaining object reference of an RTC anyway;<br>
 RTC::ExecutionContextServiceList_var ecs = rtobj->get_owned_contexts();<br>
 // ecs[0] is default context<br>
 LifeCycleState state = ecs[0]->get_component_state(rtobj);<br>
 // Now you can get state of the RTC :-)<br>
<br>
But, the RTC might have one or more ExecutionContexts. In that<br>
case, you have to investigate states of the RTC in each<br>
ExecutionContext.<br>
<br>
You can also know the state of an RTC through service ports if<br>
the RTC has provided interfaces (provider) on it.<br>
RTC::CorbaComsumer<> can be three states: nil, inactive, active.<br>
<br>
<a href="http://www.openrtm.org/OpenRTM-aist/documents/current/cxx/classreference_en/classRTC_1_1CorbaPort.html#a1b9efe804a293b2c38a9cbe3b5ba54a0" target="_blank">http://www.openrtm.org/OpenRTM-aist/documents/current/cxx/classreference_en/classRTC_1_1CorbaPort.html#a1b9efe804a293b2c38a9cbe3b5ba54a0</a><br>


<br>
- nil: Any object references are not assigned to this placeholder.<br>
- active: an object reference is assigned and activated.<br>
- inactive: an object reference is assigned but inactivated.<br>
<br>
You can investigate whether the CorbaConsumer is nil by using<br>
CORBA::is_nil().  Active or inactive object state can be<br>
obtained by using "_non_existent()" function.<br>
<br>
This knowledge can be obtained from CORBA's documentation.  The<br>
best way is to read CORBA specifications which are available<br>
from OMG website.<br>
<br>
- <a href="http://www.omg.org/spec/CORBA" target="_blank">http://www.omg.org/spec/CORBA</a><br>
- <a href="http://www.omg.org/spec/CORBA/3.3/Interfaces/PDF" target="_blank">http://www.omg.org/spec/CORBA/3.3/Interfaces/PDF</a><br>
<br>
But these are huge specifications, so I prefer to read VisiBroker<br>
programmers reference.<br>
<br>
- <a href="http://techpubs.borland.com/am/bes/v5x/v51/en/vbprogrammersref.pdf" target="_blank">http://techpubs.borland.com/am/bes/v5x/v51/en/vbprogrammersref.pdf</a><br>
- <a href="http://techpubs.borland.com/am/bes/v5x/" target="_blank">http://techpubs.borland.com/am/bes/v5x/</a><br>
<br>
Consequently, example code would be the following.<br>
<br>
 RTC::ReturnCode_t MyServiceConsumer::onExecute(RTC::UniqueId ec_id)<br>
 {<br>
   try<br>
     {<br>
       if (CORBA::is_nil(m_myservice0._ptr()))<br>
         {<br>
           std::cout << "[nil] object reference is not assigned." << std::endl;<br>
         }<br>
       else<br>
         {<br>
           if (m_myservice0->_non_existent())<br>
             {<br>
               std::cout << "[inactive] provider is inactive." << std::endl;<br>
             }<br>
           else<br>
             {<br>
               std::cout << "[active] provider is active." << std::endl;<br>
             }<br>
         }<br>
     }<br>
   catch (...)<br>
     {<br>
       std::cout << "Unknown exception." << std::endl;<br>
     }<br>
   coil::sleep(1);<br>
   return RTC::RTC_OK;<br>
 }<br>
<br>
Please try the example code. At first, activate the Consumer<br>
component.  Before connecting service ports, the consumer state<br>
would be "nil."  After connecting ports, the consumer state would<br>
be "inactive", and after activating the Provider RTC the state<br>
would be "active."<br>
<br>
But if the provider RTC has one or more ExecutionContext, this<br>
might be broken.That's an unresolved the design problem of the<br>
OMG RTC specification and OpenRTM-aist implementation.<br>
<br>
<br>
Best regards,<br>
Noriaki Ando<br>
<br>
<br>
--<br>
Noriaki Ando, Ph.D.<br>
    Senior Research Scientist, RT-Synthesis R.G., ISRI, AIST<br>
    AIST Tsukuba Central 2, Tsukuba, Ibaraki 305-8568 JAPAN<br>
    e-mail: <a href="mailto:n-ando@aist.go.jp">n-ando@aist.go.jp</a>, web: <a href="http://staff.aist.go.jp/n-ando" target="_blank">http://staff.aist.go.jp/n-ando</a><br>
    OpenRTM-aist: <a href="http://www.openrtm.org" target="_blank">http://www.openrtm.org</a><br>
<br>
<br>
2013/6/19 György Persa <<a href="mailto:persa@sztaki.hu">persa@sztaki.hu</a>>:<br>
<div><div class="h5">> Hello everyone,<br>
><br>
> In my project the order of components' activation is crucial. Meanwhile, we<br>
> have an on-line tool for connecting components, which uses random order when<br>
> activating components.<br>
> Because of that, I'm looking for a function, which is able to decide whether<br>
> the component(s) on the other end of a service port's interface is activated<br>
> or not. Does such a function exists? If so, how to call it via an<br>
> RTC::CorbaComsumer<> object, for instance?<br>
> I've investigated the "SimpleService" example as well but couldn't find<br>
> anything like this in the code. MyServiceConsumer doesn't check whether<br>
> MyServiceProvider is active or not. It just uses try-catch blocks to<br>
> identify inactive service provider.<br>
><br>
> Thanks in advance,<br>
> György Persa<br>
><br>
><br>
> --<br>
> Software engineer<br>
> Computer and Automation Research Institute<br>
> Hungarian Academy of Sciences<br>
> Project VirCA, <a href="http://www.virca.hu" target="_blank">www.virca.hu</a><br>
><br>
</div></div>> _______________________________________________<br>
> openrtm-users mailing list<br>
> <a href="mailto:openrtm-users@openrtm.org">openrtm-users@openrtm.org</a><br>
> <a href="http://www.openrtm.org/mailman/listinfo/openrtm-users" target="_blank">http://www.openrtm.org/mailman/listinfo/openrtm-users</a><br>
><br>
<br>_______________________________________________<br>
openrtm-users mailing list<br>
<a href="mailto:openrtm-users@openrtm.org">openrtm-users@openrtm.org</a><br>
<a href="http://www.openrtm.org/mailman/listinfo/openrtm-users" target="_blank">http://www.openrtm.org/mailman/listinfo/openrtm-users</a><br>
<br></blockquote></div><br>