FastDDS参数介绍总结

FastDDS配置参数的介绍和使用
一、ReliabilityQoS 的 kind 属性能设置的值(ReliabilityQosPolicyKind):
1、RELIABLEE_RELIABILITY_QOS:可靠的传输。发布端写者在发出数据之后中间件会判断订阅端读者是否成功收到数据。若订阅端没有收到,中间件会通知发布端,发布端的写者就会再发一次订阅端没收到的数据,保证订阅端能收到。在稳定状态下(写者不会再写新的数据),中间件会保证写者的历史记录所有数据能够全部发送给读者。但在写者会发送新数据的情况下,就需要对 History 进行设置,确定写者发送的数据样本哪些作为历史记录保存,哪些需要从历史记录丢弃。
2、BEST_EFFORT_RELIABILITY_QOS:尽力而为的传输。发布端写者在发送数据的时候不会关注订阅端读者是否接受到数据,写者不会因为读者漏接某个数据而再发送一次漏接的数据,依然会继续发送接下来的数据。一般用于更新速率很快,丢失少许数据无碍的情况。是 DataReaders 和 Topics 的默认值。
若发布者和订阅者的ReliabilityQosPolicyKind不同,无法建立通信。
二、ParticipantAttributes
1、ParticipantAttributes类

class ParticipantAttributes
{
public:   
 	//! DomainId to be used by the associated RTPSParticipant (default: 0)
	uint32_t domainId = 0;//域值
	//!Attributes of the associated RTPSParticipant.
 	rtps::RTPSParticipantAttributes rtps;//rtps参数详见下文
};

2、RTPSParticipantAttributes类

class RTPSParticipantAttributes
{
	public:

	RTPSParticipantAttributes()
	{
		setName("RTPSParticipant");
		sendSocketBufferSize = 0;
		listenSocketBufferSize = 0;
		participantID = -1;
		useBuiltinTransports = true;
	}

	/**
	 * Default list of Unicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the case
	 * that it was defined with NO UnicastLocators. At least ONE locator should be included in this list.
	 * /
	 /*在以下情况下,用于此RTPSP参与者内定义的任何端点的单播定位器的	
	 *默认列表,它被定义为没有单播定位器。此列表中应至少包含一个定位器	 
	 * /
	LocatorList_t defaultUnicastLocatorList;

	/**
	 * Default list of Multicast Locators to be used for any Endpoint defined inside this RTPSParticipant in the
	 * case that it was defined with NO UnicastLocators. This is usually left empty.
	 */
	  /*用于此RTPSP参与者中定义的任何端点的默认多播定位器列表
	 *如果它被定义为没有单播定位器。这通常是空的。 * /
	LocatorList_t defaultMulticastLocatorList;

	/*!
	 * @brief Send socket buffer size for the send resource. Zero value indicates to use default system buffer size.
	 * Default value: 0.
	 */
	 /*@short发送资源的套接字缓冲区大小。零值表示使用默认系统缓冲区大  小。
	 *默认值:0。 */
	uint32_t sendSocketBufferSize;

	/*! Listen socket buffer for all listen resources. Zero value indicates to use default system buffer size.
	 * Default value: 0.
	 */
	/*所有侦听资源的侦听套接字缓冲区。零值表示使用默认系统缓冲区大小。
	*默认值:0 */
	uint32_t listenSocketBufferSize;

	//! Builtin parameters.//内置参数,详见下文
	BuiltinAttributes builtin;

	//!Port Parameters//端口参数,详见下文
	PortParameters port;

	//!User Data of the participant//参与者的用户数据
	std::vector<octet> userData;

	//!Participant ID//参与者ID
	int32_t participantID;

	//!Throughput controller parameters. Leave default for uncontrolled flow.
	//吞吐量控制器参数。将默认值保留为不受控制的流量
	ThroughputControllerDescriptor throughputController;

	//!User defined transports to use alongside or in place of builtins.
	//用户定义的运输工具,可与内置工具一起使用或代替内置工具使用
	std::vector<std::shared_ptr<fastdds::rtps::TransportDescriptorInterface>> userTransports;

	//!Set as false to disable the default UDPv4 implementation.
	//设置为false以禁用默认UDPv4实现
	bool useBuiltinTransports;
	//!Holds allocation limits affecting collections managed by a participant.
	//持有影响参与者管理的集合的分配限制
	RTPSParticipantAllocationAttributes allocation;

	//! Property policies//方针政策?
	PropertyPolicy properties;
	private:
	//!Name of the participant.
	//参与者名字
	string_255 name;
}

