Skip to content

Commit 45546c2

Browse files
Enabler participant suggestion
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
1 parent b68021d commit 45546c2

3 files changed

Lines changed: 25 additions & 26 deletions

File tree

ddsenabler_participants/include/ddsenabler_participants/EnablerParticipant.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class EnablerParticipant : public ddspipe::participants::SchemaParticipant
6767
bool publish_rpc(
6868
const std::string& topic_name,
6969
const std::string& json,
70-
const uint64_t& request_id);
70+
const uint64_t request_id);
7171

7272
DDSENABLER_PARTICIPANTS_DllAPI
7373
void set_topic_query_callback(
@@ -218,7 +218,7 @@ class EnablerParticipant : public ddspipe::participants::SchemaParticipant
218218
const TopicInfo& topic_info,
219219
ddspipe::core::types::DdsTopic& topic);
220220

221-
bool fulfill_service_type_nts_(
221+
bool fill_service_type_nts_(
222222
const ServiceInfo& service_info,
223223
std::shared_ptr<ServiceDiscovered> service,
224224
RpcProtocol RpcProtocol);

ddsenabler_participants/include/ddsenabler_participants/rpc/RpcStructs.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct RpcInfo
9494
rpc_protocol = RpcProtocol::ROS2;
9595
return;
9696
}
97+
// With the current Fast Prefixes being empty strings, this check must be the last one
9798
else if (topic_name.rfind(FASTDDS_TOPIC_PREFIX, 0) == 0 ||
9899
topic_name.rfind(FASTDDS_REQUEST_PREFIX, 0) == 0 ||
99100
topic_name.rfind(FASTDDS_REPLY_PREFIX, 0) == 0)

ddsenabler_participants/src/cpp/EnablerParticipant.cpp

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,18 @@ bool EnablerParticipant::action_discovered_nts_(
6969
std::make_shared<ActionDiscovered>(rpc_info->action_name, rpc_info->rpc_protocol));
7070
if (ServiceType::NONE != rpc_info->service_type)
7171
{
72-
service_discovered_nts_(rpc_info, topic);
73-
auto service_it = services_.find(rpc_info->service_name);
74-
if (services_.end() == service_it)
72+
if (service_discovered_nts_(rpc_info, topic))
7573
{
76-
EPROSIMA_LOG_ERROR(DDSENABLER_ENABLER_PARTICIPANT,
77-
"Service " << rpc_info->service_name << " not found in action " << rpc_info->action_name);
78-
return false;
79-
}
74+
auto service_it = services_.find(rpc_info->service_name);
75+
if (services_.end() == service_it)
76+
{
77+
EPROSIMA_LOG_ERROR(DDSENABLER_ENABLER_PARTICIPANT,
78+
"Service " << rpc_info->service_name << " not found in action " << rpc_info->action_name);
79+
return false;
80+
}
8081

81-
it->second->add_service(service_it->second, rpc_info->action_type);
82+
it->second->add_service(service_it->second, rpc_info->action_type);
83+
}
8284
}
8385
else
8486
{
@@ -165,10 +167,6 @@ std::shared_ptr<IReader> EnablerParticipant::create_reader(
165167
}
166168
}
167169
}
168-
else
169-
{
170-
std::cout << "Topic " << dds_topic.m_topic_name << " discovered from topic query callback. Not adding RPC." << std::endl;
171-
}
172170
}
173171
else
174172
{
@@ -287,7 +285,7 @@ bool EnablerParticipant::publish(
287285
bool EnablerParticipant::publish_rpc(
288286
const std::string& topic_name,
289287
const std::string& json,
290-
const uint64_t& request_id)
288+
const uint64_t request_id)
291289
{
292290
std::unique_lock<std::mutex> lck(mtx_);
293291

@@ -462,13 +460,13 @@ bool EnablerParticipant::revoke_service_nts_(
462460
if (it == services_.end())
463461
{
464462
EPROSIMA_LOG_ERROR(DDSENABLER_ENABLER_PARTICIPANT,
465-
"Failed to stop service " << service_name << " : service not found.");
463+
"Failed to revoke service " << service_name << " : service not found.");
466464
return false;
467465
}
468466
if (!it->second->enabler_as_server || !it->second->endpoint_request.has_value())
469467
{
470468
EPROSIMA_LOG_ERROR(DDSENABLER_ENABLER_PARTICIPANT,
471-
"Failed to stop service " << service_name << " : service not announced as server.");
469+
"Failed to revoke service " << service_name << " : service not announced as server.");
472470
return false;
473471
}
474472

@@ -632,14 +630,14 @@ bool EnablerParticipant::revoke_action(
632630
if (it == actions_.end())
633631
{
634632
EPROSIMA_LOG_ERROR(DDSENABLER_ENABLER_PARTICIPANT,
635-
"Failed to stop action " << action_name << " : action not found.");
633+
"Failed to revoke action " << action_name << " : action not found.");
636634
return false;
637635
}
638636

639637
if (!it->second->enabler_as_server)
640638
{
641639
EPROSIMA_LOG_ERROR(DDSENABLER_ENABLER_PARTICIPANT,
642-
"Failed to stop action " << action_name << " : action not announced as server.");
640+
"Failed to revoke action " << action_name << " : action not announced as server.");
643641
return false;
644642
}
645643

