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


C# IPublisher.CreateDataWriter方法代码示例

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


在下文中一共展示了IPublisher.CreateDataWriter方法的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


//.........这里部分代码省略.........

            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)");

            /* Narrow the abstract parent into its typed representative. */
            nameServiceDR = parentReader as NameServiceDataReader;

            /* Define the SQL expression (using a parameterized value). */
            nameFinderExpr = "userID = %0";

            /* Allocate and assign the query parameters. */
            nameFinderParams = new string[1];
            nameFinderParams[0] = expression_parameters[0];

            /* Create a QueryCondition to only read corresponding
               nameService information by key-value. */
            nameFinder = nameServiceDR.CreateQueryCondition(
            SampleStateKind.Any,
            ViewStateKind.Any,
            InstanceStateKind.Any,
            nameFinderExpr,
            nameFinderParams);
            ErrorHandler.checkHandle(
            nameFinder, "DDS.DataReader.create_querycondition (nameFinder)");

            /* Create the Topic that simulates the multi-topic
               (use Qos from chatMessage).*/
            status = chatMessageTopic.GetQos(ref namedMessageQos);
            ErrorHandler.checkStatus(status, "DDS.Topic.GetQos");

            /* Create the NamedMessage Topic whose samples simulate
               the MultiTopic */
            namedMessageTopic = realParticipant.CreateTopic(
            "Chat_NamedMessage",
            type_name,
            namedMessageQos);
            ErrorHandler.checkHandle(
            namedMessageTopic,
            "DDS.DomainParticipant.CreateTopic (NamedMessage)");

            /* Adapt the default PublisherQos to write into the
               "ChatRoom" Partition. */
            status = realParticipant.GetDefaultPublisherQos(ref pubQos);
            ErrorHandler.checkStatus(
            status, "DDS.DomainParticipant.get_default_publisher_qos");
            pubQos.Partition.Name = new string[1];
            pubQos.Partition.Name[0] = partitionName;

            /* Create a private Publisher for the multitopic simulator. */
            multiPub = realParticipant.CreatePublisher(pubQos);
            ErrorHandler.checkHandle(
            multiPub,
            "DDS.DomainParticipant.create_publisher (for multitopic)");

            DataWriterQos nmDwQos = new DataWriterQos();
            TopicQos nmQos = new TopicQos();
            multiPub.GetDefaultDataWriterQos(ref nmDwQos);
            namedMessageTopic.GetQos(ref nmQos);
            multiPub.CopyFromTopicQos(ref nmDwQos, nmQos);

            /* Create a DataWriter for the multitopic. */
            parentWriter = multiPub.CreateDataWriter(namedMessageTopic, nmDwQos);
            ErrorHandler.checkHandle(
            parentWriter, "DDS.Publisher.CreateDatawriter (NamedMessage)");

            /* Narrow the abstract parent into its typed representative. */
            namedMessageDW = parentWriter as NamedMessageDataWriter;

            /* Store the relevant Entities in our Listener. */
            msgListener.ChatMessageDR = chatMessageDR;
            msgListener.NameServiceDR = nameServiceDR;
            msgListener.NamedMessageDW = namedMessageDW;
            msgListener.NameFinder = nameFinder;
            msgListener.NameFinderParams = nameFinderParams;

            /* Return the simulated Multitopic. */
            return namedMessageTopic;
        }
开发者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


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