3、BuiltinAttributes类

/**
* Class BuiltinAttributes, to define the behavior of the 	RTPSParticipant builtin protocols.
 * @ingroup RTPS_ATTRIBUTES_MODULE
 */
/*类内置属性,用于定义RTPSP参与内置协议的行为*/
class BuiltinAttributes
{
public:
	//! Discovery protocol related attributes
	//发现协议相关属性
 	DiscoverySettings discovery_config;

	//!Indicates to use the WriterLiveliness protocol.
	//标识是否使用WriterLivelines协议
	bool use_WriterLivelinessProtocol = true;

	//!TypeLookup Service settings
	//类型查找服务设置
	TypeLookupSettings typelookup_config;

 	//!Metatraffic Unicast Locator List
 	//Metatraffic单播定位器列表
	LocatorList_t metatrafficUnicastLocatorList;

	//!Metatraffic Multicast Locator List.
	//元流量多播定位器列表
	LocatorList_t metatrafficMulticastLocatorList;

	//! Initial peers.
	//初始对等体
	LocatorList_t initialPeersList;

 	//! Memory policy for builtin readers
 	//内置读卡器的内存策略
	MemoryManagementPolicy_t readerHistoryMemoryPolicy =          MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;

	//! Maximum payload size for builtin readers
	//内置读卡器的最大有效载荷大小
	uint32_t readerPayloadSize = BUILTIN_DATA_MAX_SIZE;

	//! Memory policy for builtin writers
	//内置写入程序的内存策略
	MemoryManagementPolicy_t writerHistoryMemoryPolicy =MemoryManagementPolicy_t::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;

	//! Maximum payload size for builtin writers
	//内置写入程序的最大有效负载大小
	uint32_t writerPayloadSize = BUILTIN_DATA_MAX_SIZE;

	//! Mutation tries if the port is being used.
	//如果端口正在使用,则进行突变尝试
	uint32_t mutation_tries = 100u;

	//!Set to true to avoid multicast traffic on builtin endpoints
	//设置为true以避免内置端点上的多播流量
	bool avoid_builtin_multicast = true;

	BuiltinAttributes() = default;
};

4、DiscoverySettings类

class DiscoverySettings
{
public:
	//! Chosen discovery protocol
	DiscoveryProtocol_t discoveryProtocol = DiscoveryProtocol_t::SIMPLE;
 /**
 	* If set to true, SimpleEDP would be used.
 	*/
	bool use_SIMPLE_EndpointDiscoveryProtocol = true;

 /**
 	* If set to true, StaticEDP based on an XML file would be implemented.
 	* The XML filename must be provided.
	 */
	bool use_STATIC_EndpointDiscoveryProtocol = false;

	/**
	 * Lease Duration of the RTPSParticipant,
 	* indicating how much time remote RTPSParticipants should consider this RTPSParticipant alive.
 	*/
 	//! Time_t (Duration_t) representing an infinite time. DONT USE IT IN CONSTRUCTORS
	//const Time_t c_TimeInfinite(TIME_T_INFINITE_SECONDS, TIME_T_INFINITE_NANOSECONDS);
	//! Time_t (Duration_t) representing a zero time. DONT USE IT IN CONSTRUCTORS
	//const Time_t c_TimeZero(0, 0);
	//! Time_t (Duration_t) representing an invalid time. DONT USE IT IN CONSTRUCTORS
	//const Time_t c_TimeInvalid(-1, TIME_T_INFINITE_NANOSECONDS);
	//#define TIME_T_INFINITE_SECONDS 0x7fffffff
	//#define TIME_T_INFINITE_NANOSECONDS 0xffffffff
	Duration_t leaseDuration = { 20, 0 };

	/**
 	* The period for the RTPSParticipant to send its Discovery Message to all other discovered RTPSParticipants
 	* as well as to all Multicast ports.
 	*/
 	/*RTPSP参与者向所有其他已发现的RTPSP参与者发送其发现消息的时间段,以及所有多播端口*/
	Duration_t leaseDuration_announcementperiod = { 3, 0 };

	//!Initial announcements configuration
	//初始公告配置
	InitialAnnouncementConfig initial_announcements;

	//!Attributes of the SimpleEDP protocol
	//SimpleEDP协议的属性
   SimpleEDPAttributes m_simpleEDP;

