コード例 #1
0
        public static void AssemblyInitialize(TestContext context)
        {
            Ace.Init();

            RtpsDiscovery disc = new RtpsDiscovery(RTPS_DISCOVERY);

            ParticipantService.Instance.AddDiscovery(disc);
            ParticipantService.Instance.DefaultDiscovery = RTPS_DISCOVERY;
            Assert.AreEqual(RTPS_DISCOVERY, ParticipantService.Instance.DefaultDiscovery);
            ParticipantService.Instance.SetRepoDomain(RTPS_DOMAIN, RTPS_DISCOVERY);
            ParticipantService.Instance.SetRepoDomain(RTPS_OTHER_DOMAIN, RTPS_DISCOVERY);

            InfoRepoDiscovery infoRepo = new InfoRepoDiscovery(INFOREPO_DISCOVERY, "file://" + INFOREPO_IOR);

            ParticipantService.Instance.AddDiscovery(infoRepo);
            ParticipantService.Instance.SetRepoDomain(INFOREPO_DOMAIN, INFOREPO_DISCOVERY);

            _supportProcess = new SupportProcessHelper(context);
            _infoProcess    = _supportProcess.SpawnDCPSInfoRepo();
            System.Threading.Thread.Sleep(1000);

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

            Assert.IsFalse(TransportRegistry.Instance.Released);
            Assert.IsFalse(ParticipantService.Instance.IsShutdown);
        }
コード例 #2
0
        public static void AssemblyInitialize(TestContext context)
        {
            Ace.Init();

            RtpsDiscovery disc = new RtpsDiscovery(RTPS_DISCOVERY);

            Assert.AreEqual(RTPS_DISCOVERY, disc.Key);
            ParticipantService.Instance.AddDiscovery(disc);
            ParticipantService.Instance.DefaultDiscovery = RTPS_DISCOVERY;
            Assert.AreEqual(RTPS_DISCOVERY, ParticipantService.Instance.DefaultDiscovery);
            ParticipantService.Instance.SetRepoDomain(RTPS_DOMAIN, RTPS_DISCOVERY);
            ParticipantService.Instance.SetRepoDomain(RTPS_OTHER_DOMAIN, RTPS_DISCOVERY);

            InfoRepoDiscovery infoRepo = new InfoRepoDiscovery(INFOREPO_DISCOVERY, "corbaloc::localhost:12345/DCPSInfoRepo");

            ParticipantService.Instance.AddDiscovery(infoRepo);
            infoRepo.BitTransportIp   = "localhost";
            infoRepo.BitTransportPort = 0;
            ParticipantService.Instance.SetRepoDomain(INFOREPO_DOMAIN, INFOREPO_DISCOVERY);

            _supportProcess = new SupportProcessHelper(context);
            _infoProcess    = _supportProcess.SpawnDCPSInfoRepo();
            System.Threading.Thread.Sleep(1000);

            Factory = ParticipantService.Instance.GetDomainParticipantFactory();

            Assert.IsFalse(TransportRegistry.Instance.Released);
            Assert.IsFalse(ParticipantService.Instance.IsShutdown);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                throw new ApplicationException("Incorrect number of arguments.");
            }

            OpenDDSharp.Ace.Init();

            RtpsDiscovery disc = new RtpsDiscovery(RTPS_DISCOVERY);

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

            InfoRepoDiscovery infoRepo = new InfoRepoDiscovery(INFOREPO_DISCOVERY, "file://" + INFOREPO_IOR);

            ParticipantService.Instance.AddDiscovery(infoRepo);
            ParticipantService.Instance.SetRepoDomain(INFOREPO_DOMAIN, INFOREPO_DISCOVERY);

            if (Enum.TryParse(args[0], out SupportTestKind testKind))
            {
                switch (testKind)
                {
                case SupportTestKind.InconsistentTopicTest:
                    TestOnInconsistentTopic();
                    break;

                case SupportTestKind.PublicationDisconnectedTest:
                case SupportTestKind.PublicationLostTest:
                    TestOnPublicationLostDisconnected();
                    break;

                case SupportTestKind.SubscriptionDisconnectedTest:
                case SupportTestKind.SubscriptionLostTest:
                    TestOnSubscriptionLostDisconnected();
                    break;

                default:
                    throw new ApplicationException("Unkwnon test requested." + testKind.ToString());
                }
            }
            else
            {
                throw new ApplicationException("Argument is not a valid test kind.");
            }

            OpenDDSharp.Ace.Fini();
        }
