Exemplo n.º 1
0
        public ReturnCode SetDefaultDataWriterQos(DataWriterQos qos)
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            lock (this)
            {
                if (this.rlReq_isAlive)
                {
                    result = QosManager.checkQos(qos);
                    if (result == DDS.ReturnCode.Ok)
                    {
                        using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler =
                                   new OpenSplice.CustomMarshalers.DataWriterQosMarshaler())
                        {
                            result = marshaler.CopyIn(qos);
                            if (result == ReturnCode.Ok)
                            {
                                marshaler.CopyOut(ref defaultDataWriterQos);
                            }
                        }
                    }
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 2
0
        public DomainParticipantTransportSource(DomainParticipant participant, string senderTopic, string receiverTopic)
        {
            _participant = participant;

            var senderTopicQos = new TopicQos();

            participant.get_default_topic_qos(senderTopicQos);

            var receiverTopicQos = new TopicQos();

            participant.get_default_topic_qos(receiverTopicQos);

            _sender   = participant.create_topic(senderTopic, BytesTypeSupport.TYPENAME, senderTopicQos, null, StatusMask.STATUS_MASK_NONE);
            _receiver = participant.create_topic(receiverTopic, BytesTypeSupport.TYPENAME, receiverTopicQos, null, StatusMask.STATUS_MASK_NONE);

            var writerQos = new DataWriterQos();

            //writerQos.publish_mode.kind = PublishModeQosPolicyKind.ASYNCHRONOUS_PUBLISH_MODE_QOS;
            writerQos.publish_mode.flow_controller_name = FlowController.FIXED_RATE_FLOW_CONTROLLER_NAME;

            participant.get_default_datawriter_qos(writerQos);

            var readerQos = new DataReaderQos();

            participant.get_default_datareader_qos(readerQos);

            _writer = participant.create_datawriter(_sender, writerQos, null, StatusMask.STATUS_MASK_NONE);
            _reader = participant.create_datareader(_receiver, readerQos, this, StatusMask.STATUS_MASK_ALL);
        }
Exemplo n.º 3
0
        public ReturnCode GetQos(ref DataWriterQos qos)
        {
            IntPtr     userQos = IntPtr.Zero;
            ReturnCode result  = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                result = uResultToReturnCode(
                    User.Writer.GetQos(rlReq_UserPeer, ref userQos));
                if (result == ReturnCode.Ok)
                {
                    using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler =
                               new OpenSplice.CustomMarshalers.DataWriterQosMarshaler(userQos, true))
                    {
                        marshaler.CopyOut(ref qos);
                    }
                }
                else
                {
                    ReportStack.Report(result, "Could not copy DataWriterQos.");
                }
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 4
0
        public void TestGetLivelinessLostStatus()
        {
            // Initialize entities
            DataWriterQos dwQos = new DataWriterQos();

            dwQos.Liveliness.Kind          = LivelinessQosPolicyKind.ManualByTopicLivelinessQos;
            dwQos.Liveliness.LeaseDuration = new Duration
            {
                Seconds = 1,
            };
            DataWriter writer = _publisher.CreateDataWriter(_topic, dwQos);

            Assert.IsNotNull(writer);
            TestStructDataWriter dataWriter = new TestStructDataWriter(writer);

            Assert.IsNotNull(dataWriter);

            // After half second liveliness should not be lost yet
            System.Threading.Thread.Sleep(500);

            LivelinessLostStatus status = default;
            ReturnCode           result = writer.GetLivelinessLostStatus(ref status);

            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(0, status.TotalCount);
            Assert.AreEqual(0, status.TotalCountChange);

            // After one second and a half one liveliness should be lost
            System.Threading.Thread.Sleep(1000);

            result = writer.GetLivelinessLostStatus(ref status);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(1, status.TotalCount);
            Assert.AreEqual(1, status.TotalCountChange);
        }
Exemplo n.º 5
0
        public ReturnCode SetQos(DataWriterQos qos)
        {
            ReturnCode result = DDS.ReturnCode.AlreadyDeleted;

            ReportStack.Start();
            if (this.rlReq_isAlive)
            {
                result = QosManager.checkQos(qos);
                if (result == DDS.ReturnCode.Ok)
                {
                    using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler =
                               new OpenSplice.CustomMarshalers.DataWriterQosMarshaler())
                    {
                        result = marshaler.CopyIn(qos);
                        if (result == ReturnCode.Ok)
                        {
                            result = uResultToReturnCode(
                                User.Writer.SetQos(rlReq_UserPeer, marshaler.UserPtr));
                        }
                        else
                        {
                            ReportStack.Report(result, "Could not apply DataWriterQos.");
                        }
                    }
                }
            }

            ReportStack.Flush(this, result != ReturnCode.Ok);

            return(result);
        }
Exemplo n.º 6
0
        public void TestAssertLiveliness()
        {
            // Initialize entities
            DataWriterQos qos = new DataWriterQos();

            qos.Liveliness.Kind          = LivelinessQosPolicyKind.ManualByTopicLivelinessQos;
            qos.Liveliness.LeaseDuration = new Duration
            {
                Seconds = 1,
            };
            DataWriter writer = _publisher.CreateDataWriter(_topic, qos);

            Assert.IsNotNull(writer);

            // Manually assert liveliness
            for (int i = 0; i < 5; i++)
            {
                ReturnCode assertResult = writer.AssertLiveliness();
                Assert.AreEqual(ReturnCode.Ok, assertResult);
                System.Threading.Thread.Sleep(500);
            }

            //// Check that no liveliness has been lost
            LivelinessLostStatus status = default;
            ReturnCode           result = writer.GetLivelinessLostStatus(ref status);

            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(0, status.TotalCount);
            Assert.AreEqual(0, status.TotalCountChange);
        }
Exemplo n.º 7
0
        public ReturnCode CopyFromTopicQos(ref DataWriterQos dataWriterQos, TopicQos topicQos)
        {
            ReturnCode result = DDS.ReturnCode.BadParameter;

            ReportStack.Start();
            if (topicQos != null)
            {
                if (dataWriterQos == null)
                {
                    GetDefaultDataWriterQos(ref dataWriterQos);
                }
                dataWriterQos.Durability        = topicQos.Durability;
                dataWriterQos.Deadline          = topicQos.Deadline;
                dataWriterQos.LatencyBudget     = topicQos.LatencyBudget;
                dataWriterQos.Liveliness        = topicQos.Liveliness;
                dataWriterQos.Reliability       = topicQos.Reliability;
                dataWriterQos.DestinationOrder  = topicQos.DestinationOrder;
                dataWriterQos.History           = topicQos.History;
                dataWriterQos.ResourceLimits    = topicQos.ResourceLimits;
                dataWriterQos.TransportPriority = topicQos.TransportPriority;
                dataWriterQos.Lifespan          = topicQos.Lifespan;
                dataWriterQos.Ownership         = topicQos.Ownership;
                result = DDS.ReturnCode.Ok;
            }
            ReportStack.Flush(this, result != ReturnCode.Ok);
            return(result);
        }