	//! function that returns a PDP object (only if EXTERNAL selected)
	//返回PDP对象的函数(仅当选择EXTERNAL时)
 	PDPFactory m_PDPfactory{};
	/**
 	* The period for the RTPSParticipant to:
 	*  send its Discovery Message to its servers
 	*  check for EDP endpoints matching
 	*/
 	/**RTPSP参与者的期限为:
	*将其发现消息发送到其服务器
	*检查EDP端点是否匹配*/
	Duration_t discoveryServer_client_syncperiod = { 0, 450 * 1000000}; // 450 milliseconds

	//! Discovery Server settings, only needed if use_CLIENT_DiscoveryProtocol=true
	//发现服务器设置,仅在use_CLIENT_DiscoveryProtocol=true时才需要
	eprosima::fastdds::rtps::RemoteServerList_t m_DiscoveryServers;

	//! Filtering participants out depending on location
	//根据地点筛选参与者
 	ParticipantFilteringFlags_t ignoreParticipantFlags = ParticipantFilteringFlags::NO_FILTER;

	DiscoverySettings() = default;

private:
	//! StaticEDP XML filename, only necessary if use_STATIC_EndpointDiscoveryProtocol=true
	//StaticEDP XML文件名,仅在使用_STATIC_EndpointDiscoveryProtocol=true时才需要
	std::string m_staticEndpointXMLFilename = "";
};

三、PublisherAttributes类
1、PublisherAttributes

class PublisherAttributes
{
public:
	PublisherAttributes()
		: historyMemoryPolicy(rtps::PREALLOCATED_MEMORY_MODE)
		, m_userDefinedID(-1)
		, m_entityID(-1)
	{}

	virtual ~PublisherAttributes(){}

	//!Topic Attributes for the Publisher
	//发布者的主题属性
	TopicAttributes topic;

	//!QOS for the Publisher
	//发布者的Qos属性
	WriterQos qos;

	//!Writer Attributes
	//写属性
	rtps::WriterTimes times;

	//!Unicast locator list
	//单播定位器列表
	rtps::LocatorList_t unicastLocatorList;

	//!Multicast locator list
	//多播定位器列表
	rtps::LocatorList_t multicastLocatorList;

	//!Remote locator list
	//远程定位器列表
	rtps::LocatorList_t remoteLocatorList;

	//!Throughput controller
	//吞吐量控制器
	rtps::ThroughputControllerDescriptor throughputController;

	//!Underlying History memory policy
	//基础历史存储策略
	rtps::MemoryManagementPolicy_t historyMemoryPolicy;

	//!Properties
	//特性
	rtps::PropertyPolicy properties;
	ResourceLimitedContainerConfig matched_subscriber_allocation;

private:
	//!User Defined ID, used for StaticEndpointDiscovery, default value -1.
	//用户定义ID,用于StaticEndpointDiscovery,默认值为-1
	int16_t m_userDefinedID;
	//!Entity ID, if the user want to specify the EntityID of the enpoint, default value -1.
	//实体ID,如果用户要指定enpoint的EntityID,默认值为-1
	int16_t m_entityID;
};

2、TopicAttributes

/**
 * Class TopicAttributes, used by the user to define the attributes of the topic associated with a Publisher or Subscriber.
 * @ingroup FASTRTPS_ATTRIBUTES_MODULE
 */
 /*类TopicAttributes,用户用于定义与发布者或订阅者关联的主题的属性*/
class TopicAttributes
{
public:

	/**
	 * Default constructor
	 */
	TopicAttributes()
		: topicKind(rtps::NO_KEY)
		, topicName("UNDEF")
		, topicDataType("UNDEF")
		, auto_fill_type_object(true)
		, auto_fill_type_information(true)
	{
	}

	//!Constructor, you need to provide the topic name and the topic data type.
	//构造函数,您需要提供主题名称和主题数据类型
	TopicAttributes(
			const char* name,
			const char* dataType,
			rtps::TopicKind_t tKind= rtps::NO_KEY)
		{
			topicKind = tKind;
			topicName = name;
			topicDataType = dataType;
			auto_fill_type_object = true;
			auto_fill_type_information = true;
		}

