[openrtm-users 02818] component is_activated() via service interface

3 個の投稿 / 0 new
最終投稿
pergy
オフライン
Last seen: 11年 2ヶ月 前
登録日: 2012-08-14 17:49
[openrtm-users 02818] component is_activated() via service interface

Hello everyone,In my project the order of components' activation is crucial. Meanwhile, we have an on-line tool for connecting components, which uses random order when activating components.Because of that, I'm looking for a function, which is able to decide whether the component(s) on the other end of a service port's interface is activated or not. Does such a function exists? If so, how to call it via an RTC::CorbaComsumer<> object, for instance?

I've investigated the "SimpleService" example as well but couldn't find anything like this in the code. MyServiceConsumer doesn't check whether MyServiceProvider is active or not. It just uses try-catch blocks to identify inactive service provider.

Thanks in advance,György Persa-- Software engineerComputer and Automation Research InstituteHungarian Academy of SciencesProject VirCA, www.virca.hu

未定義
Ando Noriaki
オフライン
Last seen: 1年 8ヶ月 前
登録日: 2011-09-04 17:20
[openrtm-users 02820] component is_activated() via service inte

Hello,

At first, basic three states (inactive, active and error) belong
to ExecutionContext. It means that an RTC A can be in Inactive
state on an ExecutionContext X while the RTC A might be in Active
state on an ExecutionContext Y.

But usually an RTC is associated with only one its own
ExecutionContext with ec_id=0.

If you can get the object reference of an RTC, you also can get
its ExecutionContextService object(s). So an operation
RTC::ExecutionContext::get_component_state(in LightweightRTObject
comp ) is available.

http://www.openrtm.org/OpenRTM-aist/documents/IDLReference-en/interfaceRTC_1_1ExecutionContext.html#51a0396327ec0bab96f06a246032fc84

This is an example code.

// -*- C++ -*-
RTC::RTObject_var rtobj = obtaining object reference of an RTC anyway;
RTC::ExecutionContextServiceList_var ecs = rtobj->get_owned_contexts();
// ecs[0] is default context
LifeCycleState state = ecs[0]->get_component_state(rtobj);
// Now you can get state of the RTC :-)

But, the RTC might have one or more ExecutionContexts. In that
case, you have to investigate states of the RTC in each
ExecutionContext.

You can also know the state of an RTC through service ports if
the RTC has provided interfaces (provider) on it.
RTC::CorbaComsumer<> can be three states: nil, inactive, active.

http://www.openrtm.org/OpenRTM-aist/documents/current/cxx/classreference_en/classRTC_1_1CorbaPort.html#a1b9efe804a293b2c38a9cbe3b5ba54a0

- nil: Any object references are not assigned to this placeholder.
- active: an object reference is assigned and activated.
- inactive: an object reference is assigned but inactivated.

You can investigate whether the CorbaConsumer is nil by using
CORBA::is_nil(). Active or inactive object state can be
obtained by using "_non_existent()" function.

This knowledge can be obtained from CORBA's documentation. The
best way is to read CORBA specifications which are available
from OMG website.

- http://www.omg.org/spec/CORBA
- http://www.omg.org/spec/CORBA/3.3/Interfaces/PDF

But these are huge specifications, so I prefer to read VisiBroker
programmers reference.

- http://techpubs.borland.com/am/bes/v5x/v51/en/vbprogrammersref.pdf
- http://techpubs.borland.com/am/bes/v5x/

Consequently, example code would be the following.

RTC::ReturnCode_t MyServiceConsumer::onExecute(RTC::UniqueId ec_id)
{
try
{
if (CORBA::is_nil(m_myservice0._ptr()))
{
std::cout << "[nil] object reference is not assigned." << std::endl;
}
else
{
if (m_myservice0->_non_existent())
{
std::cout << "[inactive] provider is inactive." << std::endl;
}
else
{
std::cout << "[active] provider is active." << std::endl;
}
}
}
catch (...)
{
std::cout << "Unknown exception." << std::endl;
}
coil::sleep(1);
return RTC::RTC_OK;
}

Please try the example code. At first, activate the Consumer
component. Before connecting service ports, the consumer state
would be "nil." After connecting ports, the consumer state would
be "inactive", and after activating the Provider RTC the state
would be "active."

But if the provider RTC has one or more ExecutionContext, this
might be broken.That's an unresolved the design problem of the
OMG RTC specification and OpenRTM-aist implementation.

Best regards,
Noriaki Ando

--
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

2013/6/19 György Persa :
> Hello everyone,
>
> In my project the order of components' activation is crucial. Meanwhile, we
> have an on-line tool for connecting components, which uses random order when
> activating components.
> Because of that, I'm looking for a function, which is able to decide whether
> the component(s) on the other end of a service port's interface is activated
> or not. Does such a function exists? If so, how to call it via an
> RTC::CorbaComsumer<> object, for instance?
> I've investigated the "SimpleService" example as well but couldn't find
> anything like this in the code. MyServiceConsumer doesn't check whether
> MyServiceProvider is active or not. It just uses try-catch blocks to
> identify inactive service provider.
>
> Thanks in advance,
> György Persa
>
>
> --
> Software engineer
> Computer and Automation Research Institute
> Hungarian Academy of Sciences
> Project VirCA, www.virca.hu
>
> _______________________________________________
> openrtm-users mailing list
> openrtm-users@openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-users
>

pergy
オフライン
Last seen: 11年 2ヶ月 前
登録日: 2012-08-14 17:49
[openrtm-users 02821] component is_activated() via service inte

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