@@ -657,7 +655,7 @@ bool EnablerParticipant::revoke_action(
657655
if (!goal || !result || !cancel)
658656
{
659657
EPROSIMA_LOG_ERROR(DDSENABLER_ENABLER_PARTICIPANT,
660-
"Failed to stop action " << action_name << " : action services not fully discovered.");
658+
"Failed to revoke action " << action_name << " : action services not fully discovered.");
661659
return false;
662660
}
663661
if (this->revoke_service_nts_(goal->service_name) &&
@@ -670,7 +668,7 @@ bool EnablerParticipant::revoke_action(
670668
}
671669

672670
EPROSIMA_LOG_ERROR(DDSENABLER_ENABLER_PARTICIPANT,
673-
"Failed to stop action " << action_name << " : error revoking action services.");
671+
"Failed to revoke action " << action_name << " : error revoking action services.");
674672
return false;
675673
}
676674

@@ -734,7 +732,7 @@ bool EnablerParticipant::fill_topic_struct_nts_(
734732
return true;
735733
}
736734

737-
bool EnablerParticipant::fulfill_service_type_nts_(
735+
bool EnablerParticipant::fill_service_type_nts_(
738736
const ServiceInfo& service_info,
739737
std::shared_ptr<ServiceDiscovered> service,
740738
RpcProtocol RpcProtocol)
@@ -811,7 +809,7 @@ bool EnablerParticipant::query_service_nts_(
811809
return false;
812810
}
813811

814-
return fulfill_service_type_nts_(service_info, service, RpcProtocol);
812+
return fill_service_type_nts_(service_info, service, RpcProtocol);
815813
}
816814

817815
bool EnablerParticipant::query_action_nts_(
@@ -858,7 +856,7 @@ bool EnablerParticipant::query_action_nts_(
858856

859857
std::shared_ptr<ServiceDiscovered> goal_service = std::make_shared<ServiceDiscovered>(goal_service_name,
860858
RpcProtocol);
861-
if (!fulfill_service_type_nts_(
859+
if (!fill_service_type_nts_(
862860
action_info.goal,
863861
goal_service,
864862
RpcProtocol))
@@ -878,7 +876,7 @@ bool EnablerParticipant::query_action_nts_(
878876

879877
std::shared_ptr<ServiceDiscovered> cancel_service = std::make_shared<ServiceDiscovered>(cancel_service_name,
880878
RpcProtocol);
881-
if (!fulfill_service_type_nts_(
879+
if (!fill_service_type_nts_(
882880
action_info.cancel,
883881
cancel_service,
884882
RpcProtocol))
@@ -898,7 +896,7 @@ bool EnablerParticipant::query_action_nts_(
898896

899897
std::shared_ptr<ServiceDiscovered> result_service = std::make_shared<ServiceDiscovered>(result_service_name,
900898
RpcProtocol);
901-
if (!fulfill_service_type_nts_(
899+
if (!fill_service_type_nts_(
902900
action_info.result,
903901
result_service,
904902
RpcProtocol))

0 commit comments

Comments
 (0)