		//! TopicKind_t, default value NO_KEY.
		//是否使用带有Keys主题的发布和订阅NO_KEY、WITH_KEY
		rtps::TopicKind_t topicKind;
		//! Topic Name.//主题名
		string_255 topicName;
		//!Topic Data Type.//主题数据类型(同一主题下可以自定义多种数据类型)
		string_255 topicDataType;
		//!QOS Regarding the History to be saved.
		//QOS关于要保存的历史记录
		HistoryQosPolicy historyQos;
		//!QOS Regarding the resources to allocate.
		//QOS关于要分配的资源
		ResourceLimitsQosPolicy resourceLimitsQos;
		//!Type Identifier XTYPES 1.1
		//类型标识符XTYPES 1.1
		TypeIdV1 type_id;
		//!Type Object XTYPES 1.1
		//类型对象XTYPES 1.1
		TypeObjectV1 type;
		//!XTYPES 1.2
		xtypes::TypeInformation type_information;
		//!Tries to complete type identifier and type object (TypeObjectV1)
		//尝试完成类型标识符和类型对象(TypeObjectV1)
		bool auto_fill_type_object;
		//!Tries to complete type information (TypeObjectV2)
		//尝试完成类型信息(TypeObjectV2)
		bool auto_fill_type_information;

		/**
		 * Method to check whether the defined QOS are correct.
		 * @return True if they are valid.
		 */
		bool checkQos() const;
};

3、HistoryQosPolicy

class HistoryQosPolicy : public Parameter_t, public QosPolicy
{
public:

	/**
	 * @brief Constructor
	 */
	RTPS_DllAPI HistoryQosPolicy()
		: Parameter_t(PID_HISTORY, PARAMETER_KIND_LENGTH + 4)
		, QosPolicy(true)
		, kind(KEEP_LAST_HISTORY_QOS)
		, depth(1)
	{
	}

public:

	//!HistoryQosPolicyKind. <br> By default, KEEP_LAST_HISTORY_QOS.
	HistoryQosPolicyKind kind;
	//!History depth. <br> By default, 1. If a value other than 1 is specified, it should
	//! be consistent with the settings of the ResourceLimitsQosPolicy.
	//! @warning Only takes effect if the kind is KEEP_LAST_HISTORY_QOS.
	//历史深度<br>默认情况下,1。如果指定了1以外的值,则应与ResourceLimitsQosPolicy的设置保持一致
	//仅当类型为KEEP_LAST_HISTORY_QOS时生效
	int32_t depth;
};


/**
 * Enum HistoryQosPolicyKind, different kinds of History Qos for HistoryQosPolicy.
 */
 /*枚举历史QosPolicyKind,历史QosPolicy的不同历史Qos类型*/
enum HistoryQosPolicyKind : fastrtps::rtps::octet
{
	/**
	 * On the publishing side, the Service will only attempt to keep the most recent “depth” samples of each instance
	 * of data (identified by its key) managed by the DataWriter. On the subscribing side, the DataReader will only attempt
	 * to keep the most recent “depth” samples received for each instance (identified by its key) until the application
	 * “takes” them via the DataReader’s take operation.
	 */
	 /**该策略的含义是仅保存最近的样本数据。
	 *从datawriter来说,每个instance没发送一个样本数据,则会从内存中删除该该样本数据,
	 *如果该instance下有个等多个未发送的数据,此时又有新的样本数据添加进来,
	 *则会将最老的未发送的数据从内存中删除,进而达到内存中最多保持depth个样本实例的目的。
	 *datareader类似,最多保持depth个未读实例,如果此时收到的新的样本数据,则从内存中删除最老的样本数据。
	 *需要注意的是这里的讨论是针对单个instance的。讲到这里朋友们可能就明白采取这种策略有可能会丢失数据。*/
	KEEP_LAST_HISTORY_QOS,
	/**
	 * On the publishing side, the Service will attempt to keep all samples (representing each value written) of each
	 * instance of data (identified by its key) managed by the DataWriter until they can be delivered to all subscribers.
	 * On the subscribing side, the Service will attempt to keep all samples of each instance of data (identified by its
	 * key) managed by the DataReader. These samples are kept until the application “takes” them from the Service via the
	 * take operation.
	 */
	 /**该策略很明显是要保存所有的历史数据,无论读取与否,除非显式的删除内存中的数据或者定时进行内存管理。
	 *否则采取这种模式会对内存的压力较大。尤其是对于发送频率比较大的情况下。最初看到这个策略的时候我有些疑惑,
	 *认为设置这种策略会与读取样本数据冲突,但是后来想通了,这里仅仅是要保存样本数据,
	 *如果调用take方法读取样本数据的话相当于显式的从内存缓冲区中显式的删除的该样本数据,并无冲突的含义。*/
	KEEP_ALL_HISTORY_QOS
};

4、ResourceLimitsQosPolicy

/**
 * Specifies the resources that the Service can consume in order to meet the requested QoS
 * @note Immutable Qos Policy
 */
 /**指定服务可以消耗的资源,以满足请求的QoS
*@note不可变Qos策略*/
class ResourceLimitsQosPolicy : public Parameter_t, public QosPolicy
{
public:

	/**
	 * @brief Specifies the maximum number of data-samples the DataWriter (or DataReader) can manage across all the
	 * instances associated with it. Represents the maximum samples the middleware can store for any one DataWriter
	 * (or DataReader). <br>
	 * By default, 5000.
	 * @warning It is inconsistent for this value to be less than max_samples_per_instance.
	 */
	 /**@short指定DataWriter(或DataReader)可以在所有数据库中管理的最大数据样本数
	*与之关联的实例。表示中间件可以为任何一个DataWriter存储的最大样本数
	*(或DataReader)<br>
	*默认情况下为5000。
	*@warning此值小于max_samples_per_instance是不一致的*/
	int32_t max_samples;
	/**
	 * @brief Represents the maximum number of instances DataWriter (or DataReader) can manage. <br>
	 * By default, 10.
	 */
	 /**@short表示DataWriter(或DataReader)可以管理的最大实例数<br>
	*默认情况下,10*/
	int32_t max_instances;
	/**
	 * @brief Represents the maximum number of samples of any one instance a DataWriter(or DataReader) can manage. <br>
	 * By default, 400.
	 * @warning It is inconsistent for this value to be greater than max_samples.
	 */
	 /**@short表示DataWriter(或DataReader)可以管理的任何一个实例的最大样本数<br>
	*默认情况下为400。
	*@warning此值大于max_samples是不一致的。*/
	int32_t max_samples_per_instance;
	/**
	 * @brief Number of samples currently allocated. <br>
	 * By default, 100.
	 */
	 /**@short当前分配的样本数<br>
	*默认情况下为100。*/
	int32_t allocated_samples;
	/**
	 * @brief Represents the extra number of samples available once the max_samples have been reached in the history.
	 * This makes it possible, for example, to loan samples even with a full history. By default, 1.
	 */
	 /**@short表示在历史记录中达到max_samples后可用的额外样本数。
	*例如,这使得即使有完整的历史记录,也可以借出样本。默认情况下,1*/
	int32_t extra_samples;

	/**
	 * @brief Constructor
	 */
	RTPS_DllAPI ResourceLimitsQosPolicy()
		: Parameter_t(PID_RESOURCE_LIMITS, 4 + 4 + 4)
		, QosPolicy(false)
		, max_samples(5000)
		, max_instances(10)
		, max_samples_per_instance(400)
		, allocated_samples(100)
		, extra_samples(1)
	{
	}
};

5、 WriterQos

/**
 * Class WriterQos, containing all the possible Qos that can be set for a determined Publisher.
 * Although these values can be set and are transmitted
 * during the Endpoint Discovery Protocol, not all of the behaviour associated with them has been implemented in the library.
 * Please consult each of them to check for implementation details and default values.
 * @ingroup FASTRTPS_ATTRIBUTES_MODULE
 */
 /**类WriterQos,包含可以为确定的发布服务器设置的所有可能的Qos。
*虽然这些值可以设置和传输
*在端点发现协议期间,库中并未实现与它们相关的所有行为。
*请咨询他们中的每一个,以检查实现细节和默认值。
*@ingroup快速分组_属性_副本*/
class WriterQos
{
public:
	//!Durability Qos, implemented in the library.
	DurabilityQosPolicy m_durability;

	//!Durability Service Qos, NOT implemented in the library.
	DurabilityServiceQosPolicy m_durabilityService;

	//!Deadline Qos, implemented in the library.
	DeadlineQosPolicy m_deadline;

	//!Latency Budget Qos, NOT implemented in the library.
	LatencyBudgetQosPolicy m_latencyBudget;

	//!Liveliness Qos, implemented in the library.
	LivelinessQosPolicy m_liveliness;

	//!Reliability Qos, implemented in the library.
	ReliabilityQosPolicy m_reliability;

	//!Lifespan Qos, NOT implemented in the library.
	LifespanQosPolicy m_lifespan;

	//!UserData Qos, NOT implemented in the library.
	UserDataQosPolicy m_userData;

	//!Time Based Filter Qos, NOT implemented in the library.
	TimeBasedFilterQosPolicy m_timeBasedFilter;

	//!Ownership Qos, NOT implemented in the library.
	OwnershipQosPolicy m_ownership;

	//!Owenership Strength Qos, NOT implemented in the library.
	OwnershipStrengthQosPolicy m_ownershipStrength;

	//!Destination Order Qos, NOT implemented in the library.
	DestinationOrderQosPolicy m_destinationOrder;