Exemplo n.º 8
0
        public void TestGetDefaultDataWriterQos()
        {
            // Initialize entities
            TestStructTypeSupport support = new TestStructTypeSupport();
            string     typeName           = support.GetTypeName();
            ReturnCode result             = support.RegisterType(_participant, typeName);

            Assert.AreEqual(ReturnCode.Ok, result);

            Topic topic = _participant.CreateTopic(nameof(TestGetDefaultDataWriterQos), typeName);

            Assert.IsNotNull(topic);
            Assert.IsNull(topic.GetListener());
            Assert.AreEqual(nameof(TestGetDefaultDataWriterQos), topic.Name);
            Assert.AreEqual(typeName, topic.TypeName);

            Publisher publisher = _participant.CreatePublisher();

            Assert.IsNotNull(publisher);

            // Create a non-default DataWriter Qos, call GetDefaultDataWriterQos and check the default values
            DataWriterQos qos = TestHelper.CreateNonDefaultDataWriterQos();

            result = publisher.GetDefaultDataWriterQos(qos);
            Assert.AreEqual(ReturnCode.Ok, result);
            TestHelper.TestDefaultDataWriterQos(qos);

            // Test with null parameter
            result = publisher.GetDefaultDataWriterQos(null);
            Assert.AreEqual(ReturnCode.BadParameter, result);
        }
Exemplo n.º 9
0
		public DomainParticipantTransportSource(DomainParticipant participant, string senderTopic, string receiverTopic)
		{
			_participant = participant;

			var senderTopicQos = new TopicQos();
			participant.get_default_topic_qos(senderTopicQos);

			var receiverTopicQos = new TopicQos();
			participant.get_default_topic_qos(receiverTopicQos);

			_sender = participant.create_topic(senderTopic, BytesTypeSupport.TYPENAME, senderTopicQos, null, StatusMask.STATUS_MASK_NONE);
			_receiver = participant.create_topic(receiverTopic, BytesTypeSupport.TYPENAME, receiverTopicQos, null, StatusMask.STATUS_MASK_NONE);

			var writerQos = new DataWriterQos();
			//writerQos.publish_mode.kind = PublishModeQosPolicyKind.ASYNCHRONOUS_PUBLISH_MODE_QOS;
			writerQos.publish_mode.flow_controller_name = FlowController.FIXED_RATE_FLOW_CONTROLLER_NAME;

			participant.get_default_datawriter_qos(writerQos);
			
			var readerQos = new DataReaderQos();
			participant.get_default_datareader_qos(readerQos);

			_writer = participant.create_datawriter(_sender, writerQos, null, StatusMask.STATUS_MASK_NONE);
			_reader = participant.create_datareader(_receiver, readerQos, this, StatusMask.STATUS_MASK_ALL);
		}
Exemplo n.º 10
0
        public void TestOnOfferedDeadlineMissed()
        {
            DataWriter writer             = null;
            int        totalCount         = 0;
            int        totalCountChange   = 0;
            var        lastInstanceHandle = InstanceHandle.HandleNil;

            // Attach to the event
            int count = 0;

            _listener.OfferedDeadlineMissed += (w, s) =>
            {
                writer             = w;
                totalCount         = s.TotalCount;
                totalCountChange   = s.TotalCountChange;
                lastInstanceHandle = s.LastInstanceHandle;
                count++;
            };

            // Prepare QoS for the test
            DataWriterQos dwQos = new DataWriterQos();

            dwQos.Deadline.Period = new Duration {
                Seconds = 1
            };
            ReturnCode result = _writer.SetQos(dwQos);

            Assert.AreEqual(ReturnCode.Ok, result);

            // Enable entities
            result = _writer.Enable();
            Assert.AreEqual(ReturnCode.Ok, result);

            result = _reader.Enable();
            Assert.AreEqual(ReturnCode.Ok, result);

            // Wait for discovery and write an instance
            bool found = _writer.WaitForSubscriptions(1, 1000);

            Assert.IsTrue(found);

            _dataWriter.Write(new TestStruct {
                Id = 1
            });

            // After half second deadline should not be lost yet
            System.Threading.Thread.Sleep(500);
            Assert.AreEqual(0, count);

            // After one second and a half one deadline should be lost
            System.Threading.Thread.Sleep(1000);
            Assert.AreEqual(1, count);
            Assert.AreEqual(_writer, writer);
            Assert.AreEqual(1, totalCount);
            Assert.AreEqual(1, totalCountChange);

            // Remove the listener to avoid extra messages
            result = _publisher.SetListener(null);
            Assert.AreEqual(ReturnCode.Ok, result);
        }
Exemplo n.º 11
0
        public void TestGetPublicationMatchedStatus()
        {
            // Initialize entities
            DataWriterQos qos = new DataWriterQos();

            qos.Reliability.Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos;
            DataWriter writer = _publisher.CreateDataWriter(_topic, qos);

            Assert.IsNotNull(writer);

            // If not datareaders are created should return the default status
            PublicationMatchedStatus status = default;
            ReturnCode result = writer.GetPublicationMatchedStatus(ref status);

            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(0, status.CurrentCount);
            Assert.AreEqual(0, status.CurrentCountChange);
            Assert.AreEqual(0, status.TotalCount);
            Assert.AreEqual(0, status.TotalCountChange);
            Assert.AreEqual(InstanceHandle.HandleNil, status.LastSubscriptionHandle);

            // Create a not compatible reader
            Subscriber subscriber = _participant.CreateSubscriber();

            Assert.IsNotNull(subscriber);

            DataReaderQos drQos = new DataReaderQos();

            drQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;
            DataReader reader = subscriber.CreateDataReader(_topic, drQos);

            Assert.IsNotNull(reader);

            // Wait for discovery and check the status
            System.Threading.Thread.Sleep(100);

            result = writer.GetPublicationMatchedStatus(ref status);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(0, status.CurrentCount);
            Assert.AreEqual(0, status.CurrentCountChange);
            Assert.AreEqual(0, status.TotalCount);
            Assert.AreEqual(0, status.TotalCountChange);
            Assert.AreEqual(InstanceHandle.HandleNil, status.LastSubscriptionHandle);

            // Create a compatible reader
            DataReader otherReader = subscriber.CreateDataReader(_topic);

            Assert.IsNotNull(otherReader);

            // Wait for discovery and check the status
            System.Threading.Thread.Sleep(100);

            result = writer.GetPublicationMatchedStatus(ref status);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(1, status.CurrentCount);
            Assert.AreEqual(1, status.CurrentCountChange);
            Assert.AreEqual(1, status.TotalCount);
            Assert.AreEqual(1, status.TotalCountChange);
            Assert.AreEqual(otherReader.InstanceHandle, status.LastSubscriptionHandle);
        }
Exemplo n.º 12
0
        public void TestTakeNextInstance()
        {
            List <PublicationBuiltinTopicData> data = new List <PublicationBuiltinTopicData>();
            List <SampleInfo> infos = new List <SampleInfo>();
            ReturnCode        ret   = _dr.TakeNextInstance(data, infos, InstanceHandle.HandleNil);

            Assert.AreEqual(ReturnCode.NoData, ret);
            Assert.AreEqual(0, data.Count);
            Assert.AreEqual(0, infos.Count);

            DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN);

            Assert.IsNotNull(otherParticipant);
            otherParticipant.BindRtpsUdpTransportConfig();

            Assert.IsTrue(_participant.WaitForParticipants(1, 20_000));

            TestStructTypeSupport support = new TestStructTypeSupport();
            string     typeName           = support.GetTypeName();
            ReturnCode result             = support.RegisterType(otherParticipant, typeName);

            Assert.AreEqual(ReturnCode.Ok, result);

            var topic = otherParticipant.CreateTopic(TestContext.TestName, typeName);

            Assert.IsNotNull(topic);

            var publisher = otherParticipant.CreatePublisher();

            Assert.IsNotNull(publisher);

            DataWriterQos dwQos = TestHelper.CreateNonDefaultDataWriterQos();

            dwQos.Ownership.Kind = OwnershipQosPolicyKind.SharedOwnershipQos;
            DataWriter dataWriter = publisher.CreateDataWriter(topic, dwQos);

            Assert.IsNotNull(dataWriter);

            int count = 200;

            ret = ReturnCode.NoData;
            while (ret != ReturnCode.Ok && count > 0)
            {
                Thread.Sleep(100);
                ret = _dr.TakeNextInstance(data, infos, InstanceHandle.HandleNil);
                count--;
            }

            Assert.AreEqual(ReturnCode.Ok, ret);
            Assert.AreEqual(1, data.Count);
            Assert.AreEqual(1, infos.Count);
            TestHelper.TestNonDefaultPublicationData(data.First());

            ret = otherParticipant.DeleteContainedEntities();
            Assert.AreEqual(ReturnCode.Ok, ret);

            ret = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant);
            Assert.AreEqual(ReturnCode.Ok, ret);
        }