Best regards,
György PersaSoftware engineerInstitute for Computer Science and ControlHungarian Academy of Sciences3D Internet-based Control and Communications Research Laboratory / 3DICC

Project VirCA (www.virca.hu)

On Wed, Jun 26, 2013 at 5:37 AM, Ando Noriaki <n-ando@aist.go.jp> wrote:

Hello,

At first, basic three states (inactive, active and error) belong
to ExecutionContext.  It means that an RTC A can be in Inactive
state on an ExecutionContext X while the RTC A might be in Active
state on an ExecutionContext Y.

But usually an RTC is associated with only one its own
ExecutionContext with ec_id=0.

If you can get the object reference of an RTC, you also can get
its ExecutionContextService object(s).  So an operation
RTC::ExecutionContext::get_component_state(in LightweightRTObject
comp ) is available.

http://www.openrtm.org/OpenRTM-aist/documents/IDLReference-en/interfaceRTC_1_1ExecutionContext.html#51a0396327ec0bab96f06a246032fc84

This is an example code.

 // -*- C++ -*-
 RTC::RTObject_var rtobj = obtaining object reference of an RTC anyway;
 RTC::ExecutionContextServiceList_var ecs = rtobj->get_owned_contexts();
 // ecs[0] is default context
 LifeCycleState state = ecs[0]->get_component_state(rtobj);
 // Now you can get state of the RTC :-)

But, the RTC might have one or more ExecutionContexts. In that
case, you have to investigate states of the RTC in each
ExecutionContext.

You can also know the state of an RTC through service ports if
the RTC has provided interfaces (provider) on it.
RTC::CorbaComsumer<> can be three states: nil, inactive, active.

http://www.openrtm.org/OpenRTM-aist/documents/current/cxx/classreference_en/classRTC_1_1CorbaPort.html#a1b9efe804a293b2c38a9cbe3b5ba54a0

- nil: Any object references are not assigned to this placeholder.
- active: an object reference is assigned and activated.
- inactive: an object reference is assigned but inactivated.

You can investigate whether the CorbaConsumer is nil by using
CORBA::is_nil().  Active or inactive object state can be
obtained by using "_non_existent()" function.

This knowledge can be obtained from CORBA's documentation.  The
best way is to read CORBA specifications which are available
from OMG website.

- http://www.omg.org/spec/CORBA
- http://www.omg.org/spec/CORBA/3.3/Interfaces/PDF

But these are huge specifications, so I prefer to read VisiBroker
programmers reference.

- http://techpubs.borland.com/am/bes/v5x/v51/en/vbprogrammersref.pdf
- http://techpubs.borland.com/am/bes/v5x/

Consequently, example code would be the following.

 RTC::ReturnCode_t MyServiceConsumer::onExecute(RTC::UniqueId ec_id)
 {
   try
     {
       if (CORBA::is_nil(m_myservice0._ptr()))
         {
           std::cout << "[nil] object reference is not assigned." << std::endl;
         }
       else
         {
           if (m_myservice0->_non_existent())
             {
               std::cout << "[inactive] provider is inactive." << std::endl;
             }
           else
             {
               std::cout << "[active] provider is active." << std::endl;
             }
         }
     }
   catch (...)
     {
       std::cout << "Unknown exception." << std::endl;
     }
   coil::sleep(1);
   return RTC::RTC_OK;
 }

Please try the example code. At first, activate the Consumer
component.  Before connecting service ports, the consumer state
would be "nil."  After connecting ports, the consumer state would
be "inactive", and after activating the Provider RTC the state
would be "active."

But if the provider RTC has one or more ExecutionContext, this
might be broken.That's an unresolved the design problem of the
OMG RTC specification and OpenRTM-aist implementation.

Best regards,
Noriaki Ando

--
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

2013/6/19 György Persa <persa@sztaki.hu>:
> Hello everyone,
>
> In my project the order of components' activation is crucial. Meanwhile, we
> have an on-line tool for connecting components, which uses random order when
> activating components.
> Because of that, I'm looking for a function, which is able to decide whether
> the component(s) on the other end of a service port's interface is activated
> or not. Does such a function exists? If so, how to call it via an
> RTC::CorbaComsumer<> object, for instance?
> I've investigated the "SimpleService" example as well but couldn't find
> anything like this in the code. MyServiceConsumer doesn't check whether
> MyServiceProvider is active or not. It just uses try-catch blocks to
> identify inactive service provider.
>
> Thanks in advance,
> György Persa
>
>
> --
> Software engineer
> Computer and Automation Research Institute
> Hungarian Academy of Sciences
> Project VirCA, www.virca.hu
>
> _______________________________________________
> openrtm-users mailing list
> openrtm-users@openrtm.org
> http://www.openrtm.org/mailman/listinfo/openrtm-users
>
_______________________________________________
openrtm-users mailing list
openrtm-users@openrtm.org
http://www.openrtm.org/mailman/listinfo/openrtm-users

コメントを投稿するにはログインまたはユーザー登録を行ってください

ダウンロード

最新バージョン : 2.0.1-RELESE

統計

Webサイト統計
ユーザ数:2195
プロジェクト統計
RTコンポーネント307
RTミドルウエア35
ツール22
文書・仕様書2

Choreonoid

モーションエディタ/シミュレータ

OpenHRP3

動力学シミュレータ

OpenRTP

統合開発プラットフォーム

産総研RTC集

産総研が提供するRTC集

TORK

東京オープンソースロボティクス協会

DAQ-Middleware

ネットワーク分散環境でデータ収集用ソフトウェアを容易に構築するためのソフトウェア・フレームワーク