	//!Presentation Qos, NOT implemented in the library.
	PresentationQosPolicy m_presentation;

	//!Partition Qos, implemented in the library.
	PartitionQosPolicy m_partition;

	//!Topic Data Qos, NOT implemented in the library.
	TopicDataQosPolicy m_topicData;

	//!Group Data Qos, NOT implemented in the library.
	GroupDataQosPolicy m_groupData;

	//!Publication Mode Qos, implemented in the library.
	PublishModeQosPolicy m_publishMode;

	//!Data Representation Qos, implemented in the library.
	DataRepresentationQosPolicy representation;

	//!Disable positive acks QoS, implemented in the library.
	DisablePositiveACKsQosPolicy m_disablePositiveACKs;

	//!Information for data sharing compatibility check.
	DataSharingQosPolicy data_sharing;

	/**
	 * Set Qos from another class
	 * @param qos Reference from a WriterQos object.
	 * @param first_time Boolean indicating whether is the first time (If not some parameters cannot be set).
	 */
	RTPS_DllAPI void setQos(
			const WriterQos& qos,
			bool first_time);

	/**
	 * Check if the Qos values are compatible between each other.
	 * @return True if correct.
	 */
	RTPS_DllAPI bool checkQos() const;

	RTPS_DllAPI bool canQosBeUpdated(
			const WriterQos& qos) const;

	void clear();
};

6、ReliabilityQosPolicy

	/**
 * Indicates the reliability of the endpoint.
 * @note Immutable Qos Policy
 */
class ReliabilityQosPolicy : public Parameter_t, public QosPolicy
{
public:

	/**
	 * @brief Constructor
	 */
	RTPS_DllAPI ReliabilityQosPolicy()
		: Parameter_t(PID_RELIABILITY, PARAMETER_KIND_LENGTH + PARAMETER_TIME_LENGTH)
		, QosPolicy(true) //indicate send always
		, kind(BEST_EFFORT_RELIABILITY_QOS)
		, max_blocking_time{0, 100000000} // max_blocking_time = 100ms
	{
	}

public:

	/*!
	 * @brief Defines the reliability kind of the endpoint. <br>
	 * By default, BEST_EFFORT_RELIABILITY_QOS for DataReaders and RELIABLE_RELIABILITY_QOS for DataWriters.
	 */
	 /**@short定义端点的可靠性类型<br>
	*默认情况下,数据读取器使用BEST_EFFORT_RELIABILITY_QOS,数据写入器使用RELIABLE_Reliality_QOS。*/
	ReliabilityQosPolicyKind kind;

	/*!
	 * @brief Defines the maximum period of time certain methods will be blocked.
	 *
	 * Methods affected by this property are:
	 * - DataWriter::write
	 * - DataReader::takeNextData
	 * - DataReader::readNextData
	 * <br>
	 * By default, 100 ms.
	 */
	 /**@brief定义某些方法被阻止的最长时间。
	*
	*受此属性影响的方法有:
	*-数据写入器::写入
	*-数据阅读器::takeNextData
	*-DataReader::readNextData
	*<br>
	*默认情况下为100毫秒。*/
	fastrtps::Duration_t max_blocking_time;
};

7、DurabilityQosPolicy

/**
 * This policy expresses if the data should ‘outlive’ their writing time.
 * @note Immutable Qos Policy
 */
class DurabilityQosPolicy : public Parameter_t, public QosPolicy
{
public:

	/**
	 * @brief Constructor
	 */
	RTPS_DllAPI DurabilityQosPolicy()
		: Parameter_t(PID_DURABILITY, PARAMETER_KIND_LENGTH)
		, QosPolicy(true)
		, kind(VOLATILE_DURABILITY_QOS)
	{
	}

	/**
	 * @brief Destructor
	 */
	virtual RTPS_DllAPI ~DurabilityQosPolicy() = default;

	/**
	 * Translates kind to rtps layer equivalent
	 * @return fastrtps::rtps::DurabilityKind_t
	 */
	inline fastrtps::rtps::DurabilityKind_t durabilityKind() const
	{
		switch (kind)
		{
			default:
			case VOLATILE_DURABILITY_QOS: return fastrtps::rtps::VOLATILE;
			case TRANSIENT_LOCAL_DURABILITY_QOS: return fastrtps::rtps::TRANSIENT_LOCAL;
			case TRANSIENT_DURABILITY_QOS: return fastrtps::rtps::TRANSIENT;
			case PERSISTENT_DURABILITY_QOS: return fastrtps::rtps::PERSISTENT;
		}
	}
public:

