Hi everybody,
I have written a simple application which discover all domains with the help of dds::topic::ParticipantBuiltinTopicData. When a domain joins my LAN network, my program detects it but it cannot detect leaving domains. Is there any way to detect leaving domains?
I bring some of my application code below for further uses:
// By default, the participant is enabled upon construction. // At that time our listeners for the builtin topics have not // been installed, so we disable the participant until we // set up the listeners. dds::domain::qos::DomainParticipantFactoryQos factoryQos = dds::domain::DomainParticipant::participant_factory_qos(); factoryQos << dds::core::policy::EntityFactory::ManuallyEnable(); factoryQos->resource_limits.max_objects_per_thread(4096); dds::domain::DomainParticipant::participant_factory_qos(factoryQos);
dds::domain::qos::DomainParticipantQos dpQos = dds::core::QosProvider::Default() .participant_qos(rti::core::builtin_profiles::qos_lib::baseline());
dpQos->discovery_config.ignore_default_domain_announcements(false); dpQos->discovery_config.participant_liveliness_assert_period(dds::core::Duration(1,0)); dpQos->discovery_config.participant_liveliness_lease_duration(dds::core::Duration(10,0)); // quickly detect the loss of liveness of remote participants dpQos->discovery_config.max_liveliness_loss_detection_period(dds::core::Duration(5,0)); dpQos->discovery_config.asynchronous_publisher().disable_asynchronous_write(false); dpQos->discovery_config.publication_writer_publish_mode().Asynchronous(); dpQos->discovery_config.subscription_writer_publish_mode().Asynchronous();
dpQos->resource_limits.type_code_max_serialized_length(65535); dpQos->resource_limits.deserialized_type_object_dynamic_allocation_threshold(1024); dpQos->resource_limits.type_object_max_deserialized_length(dds::core::LENGTH_UNLIMITED); dpQos->resource_limits.type_object_max_serialized_length(12288); dpQos->resource_limits.participant_property_list_max_length(1024); dpQos->resource_limits.participant_property_string_max_length(32768);
// Don't ignore the local loopback std::map<std::string,std::string> dpPropertyMap = {{"dds.transport.UDPv4.builtin.ignore_loopback_interface", "0"},{"dds.transport.UDPv4.builtin.recv_socket_buffer_size", "1048576"}}; dpQos << rti::core::policy::Property(dpPropertyMap.begin(),dpPropertyMap.end()); dp = dds::domain::DomainParticipant(DEFAULT_DISCOVERY_DOMAIN,dpQos);
builtin_subscriber = dds::sub::builtin_subscriber(dp);
// Get builtin subscriber's datareader for participants. participant_reader = rti::sub::find_datareader_by_topic_name< dds::sub::DataReader<dds::topic::ParticipantBuiltinTopicData> >( builtin_subscriber, dds::topic::participant_topic_name());
// Set a waitset for reading participants // Get status conditions. // Each entity may have an attached Status Condition. To modify the // statuses we need to get the reader's Status Conditions first. // By instantiating a StatusCondition we are obtaining a reference to this // reader's StatusCondition dds::core::cond::StatusCondition participants_status_condition(participant_reader); discovery_Waitset = new dds::core::cond::WaitSet(); discovery_Waitset->attach_condition(participants_status_condition);
// Done! All the listeners are installed, so we can enable the participant now. dp.enable();
Thanks in advance for your help.
Bonjefir
Hi,
I found a way to find local domains (in a host) by use of "dds::domain::find(domain_id)", but this function cannot find all domains in a local network consisting of several PCs. Is there anything like this function for all domains?
Bonjefir
Hi Bonjefir,
I assume that you want to do something similar to what RTI Admin Console does, which is (unless otherwise specified) to discover all the participants that are available in all the domains and once you know that, find out the domains that are in use.
As specified in the description of default_domain_announcement_period in the DDS_DiscoveryConfigQosPolicy:
Let me know if this helps.
Thanks,
Fernando.
Hi Fernando,
First of all, thanks for your answer. Second, I can detect all domain participant with a waitset on participant builtin reader (codes are given below). But I can not detect whether they are alive or not. That's my problem. I would be very grateful if you can let me know how to solve it.
// We only process newly seen participant
dds::sub::LoanedSamples<dds::topic::ParticipantBuiltinTopicData> samples = participant_reader.select()
.state(dds::sub::status::DataState::new_instance())
.take();
for (const auto& it : samples)
{
if (!it.info().valid()) {
continue;
}
addDomainID(it.data()->domain_id());
}
Best Regards,
Bonjefir