Exemplo n.º 13
0
        public void TestOnOfferedIncompatibleQos()
        {
            DataWriter dw                         = null;
            int        totalCount                 = 0;
            int        totalCountChange           = 0;
            int        lastPolicyId               = 0;
            ICollection <QosPolicyCount> policies = new List <QosPolicyCount>();

            // Attach to the event
            int count = 0;

            _listener.OfferedIncompatibleQos += (w, s) =>
            {
                dw               = w;
                totalCount       = s.TotalCount;
                totalCountChange = s.TotalCountChange;
                lastPolicyId     = s.LastPolicyId;
                policies         = s.Policies;

                count++;
            };

            // Prepare QoS for the test
            DataWriterQos dwQos = new DataWriterQos();

            dwQos.Reliability.Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos;
            ReturnCode result = _writer.SetQos(dwQos);

            Assert.AreEqual(ReturnCode.Ok, result);

            DataReaderQos drQos = new DataReaderQos();

            drQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;
            result = _reader.SetQos(drQos);
            Assert.AreEqual(ReturnCode.Ok, result);

            // Enable entities
            result = _writer.Enable();
            Assert.AreEqual(ReturnCode.Ok, result);

            result = _reader.Enable();
            Assert.AreEqual(ReturnCode.Ok, result);

            // Wait for discovery
            System.Threading.Thread.Sleep(100);
            Assert.AreEqual(1, count);
            Assert.AreEqual(_writer, dw);
            Assert.AreEqual(1, totalCount);
            Assert.AreEqual(1, totalCountChange);
            Assert.AreEqual(11, lastPolicyId);
            Assert.IsNotNull(policies);
            Assert.AreEqual(1, policies.Count);
            Assert.AreEqual(1, policies.First().Count);
            Assert.AreEqual(11, policies.First().PolicyId);

            // Remove the listener to avoid extra messages
            result = _publisher.SetListener(null);
            Assert.AreEqual(ReturnCode.Ok, result);
        }
Exemplo n.º 14
0
 public void setStrength(int strength)
 {
     DataWriterQos dq = new DataWriterQos();
     dwriter.GetQos(ref dq);
     dq.OwnershipStrength.Value = strength;
     ReturnCode status = dwriter.SetQos(dq);
     ErrorHandler.checkStatus(status, "DataWriter.SetQos");
 }
        public void TestOnRequestedDeadlineMissed()
        {
            // Prepare qos for the test
            DataWriterQos dwQos = new DataWriterQos();

            dwQos.Deadline.Period = new Duration {
                Seconds = 1
            };
            ReturnCode result = _writer.SetQos(dwQos);

            Assert.AreEqual(ReturnCode.Ok, result);

            DataReaderQos drQos = new DataReaderQos();

            drQos.Deadline.Period = new Duration {
                Seconds = 1
            };
            drQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;
            result = _reader.SetQos(drQos);
            Assert.AreEqual(ReturnCode.Ok, result);

            // Enable entities
            result = _writer.Enable();
            Assert.AreEqual(ReturnCode.Ok, result);

            result = _reader.Enable();
            Assert.AreEqual(ReturnCode.Ok, result);

            // Wait for discovery
            bool found = _writer.WaitForSubscriptions(1, 1000);

            Assert.IsTrue(found);

            // Attach to the event
            int count = 0;

            _listener.RequestedDeadlineMissed += (r, s) =>
            {
                Assert.AreEqual(_reader, r);
                Assert.AreEqual(1, s.TotalCount);
                Assert.AreEqual(1, s.TotalCountChange);
                Assert.AreNotEqual(InstanceHandle.HandleNil, s.LastInstanceHandle);
                count++;
            };

            // Write an instance
            _dataWriter.Write(new TestStruct {
                Id = 1
            });

            // After half second deadline should not be lost yet
            System.Threading.Thread.Sleep(500);
            Assert.AreEqual(0, count);

            // After one second and a half one deadline should be lost
            System.Threading.Thread.Sleep(1000);
            Assert.AreEqual(1, count);
        }
Exemplo n.º 16
0
        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);
            }
        }
        public void TestGetKeyValue()
        {
            // Call GetKeyValue with HandleNil
            PublicationBuiltinTopicData data = default;
            SampleInfo info = new SampleInfo();
            ReturnCode ret  = _dr.GetKeyValue(ref data, InstanceHandle.HandleNil);

            Assert.AreEqual(ReturnCode.BadParameter, ret);

            DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN);

            Assert.IsNotNull(otherParticipant);
            otherParticipant.BindRtpsUdpTransportConfig();

            TestStructTypeSupport support = new TestStructTypeSupport();
            string     typeName           = support.GetTypeName();
            ReturnCode result             = support.RegisterType(otherParticipant, typeName);

            Assert.AreEqual(ReturnCode.Ok, result);

            var topic = otherParticipant.CreateTopic(TestContext.TestName, typeName);

            Assert.IsNotNull(topic);

            var publisher = otherParticipant.CreatePublisher();

            Assert.IsNotNull(publisher);

            DataWriterQos dwQos = TestHelper.CreateNonDefaultDataWriterQos();

            dwQos.Ownership.Kind = OwnershipQosPolicyKind.SharedOwnershipQos;
            DataWriter dataWriter = publisher.CreateDataWriter(topic, dwQos);

            Assert.IsNotNull(dataWriter);

            Thread.Sleep(500);

            // Get the for an existing instance
            ret = _dr.ReadNextSample(ref data, info);
            Assert.AreEqual(ReturnCode.Ok, ret);
            TestHelper.TestNonDefaultPublicationData(data);

            PublicationBuiltinTopicData aux = default;

            ret = _dr.GetKeyValue(ref aux, info.InstanceHandle);
            Assert.AreEqual(ReturnCode.Ok, ret);
            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(data.Key.Value[i], aux.Key.Value[i]);
            }

            ret = otherParticipant.DeleteContainedEntities();
            Assert.AreEqual(ReturnCode.Ok, ret);

            ret = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant);
            Assert.AreEqual(ReturnCode.Ok, ret);
        }
