コード例 #1
0
        /// <summary>
        /// Create DataWriter(s)
        /// </summary>
        public void createWriter()
        {
            status = publisher.GetDefaultDataWriterQos(ref WQosH);
            ErrorHandler.checkStatus(status, "Publisher.GetDefaultDataWriterQos");
            status = publisher.CopyFromTopicQos(ref WQosH, topicQos);
            ErrorHandler.checkStatus(status, "Publisher.CopyFromTopicQos");
            if (durabilityKind.Equals("transient"))
            {
                WQosH.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos;
            }
            else
            {
                WQosH.Durability.Kind = DurabilityQosPolicyKind.PersistentDurabilityQos;
            }

            WQosH.WriterDataLifecycle.AutodisposeUnregisteredInstances = autoDisposeFlag;
            writer = publisher.CreateDataWriter(
                topic,
                WQosH,
                null,
                StatusKind.Any);
            ErrorHandler.checkHandle(writer, "Publisher.CreateDataWriter");

            if (exampleName.Equals("Lifecycle"))
            {
                writerStopper = publisher.CreateDataWriter(
                    topic,
                    WQosH,
                    null,
                    StatusKind.Any);
                ErrorHandler.checkHandle(writerStopper, "Publisher.CreateDataWriter");
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
		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);
		}
コード例 #4
0
ファイル: Program.cs プロジェクト: Ghazanfar373/FDMPublisher
        static void Main(string[] args)
        {
            _dpf = DomainParticipantFactory.Instance;
            ErrorHandler.checkHandle(_dpf, "Domain Participant Factory");

            _dp = _dpf.CreateParticipant(Domain);

            //Initialize QOS
            pQos  = new PublisherQos();
            dwQos = new DataWriterQos();

            fdmDataType = new FDMTypeSupport();
            string     FDMDATATypeName = fdmDataType.TypeName;
            ReturnCode status          = fdmDataType.RegisterType(_dp, FDMDATATypeName);

            ErrorHandler.checkStatus(status, "FDMDATA: Cannot Register Type");


            //Create FDMDATA Topic
            fdmDataTopic = _dp.FindTopic("FDMDATA", Duration.FromMilliseconds(1000));
            if (fdmDataTopic == null)
            {
                fdmDataTopic = _dp.CreateTopic("FDMDATA", FDMDATATypeName);
            }
            ErrorHandler.checkHandle(fdmDataTopic, "Cannot Create Topic FDMDATA");

            //Get Publisher QOS and Set Partition Name
            _dp.GetDefaultPublisherQos(ref pQos);
            pQos.Partition.Name    = new String[1];
            pQos.Partition.Name[0] = PartitionName;

            //Create Subscriber for FDMDATA Topic
            Publisher = _dp.CreatePublisher(pQos);
            ErrorHandler.checkHandle(Publisher, "Cannot Create FDMDATA Publisher");

            //Get Data Writer QOS and Set History Depth
            Publisher.GetDefaultDataWriterQos(ref dwQos);
            ErrorHandler.checkHandle(dwQos, "Cannot get Data Writer Qos");
            dwQos.History.Depth    = 5;
            dwQos.Reliability.Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos;


            //Create DataReader for FDMDATA Topic
            parentWriter = Publisher.CreateDataWriter(fdmDataTopic, dwQos);
            ErrorHandler.checkHandle(parentWriter, "Cannot Create FDMDATA Data Writer");

            //Narrow abstract parentWriter into its typed representative
            fdmDataWriter = parentWriter as FDMDataWriter;
            ErrorHandler.checkHandle(fdmDataWriter, "Cannot Narrow FDMDATA Data Writer");

            fdmData = new FDM();
            while (true)
            {
                StartPublish();
                Console.WriteLine("Publishing data! ");
                Thread.Sleep(10);
            }
        }
