当前位置: 首页>>代码示例>>C#>>正文


C# ISubscriber.CreateDataReader方法代码示例

本文整理汇总了C#中ISubscriber.CreateDataReader方法的典型用法代码示例。如果您正苦于以下问题:C# ISubscriber.CreateDataReader方法的具体用法?C# ISubscriber.CreateDataReader怎么用?C# ISubscriber.CreateDataReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISubscriber的用法示例。


在下文中一共展示了ISubscriber.CreateDataReader方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
		}
开发者ID:BrannonKing,项目名称:Kts.Remoting,代码行数:28,代码来源:DdsExtensions.cs

示例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)");
//.........这里部分代码省略.........
开发者ID:xrl,项目名称:opensplice_dds,代码行数:101,代码来源:ExtDomainParticipant.cs

示例3: init

     private void init()
     {
         MyTopicTypeSupport typeSupport;
         DataWriterQos wQos = null;
         string msg = "Unknown error";
         
         /**
          * @addtogroup group_dds1290
          *
          * \b Test \b ID: \b sacs_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 MyTopicModule::MyTopic type is registered
          * \arg \c A topic T1 of type MyTopicModule::MyTopic is created with default QoS settings
          * \arg \c A DataWriter W1 for T1 with default QoS settings, writer_data_lifecycle.autodispose_unregistered_instances = FALSE
          * \arg \c A DataWriter W2 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_invalid_data_000","invalid_data","initialization");
         tfw.TestTitle ("Test initialization.");
         tfw.TestPurpose ("Test initialization.");
 
         factory = DomainParticipantFactory.Instance;
         
         if(factory == null){
             msg = "DomainParticipantFactory could NOT be resolved";
             proceed = false;
         } else {
             participant = factory.CreateParticipant(DDS.DomainId.Default);
 
             if(participant == null){
                 msg = "DomainParticipant could NOT be created";
                 proceed = false;
             } else {
                 typeSupport = new MyTopicTypeSupport();
 
                 result = typeSupport.RegisterType(participant, "MyTopic");
                 if(result == ReturnCode.Ok){
                     topic = participant.CreateTopic("my_topic", "MyTopic");
 
                     if(topic != null){
                         subscriber = participant.CreateSubscriber();
 
                         if(subscriber != null){
                             reader = subscriber.CreateDataReader(topic) as MyTopicDataReader;
 
                             if(reader != null){
 
                                 publisher = participant.CreatePublisher();
 
                                 if(publisher != null){
                                     result = publisher.GetDefaultDataWriterQos(ref wQos);
                                     if(wQos != null && result == ReturnCode.Ok){
                                         wQos.WriterDataLifecycle.AutodisposeUnregisteredInstances = false;
                                         writer1 = publisher.CreateDataWriter(topic, wQos) as MyTopicDataWriter;
                                         if(writer1 != null){
                                             writer2 = publisher.CreateDataWriter(topic, wQos) as MyTopicDataWriter;
                                             if(writer2 == null){
                                                 msg = "DataWriter could NOT be created";
                                                 proceed = false;
                                             }
                                         } else {
                                             msg = "DataWriter could NOT be created";
                                             proceed = false;
                                         }
                                     } else {
                                         reportResultCode(result);
                                         msg = "Default DataWriterQos could NOT be retrieved";
                                         proceed = false;
                                     }
                                 } else {
                                     msg = "Publisher could NOT be created";
                                     proceed = false;
                                 }
 
                             } else {
                                 msg = "DataReader could NOT be created";
                                 proceed = false;
                             }
                         } else {
                             msg = "Subscriber could NOT be created";
                             proceed = false;
                         }
//.........这里部分代码省略.........
开发者ID:shizhexu,项目名称:opensplice,代码行数:101,代码来源:InvalidData.cs

示例4: 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;
//.........这里部分代码省略.........
开发者ID:shizhexu,项目名称:opensplice,代码行数:101,代码来源:SampleInfo1.cs


注:本文中的ISubscriber.CreateDataReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。