示例#1
0
        public static void BindRtpsUdpTransportConfig(this Entity entity)
        {
            string guid       = Guid.NewGuid().ToString("N");
            string configName = "openddsharp_rtps_interop_" + guid;
            string instName   = "internal_openddsharp_rtps_transport_" + guid;

            TransportConfig config = TransportRegistry.Instance.CreateConfig(configName);
            TransportInst   inst   = TransportRegistry.Instance.CreateInst(instName, "rtps_udp");
            RtpsUdpInst     rui    = new RtpsUdpInst(inst);

            config.Insert(inst);

            TransportRegistry.Instance.BindConfig(configName, entity);
        }
示例#2
0
        private static void BindRtpsUdpTransportConfig(DomainParticipant participant)
        {
            long   ticks      = DateTime.Now.Ticks;
            string configName = "openddsharp_rtps_interop_" + ticks.ToString();
            string instName   = "internal_openddsharp_rtps_transport_" + ticks.ToString();

            TransportConfig config = TransportRegistry.Instance.CreateConfig(configName);
            TransportInst   inst   = TransportRegistry.Instance.CreateInst(instName, "rtps_udp");
            RtpsUdpInst     rui    = new RtpsUdpInst(inst);

            config.Insert(inst);

            TransportRegistry.Instance.BindConfig(configName, participant);
        }
示例#3
0
        private static void BindRtpsUdpTransportConfig(DomainParticipant participant)
        {
            string guid       = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
            string configName = "openddsharp_rtps_interop_" + guid;
            string instName   = "internal_openddsharp_rtps_transport_" + guid;

            TransportConfig config = TransportRegistry.Instance.CreateConfig(configName);
            TransportInst   inst   = TransportRegistry.Instance.CreateInst(instName, "rtps_udp");
            RtpsUdpInst     rui    = new RtpsUdpInst(inst);

            config.Insert(rui);

            TransportRegistry.Instance.BindConfig(configName, participant);
        }
示例#4
0
        public void TestDefaultValues()
        {
            TransportInst inst = TransportRegistry.Instance.CreateInst(INSTANCE_NAME, TRANSPORT_TYPE);
            RtpsUdpInst   rui  = new RtpsUdpInst(inst);

            Assert.IsTrue(rui.UseMulticast);
            Assert.AreEqual("239.255.0.2:7401", rui.MulticastGroupAddress);
            Assert.AreEqual(string.Empty, rui.MulticastInterface);
            Assert.AreEqual("0.0.0.0:0", rui.LocalAddress);
            Assert.AreEqual(0U, rui.NakDepth);
            Assert.IsNotNull(rui.NakResponseDelay);
            Assert.AreEqual(0, rui.NakResponseDelay.Seconds);
            Assert.AreEqual(200000, rui.NakResponseDelay.MicroSeconds);
            Assert.IsNotNull(rui.HeartbeatPeriod);
            Assert.AreEqual(1, rui.HeartbeatPeriod.Seconds);
            Assert.AreEqual(0, rui.HeartbeatPeriod.MicroSeconds);
            Assert.AreEqual(1, rui.Ttl);
            Assert.AreEqual(32U, rui.DatalinkControlChunks);
            Assert.AreEqual(10000, rui.DatalinkReleaseDelay);
            Assert.IsTrue(rui.IsReliable);
            Assert.AreEqual(2147481599u, rui.MaxPacketSize);
            Assert.AreEqual(10U, rui.MaxSamplesPerPacket);
            Assert.AreEqual(INSTANCE_NAME, rui.Name);
            Assert.AreEqual(4096u, rui.OptimumPacketSize);
            Assert.AreEqual(5U, rui.QueueInitialPools);
            Assert.AreEqual(10U, rui.QueueMessagesPerPool);
            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
            {
                Assert.AreEqual(65536, rui.RcvBufferSize);
                Assert.AreEqual(65536, rui.SendBufferSize);
            }
            else
            {
                Assert.AreEqual(65535, rui.RcvBufferSize);
                Assert.AreEqual(65535, rui.SendBufferSize);
            }
            Assert.AreEqual(TRANSPORT_TYPE, rui.TransportType);
            Assert.IsTrue(rui.RequiresCdr);
            Assert.IsFalse(rui.ThreadPerConnection);
            Assert.AreEqual(5, rui.ReceiveAddressDuration.Seconds);
            Assert.AreEqual(0, rui.ReceiveAddressDuration.MicroSeconds);

            TransportRegistry.Instance.RemoveInst(rui);
        }