コード例 #4
0
        public void TestNonDefaultValues()
        {
            RtpsDiscovery disc = new RtpsDiscovery(RTPS_DISCOVERY)
            {
                ResendPeriod = new TimeValue
                {
                    Seconds      = 1,
                    MicroSeconds = 500000
                },
                PB                    = 8400,
                DG                    = 500,
                PG                    = 4,
                D0                    = 10,
                D1                    = 20,
                DX                    = 4,
                SedpMulticast         = false,
                SedpLocalAddress      = "127.0.0.1",
                SpdpLocalAddress      = "127.0.0.1",
                DefaultMulticastGroup = "239.255.42.1",
                Ttl                   = 2,
                MulticastInterface    = "eth0",
                GuidInterface         = "eth0"
            };

            Assert.IsNotNull(disc.ResendPeriod);
            Assert.AreEqual(1, disc.ResendPeriod.Seconds);
            Assert.AreEqual(500000, disc.ResendPeriod.MicroSeconds);
            Assert.AreEqual(8400, disc.PB);
            Assert.AreEqual(500, disc.DG);
            Assert.AreEqual(4, disc.PG);
            Assert.AreEqual(10, disc.D0);
            Assert.AreEqual(20, disc.D1);
            Assert.AreEqual(4, disc.DX);
            Assert.AreEqual(false, disc.SedpMulticast);
            Assert.AreEqual("127.0.0.1", disc.SedpLocalAddress);
            Assert.AreEqual("127.0.0.1", disc.SpdpLocalAddress);
            Assert.AreEqual("239.255.42.1", disc.DefaultMulticastGroup);
            Assert.AreEqual(2, disc.Ttl);
            Assert.AreEqual("eth0", disc.MulticastInterface);
            Assert.AreEqual("eth0", disc.GuidInterface);
            Assert.IsFalse(string.IsNullOrWhiteSpace(disc.Key));
        }
コード例 #5
0
        public void TestNullOrEmptyName()
        {
            bool exception = false;

            try
            {
                RtpsDiscovery disc = new RtpsDiscovery(null);
            }
            catch (Exception ex)
            {
                exception = true;
                Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException));
            }
            Assert.IsTrue(exception);

            exception = false;
            try
            {
                RtpsDiscovery disc = new RtpsDiscovery(string.Empty);
            }
            catch (Exception ex)
            {
                exception = true;
                Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException));
            }
            Assert.IsTrue(exception);

            exception = false;
            try
            {
                RtpsDiscovery disc = new RtpsDiscovery("   ");
            }
            catch (Exception ex)
            {
                exception = true;
                Assert.IsTrue(ex.GetType() == typeof(ArgumentNullException));
            }
            Assert.IsTrue(exception);
        }
コード例 #6
0
        public void TestDefaultValues()
        {
            RtpsDiscovery disc = new RtpsDiscovery(RTPS_DISCOVERY);

            Assert.IsNotNull(disc.ResendPeriod);
            Assert.AreEqual(30, disc.ResendPeriod.Seconds);
            Assert.AreEqual(0, disc.ResendPeriod.MicroSeconds);
            Assert.AreEqual(7400, disc.PB);
            Assert.AreEqual(250, disc.DG);
            Assert.AreEqual(2, disc.PG);
            Assert.AreEqual(0, disc.D0);
            Assert.AreEqual(10, disc.D1);
            Assert.AreEqual(2, disc.DX);
            Assert.AreEqual(true, disc.SedpMulticast);
            Assert.AreEqual("", disc.SedpLocalAddress);
            Assert.AreEqual("", disc.SpdpLocalAddress);
            Assert.IsNotNull(disc.SpdpSendAddrs);
            Assert.AreEqual(0, disc.SpdpSendAddrs.Count());
            Assert.AreEqual("239.255.0.1", disc.DefaultMulticastGroup);
            Assert.AreEqual(1, disc.Ttl);
            Assert.AreEqual("", disc.MulticastInterface);
            Assert.AreEqual("", disc.GuidInterface);
            Assert.IsFalse(string.IsNullOrWhiteSpace(disc.Key));
        }
コード例 #7
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;
        }