	/**
	 * @brief DurabilityQosPolicyKind. <br>
	 * By default the value for DataReaders: VOLATILE_DURABILITY_QOS, for DataWriters TRANSIENT_LOCAL_DURABILITY_QOS
	 */
	DurabilityQosPolicyKind_t kind;
};
enum DurabilityQosPolicyKind {        
        VOLATILE_DURABILITY_QOS,//忽略DataReader加入之前的消息
        TRANSIENT_LOCAL_DURABILITY_QOS,    //新的DataReader加入后,在话题中的历史消息会保存在内存中    
        TRANSIENT_DURABILITY_QOS,       //新的DataReader加入后,在话题中的历史消息会保存在硬盘中 
        PERSISTENT_DURABILITY_QOS    
};

8、PublishModeQosPolicy

/**
 * Class PublishModeQosPolicy, defines the publication mode for a specific writer.
 */
class PublishModeQosPolicy : public QosPolicy
{
public:
	//!PublishModeQosPolicyKind <br> By default, SYNCHRONOUS_PUBLISH_MODE.
	//PublishModeQosPolicyKind<br>默认情况下,SYNCHRONOS_PUBLISH_MODE
	//SYNCHRONOUS_PUBLISH_MODE:同步的,数据是在调用写操作的用户线程的上下文中发送的。 
	//ASYNCHRONOUS_PUBLISH_MODE:异步的,一个内部线程负责异步发送数据
	PublishModeQosPolicyKind kind;
};	

8、WriterTimes

/**
 * Struct WriterTimes, defining the times associated with the Reliable Writers events.
 * @ingroup RTPS_ATTRIBUTES_MODULE
 */
/**Struct WriterTimes,定义与Reliable Writers事件关联的时间。
*@ingroup RTPS_ATTRIBUTES_MODULE*/
struct WriterTimes
{
	//! Initial heartbeat delay. Default value ~11ms.
	//初始心跳延迟。默认值~11ms。
	Duration_t initialHeartbeatDelay;
	//! Periodic HB period, default value 3s.
	//周期性HB周期,默认值3s
	Duration_t heartbeatPeriod;
	//!Delay to apply to the response of a ACKNACK message, default value ~5ms.
	//延迟应用于ACK/NACK消息的响应,默认值~5ms。
	Duration_t nackResponseDelay;
	//!This time allows the RTPSWriter to ignore nack messages too soon after the data as sent, default value 0s.
	//此时间允许RTPSWriter在数据发送后过早忽略nack消息,默认值为0s
	Duration_t nackSupressionDuration;

	WriterTimes()
	{
		//initialHeartbeatDelay.fraction = 50*1000*1000;
		initialHeartbeatDelay.nanosec = 12 * 1000 * 1000;
		heartbeatPeriod.seconds = 3;
		//nackResponseDelay.fraction = 20*1000*1000;
		nackResponseDelay.nanosec = 5 * 1000 * 1000;
	}
};
struct Duration_t {        
    long sec;        //秒
	unsigned long nanosec;   //纳秒 
};

四、SubscriberAttributes类
1、SubscriberAttributes

/**
 * Class SubscriberAttributes, used by the user to define the attributes of a Subscriber.
 * @ingroup FASTRTPS_ATTRIBUTES_MODULE
 */
class SubscriberAttributes
{
	public:
		//!Topic Attributes
		TopicAttributes topic;

		//!Reader QOs.
		ReaderQos qos;

		//!Times for a RELIABLE Reader
		rtps::ReaderTimes times;

		//!Unicast locator list
		rtps::LocatorList_t unicastLocatorList;

		//!Multicast locator list
		rtps::LocatorList_t multicastLocatorList;

		//!Remote locator list
		rtps::LocatorList_t remoteLocatorList;

		//!Expects Inline QOS
		bool expectsInlineQos;

		//!Underlying History memory policy
		rtps::MemoryManagementPolicy_t historyMemoryPolicy;

		//!Properties
		rtps::PropertyPolicy properties;

		//!Matched publishers allocation limits
		ResourceLimitedContainerConfig matched_publisher_allocation;

		SubscriberAttributes()
			: expectsInlineQos(false)
			, historyMemoryPolicy(rtps::PREALLOCATED_MEMORY_MODE)
			, m_userDefinedID(-1)
			, m_entityID(-1)
		{}


		/**
		 * Get the user defined ID
		 * @return User defined ID
		 */
		inline int16_t getUserDefinedID() const { return m_userDefinedID; }