コード例 #5
0
        private void InitializeWriter(AdapterWriterQos desiredQos)
        {
            var writerQos = new DataWriterQos();

            topicPublisher.GetDefaultDataWriterQos(ref writerQos);
            topicPublisher.CopyFromTopicQos(ref writerQos, currentTopic.TopicQos);
            if (desiredQos != null)
            {
                writerQos.WriterDataLifecycle.AutodisposeUnregisteredInstances = false;
                writerQos.Reliability.Kind = desiredQos.MessageReliabilityType.ConvertReliability();
                writerQos.Durability.Kind  = desiredQos.PersistenceType.ConvertPersistence();
            }

            // Create a DataWritter for the current Topic
            dataWriter = topicPublisher.CreateDataWriter(currentTopic.TopicMessageTopic, writerQos) as DataWriter <T>;
            ErrorHandler.CheckHandle(
                DataWriter, "Publisher.CreateDatawriter (InitializeWriter)");
        }
コード例 #6
0
        /***
         * 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)");

            /* 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);
        }
コード例 #7
0
        /***
         * 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)");

            /* 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;
        }
コード例 #8
0
ファイル: TestBinding.cs プロジェクト: fville/opensplice
        public void Run()
        {
#if DBCallTests
            DDS.Test.DatabaseTests();
#endif

            Console.WriteLine("Press enter to enter...");
            Console.ReadLine();
            Data.DataTest detectionData = new Data.DataTest();
            detectionData.TestId    = 3214;
            detectionData.Emergency = true;
            detectionData.TestStr   = "not really";
            //detectionData.SeqInt[3] = 23;
#if TestMarshaling
            //Tactical.DetectionTypeSupport support = new Tactical.DetectionTypeSupport();
            //Tactical.Detection cachedObj = new Tactical.Detection();
            //support.Copy(cachedObj, detectionData);

            //SampleMarshaler marshaler = SampleMarshalerFactory.CreateMarshaler(detectionData);

            //using (SampleMarshalHelper helper = new SampleMarshalHelper(marshaler))
            //{
            //    DDS.OpenSplice.Gapi.Test.test_detection(helper.GapiPtr);

            //    Tactical.Detection detectionData2 = new Tactical.Detection();
            //    SampleMarshaler marshaler2 = SampleMarshalerFactory.CreateMarshaler(detectionData2);
            //    marshaler2.CopyOut(helper.GapiPtr, 0);
            //}

            //Duration d = new Duration(234, 2343);
            //int sec;
            //uint nanosec;
            //DDS.OpenSplice.Gapi.Test.test_duration(d, out sec, out nanosec);

            //LivelinessChangedStatus status;
            //DDS.OpenSplice.Gapi.Test.get_liveliness_changed_status(out status);

            //Time t = new Time(1, 2);
            //int size = Marshal.SizeOf(t);
            //IntPtr ptr = Marshal.AllocHGlobal(size);
            //Marshal.StructureToPtr(t, ptr, true);
#endif

            //DDS.Test.TestDataReaderQos();
            //DDS.Test.TestTopicQos();

            // Create a DomainParticipantFactory
            DomainParticipantFactory dpf = DomainParticipantFactory.Instance;
            Console.WriteLine("DomainParticipantFactory: " + dpf);

            // Tailor the DomainPartipantFactoryQos;
            DomainParticipantFactoryQos dpfQos = null;
            ReturnCode result = dpf.GetQos(ref dpfQos);
            Console.WriteLine("DomainParticipantFactory.get_qos: {0}", result);
            Console.WriteLine("DomainParticipantFactoryQos.entity_factory.autoenable_created_entities: " + dpfQos.EntityFactory.AutoenableCreatedEntities);

            dpfQos.EntityFactory.AutoenableCreatedEntities = false;
            result = dpf.SetQos(dpfQos);
            Console.WriteLine("DomainParticipantFactory.set_qos: {0}", result);

            // Get the QOS settings for the Factory...  Check values without additional changes
            DomainParticipantFactoryQos dpf2Qos = null;
            result = dpf.GetQos(ref dpf2Qos);
            Console.WriteLine("DomainParticipantFactory.get_qos: {0}", result);
            Console.WriteLine("DomainParticipantFactoryQos.entity_factory.autoenable_created_entities: " + dpf2Qos.EntityFactory.AutoenableCreatedEntities);

            // Create the domainParticipant itself.
            DomainParticipantQos dpQos = new DomainParticipantQos();
            dpQos.UserData.Value = new byte[] { (byte)1, (byte)2, (byte)3 };
            dpQos.EntityFactory.AutoenableCreatedEntities        = true;
            dpQos.ListenerScheduling.SchedulingClass.Kind        = SchedulingClassQosPolicyKind.ScheduleDefault;
            dpQos.ListenerScheduling.SchedulingPriorityKind.Kind = SchedulingPriorityQosPolicyKind.PriorityRelative;
            dpQos.ListenerScheduling.SchedulingPriority          = 0;
            dpQos.WatchdogScheduling.SchedulingClass.Kind        = SchedulingClassQosPolicyKind.ScheduleDefault;
            dpQos.WatchdogScheduling.SchedulingPriorityKind.Kind = SchedulingPriorityQosPolicyKind.PriorityRelative;
            dpQos.WatchdogScheduling.SchedulingPriority          = 4;

            IDomainParticipant dp = dpf.CreateParticipant(null, dpQos);
            Console.Write("DomainParticipant: ");
            Console.WriteLine(dp != null ? "yes" : "no");


            if (dp.ContainsEntity(0))
            {
                Console.WriteLine("contains_entity with nil handle incorrect");
            }
            if (dp.ContainsEntity(100))
            {
                Console.WriteLine("contains_entity with incorrect handle incorrect");
            }

            Time currentTime;
            dp.GetCurrentTime(out currentTime);
            Console.WriteLine("Current Local Time: {0}", currentTime.ToDatetime().ToLocalTime());

            // And look up this DomainParticipant.
            IDomainParticipant dp2 = dpf.LookupParticipant(null);

            DomainParticipantQos dp2Qos = null;

            Console.Write("lookup DomainParticipant: ");
            Console.WriteLine(dp2 != null ? "Success" : "Fail");
            result = dp2.GetQos(ref dp2Qos);
            Console.WriteLine("DomainParticipant.get_qos: {0}", result);
            Console.WriteLine("DomainParticipantQos.entity_factory.autoenable_created_entities: " + dp2Qos.EntityFactory.AutoenableCreatedEntities);

            // Create a new PublisherQos and set some values...
            PublisherQos publisherQos = new PublisherQos();
            publisherQos.EntityFactory.AutoenableCreatedEntities = true;
            publisherQos.Partition.Name = new string[] { "howdy" }; //, "neighbor", "partition" };

            // true not supported in 4.1 ??
            publisherQos.Presentation.OrderedAccess = false;

            // Create the Publisher
            dp.Enable();
            IPublisher publisher = dp.CreatePublisher(publisherQos);
            Console.WriteLine("Create Publisher: {0}", publisher);

            //DataWriterQos dwQos;
            //publisher.GetDefaultDataWriterQos(out dwQos);


            // Create a Detection Type Support and register it's type
            Data.DataTestTypeSupport support = new Data.DataTestTypeSupport();

            string test2 = support.TypeName;
            Console.WriteLine("Register Typesupport");
            result = support.RegisterType(dp, support.TypeName);
            Console.WriteLine("Register Typesupport Result: {0}", result);

            // Create a topic for the Detection type
            TopicQos topicQos = null;
            result = dp.GetDefaultTopicQos(ref topicQos);

            //topicQos.Ownership.Kind = OwnershipQosPolicyKind.ExclusiveOwnershipQos;

            //DDS.Test.TestTopicQos2(ref topicQos);

            // Add a listener to the topic
            ITopic topic = dp.CreateTopic("Data_DataTest", support.TypeName, topicQos,
                                          this, StatusKind.InconsistentTopic);

            topicQos.History.Depth = 5;

            ITopic topic2 = dp.CreateTopic("Data_DataTest", support.TypeName, topicQos);

            //			ErrorCode errorCode;
            //			string msg;
            //			result = ErrorInfo.Update();
            //			result = ErrorInfo.GetCode(out errorCode);
            //			result = ErrorInfo.GetMessage(out msg);

            // Create a DataWriter for the topic
            Data.IDataTestDataWriter dataWriter = publisher.CreateDataWriter(topic) as Data.IDataTestDataWriter;

            // Create a SubscriberQos object and set the partition name
            SubscriberQos subscriberQos = null;
            result = dp.GetDefaultSubscriberQos(ref subscriberQos);
            subscriberQos.Partition.Name = new string[] { "howdy" };

            // Create the subscriber
            ISubscriber sub = dp.CreateSubscriber(subscriberQos);
            // Verify that the subsciber was created...
            if (sub == null)
            {
                Console.WriteLine("Subscriber not created");
                return;
            }

            DDS.DataReaderQos readerQos = null;
            sub.GetDefaultDataReaderQos(ref readerQos);

            //readerQos.SubscriptionKeys.KeyList = new string[] { "test" };
            //readerQos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos;
            //readerQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;

            // Create a DataReader for the Detection topic
            Data.IDataTestDataReader dataReader = sub.CreateDataReader(topic, readerQos, this, StatusKind.DataAvailable)
                                                  as Data.IDataTestDataReader;

            // Create a filtered detection topic (only read detections that have an id != 4)
            IContentFilteredTopic filteredTopic = dp.CreateContentFilteredTopic("Another", topic, "TestId <> %0", "4");

            string[] testParams = null;
            result = filteredTopic.GetExpressionParameters(ref testParams);
            result = filteredTopic.SetExpressionParameters("hello", "test");
            result = filteredTopic.GetExpressionParameters(ref testParams);

            // Create a DataReader to read the filtered topic
            IDataReader reader2 = sub.CreateDataReader(filteredTopic);

            IQueryCondition queryCondition = dataReader.CreateQueryCondition(
                "TestId = %0",
                "234");

            // just for testing...
            //GC.Collect();

            // WaitSet
            WaitSet waitSet = new WaitSet();

            // either use status conditions...or
            IStatusCondition sc = reader2.StatusCondition;
            sc.SetEnabledStatuses(StatusKind.DataAvailable);
            waitSet.AttachCondition(sc);

            IStatusCondition sc2 = reader2.StatusCondition;

            // read conditions...
            // IReadCondition readCond = reader2.CreateReadCondition();
            // waitSet.AttachCondition(readCond);

            ICondition[] cond = null;
            //waitSet.Wait(ref cond, Duration.Infinite);


            Console.WriteLine("Press enter to write data");
            Console.ReadLine();

            detectionData.SequenceTest = new int[1];// new System.Collections.Generic.List<int>();
            //detectionData.SequenceTest.Add(4);
            detectionData.SequenceTest[0] = 4;

            // Write detection data
            result = dataWriter.Write(detectionData);

            detectionData        = new Data.DataTest();
            detectionData.TestId = 234;
            dataWriter.Write(detectionData, InstanceHandle.Nil);

            detectionData        = new Data.DataTest();
            detectionData.TestId = 235;
            dataWriter.Write(detectionData);

            detectionData        = new Data.DataTest();
            detectionData.TestId = 236;
            dataWriter.Write(detectionData);

            detectionData        = new Data.DataTest();
            detectionData.TestId = 237;
            dataWriter.Write(detectionData);

            Console.WriteLine("Press enter to read data");
            Console.ReadLine();

            // Read the data
            SampleInfo[]    infos      = null;
            Data.DataTest[] dataValues = null;

//            result = dataReader.ReadWithCondition(ref dataValues, ref infos, DDS.Length.Unlimited, queryCondition);

            result = dataReader.Read(ref dataValues, ref infos);
            Console.WriteLine("dataReader: {0}", dataReader);

            if (dataValues != null)
            {
                Console.WriteLine("Number of samples received: {0}", dataValues.Length);
                for (int index = 0; index < dataValues.Length; index++)
                {
                    Console.WriteLine("TestId: {0}, ProviderId: {1}, Emergency: {2}, TestStr: {3}", dataValues[index].TestId,
                                      dataValues[index].ProviderId, dataValues[index].Emergency, dataValues[index].TestStr);
                    Console.WriteLine("info: ValidData: {0},  InstHandle: {1},  PubHandle:{2},  SourceTS: {3}, ArrivalTS: {4}, sample: {5}, view: {6}, instance: {7}",
                                      infos[index].ValidData,
                                      infos[index].InstanceHandle, infos[index].PublicationHandle,
                                      infos[index].SourceTimestamp, infos[index].ArrivalTimestamp,
                                      infos[index].SampleState, infos[index].ViewState, infos[index].InstanceState);
                }
            }
            Console.WriteLine("Press enter to cleanup");
            Console.ReadLine();

            Console.WriteLine("DeleteContainedEntities");
            result = dp.DeleteContainedEntities();

            // If you don't use DeleteContainedEntities then you must delete everything that was created
            //result = sub.DeleteDataReader(dataReader);
            //result = publisher.DeleteDataWriter(dataWriter);

            //result = dp.DeleteTopic(topic);
            //result = dp.DeletePublisher(publisher);

            //result = dp.DeleteSubscriber(sub);

            Console.WriteLine("DeleteParticipant");
            result = dpf.DeleteParticipant(dp);

            Console.WriteLine("Press enter to exit");
            Console.ReadLine();
        }
コード例 #9
0
        static void Main(string[] args)
        {
            int    ownID         = 1;
            string chatterName   = null;
            int    domain        = DDS.DomainId.Default;
            string partitionName = "ChatRoom";

            /* Options: Chatter [ownID [name]] */
            if (args.Length > 0)
            {
                ownID = int.Parse(args[0]);
                if (args.Length > 1)
                {
                    chatterName = args[1];
                }
            }

            /* Create a DomainParticipantFactory and a DomainParticipant
             * (using Default QoS settings. */
            DomainParticipantFactory dpf = DomainParticipantFactory.Instance;

            ErrorHandler.checkHandle(dpf, "DDS.DomainParticipantFactory.Instance");

            IDomainParticipant participant = dpf.CreateParticipant(domain, null, StatusKind.Any);

            ErrorHandler.checkHandle(participant, "DDS.DomainParticipantFactory.CreateParticipant");

            /* Register the required datatype for ChatMessage. */
            ChatMessageTypeSupport chatMessageTS = new ChatMessageTypeSupport();
            string     chatMessageTypeName       = chatMessageTS.TypeName;
            ReturnCode status = chatMessageTS.RegisterType(
                participant, chatMessageTypeName);

            ErrorHandler.checkStatus(
                status, "Chat.ChatMessageTypeSupport.RegisterType");

            /* Register the required datatype for NameService. */
            NameServiceTypeSupport nameServiceTS = new NameServiceTypeSupport();
            string nameServiceTypeName           = nameServiceTS.TypeName;

            status = nameServiceTS.RegisterType(
                participant, nameServiceTypeName);
            ErrorHandler.checkStatus(
                status, "Chat.NameServiceTypeSupport.RegisterType");

            /* Initialise Qos variables */
            TopicQos      reliableTopicQos = new TopicQos();
            TopicQos      settingTopicQos  = new TopicQos();
            PublisherQos  pubQos           = new PublisherQos();
            DataWriterQos dwQos            = new DataWriterQos();
            DataWriterQos nsDwQos          = new DataWriterQos();

            /* Set the ReliabilityQosPolicy to RELIABLE. */
            status = participant.GetDefaultTopicQos(ref reliableTopicQos);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.GetDefaultTopicQos");
            reliableTopicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;

            /* Make the tailored QoS the new default. */
            status = participant.SetDefaultTopicQos(reliableTopicQos);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.SetDefaultTopicQos");

            /* Use the changed policy when defining the ChatMessage topic */
            ITopic chatMessageTopic = participant.CreateTopic(
                "Chat_ChatMessage",
                chatMessageTypeName,
                reliableTopicQos);

            ErrorHandler.checkHandle(
                chatMessageTopic,
                "DDS.DomainParticipant.CreateTopic (ChatMessage)");

            /* Set the DurabilityQosPolicy to TRANSIENT. */
            status = participant.GetDefaultTopicQos(ref settingTopicQos);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.GetDefaultTopicQos");
            settingTopicQos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos;

            /* Create the NameService Topic. */
            ITopic nameServiceTopic = participant.CreateTopic(
                "Chat_NameService",
                nameServiceTypeName,
                settingTopicQos);

            ErrorHandler.checkHandle(
                nameServiceTopic,
                "DDS.DomainParticipant.CreateTopic (NameService)");

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

            /* Create a Publisher for the chatter application. */
            IPublisher chatPublisher = participant.CreatePublisher(pubQos);

            ErrorHandler.checkHandle(
                chatPublisher, "DDS.DomainParticipant.CreatePublisher");

            /* Create a DataWriter for the ChatMessage Topic
             * (using the appropriate QoS). */
            chatPublisher.GetDefaultDataWriterQos(ref dwQos);
            status = chatPublisher.CopyFromTopicQos(ref dwQos, reliableTopicQos);
            ErrorHandler.checkStatus(status, "DDS.Publisher.CopyFromTopicQos");

            IDataWriter parentWriter = chatPublisher.CreateDataWriter(chatMessageTopic, dwQos);

            ErrorHandler.checkHandle(
                parentWriter, "DDS.Publisher.CreateDatawriter (chatMessage)");

            /* Narrow the abstract parent into its typed representative. */
            ChatMessageDataWriter talker = parentWriter as ChatMessageDataWriter;

            ErrorHandler.checkHandle(
                talker, "Chat.ChatMessageDataWriter");

            /* Create a DataWriter for the NameService Topic
             * (using the appropriate QoS). */
            status = chatPublisher.GetDefaultDataWriterQos(ref nsDwQos);
            ErrorHandler.checkStatus(
                status, "DDS.Publisher.GetDefaultDatawriterQos");
            status = chatPublisher.CopyFromTopicQos(ref nsDwQos, settingTopicQos);
            ErrorHandler.checkStatus(status, "DDS.Publisher.CopyFromTopicQos");

            WriterDataLifecycleQosPolicy writerDataLifecycle = nsDwQos.WriterDataLifecycle;

            writerDataLifecycle.AutodisposeUnregisteredInstances = false;
            IDataWriter nsParentWriter = chatPublisher.CreateDataWriter(nameServiceTopic, nsDwQos);

            ErrorHandler.checkHandle(
                nsParentWriter, "DDS.Publisher.CreateDatawriter (NameService)");

            /* Narrow the abstract parent into its typed representative. */
            NameServiceDataWriter nameServer = nsParentWriter as NameServiceDataWriter;

            ErrorHandler.checkHandle(
                nameServer, "Chat.NameServiceDataWriterHelper");

            /* Initialize the NameServer attributes. */
            NameService ns = new NameService();

            ns.userID = ownID;
            if (chatterName != null)
            {
                ns.name = chatterName;
            }
            else
            {
                ns.name = "Chatter " + ownID;
            }

            /* Write the user-information into the system
             * (registering the instance implicitly). */
            status = nameServer.Write(ns);
            ErrorHandler.checkStatus(status, "Chat.ChatMessageDataWriter.Write");

            /* Initialize the chat messages. */
            ChatMessage msg = new ChatMessage();

            msg.userID = ownID;
            msg.index  = 0;
            if (ownID == TERMINATION_MESSAGE)
            {
                msg.content = "Termination message.";
            }
            else
            {
                msg.content = "Hi there, I will send you " +
                              NUM_MSG + " more messages.";
            }
            System.Console.WriteLine("Writing message: \"" + msg.content + "\"");

            /* Register a chat message for this user
             * (pre-allocating resources for it!!) */
            InstanceHandle userHandle = talker.RegisterInstance(msg);

            /* Write a message using the pre-generated instance handle. */
            status = talker.Write(msg, userHandle);
            ErrorHandler.checkStatus(status, "Chat.ChatMessageDataWriter.Write");

            Thread.Sleep(1000);

            /* Write any number of messages . */
            for (int i = 1; i <= NUM_MSG && ownID != TERMINATION_MESSAGE; i++)
            {
                msg.index   = i;
                msg.content = "Message no. " + i;
                Console.WriteLine("Writing message: \"" + msg.content + "\"");
                status = talker.Write(msg, userHandle);
                ErrorHandler.checkStatus(status, "Chat.ChatMessageDataWriter.Write");

                Thread.Sleep(1000); /* do not run so fast! */
            }

            /* Leave the room by disposing and unregistering the message instance */
            status = talker.Dispose(msg, userHandle);
            ErrorHandler.checkStatus(
                status, "Chat.ChatMessageDataWriter.Dispose");
            status = talker.UnregisterInstance(msg, userHandle);
            ErrorHandler.checkStatus(
                status, "Chat.ChatMessageDataWriter.unregister_instance");

            /* Also unregister our name. */
            status = nameServer.UnregisterInstance(ns, InstanceHandle.Nil);
            ErrorHandler.checkStatus(
                status, "Chat.NameServiceDataWriter.unregister_instance");

            /* Remove the DataWriters */
            status = chatPublisher.DeleteDataWriter(talker);
            ErrorHandler.checkStatus(
                status, "DDS.Publisher.DeleteDatawriter (talker)");

            status = chatPublisher.DeleteDataWriter(nameServer);
            ErrorHandler.checkStatus(status,
                                     "DDS.Publisher.DeleteDatawriter (nameServer)");

            /* Remove the Publisher. */
            status = participant.DeletePublisher(chatPublisher);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.DeletePublisher");

            /* Remove the Topics. */
            status = participant.DeleteTopic(nameServiceTopic);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.DeleteTopic (nameServiceTopic)");

            status = participant.DeleteTopic(chatMessageTopic);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipant.DeleteTopic (chatMessageTopic)");

            /* Remove the DomainParticipant. */
            status = dpf.DeleteParticipant(participant);
            ErrorHandler.checkStatus(
                status, "DDS.DomainParticipantFactory.DeleteParticipant");
        }