Exemplo n.º 18
0
        public void TestOnRequestedIncompatibleQos()
        {
            int        count                      = 0;
            DataReader dr                         = null;
            int        totalCount                 = 0;
            int        totalCountChange           = 0;
            int        lastPolicyId               = 0;
            ICollection <QosPolicyCount> policies = new List <QosPolicyCount>();

            // Attach to the event
            _listener.RequestedIncompatibleQos += (r, s) =>
            {
                dr               = r;
                totalCount       = s.TotalCount;
                totalCountChange = s.TotalCountChange;
                lastPolicyId     = s.LastPolicyId;
                policies         = s.Policies;

                count++;
            };

            // Create a incompatible DataWriter
            DataWriterQos dwQos = new DataWriterQos();

            dwQos.Reliability.Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos;
            DataWriter otherDataWriter = _publisher.CreateDataWriter(_topic, dwQos);

            Assert.IsNotNull(otherDataWriter);

            // Enable entities
            ReturnCode result = _writer.Enable();

            Assert.AreEqual(ReturnCode.Ok, result);

            result = _reader.Enable();
            Assert.AreEqual(ReturnCode.Ok, result);

            result = otherDataWriter.Enable();
            Assert.AreEqual(ReturnCode.Ok, result);

            // Wait for discovery
            bool found = _writer.WaitForSubscriptions(1, 1000);

            Assert.IsTrue(found);

            // Check the number of incompatible DataWriter
            Thread.Sleep(100);
            Assert.AreEqual(1, count);
            Assert.AreEqual(_reader, dr);
            Assert.AreEqual(1, totalCount);
            Assert.AreEqual(1, totalCountChange);
            Assert.AreEqual(11, lastPolicyId);
            Assert.IsNotNull(policies);
            Assert.AreEqual(1, policies.Count);
            Assert.AreEqual(1, policies.First().Count);
            Assert.AreEqual(11, policies.First().PolicyId);
        }
Exemplo n.º 19
0
        public void TestGetMatchedSubscriptions()
        {
            // Initialize entities
            DataWriterQos qos = new DataWriterQos();

            qos.Reliability.Kind = ReliabilityQosPolicyKind.BestEffortReliabilityQos;
            DataWriter writer = _publisher.CreateDataWriter(_topic, qos);

            Assert.IsNotNull(writer);

            // Test matched subscriptions without any match
            List <InstanceHandle> list = new List <InstanceHandle>
            {
                InstanceHandle.HandleNil,
            };
            ReturnCode result = writer.GetMatchedSubscriptions(list);

            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(0, list.Count);

            // Create a not compatible reader
            Subscriber subscriber = _participant.CreateSubscriber();

            Assert.IsNotNull(subscriber);

            DataReaderQos drQos = new DataReaderQos();

            drQos.Reliability.Kind = ReliabilityQosPolicyKind.ReliableReliabilityQos;
            DataReader reader = subscriber.CreateDataReader(_topic, drQos);

            Assert.IsNotNull(reader);

            // Wait for discovery and check the matched subscriptions
            System.Threading.Thread.Sleep(100);

            result = writer.GetMatchedSubscriptions(list);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(0, list.Count);

            // Create a compatible reader
            DataReader otherReader = subscriber.CreateDataReader(_topic);

            Assert.IsNotNull(otherReader);

            // Wait for discovery and check the matched subscriptions
            System.Threading.Thread.Sleep(100);

            result = writer.GetMatchedSubscriptions(list);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(1, list.Count);
            Assert.AreEqual(otherReader.InstanceHandle, list.First());

            // Test with null parameter
            result = writer.GetMatchedSubscriptions(null);
            Assert.AreEqual(ReturnCode.BadParameter, result);
        }
Exemplo n.º 20
0
        public void setStrength(int strength)
        {
            DataWriterQos dq = new DataWriterQos();

            dwriter.GetQos(ref dq);
            dq.OwnershipStrength.Value = strength;
            ReturnCode status = dwriter.SetQos(dq);

            ErrorHandler.checkStatus(status, "DataWriter.SetQos");
        }
Exemplo n.º 21
0
        public static void TestNonDefaultDataWriterQos(DataWriterQos qos)
        {
            Assert.IsNotNull(qos);
            Assert.IsNotNull(qos.Deadline);
            Assert.IsNotNull(qos.DestinationOrder);
            Assert.IsNotNull(qos.Durability);
            Assert.IsNotNull(qos.DurabilityService);
            Assert.IsNotNull(qos.History);
            Assert.IsNotNull(qos.LatencyBudget);
            Assert.IsNotNull(qos.Lifespan);
            Assert.IsNotNull(qos.Liveliness);
            Assert.IsNotNull(qos.Ownership);
            Assert.IsNotNull(qos.OwnershipStrength);
            Assert.IsNotNull(qos.Reliability);
            Assert.IsNotNull(qos.ResourceLimits);
            Assert.IsNotNull(qos.TransportPriority);
            Assert.IsNotNull(qos.UserData);
            Assert.IsNotNull(qos.WriterDataLifecycle);

            Assert.IsNotNull(qos.Deadline.Period);
            Assert.AreEqual(5, qos.Deadline.Period.Seconds);
            Assert.AreEqual(Duration.ZeroNanoseconds, qos.Deadline.Period.NanoSeconds);
            Assert.AreEqual(DestinationOrderQosPolicyKind.BySourceTimestampDestinationOrderQos, qos.DestinationOrder.Kind);
            Assert.AreEqual(DurabilityQosPolicyKind.TransientLocalDurabilityQos, qos.Durability.Kind);
            Assert.AreEqual(HistoryQosPolicyKind.KeepAllHistoryQos, qos.DurabilityService.HistoryKind);
            Assert.AreEqual(5, qos.DurabilityService.HistoryDepth);
            Assert.AreEqual(5, qos.DurabilityService.MaxInstances);
            Assert.AreEqual(5, qos.DurabilityService.MaxSamples);
            Assert.AreEqual(5, qos.DurabilityService.MaxSamplesPerInstance);
            Assert.AreEqual(HistoryQosPolicyKind.KeepAllHistoryQos, qos.History.Kind);
            Assert.AreEqual(5, qos.History.Depth);
            Assert.IsNotNull(qos.LatencyBudget.Duration);
            Assert.AreEqual(5, qos.LatencyBudget.Duration.Seconds);
            Assert.AreEqual((uint)5, qos.LatencyBudget.Duration.NanoSeconds);
            Assert.IsNotNull(qos.Lifespan.Duration);
            Assert.AreEqual(5, qos.Lifespan.Duration.Seconds);
            Assert.AreEqual((uint)5, qos.Lifespan.Duration.NanoSeconds);
            Assert.AreEqual(LivelinessQosPolicyKind.ManualByParticipantLivelinessQos, qos.Liveliness.Kind);
            Assert.IsNotNull(qos.Liveliness.LeaseDuration);
            Assert.AreEqual(5, qos.Liveliness.LeaseDuration.Seconds);
            Assert.AreEqual((uint)5, qos.Liveliness.LeaseDuration.NanoSeconds);
            Assert.AreEqual(OwnershipQosPolicyKind.ExclusiveOwnershipQos, qos.Ownership.Kind);
            Assert.AreEqual(5, qos.OwnershipStrength.Value);
            Assert.AreEqual(ReliabilityQosPolicyKind.BestEffortReliabilityQos, qos.Reliability.Kind);
            Assert.IsNotNull(qos.Reliability.MaxBlockingTime);
            Assert.AreEqual(5, qos.Reliability.MaxBlockingTime.Seconds);
            Assert.AreEqual((uint)5, qos.Reliability.MaxBlockingTime.NanoSeconds);
            Assert.AreEqual(5, qos.ResourceLimits.MaxInstances);
            Assert.AreEqual(5, qos.ResourceLimits.MaxSamples);
            Assert.AreEqual(5, qos.ResourceLimits.MaxSamplesPerInstance);
            Assert.AreEqual(1, qos.UserData.Value.Count());
            Assert.AreEqual(0x5, qos.UserData.Value.First());
            Assert.AreEqual(5, qos.TransportPriority.Value);
            Assert.IsTrue(qos.WriterDataLifecycle.AutodisposeUnregisteredInstances);
        }
        /// <summary>
        /// The Main function runs the Qos printing example.
        /// </summary>
        public static void Main(string[] args)
        {
            using DomainParticipant participant = DomainParticipantFactory.Instance.CreateParticipant(0);
            Topic <HelloWorld> topic     = participant.CreateTopic <HelloWorld>("Example QosPrintingExample_HelloWorld");
            Publisher          publisher = participant.CreatePublisher();

            // In order to demonstrate a possible use-case for the Qos printing APIs
            // we create a DataWriter which is a combination of policies set in
            // the XML file, and of policies set in code.
            DataWriterQos writerQos = QosProvider.Default.GetDataWriterQos()
                                      .WithReliability(policy => policy.Kind = ReliabilityKind.BestEffort);
            DataWriter <HelloWorld> writer = publisher.CreateDataWriter(topic, writerQos);


            // The Qos we have obtained from the XML file inherits from the
            // Generic.StrictReliable built-in profile. It also explicitly sets
            // the Durability Qos policy. We have also explicitly set (in code)
            // the Reliability Qos (overriding the ReliabilityKind set in the
            // built-in profile). Using the Qos printing APIs we can check what
            // is the final Qos in use by an entity.
            Console.WriteLine("Printing DataWriterQos to stdout");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
            Console.WriteLine(writer.Qos);

            // The output can be configured using QosPrintFormat
            QosPrintFormat format = new QosPrintFormat
            {
                Indent       = 1,
                IsStandalone = true
            };

            Console.WriteLine("Printing formatted DataWriterQos to stdout");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
            Console.WriteLine(writer.Qos.ToString(format));

            // By default, only the differences with respect to the documented
            // QoS default (the default values as stated in the API reference)
            // are printed. This behavior can be overridden by passing another
            // QoS object to use as the baseQos to ToString.
            Console.WriteLine("Printing DataWriterQos differences with respect to \"BuiltinQosLib::Generic.StrictReliable\" to stdout");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
            Console.WriteLine(writer.Qos.ToString(
                                  baseQos: QosProvider.Default.GetDataWriterQos("BuiltinQosLib::Generic.StrictReliable")));

            // To print all the Qos policies (not just the differences), call
            // ToString with sentinel QosPrintAll.Value
            Console.WriteLine("Printing entire DataWriterQos object to stdout");
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();
            Console.WriteLine(writer.Qos.ToString(baseQos: QosPrintAll.Value));
        }
