Beispiel #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");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Utility method to create a DDS Topic.
        /// </summary>
        /// <param name="topicName">The Topic name to create the topic with.</param>
        /// <param name="exampleNameToCreateTopicFor">The name of the example we are
        /// creating the topic for. This is used to define any specific Qos that the example
        /// requires.</param>
        /// <returns>The newly created Topic</returns>
        public ITopic createTopic(String topicName)
        {
            status = participant.GetDefaultTopicQos(ref topicQos);
            ErrorHandler.checkStatus(status, "DomainParticipant.GetDefaultTopicQos");

            switch (exampleName)
            {
            case "ContentFilteredTopic":
            case "Durability":
            case "HelloWorld":
            case "WaitSet":
            case "Lifecycle":
                topicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;
                if (durabilityKind.Equals("transient"))
                {
                    topicQos.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos;
                }
                else
                {
                    topicQos.Durability.Kind = DurabilityQosPolicyKind.PersistentDurabilityQos;
                }
                break;

            case "Ownership":
                topicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;
                topicQos.Ownership.Kind   = OwnershipQosPolicyKind.ExclusiveOwnershipQos;
                break;

            case "QueryCondition":
                topicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;
                break;

            case "Listener":
                topicQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;
                topicQos.Durability.Kind  = DurabilityQosPolicyKind.TransientDurabilityQos;
                // DeadlineQoSPolicy : period used to trigger the listener
                // (on_requested_deadline_missed)
                topicQos.Deadline.Period.NanoSec = 0;
                topicQos.Deadline.Period.Sec     = 5;
                break;

            default:
                Console.WriteLine("Unidentified example to create topic for.");
                break;
            }

            status = participant.SetDefaultTopicQos(topicQos);
            ErrorHandler.checkStatus(status, "DomainParticipant.SetDefaultTopicQos");
            topic = participant.CreateTopic(
                topicName,
                typeName,
                topicQos,
                null,
                StatusKind.Any
                );
            ErrorHandler.checkHandle(topic, "DomainParticipant.CreateTopic");
            return(topic);
        }
Beispiel #3
0
        /// <summary>
        /// Create a ContentFilteredTopic
        /// </summary>
        /// <param name="topicFName">The name of the topic.</param>
        /// <param name="topic">The topic to which the filter is applied.</param>
        /// <param name="arg">The handle to a sequence of strings with the parameter
        /// value used in the SQL expression.</param>
        public void createContentFilter(String topicName, ITopic topic, String arg)
        {
            String[] tab = new String[1];
            tab[0] = arg;
            String filter = "ticker = %0";

            filteredTopic =
                participant.CreateContentFilteredTopic(topicName, topic, filter, tab);
            ErrorHandler.checkHandle(filteredTopic, "DomainParticipant.CreateContentFilteredTopic");
        }
        /// <summary>
        /// Create a Publisher
        /// </summary>
        public void createPublisher()
        {
            status = participant.GetDefaultPublisherQos(ref pubQos);
            ErrorHandler.checkStatus(status, "DomainParticipant.GetDefaultPublisherQos");

            pubQos.Partition.Name    = new String[1];
            pubQos.Partition.Name[0] = partitionName;
            publisher = participant.CreatePublisher(pubQos);
            ErrorHandler.checkHandle(publisher, "DomainParticipant.CreatePublisher");
        }
Beispiel #5
0
        /// <summary>
        /// Creates a DataReader
        /// </summary>
        /// <param name="exampleNameToCreateReaderFor">The example name to create the
        /// DataReader for. This param is used to define any specific Qos values the
        /// example requires.</param>
        /// <param name="filtered">This param determines whether a reader will be created
        /// for a normal or filtered topic.</param>
        public void createReader(Boolean filtered)
        {
            status = subscriber.GetDefaultDataReaderQos(ref RQosH);
            ErrorHandler.checkStatus(status, "Subscriber.GetDefaultDataReaderQoS");
            status = subscriber.CopyFromTopicQos(ref RQosH, topicQos);
            ErrorHandler.checkStatus(status, "Subscriber.CopyFromTopicQoS");

            switch (exampleName)
            {
            case "ContentFilteredTopic":
            case "Listener":
                RQosH.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos;
                break;

            case "Durability":
                if (durabilityKind.Equals("transient"))
                {
                    RQosH.Durability.Kind = DurabilityQosPolicyKind.TransientDurabilityQos;
                }
                else
                {
                    RQosH.Durability.Kind = DurabilityQosPolicyKind.PersistentDurabilityQos;
                }

                break;

            case "HelloWorld":
            case "Ownership":
            case "WaitSet":
            case "QueryCondition":
            case "Lifecycle":
                break;

            default:
                break;
            }
            if (filtered)
            {
                reader = subscriber.CreateDataReader(
                    filteredTopic,
                    RQosH,
                    null,
                    StatusKind.Any);
            }
            else
            {
                reader = subscriber.CreateDataReader(
                    topic,
                    RQosH,
                    null,
                    StatusKind.Any);
            }
            ErrorHandler.checkHandle(reader, "Subscriber.CreateDataReader");
        }
Beispiel #6
0
        /// <summary>
        /// Creates a Subscriber
        /// </summary>
        public void createSubscriber()
        {
            status = participant.GetDefaultSubscriberQos(ref subQos);
            ErrorHandler.checkStatus(status, "DomainParticipant.GetDefaultSubscriberQos");

            subQos.Partition.Name    = new String[1];
            subQos.Partition.Name[0] = partitionName;
            subscriber = participant.CreateSubscriber(
                subQos, null, StatusKind.Any);
            ErrorHandler.checkHandle(subscriber, "DomainParticipant.CreateSubscriber");
        }
Beispiel #7
0
        /// <summary>
        /// Create Domain Participant
        /// </summary>
        /// <param name="partitionName">Create the participant and assign the partition name.</param>
        public void createParticipant(String partitionName)
        {
            dpf   = DomainParticipantFactory.Instance;
            dpQos = new DomainParticipantQos();
            dpf.GetDefaultParticipantQos(ref dpQos);

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

            participant = dpf.CreateParticipant(null, dpQos);
            ErrorHandler.checkHandle(participant, "DomainParticipantFactory.CreateParticipant");
            this.partitionName = partitionName;
        }