		/**
		 * Get the entity defined ID
		 * @return Entity ID
		 */
		inline int16_t getEntityID() const { return m_entityID; }

		/**
		 * Set the user defined ID
		 * @param id User defined ID to be set
		 */
		inline void setUserDefinedID(uint8_t id) { m_userDefinedID = id; }

		/**
		 * Set the entity ID
		 * @param id Entity ID to be set
		 */
		inline void setEntityID(uint8_t id) { m_entityID = id; }

	private:
		//!User Defined ID, used for StaticEndpointDiscovery, default value -1.
		int16_t m_userDefinedID;

		//!Entity ID, if the user want to specify the EntityID of the enpoint, default value -1.
		int16_t m_entityID;
};

2、ReaderQos

/**
 * Class ReaderQos, contains all the possible Qos that can be set for a determined Subscriber.
 * Although these values can be set and are transmitted
 * during the Endpoint Discovery Protocol, not all of the behaviour associated with them has been implemented in the library.
 * Please consult each of them to check for implementation details and default values.
 * @ingroup FASTRTPS_ATTRIBUTES_MODULE
 */
class ReaderQos
{
public:

	//!Durability Qos, implemented in the library.
	DurabilityQosPolicy m_durability;

	//!Deadline Qos, implemented in the library.
	DeadlineQosPolicy m_deadline;

	//!Latency Budget Qos, NOT implemented in the library.
	LatencyBudgetQosPolicy m_latencyBudget;

	//!Liveliness Qos, implemented in the library.
	LivelinessQosPolicy m_liveliness;

	//!ReliabilityQos, implemented in the library.
	ReliabilityQosPolicy m_reliability;

	//!Ownership Qos, NOT implemented in the library.
	OwnershipQosPolicy m_ownership;

	//!Destinatio Order Qos, NOT implemented in the library.
	DestinationOrderQosPolicy m_destinationOrder;

	//!UserData Qos, NOT implemented in the library.
	UserDataQosPolicy m_userData;

	//!Time Based Filter Qos, NOT implemented in the library.
	TimeBasedFilterQosPolicy m_timeBasedFilter;

	//!Presentation Qos, NOT implemented in the library.
	PresentationQosPolicy m_presentation;

	//!Partition Qos, implemented in the library.
	PartitionQosPolicy m_partition;

	//!Topic Data Qos, NOT implemented in the library.
	TopicDataQosPolicy m_topicData;

	//!GroupData Qos, NOT implemented in the library.
	GroupDataQosPolicy m_groupData;

	//!Durability Service Qos, NOT implemented in the library.
	DurabilityServiceQosPolicy m_durabilityService;

	//!Lifespan Qos, NOT implemented in the library.
	LifespanQosPolicy m_lifespan;

	//!Data Representation Qos, implemented in the library.
	DataRepresentationQosPolicy representation;

	//!Type consistency enforcement Qos, NOT implemented in the library.
	TypeConsistencyEnforcementQosPolicy type_consistency;

	//!Disable positive ACKs QoS
	DisablePositiveACKsQosPolicy m_disablePositiveACKs;

	//!Information for data sharing compatibility check.
	DataSharingQosPolicy data_sharing;

	/**
	 * Set Qos from another class
	 * @param readerqos Reference from a ReaderQos object.
	 * @param first_time Boolean indicating whether is the first time (If not some parameters cannot be set).
	 */
	RTPS_DllAPI void setQos(
			const ReaderQos& readerqos,
			bool first_time);

	/**
	 * Check if the Qos values are compatible between each other.
	 * @return True if correct.
	 */
	RTPS_DllAPI bool checkQos() const;

	/**
	 * Check if the Qos can be update with the values provided. This method DOES NOT update anything.
	 * @param qos Reference to the new qos.
	 * @return True if they can be updated.
	 */
	RTPS_DllAPI bool canQosBeUpdated(
			const ReaderQos& qos) const;

	void clear();
};

3、ReaderTimes

/**
 * Class ReaderTimes, defining the times associated with the Reliable Readers events.
 * @ingroup RTPS_ATTRIBUTES_MODULE
 */
class ReaderTimes
{
public:

	ReaderTimes()
	{
		initialAcknackDelay.nanosec = 70 * 1000 * 1000;
		heartbeatResponseDelay.nanosec = 5 * 1000 * 1000;
	}

	//!Initial AckNack delay. Default value 70ms.
	Duration_t initialAcknackDelay;
	//!Delay to be applied when a HEARTBEAT message is received, default value 5ms.
	Duration_t heartbeatResponseDelay;
};
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值