Exemplo n.º 23
0
 public static void TestDefaultDataWriterQos(DataWriterQos qos)
 {
     Assert.IsNotNull(qos);
     Assert.IsNotNull(qos.Deadline);
     Assert.IsNotNull(qos.DestinationOrder);
     Assert.IsNotNull(qos.Durability);
     Assert.IsNotNull(qos.DurabilityService);
     Assert.IsNotNull(qos.History);
     Assert.IsNotNull(qos.LatencyBudget);
     Assert.IsNotNull(qos.Lifespan);
     Assert.IsNotNull(qos.Liveliness);
     Assert.IsNotNull(qos.Ownership);
     Assert.IsNotNull(qos.OwnershipStrength);
     Assert.IsNotNull(qos.Reliability);
     Assert.IsNotNull(qos.ResourceLimits);
     Assert.IsNotNull(qos.TransportPriority);
     Assert.IsNotNull(qos.UserData);
     Assert.IsNotNull(qos.WriterDataLifecycle);
     Assert.IsNotNull(qos.Deadline.Period);
     Assert.AreEqual(Duration.InfiniteSeconds, qos.Deadline.Period.Seconds);
     Assert.AreEqual(Duration.InfiniteNanoseconds, qos.Deadline.Period.NanoSeconds);
     Assert.AreEqual(DestinationOrderQosPolicyKind.ByReceptionTimestampDestinationOrderQos, qos.DestinationOrder.Kind);
     Assert.AreEqual(DurabilityQosPolicyKind.VolatileDurabilityQos, qos.Durability.Kind);
     Assert.AreEqual(HistoryQosPolicyKind.KeepLastHistoryQos, qos.DurabilityService.HistoryKind);
     Assert.AreEqual(1, qos.DurabilityService.HistoryDepth);
     Assert.AreEqual(ResourceLimitsQosPolicy.LengthUnlimited, qos.DurabilityService.MaxInstances);
     Assert.AreEqual(ResourceLimitsQosPolicy.LengthUnlimited, qos.DurabilityService.MaxSamples);
     Assert.AreEqual(ResourceLimitsQosPolicy.LengthUnlimited, qos.DurabilityService.MaxSamplesPerInstance);
     Assert.AreEqual(HistoryQosPolicyKind.KeepLastHistoryQos, qos.History.Kind);
     Assert.AreEqual(1, qos.History.Depth);
     Assert.IsNotNull(qos.LatencyBudget.Duration);
     Assert.AreEqual(Duration.ZeroSeconds, qos.LatencyBudget.Duration.Seconds);
     Assert.AreEqual(Duration.ZeroNanoseconds, qos.LatencyBudget.Duration.NanoSeconds);
     Assert.IsNotNull(qos.Lifespan.Duration);
     Assert.AreEqual(Duration.InfiniteSeconds, qos.Lifespan.Duration.Seconds);
     Assert.AreEqual(Duration.InfiniteNanoseconds, qos.Lifespan.Duration.NanoSeconds);
     Assert.AreEqual(LivelinessQosPolicyKind.AutomaticLivelinessQos, qos.Liveliness.Kind);
     Assert.IsNotNull(qos.Liveliness.LeaseDuration);
     Assert.AreEqual(Duration.InfiniteSeconds, qos.Liveliness.LeaseDuration.Seconds);
     Assert.AreEqual(Duration.InfiniteNanoseconds, qos.Liveliness.LeaseDuration.NanoSeconds);
     Assert.AreEqual(OwnershipQosPolicyKind.SharedOwnershipQos, qos.Ownership.Kind);
     Assert.AreEqual(0, qos.OwnershipStrength.Value);
     Assert.AreEqual(ReliabilityQosPolicyKind.ReliableReliabilityQos, qos.Reliability.Kind);
     Assert.IsNotNull(qos.Reliability.MaxBlockingTime);
     Assert.AreEqual(0, qos.Reliability.MaxBlockingTime.Seconds);
     Assert.AreEqual((uint)100000000, qos.Reliability.MaxBlockingTime.NanoSeconds);
     Assert.AreEqual(ResourceLimitsQosPolicy.LengthUnlimited, qos.ResourceLimits.MaxInstances);
     Assert.AreEqual(ResourceLimitsQosPolicy.LengthUnlimited, qos.ResourceLimits.MaxSamples);
     Assert.AreEqual(ResourceLimitsQosPolicy.LengthUnlimited, qos.ResourceLimits.MaxSamplesPerInstance);
     Assert.AreEqual(0, qos.TransportPriority.Value);
     Assert.IsNotNull(qos.UserData.Value);
     Assert.AreEqual(0, qos.UserData.Value.Count());
     Assert.IsTrue(qos.WriterDataLifecycle.AutodisposeUnregisteredInstances);
 }