示例#5
0
        public void TestNonDefaultValues()
        {
            TransportInst inst = TransportRegistry.Instance.CreateInst(INSTANCE_NAME, TRANSPORT_TYPE);
            RtpsUdpInst   rui  = new RtpsUdpInst(inst)
            {
                UseMulticast          = false,
                MulticastGroupAddress = "239.255.0.1:7402",
                LocalAddress          = "127.0.0.1:",
                MulticastInterface    = "eth0",
                NakDepth         = 64U,
                NakResponseDelay = new TimeValue
                {
                    Seconds      = 1,
                    MicroSeconds = 400000
                },
                HeartbeatPeriod = new TimeValue
                {
                    Seconds      = 2,
                    MicroSeconds = 100000
                },
                HeartbeatResponseDelay = new TimeValue
                {
                    Seconds      = 2,
                    MicroSeconds = 100000
                },
                HandshakeTimeout = new TimeValue
                {
                    Seconds      = 60,
                    MicroSeconds = 100000
                },
                Ttl = 2,
                DatalinkControlChunks = 64U,
                DatalinkReleaseDelay  = 20000,
                DurableDataTimeout    = new TimeValue
                {
                    Seconds      = 20,
                    MicroSeconds = 100000
                },
                MaxPacketSize        = 2147481500u,
                MaxSamplesPerPacket  = 20U,
                OptimumPacketSize    = 2048u,
                QueueInitialPools    = 20U,
                QueueMessagesPerPool = 20U,
                RcvBufferSize        = 65530,
                SendBufferSize       = 65530,
                ThreadPerConnection  = true
            };

            Assert.IsFalse(rui.UseMulticast);
            Assert.AreEqual("239.255.0.1:7402", rui.MulticastGroupAddress);
            Assert.AreEqual("eth0", rui.MulticastInterface);
            Assert.AreEqual("127.0.0.1:", rui.LocalAddress);
            Assert.AreEqual(64U, rui.NakDepth);
            Assert.IsNotNull(rui.NakResponseDelay);
            Assert.AreEqual(1, rui.NakResponseDelay.Seconds);
            Assert.AreEqual(400000, rui.NakResponseDelay.MicroSeconds);
            Assert.IsNotNull(rui.HeartbeatPeriod);
            Assert.AreEqual(2, rui.HeartbeatPeriod.Seconds);
            Assert.AreEqual(100000, rui.HeartbeatPeriod.MicroSeconds);
            Assert.IsNotNull(rui.HeartbeatResponseDelay);
            Assert.AreEqual(2, rui.HeartbeatResponseDelay.Seconds);
            Assert.AreEqual(100000, rui.HeartbeatResponseDelay.MicroSeconds);
            Assert.IsNotNull(rui.HandshakeTimeout);
            Assert.AreEqual(60, rui.HandshakeTimeout.Seconds);
            Assert.AreEqual(100000, rui.HandshakeTimeout.MicroSeconds);
            Assert.AreEqual(2, rui.Ttl);
            Assert.AreEqual(64U, rui.DatalinkControlChunks);
            Assert.AreEqual(20000, rui.DatalinkReleaseDelay);
            Assert.IsNotNull(rui.DurableDataTimeout);
            Assert.AreEqual(20, rui.DurableDataTimeout.Seconds);
            Assert.AreEqual(100000, rui.DurableDataTimeout.MicroSeconds);
            Assert.IsTrue(rui.IsReliable);
            Assert.AreEqual(2147481500u, rui.MaxPacketSize);
            Assert.AreEqual(20U, rui.MaxSamplesPerPacket);
            Assert.AreEqual(INSTANCE_NAME, rui.Name);
            Assert.AreEqual(2048u, rui.OptimumPacketSize);
            Assert.AreEqual(20U, rui.QueueInitialPools);
            Assert.AreEqual(20U, rui.QueueMessagesPerPool);
            Assert.AreEqual(65530, rui.RcvBufferSize);
            Assert.AreEqual(65530, rui.SendBufferSize);
            Assert.AreEqual(TRANSPORT_TYPE, rui.TransportType);
            Assert.IsTrue(rui.RequiresCdr);
            Assert.IsTrue(rui.ThreadPerConnection);

            TransportRegistry.Instance.RemoveInst(rui);
        }