コード例 #10
0
ファイル: InvalidData.cs プロジェクト: shizhexu/opensplice
     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;
                         }
                     } else {
                         msg = "Topic could NOT be created";
                         proceed = false;
                     }
                 } else {
                     msg = "Typesupport NOT loaded into DomainParticipant";
                     proceed = false;
                 }
             }
         }
         
         if(proceed == true){
             tfw.TestResult("Initialization OK", "Initialization OK", TestVerdict.Pass, TestVerdict.Pass);
             tfw.TestFinish();
         } else {
             tfw.TestResult("Initialization OK", msg, TestVerdict.Pass, TestVerdict.Fail);
             tfw.TestFinish();
         }
         /*- END OF INITIALIZATION --------------------------------------------------*/
     }
コード例 #11
0
ファイル: SampleInfo1.cs プロジェクト: shizhexu/opensplice
	    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;
	                                }
	                            } else {
	                                errMsg = "Default DataReaderQos could not be resolved.";
	                                proceed = false;
	                            }
	                        } else {
	                            errMsg = "Subscriber could NOT be created";
	                            proceed = false;
	                        }
	                    } else {
	                        errMsg = "Topic could NOT be created";
	                        proceed = false;
	                    }
	                } else {
	                    errMsg = "Typesupport NOT loaded into DomainParticipant";
	                    proceed = false;
	                }
	            }
	        }
	        
	        if(proceed == true){
	            tfw.TestResult("Initialization OK", "Initialization OK", TestVerdict.Pass, TestVerdict.Pass);
	            tfw.TestFinish();
	        } else {
	            tfw.TestResult("Initialization OK", errMsg, TestVerdict.Pass, TestVerdict.Fail);
	            tfw.TestFinish();
	        }
	        /*- END OF INITIALIZATION --------------------------------------------------*/
	    }