Exemplo n.º 24
0
        GetDataWriterQos(
            ref DataWriterQos datawriterQos,
            string id)
        {
            NamedDataWriterQos dwQos     = new NamedDataWriterQos();
            GCHandle           qosHandle = GCHandle.Alloc(dwQos, GCHandleType.Normal);
            ReturnCode         result    = OpenSplice.Common.QosProvider.GetDataWriterQos(GapiPeer, id, GCHandle.ToIntPtr(qosHandle));

            datawriterQos = dwQos.DatawriterQos;
            qosHandle.Free();
            return(result);
        }
Exemplo n.º 25
0
        public static DataWriterQos CreateNonDefaultDataWriterQos()
        {
            DataWriterQos qos = new DataWriterQos();

            qos.Deadline.Period = new Duration
            {
                Seconds     = 5,
                NanoSeconds = 0
            };
            qos.DestinationOrder.Kind                   = DestinationOrderQosPolicyKind.BySourceTimestampDestinationOrderQos;
            qos.Durability.Kind                         = DurabilityQosPolicyKind.TransientLocalDurabilityQos;
            qos.DurabilityService.HistoryDepth          = 5;
            qos.DurabilityService.HistoryKind           = HistoryQosPolicyKind.KeepAllHistoryQos;
            qos.DurabilityService.MaxInstances          = 5;
            qos.DurabilityService.MaxSamples            = 5;
            qos.DurabilityService.MaxSamplesPerInstance = 5;
            qos.History.Depth          = 5;
            qos.History.Kind           = HistoryQosPolicyKind.KeepAllHistoryQos;
            qos.LatencyBudget.Duration = new Duration
            {
                Seconds     = 5,
                NanoSeconds = 5
            };
            qos.Lifespan.Duration = new Duration
            {
                Seconds     = 5,
                NanoSeconds = 5
            };
            qos.Liveliness.Kind          = LivelinessQosPolicyKind.ManualByParticipantLivelinessQos;
            qos.Liveliness.LeaseDuration = new Duration
            {
                Seconds     = 5,
                NanoSeconds = 5
            };
            qos.Ownership.Kind              = OwnershipQosPolicyKind.ExclusiveOwnershipQos;
            qos.OwnershipStrength.Value     = 5;
            qos.Reliability.Kind            = ReliabilityQosPolicyKind.BestEffortReliabilityQos;
            qos.Reliability.MaxBlockingTime = new Duration
            {
                Seconds     = 5,
                NanoSeconds = 5
            };
            qos.ResourceLimits.MaxInstances          = 5;
            qos.ResourceLimits.MaxSamples            = 5;
            qos.ResourceLimits.MaxSamplesPerInstance = 5;
            qos.UserData.Value = new List <byte> {
                0x5
            };
            qos.TransportPriority.Value = 5;
            qos.WriterDataLifecycle.AutodisposeUnregisteredInstances = true;

            return(qos);
        }
        /// <summary>
        /// Creates a DomainParticipant, Topic, Publisher and DataWriters<Temperature>.
        /// </summary>
        public PublisherApplication(int domainId, bool useXmlQos = true)
        {
            // Start communicating in a domain, usually one participant per application
            // Load QoS profile from USER_QOS_PROFILES.xml file
            participant = DomainParticipantFactory.Instance.CreateParticipant(domainId);

            // Create the topics
            var alarmTopic       = participant.CreateTopic <Alarm>("Alarm");
            var heartRateTopic   = participant.CreateTopic <HeartRate>("HeartRate");
            var temperatureTopic = participant.CreateTopic <Temperature>("Temperature");

            // Create a Publisher
            PublisherQos publisherQos = null;

            if (useXmlQos)
            {
                // Retrieve the Publisher QoS, from USER_QOS_PROFILES.xml
                publisherQos = QosProvider.Default.GetPublisherQos();
            }
            else
            {
                // Set the Publisher QoS programatically, to the same effect
                publisherQos = participant.DefaultPublisherQos
                               .WithPresentation(policy =>
                {
                    policy.AccessScope    = PresentationAccessScopeKind.Group;
                    policy.CoherentAccess = true;
                    policy.OrderedAccess  = true;
                });
            }

            publisher = participant.CreatePublisher(publisherQos);

            // Create a DataWriter for each topic
            DataWriterQos writerQos = null;

            if (useXmlQos)
            {
                // Retrieve the DataWriter QoS, from USER_QOS_PROFILES.xml
                writerQos = QosProvider.Default.GetDataWriterQos();
            }
            else
            {
                // Set the DataWriter QoS programatically, to the same effect
                writerQos = publisher.DefaultDataWriterQos
                            .WithReliability(policy => policy.Kind = ReliabilityKind.Reliable)
                            .WithHistory(policy => policy.Kind     = HistoryKind.KeepAll);
            }

            alarmWriter       = publisher.CreateDataWriter(alarmTopic, writerQos);
            heartRateWriter   = publisher.CreateDataWriter(heartRateTopic, writerQos);
            temperatureWriter = publisher.CreateDataWriter(temperatureTopic, writerQos);
        }
Exemplo n.º 27
0
        public void TestGetOfferedDeadlineMissedStatus()
        {
            // Initialize entities
            DataWriterQos qos = new DataWriterQos();

            qos.Deadline.Period = new Duration
            {
                Seconds = 1,
            };
            DataWriter writer = _publisher.CreateDataWriter(_topic, qos);

            Assert.IsNotNull(writer);
            TestStructDataWriter dataWriter = new TestStructDataWriter(writer);

            Subscriber subscriber = _participant.CreateSubscriber();

            Assert.IsNotNull(subscriber);

            DataReader reader = subscriber.CreateDataReader(_topic);

            Assert.IsNotNull(reader);

            // Wait for discovery and write an instance
            bool found = writer.WaitForSubscriptions(1, 1000);

            Assert.IsTrue(found);

            dataWriter.Write(new TestStruct
            {
                Id = 1,
            });

            // After half second deadline should not be lost yet
            System.Threading.Thread.Sleep(500);

            OfferedDeadlineMissedStatus status = default;
            ReturnCode result = writer.GetOfferedDeadlineMissedStatus(ref status);

            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(0, status.TotalCount);
            Assert.AreEqual(0, status.TotalCountChange);
            Assert.AreEqual(InstanceHandle.HandleNil, status.LastInstanceHandle);

            // After one second and a half one deadline should be lost
            System.Threading.Thread.Sleep(1000);

            result = writer.GetOfferedDeadlineMissedStatus(ref status);
            Assert.AreEqual(ReturnCode.Ok, result);
            Assert.AreEqual(1, status.TotalCount);
            Assert.AreEqual(1, status.TotalCountChange);
            Assert.AreNotEqual(InstanceHandle.HandleNil, status.LastInstanceHandle);
        }
