本文主要是介绍Fast DDS之Qos与Profiles,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
- XML profiles
- 加载
- 创建
- 修改
- 可配置内容
- Qos
- DeadlineQosPolicy
- DestinationOrderQosPolicy
- DurabilityQosPolicy
- DurabilityServiceQosPolicy
- EntityFactoryQosPolicy
- GroupDataQosPolicy
- HistoryQosPolicy
- LatencyBudgetQosPolicy
- LivelinessQosPolicy
- OwnershipQosPolicy
- OwnershipStrengthQosPolicy
- PartitionQosPolicy
- PresentationQosPolicy
- ReaderDataLifecycleQosPolicy
- ReliabilityQosPolicy
- ResourceLimitsQosPolicy
- TimeBasedFilterQosPolicy
- TopicDataQosPolicy
- TransportPriorityQosPolicy
- UserDataQosPolicy
- WriterDataLifecycleQosPolicy
Qos (Quality of Service)用于指定服务的行为,允许用户指定每个实体怎样表现或运行。通过XML文件(Profiles)来配置或者在代码中直接指定。
XML profiles
xml配置文件可以有多个。
加载
Fast DDS在初始化阶段自动加载XML:
- 在当前可执行文件的路径下加载 DEFAULT_FASTRTPS_PROFILES.xml
- 加载环境变量FASTRTPS_DEFAULT_PROFILES_FILE指定的xml
- 加载配置参数指定的xml文件
- 直接加载xml格式的字符串
创建
<?xml version="1.0" encoding="UTF-8" ?>
<dds xmlns="http://www.eprosima.com/XMLSchemas/fastRTPS_Profiles"><profiles><domainparticipant_factory profile_name="domainparticipant_factory_profile"><!-- ... --></domainparticipant_factory><participant profile_name="participant_profile"><!-- ... --></participant><data_writer profile_name="datawriter_profile"><!-- ... --></data_writer><data_reader profile_name="datareader_profile"><!-- ... --></data_reader><topic profile_name="topic_profile"><!-- ... --></topic><transport_descriptors><!-- ... --></transport_descriptors></profiles><library_settings><!-- ... --></library_settings><log><!-- ... --></log><types><!-- ... --></types>
</dds>
<dds>, <profiles>, <library_settings>, <types>, and <log>
这些标签可以独立定义。<participant>, <data_reader>, <data_writer>, <topic>, and <transport_descriptors>
这些标签必须作为<profiles>
的子元素
修改
if (ReturnCode_t::RETCODE_OK ==DomainParticipantFactory::get_instance()->load_XML_profiles_file("my_profiles.xml"))
{DomainParticipantQos participant_qos;DomainParticipantFactory::get_instance()->get_participant_qos_from_profile("participant_xml_profile",participant_qos);// Name obtained in another section of the codeparticipant_qos.name() = custom_name;// Modify number of preallocations (this overrides the one set in the XML profile)participant_qos.allocation().send_buffers.preallocated_number = 10;// Create participant using the modified XML QosDomainParticipant* participant =DomainParticipantFactory::get_instance()->create_participant(0, participant_qos);
}
可配置内容
- DomainParticipantFactory profiles
- DomainParticipant profiles
- DataWriter profiles
- DataReader profiles
- Topic profiles
- transport_descriptor
- Intra-process delivery profiles
- Log profiles
- Dynamic Types profiles
Qos
每个Qos都有一个唯一的ID(定义在枚举QosPolicyId_t中),这个ID值用于一些Status中,以识别状态所引用的特定Qos策略。
Fast DDS中支持的Policies在这里
DeadlineQosPolicy
当新的数据样本的频率低于设定的阈值时,此QoS策略会发出警报。它对于预期定期更新数据的情况非常有用。
Data Member Name | Type | Default Value |
---|---|---|
period | Duration_t | c_TimeInfinite |
DestinationOrderQosPolicy
DurabilityQosPolicy
DurabilityServiceQosPolicy
EntityFactoryQosPolicy
GroupDataQosPolicy
HistoryQosPolicy
LatencyBudgetQosPolicy
LivelinessQosPolicy
OwnershipQosPolicy
OwnershipStrengthQosPolicy
PartitionQosPolicy
PresentationQosPolicy
ReaderDataLifecycleQosPolicy
ReliabilityQosPolicy
ResourceLimitsQosPolicy
TimeBasedFilterQosPolicy
TopicDataQosPolicy
TransportPriorityQosPolicy
UserDataQosPolicy
WriterDataLifecycleQosPolicy
eProsima扩展的Qos
这篇关于Fast DDS之Qos与Profiles的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!