Skip to content

Commit

Permalink
Merge pull request #1151 from Nobu19800/bugs/nvproperties
Browse files Browse the repository at this point in the history
データポート接続時にコネクタプロファイルからプロバイダのオブジェクトリファレンスが消えるバグの修正
  • Loading branch information
n-ando authored Jul 1, 2024
2 parents ca504f9 + d1ad364 commit 6e0cadc
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/rtm/InPortBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1136,7 +1136,7 @@ namespace RTC

node << portprop;

NVUtil::copyFromProperties(connector_profile.properties, prop);
NVUtil::mergeFromProperties(connector_profile.properties, prop);

std::string _str = node["fan_in"];
unsigned int value = 100;
Expand Down
50 changes: 50 additions & 0 deletions src/lib/rtm/NVUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,56 @@ namespace NVUtil
}
}


/*!
* @if jp
* @brief Properties を NVList へマージする
* @else
* @brief Merge the properties to NVList
* @endif
*/
#ifndef ORB_IS_RTORB
void mergeFromProperties(SDOPackage::NVList& nv, const coil::Properties& prop)
#else // ORB_IS_RTORB
void mergeFromProperties(SDOPackage_NVList& nv, const coil::Properties& prop)
#endif // ORB_IS_RTORB
{
std::vector<std::string> keys;
keys = prop.propertyNames();
#ifndef ORB_IS_RTORB
SDOPackage::NVList nve;
#else // ORB_IS_RTORB
SDOPackage_NVList nve;
#endif // ORB_IS_RTORB
nve.length(static_cast<CORBA::ULong>(keys.size()));

CORBA::ULong nsize(0);
for (CORBA::ULong i = 0; i < nv.length(); ++i)
{
if (prop.findNode(static_cast<const char*>(nv[i].name)) == nullptr)
{
nve[nsize] = nv[i];
nsize++;
}
}

CORBA::ULong ksize(static_cast<CORBA::ULong>(keys.size()));
CORBA::ULong len(ksize + nsize);
nv.length(len);

for (CORBA::ULong i = 0; i < ksize; ++i)
{
nv[i].name = CORBA::string_dup(keys[i].c_str());
nv[i].value <<= prop[keys[i]].c_str();
}

for (CORBA::ULong i = 0; i < nsize; ++i)
{
nv[i+ ksize] = nve[i];
}

}

/*!
* @if jp
* @brief NVList を Properties へコピーする
Expand Down
29 changes: 29 additions & 0 deletions src/lib/rtm/NVUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,35 @@ namespace NVUtil
void copyFromProperties(SDOPackage_NVList& nv, const coil::Properties& prop);
#endif // ORB_IS_RTORB

/*!
* @if jp
*
* @brief Properties を NVList にマージする
*
* このオペレーションは Properties を NVList へマージする。
* NVList の value は全て CORBA::string 型としてマージする。
*
* @param nv Properties の値を格納する NVList
* @param prop コピー元の Properties
*
* @else
*
* @brief Merge the properties to NVList
*
* This operation merges the properties into NVList.
* All NVList's values are copied as CORBA::string.
*
* @param nv NVList to store properties values
* @param prop Properties that is merged from
*
* @endif
*/
#ifndef ORB_IS_RTORB
void mergeFromProperties(SDOPackage::NVList& nv, const coil::Properties& prop);
#else // ORB_IS_RTORB
void mergeFromProperties(SDOPackage_NVList& nv, const coil::Properties& prop);
#endif // ORB_IS_RTORB

/*!
* @if jp
*
Expand Down
2 changes: 1 addition & 1 deletion src/lib/rtm/OutPortBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,7 +1154,7 @@ namespace RTC
node << portprop;


NVUtil::copyFromProperties(connector_profile.properties, prop);
NVUtil::mergeFromProperties(connector_profile.properties, prop);

std::string _str = node["fan_out"];
unsigned int value = 100;
Expand Down

0 comments on commit 6e0cadc

Please sign in to comment.