Exemplo n.º 28
0
        public void TestDeleteDataWriter()
        {
            // Initialize entities
            TestStructTypeSupport support = new TestStructTypeSupport();
            string     typeName           = support.GetTypeName();
            ReturnCode result             = support.RegisterType(_participant, typeName);

            Assert.AreEqual(ReturnCode.Ok, result);

            Topic topic = _participant.CreateTopic(nameof(TestDeleteDataWriter), typeName);

            Assert.IsNotNull(topic);
            Assert.IsNull(topic.GetListener());
            Assert.AreEqual(nameof(TestDeleteDataWriter), topic.Name);
            Assert.AreEqual(typeName, topic.TypeName);

            Publisher publisher = _participant.CreatePublisher();

            Assert.IsNotNull(publisher);

            Publisher otherPublisher = _participant.CreatePublisher();

            Assert.IsNotNull(otherPublisher);

            // Create a DataWriter and try to delete it with another publisher
            DataWriter datawriter = publisher.CreateDataWriter(topic);

            Assert.IsNotNull(datawriter);
            Assert.AreEqual(publisher, datawriter.Publisher);
            Assert.IsNull(datawriter.GetListener());

            DataWriterQos qos = new DataWriterQos();

            result = datawriter.GetQos(qos);
            Assert.AreEqual(ReturnCode.Ok, result);
            TestHelper.TestDefaultDataWriterQos(qos);

            result = otherPublisher.DeleteDataWriter(datawriter);
            Assert.AreEqual(ReturnCode.PreconditionNotMet, result);

            // Delete the datawriter with the correct publisher
            result = publisher.DeleteDataWriter(datawriter);
            Assert.AreEqual(ReturnCode.Ok, result);

            // Try to remove it again
            result = publisher.DeleteDataWriter(datawriter);
            Assert.AreEqual(ReturnCode.Error, result);

            // Test with null parameter
            result = publisher.DeleteDataWriter(null);
            Assert.AreEqual(ReturnCode.Ok, result);
        }
Exemplo n.º 29
0
        private ShapeTypeDataWriter CreateSquareWriter()
        {
            DataWriterQos qos    = GetDataWriterQos();
            DataWriter    writer = _publisher.CreateDataWriter(_squareTopic);

            if (writer == null)
            {
                throw new Exception("Could not create square data writer");
            }

            ShapeTypeDataWriter squareDataWriter = new ShapeTypeDataWriter(writer);

            return(squareDataWriter);
        }
Exemplo n.º 30
0
        private ShapeTypeDataWriter CreateTriangleWriter()
        {
            DataWriterQos qos    = GetDataWriterQos();
            DataWriter    writer = _publisher.CreateDataWriter(_triangleTopic, qos);

            if (writer == null)
            {
                throw new Exception("Could not create triangle data writer");
            }

            ShapeTypeDataWriter triangleDataWriter = new ShapeTypeDataWriter(writer);

            return(triangleDataWriter);
        }
Exemplo n.º 31
0
        private DataWriterQos GetDataWriterQos()
        {
            DataWriterQos dataWriterQos = new DataWriterQos();

            _publisher.GetDefaultDataWriterQos(dataWriterQos);

            dataWriterQos.Reliability.Kind        = _config.WriterQosConfig.ReliabilityKind;
            dataWriterQos.Ownership.Kind          = _config.WriterQosConfig.OwnershipKind;
            dataWriterQos.OwnershipStrength.Value = _config.WriterQosConfig.OwnershipStrength;
            dataWriterQos.Durability.Kind         = _config.WriterQosConfig.DurabilityKind;
            dataWriterQos.TransportPriority.Value = _config.WriterQosConfig.TransportPriority;

            return(dataWriterQos);
        }
        public void TestLookupInstance()
        {
            PublicationBuiltinTopicData data = default;
            SampleInfo info = new SampleInfo();

            DomainParticipant otherParticipant = AssemblyInitializer.Factory.CreateParticipant(AssemblyInitializer.RTPS_DOMAIN);

            Assert.IsNotNull(otherParticipant);
            otherParticipant.BindRtpsUdpTransportConfig();

            TestStructTypeSupport support = new TestStructTypeSupport();
            string     typeName           = support.GetTypeName();
            ReturnCode result             = support.RegisterType(otherParticipant, typeName);

            Assert.AreEqual(ReturnCode.Ok, result);

            var topic = otherParticipant.CreateTopic(TestContext.TestName, typeName);

            Assert.IsNotNull(topic);

            var publisher = otherParticipant.CreatePublisher();

            Assert.IsNotNull(publisher);

            DataWriterQos dwQos = TestHelper.CreateNonDefaultDataWriterQos();

            dwQos.Ownership.Kind = OwnershipQosPolicyKind.SharedOwnershipQos;
            DataWriter dataWriter = publisher.CreateDataWriter(topic, dwQos);

            Assert.IsNotNull(dataWriter);

            Thread.Sleep(500);

            ReturnCode ret = _dr.ReadNextSample(ref data, info);

            Assert.AreEqual(ReturnCode.Ok, ret);

            // Lookup for an existing instance
            var handle = _dr.LookupInstance(data);

            Assert.AreNotEqual(InstanceHandle.HandleNil, handle);

            ret = otherParticipant.DeleteContainedEntities();
            Assert.AreEqual(ReturnCode.Ok, ret);
            TestHelper.TestNonDefaultPublicationData(data);

            ret = AssemblyInitializer.Factory.DeleteParticipant(otherParticipant);
            Assert.AreEqual(ReturnCode.Ok, ret);
        }
Exemplo n.º 33
0
        public ReturnCode SetQos(DataWriterQos qos)
        {
            ReturnCode result;

            using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler = 
                    new OpenSplice.CustomMarshalers.DataWriterQosMarshaler())
            {
                result = marshaler.CopyIn(qos);
                if (result == ReturnCode.Ok)
                {
                    result = Gapi.DataWriter.set_qos(GapiPeer, marshaler.GapiPtr);
                }
            }

            return result;
        }
Exemplo n.º 34
0
        public ReturnCode CopyFromTopicQos(ref DataWriterQos dataWriterQos, TopicQos topicQos)
        {
            ReturnCode result = ReturnCode.Ok;

            if (dataWriterQos == null)
            {
                result = GetDefaultDataWriterQos(ref dataWriterQos);
            }

            if (result == ReturnCode.Ok)
            {
                using (OpenSplice.CustomMarshalers.TopicQosMarshaler marshaler =
                        new OpenSplice.CustomMarshalers.TopicQosMarshaler())
                {
                    result = marshaler.CopyIn(topicQos);
                    if (result == ReturnCode.Ok)
                    {
                        using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler dataWriterMarshaler =
                                new OpenSplice.CustomMarshalers.DataWriterQosMarshaler())
                        {
                            result = dataWriterMarshaler.CopyIn(dataWriterQos);
                            if (result == ReturnCode.Ok)
                            {
                                result = Gapi.Publisher.copy_from_topic_qos(
                                        GapiPeer,
                                        dataWriterMarshaler.GapiPtr,
                                        marshaler.GapiPtr);

                                if (result == ReturnCode.Ok)
                                {
                                    dataWriterMarshaler.CopyOut(ref dataWriterQos);
                                }
                            }
                        }
                    }
                }
            }

            return result;
        }
Exemplo n.º 35
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;
        }
Exemplo n.º 36
0
        public ReturnCode GetDefaultDataWriterQos(ref DataWriterQos qos)
        {
            ReturnCode result;

            using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler =
                    new OpenSplice.CustomMarshalers.DataWriterQosMarshaler())
            {
                result = Gapi.Publisher.get_default_datawriter_qos(
                        GapiPeer,
                        marshaler.GapiPtr);

                if (result == ReturnCode.Ok)
                {
                    marshaler.CopyOut(ref qos);
                }
            }

            return result;
        }
