예제 #1
0
        public void TestInsert()
        {
            // Test successfully insert
            TransportConfig config = TransportRegistry.Instance.CreateConfig(nameof(TestInsert));

            Assert.IsNotNull(config);
            TransportInst inst = TransportRegistry.Instance.CreateInst(nameof(TestInsert), "shmem");

            config.Insert(inst);
            Assert.IsNotNull(inst);

            Assert.IsNotNull(config.Transports);
            Assert.AreEqual(1, config.Transports.Count);
            Assert.AreEqual(inst.Name, config.Transports.First().Name);
            Assert.AreEqual(inst.TransportType, "shmem");

            // Test parameter guard
            bool exception = false;

            try
            {
                config.Insert(null);
            }
            catch (Exception ex)
            {
                exception = true;
                Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException));
            }
            Assert.IsTrue(exception);

            TransportRegistry.Instance.RemoveConfig(config);
        }
예제 #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
        public static void BindTcpTransportConfig(this Entity entity)
        {
            long   ticks      = DateTime.Now.Ticks;
            string configName = "openddsharp_tcp_" + ticks.ToString();
            string instName   = "internal_openddsharp_tcp_transport_" + ticks.ToString();

            TransportConfig config = TransportRegistry.Instance.CreateConfig(configName);
            TransportInst   inst   = TransportRegistry.Instance.CreateInst(instName, "tcp");
            TcpInst         tcpi   = new TcpInst(inst);

            config.Insert(inst);

            TransportRegistry.Instance.BindConfig(config, entity);
        }
예제 #4
0
        public static void BindTcpTransportConfig(this Entity entity)
        {
            string guid       = Guid.NewGuid().ToString("N");
            string configName = "openddsharp_tcp_" + guid;
            string instName   = "internal_openddsharp_tcp_transport_" + guid;

            TransportConfig config = TransportRegistry.Instance.CreateConfig(configName);
            TransportInst   inst   = TransportRegistry.Instance.CreateInst(instName, "tcp");
            TcpInst         tcpi   = new TcpInst(inst);

            config.Insert(inst);

            TransportRegistry.Instance.BindConfig(config, entity);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
0
        public void TestNonDefaultValue()
        {
            TransportConfig config = TransportRegistry.Instance.CreateConfig(nameof(TestNonDefaultValue));

            Assert.IsNotNull(config);
            config.SwapBytes = true;
            config.PassiveConnectDuration = 30000u;
            TransportInst inst = TransportRegistry.Instance.CreateInst(nameof(TestNonDefaultValue), "shmem");

            Assert.IsNotNull(inst);
            config.Insert(inst);

            Assert.IsNotNull(config);
            Assert.AreEqual(nameof(TestNonDefaultValue), config.Name);
            Assert.AreEqual(30000u, config.PassiveConnectDuration);
            Assert.IsTrue(config.SwapBytes);
            Assert.IsNotNull(config.Transports);
            Assert.AreEqual(1, config.Transports.Count);
            Assert.AreEqual(inst.Name, config.Transports.First().Name);

            TransportRegistry.Instance.RemoveConfig(config);
        }
예제 #8
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;
        }