示例#6
0
        public OpenDDSharpService()
        {
            _config = ServiceLocator.Current.GetInstance <IConfigurationService>();

            _disc = new RtpsDiscovery(RTPS_DISCOVERY)
            {
                ResendPeriod = new TimeValue {
                    Seconds = 1
                },
                SedpMulticast = true
            };

            ParticipantService.Instance.AddDiscovery(_disc);
            ParticipantService.Instance.DefaultDiscovery = RTPS_DISCOVERY;

            long   ticks      = DateTime.Now.Ticks;
            string configName = "openddsharp_rtps_interop_" + ticks.ToString();;
            string instName   = "internal_openddsharp_rtps_transport_" + ticks.ToString();;

            _tConfig = TransportRegistry.Instance.CreateConfig(configName);
            _inst    = TransportRegistry.Instance.CreateInst(instName, "rtps_udp");
            _rui     = new RtpsUdpInst(_inst);
            _tConfig.Insert(_inst);
            TransportRegistry.Instance.GlobalConfig = _tConfig;
            ParticipantService.Instance.SetRepoDomain(0, RTPS_DISCOVERY);

            _domainFactory = ParticipantService.Instance.GetDomainParticipantFactory("-DCPSDebugLevel", "10", "-ORBLogFile", "LogFile.log", "-ORBDebugLevel", "10");

            _participant = _domainFactory.CreateParticipant(0);
            if (_participant == null)
            {
                throw new Exception("Could not create the participant");
            }

            ShapeTypeTypeSupport support = new ShapeTypeTypeSupport();
            ReturnCode           result  = support.RegisterType(_participant, TYPE_NAME);

            if (result != ReturnCode.Ok)
            {
                throw new Exception("Could not register type: " + result.ToString());
            }

            _squareTopic = _participant.CreateTopic(SQUARE_TOPIC_NAME, TYPE_NAME);
            if (_squareTopic == null)
            {
                throw new Exception("Could not create square topic");
            }

            _circleTopic = _participant.CreateTopic(CIRCLE_TOPIC_NAME, TYPE_NAME);
            if (_circleTopic == null)
            {
                throw new Exception("Could not create circle topic");
            }

            _triangleTopic = _participant.CreateTopic(TRIANGLE_TOPIC_NAME, TYPE_NAME);
            if (_triangleTopic == null)
            {
                throw new Exception("Could not create triangle topic");
            }

            _publisher = _participant.CreatePublisher();
            if (_publisher == null)
            {
                throw new Exception("Could not create publisher");
            }

            _subscriber = _participant.CreateSubscriber();
            if (_subscriber == null)
            {
                throw new Exception("Could not create subscriber");
            }

            _shapeWaitSets = new List <ShapeWaitSet>();
            _shapeDynamics = new List <ShapeDynamic>();

            _cfCircleCount   = 0;
            _cfSquareCount   = 0;
            _cfTriangleCount = 0;
        }
示例#7
0
        public void TestCreateInst()
        {
            // Create a RTPS UDP transport instance
            TransportInst inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "rtps_udp");

            Assert.IsNotNull(inst);
            Assert.AreEqual(nameof(TestCreateInst), inst.Name);
            Assert.AreEqual("rtps_udp", inst.TransportType);
            RtpsUdpInst rui = new RtpsUdpInst(inst);

            Assert.IsNotNull(rui);
            TransportRegistry.Instance.RemoveInst(inst);

            // Create a UDP transport instance
            inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "udp");
            Assert.IsNotNull(inst);
            Assert.AreEqual(nameof(TestCreateInst), inst.Name);
            Assert.AreEqual("udp", inst.TransportType);
            UdpInst udpi = new UdpInst(inst);

            Assert.IsNotNull(udpi);
            TransportRegistry.Instance.RemoveInst(inst);

            // Create a Multicast transport instance
            inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "multicast");
            Assert.IsNotNull(inst);
            Assert.AreEqual(nameof(TestCreateInst), inst.Name);
            Assert.AreEqual("multicast", inst.TransportType);
            MulticastInst multicasti = new MulticastInst(inst);

            Assert.IsNotNull(multicasti);
            TransportRegistry.Instance.RemoveInst(inst);

            // Create a Multicast transport instance
            inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "tcp");
            Assert.IsNotNull(inst);
            Assert.AreEqual(nameof(TestCreateInst), inst.Name);
            Assert.AreEqual("tcp", inst.TransportType);
            MulticastInst tcpi = new MulticastInst(inst);

            Assert.IsNotNull(tcpi);
            TransportRegistry.Instance.RemoveInst(inst);

            // Create a SharedMemory transport instance
            inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "shmem");
            Assert.IsNotNull(inst);
            Assert.AreEqual(nameof(TestCreateInst), inst.Name);
            Assert.AreEqual("shmem", inst.TransportType);
            ShmemInst shmemi = new ShmemInst(inst);

            Assert.IsNotNull(shmemi);
            TransportRegistry.Instance.RemoveInst(inst);

            // Create a instance with an invalid transport type
            inst = TransportRegistry.Instance.CreateInst(nameof(TestCreateInst), "quantic_teletransport");
            Assert.IsNull(inst);

            // Try to create a transport instance with empty name
            bool exception = false;

            try
            {
                inst = TransportRegistry.Instance.CreateInst(null, "shmem");
            }
            catch (Exception ex)
            {
                exception = true;
                Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException));
            }
            Assert.IsTrue(exception);

            exception = false;
            try
            {
                inst = TransportRegistry.Instance.CreateInst(string.Empty, "shmem");
            }
            catch (Exception ex)
            {
                exception = true;
                Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException));
            }
            Assert.IsTrue(exception);

            exception = false;
            try
            {
                inst = TransportRegistry.Instance.CreateInst("  ", "shmem");
            }
            catch (Exception ex)
            {
                exception = true;
                Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException));
            }
            Assert.IsTrue(exception);
        }