本文整理汇总了C#中ISubscriber.GetDefaultDataReaderQos方法的典型用法代码示例。如果您正苦于以下问题:C# ISubscriber.GetDefaultDataReaderQos方法的具体用法?C# ISubscriber.GetDefaultDataReaderQos怎么用?C# ISubscriber.GetDefaultDataReaderQos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISubscriber
的用法示例。
在下文中一共展示了ISubscriber.GetDefaultDataReaderQos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DomainParticipantTransportSource
public DomainParticipantTransportSource(IDomainParticipant participant, string senderTopic, string receiverTopic)
{
_participant = participant;
var bdt = new ByteDataTypeSupport();
var result = bdt.RegisterType(participant, bdt.TypeName);
if (result != ReturnCode.Ok)
throw new Exception("Unable to register type: " + result);
_publisher = _participant.CreatePublisher();
_subscriber = _participant.CreateSubscriber();
var senderTopicQos = new TopicQos();
participant.GetDefaultTopicQos(ref senderTopicQos);
var receiverTopicQos = new TopicQos();
participant.GetDefaultTopicQos(ref receiverTopicQos);
_senderTopic = participant.CreateTopic(senderTopic, bdt.TypeName, senderTopicQos);
_receiverTopic = participant.CreateTopic(receiverTopic, bdt.TypeName, receiverTopicQos);
_dataWriter = (ByteDataWriter)_publisher.CreateDataWriter(_senderTopic);
_dataToSendHandle = _dataWriter.RegisterInstance(_dataToSend);
var dataReaderQos = new DataReaderQos();
_subscriber.GetDefaultDataReaderQos(ref dataReaderQos);
_dataReader = (ByteDataReader)_subscriber.CreateDataReader(_receiverTopic, dataReaderQos, this, StatusKind.Any);
}
示例2: CreateSimulatedMultitopic
/***
* Operations
***/
public ITopic CreateSimulatedMultitopic(
string name,
string type_name,
string subscription_expression,
string[] expression_parameters)
{
/* Type-specific DDS entities */
ChatMessageDataReader chatMessageDR;
NameServiceDataReader nameServiceDR;
NamedMessageDataWriter namedMessageDW;
/* Query related stuff */
IQueryCondition nameFinder;
string[] nameFinderParams;
/* QosPolicy holders */
TopicQos namedMessageQos = new TopicQos();
SubscriberQos subQos = new SubscriberQos();
PublisherQos pubQos = new PublisherQos();
/* Others */
IDataReader parentReader;
IDataWriter parentWriter;
string partitionName = "ChatRoom";
string nameFinderExpr;
ReturnCode status;
/* Lookup both components that constitute the multi-topic. */
chatMessageTopic = realParticipant.FindTopic(
"Chat_ChatMessage", Duration.Infinite);
ErrorHandler.checkHandle(
chatMessageTopic,
"DDS.DomainParticipant.FindTopic (Chat_ChatMessage)");
nameServiceTopic = realParticipant.FindTopic(
"Chat_NameService", Duration.Infinite);
ErrorHandler.checkHandle(
nameServiceTopic,
"DDS.DomainParticipant.FindTopic (Chat_NameService)");
/* Create a ContentFilteredTopic to filter out
our own ChatMessages. */
filteredMessageTopic = realParticipant.CreateContentFilteredTopic(
"Chat_FilteredMessage",
chatMessageTopic,
"userID <> %0",
expression_parameters);
ErrorHandler.checkHandle(
filteredMessageTopic,
"DDS.DomainParticipant.CreateContentFilteredTopic");
/* Adapt the default SubscriberQos to read from the
"ChatRoom" Partition. */
status = realParticipant.GetDefaultSubscriberQos (ref subQos);
ErrorHandler.checkStatus(
status, "DDS.DomainParticipant.GetDefaultSubscriberQos");
subQos.Partition.Name = new string[1];
subQos.Partition.Name[0] = partitionName;
/* Create a private Subscriber for the multitopic simulator. */
multiSub = realParticipant.CreateSubscriber(subQos);
ErrorHandler.checkHandle(
multiSub,
"DDS.DomainParticipant.CreateSubscriber (for multitopic)");
/* Create a DataReader for the FilteredMessage Topic
(using the appropriate QoS). */
DataReaderQos drQos = new DataReaderQos();
TopicQos topicQos = new TopicQos();
multiSub.GetDefaultDataReaderQos(ref drQos);
filteredMessageTopic.RelatedTopic.GetQos(ref topicQos);
multiSub.CopyFromTopicQos(ref drQos, topicQos);
parentReader = multiSub.CreateDataReader(filteredMessageTopic, drQos);
ErrorHandler.checkHandle(
parentReader, "DDS.Subscriber.create_datareader (ChatMessage)");
/* Narrow the abstract parent into its typed representative. */
chatMessageDR = parentReader as ChatMessageDataReader;
/* Allocate the DataReaderListener Implementation. */
msgListener = new DataReaderListenerImpl();
/* Attach the DataReaderListener to the DataReader,
only enabling the data_available event. */
status = chatMessageDR.SetListener(msgListener, StatusKind.DataAvailable);
ErrorHandler.checkStatus(status, "DDS.DataReader_set_listener");
/* Create a DataReader for the nameService Topic
(using the appropriate QoS). */
DataReaderQos nsDrQos = new DataReaderQos();
TopicQos nsQos = new TopicQos();
nameServiceTopic.GetQos(ref nsQos);
multiSub.CopyFromTopicQos(ref nsDrQos, nsQos);
parentReader = multiSub.CreateDataReader(nameServiceTopic, nsDrQos);
ErrorHandler.checkHandle(parentReader, "DDS.Subscriber.CreateDatareader (NameService)");
//.........这里部分代码省略.........
示例3: init
private void init()
{
tstTypeSupport typeSupport;
string errMsg = "Unknown error";
for ( int i = 0; i < MAX_INSTANCE; i++ ) {
testData[i] = new tst();
testData[i].long_1 = i;
testData[i].long_2 = 0;
testData[i].long_3 = 0;
}
initialiseInstanceData();
/**
* @addtogroup group_dds1290
*
* \b Test \b ID: \b saj_invalid_data_000
*
* \b Test \b Objectives:
*
* Create and initialise all required DDS entities
*
* \b Test \b Procedure:
*
* \e Action
*
* The following entities are obtained/created
* \arg \c DomainParticipantFactory
* \arg \c DomainParticipant with default QoS settings
* \arg \c Publisher with default QoS settings
* \arg \c Subscriber with default QoS settings
* \arg \c The mod::tst type is registered
* \arg \c A topic T1 of type tstModule::tst is created with default QoS settings
* \arg \c A DataWriter W for T1 with default QoS settings, writer_data_lifecycle.autodispose_unregistered_instances = FALSE
* \arg \c A DataReader for T1 with default QoS settings
*
* \e Result
* It is expected that all entities are created/initialized correctly and without any failures. \n
* If a failure occurs at any of the above stages, the test fails, this is reported and no further testing is performed
*/
/*- INITIALIZATION ---------------------------------------------------------*/
tfw.TestStart ("sacs_sampleInfo_000","SampleInfo","initialization");
tfw.TestTitle ("Test SampleInfo initialization.");
tfw.TestPurpose ("Test SampleInfo initialization.");
factory = DomainParticipantFactory.Instance;
if(factory == null){
errMsg = "DomainParticipantFactory could NOT be resolved";
proceed = false;
} else {
participant = factory.CreateParticipant(domainId);
if(participant == null){
errMsg = "DomainParticipant could NOT be created";
proceed = false;
} else {
typeSupport = new tstTypeSupport();
result = typeSupport.RegisterType(participant, "tst");
if(result == ReturnCode.Ok){
topic = participant.CreateTopic("my_topic", "tst");
if(topic != null){
subscriber = participant.CreateSubscriber();
if(subscriber != null){
subscriber.GetDefaultDataReaderQos(ref drQos);
if(drQos != null){
drQos.History.Kind = HistoryQosPolicyKind.KeepLastHistoryQos;
drQos.History.Depth = MAX_DEPTH;
reader = subscriber.CreateDataReader(topic, drQos) as tstDataReader;
if(reader != null){
publisher = participant.CreatePublisher();
if(publisher != null){
result = publisher.GetDefaultDataWriterQos(ref dwQos);
if(dwQos != null && result == ReturnCode.Ok){
dwQos.WriterDataLifecycle.AutodisposeUnregisteredInstances = false;
writer = publisher.CreateDataWriter(topic, dwQos) as tstDataWriter;
if(writer == null){
errMsg = "DataWriter could NOT be created";
proceed = false;
}
} else {
reportResultCode(result);
errMsg = "Default DataWriterQos could NOT be retrieved";
proceed = false;
}
} else {
errMsg = "Publisher could NOT be created";
proceed = false;
}
} else {
errMsg = "DataReader could NOT be created";
proceed = false;
//.........这里部分代码省略.........