Exemplo n.º 37
0
        public IDataWriter CreateDataWriter(
                ITopic topic, 
                DataWriterQos qos,
                IDataWriterListener listener, 
                StatusKind mask)
        {
            DataWriter dataWriter = null;
            Topic topicObj = topic as Topic;

            using (OpenSplice.CustomMarshalers.DataWriterQosMarshaler marshaler =
                    new OpenSplice.CustomMarshalers.DataWriterQosMarshaler())
            {
                if (marshaler.CopyIn(qos) == ReturnCode.Ok)
                {
                    if (listener != null)
                    {
                        // Note: we use the same gapi lister as the DataWriter since the
                        // publisher doesn't add anything unique
                        OpenSplice.Gapi.gapi_publisherDataWriterListener gapiListener;
                        PublisherDataWriterListenerHelper listenerHelper = new PublisherDataWriterListenerHelper();
                        listenerHelper.Listener = listener;
                        listenerHelper.CreateListener(out gapiListener);
                        using (PublisherDataWriterListenerMarshaler listenerMarshaler =
                                new PublisherDataWriterListenerMarshaler(ref gapiListener))
                        {
                            IntPtr gapiPtr = Gapi.Publisher.create_datawriter(
                                    GapiPeer,
                                    topicObj.GapiPeer,
                                    marshaler.GapiPtr,
                                    listenerMarshaler.GapiPtr,
                                    mask);
                            if (gapiPtr != IntPtr.Zero)
                            {
                                TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                        as OpenSplice.TypeSupport;
                                dataWriter = typeSupport.CreateDataWriter(gapiPtr);
                                dataWriter.SetListener(listenerHelper);
                            }
                        }
                    }
                    else
                    {
                        // Invoke the corresponding gapi function.
                        IntPtr gapiPtr = Gapi.Publisher.create_datawriter(
                                GapiPeer,
                                topicObj.GapiPeer,
                                marshaler.GapiPtr,
                                IntPtr.Zero,
                                mask);
                        if (gapiPtr != IntPtr.Zero)
                        {
                            TypeSupport typeSupport = topic.Participant.GetTypeSupport(topic.TypeName)
                                    as OpenSplice.TypeSupport;
                            dataWriter = typeSupport.CreateDataWriter(gapiPtr);
                        }
                    }
                }
            }

            if (dataWriter != null)
            {
                PublisherQos pubQos = null;
                ReturnCode result = GetQos(ref pubQos);
                if (result == ReturnCode.Ok)
                {
                    if (pubQos.EntityFactory.AutoenableCreatedEntities)
                    {
                        dataWriter.Enable();
                    }
                }
            }

            return dataWriter;
        }
Exemplo n.º 38
0
 public IDataWriter CreateDataWriter(ITopic topic, DataWriterQos qos)
 {
     return CreateDataWriter(topic, qos, null, 0);
 }
Exemplo n.º 39
0
 internal void CopyOut(ref DataWriterQos to)
 {
     CopyOut(GapiPtr, ref to);
 }
Exemplo n.º 40
0
 GetDataWriterQos (
     ref DataWriterQos datawriterQos,
     string id)
 {
     NamedDataWriterQos dwQos = new NamedDataWriterQos();
     GCHandle qosHandle = GCHandle.Alloc(dwQos, GCHandleType.Normal);
     ReturnCode result = OpenSplice.Common.QosProvider.GetDataWriterQos(GapiPeer, id, GCHandle.ToIntPtr(qosHandle));
     datawriterQos = dwQos.DatawriterQos;
     qosHandle.Free();
     return result;
 }
Exemplo n.º 41
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");

        }
Exemplo n.º 42
0
 internal static void CopyOut(IntPtr from, ref DataWriterQos to)
 {
     if (to == null) to = new DataWriterQos();
     DurabilityQosPolicyMarshaler.CopyOut(from, ref to.Durability, offset_durability);
     DeadlineQosPolicyMarshaler.CopyOut(from, ref to.Deadline, offset_deadline);
     LatencyBudgetQosPolicyMarshaler.CopyOut(from, ref to.LatencyBudget, offset_latency_budget);
     LivelinessQosPolicyMarshaler.CopyOut(from, ref to.Liveliness, offset_liveliness);
     ReliabilityQosPolicyMarshaler.CopyOut(from, ref to.Reliability, offset_reliability);
     DestinationOrderQosPolicyMarshaler.CopyOut(from, ref to.DestinationOrder, offset_destination_order);
     HistoryQosPolicyMarshaler.CopyOut(from, ref to.History, offset_history);
     ResourceLimitsQosPolicyMarshaler.CopyOut(from, ref to.ResourceLimits, offset_resource_limits);
     TransportPriorityQosPolicyMarshaler.CopyOut(from, ref to.TransportPriority, offset_transport_priority);
     LifespanQosPolicyMarshaler.CopyOut(from, ref to.Lifespan, offset_lifespan);
     UserDataQosPolicyMarshaler.CopyOut(from, ref to.UserData, offset_user_data);
     OwnershipQosPolicyMarshaler.CopyOut(from, ref to.Ownership, offset_ownership);
     OwnershipStrengthQosPolicyMarshaler.CopyOut(from, ref to.OwnershipStrength, offset_ownership_strength);
     WriterDataLifecycleQosPolicyMarshaler.CopyOut(from, ref to.WriterDataLifecycle, offset_writer_data_lifecycle);
 }
Exemplo n.º 43
0
 internal static DDS.ReturnCode CopyIn(DataWriterQos from, IntPtr to)
 {
     DDS.ReturnCode result;
     if (from != null) {
         result = DurabilityQosPolicyMarshaler.CopyIn(
                 from.Durability, to, offset_durability);
         if (result == DDS.ReturnCode.Ok) {
             result = DeadlineQosPolicyMarshaler.CopyIn(
                     from.Deadline, to, offset_deadline);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = LatencyBudgetQosPolicyMarshaler.CopyIn(
                     from.LatencyBudget, to, offset_latency_budget);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = LivelinessQosPolicyMarshaler.CopyIn(
                     from.Liveliness, to, offset_liveliness);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = ReliabilityQosPolicyMarshaler.CopyIn(
                     from.Reliability, to, offset_reliability);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = DestinationOrderQosPolicyMarshaler.CopyIn(
                     from.DestinationOrder, to, offset_destination_order);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = HistoryQosPolicyMarshaler.CopyIn(
                     from.History, to, offset_history);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = ResourceLimitsQosPolicyMarshaler.CopyIn(
                     from.ResourceLimits, to, offset_resource_limits);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = TransportPriorityQosPolicyMarshaler.CopyIn(
                     from.TransportPriority, to, offset_transport_priority);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = LifespanQosPolicyMarshaler.CopyIn(
                     from.Lifespan, to, offset_lifespan);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = UserDataQosPolicyMarshaler.CopyIn(
                     from.UserData, to, offset_user_data);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = OwnershipQosPolicyMarshaler.CopyIn(
                     from.Ownership, to, offset_ownership);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = OwnershipStrengthQosPolicyMarshaler.CopyIn(
                     from.OwnershipStrength, to, offset_ownership_strength);
         }
         if (result == DDS.ReturnCode.Ok) {
             result = WriterDataLifecycleQosPolicyMarshaler.CopyIn(
                     from.WriterDataLifecycle, to, offset_writer_data_lifecycle);
         }
     } else {
         result = DDS.ReturnCode.BadParameter;
         DDS.OpenSplice.OS.Report(
                 DDS.OpenSplice.ReportType.OS_ERROR,
                 "DDS.OpenSplice.CustomMarshalers.DataWriterQosMarshaler.CopyIn",
                 "DDS/OpenSplice/CustomMarshalers/QosToplevelMarshalers.cs",
                 DDS.ErrorCode.InvalidValue,
                 "DataWriterQos attribute may not be a null pointer.");
     }
     return result;
 }
Exemplo n.º 44
0
 internal DDS.ReturnCode CopyIn(DataWriterQos from)
 {
     cleanupRequired = true;
     return CopyIn(from, GapiPtr);
 }