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); }
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); }
private void OnApplicationStartup(object sender, StartupEventArgs e) { Ace.Init(); InteroperatibilityProvider provider = InteroperatibilityProvider.OpenDDS; if (e.Args.Length > 0 && e.Args[0].StartsWith("-Vendor=")) { string strProvider = e.Args[0].Replace("-Vendor=", string.Empty); switch (strProvider.ToLower()) { case "rti": provider = InteroperatibilityProvider.Rti; break; case "opensplice": provider = InteroperatibilityProvider.OpenSplice; break; default: provider = InteroperatibilityProvider.OpenDDS; break; } } ViewModelLocator.Provider = provider; }
static void Main(string[] args) { Ace.Init(); DomainParticipantFactory dpf = ParticipantService.Instance.GetDomainParticipantFactory("-DCPSConfigFile", "rtps.ini"); DomainParticipant participant = dpf.CreateParticipant(42); if (participant == null) { throw new Exception("Could not create the participant"); } // Include your program here participant.DeleteContainedEntities(); dpf.DeleteParticipant(participant); ParticipantService.Instance.Shutdown(); Ace.Fini(); }
static void Main(string[] args) { bool isPublisher = true; if (args != null && args.Length > 0) { isPublisher = !args[0].ToLowerInvariant().Equals("--sub") && !args[0].ToLowerInvariant().Equals("--subscriber"); } Ace.Init(); DomainParticipantFactory dpf = ParticipantService.Instance.GetDomainParticipantFactory("-DCPSConfigFile", "rtps.ini", "-DCPSDebugLevel", "10", "-ORBLogFile", "LogFile.log", "-ORBDebugLevel", "10"); if (dpf == null) { throw new ApplicationException("Domain participant factory could not be created."); } DomainParticipant participant = dpf.CreateParticipant(42); if (dpf == null) { throw new ApplicationException("Domain participant could not be created."); } if (isPublisher) { TestPublisher(participant); } else { TestSubscriber(participant); } Console.WriteLine("Shutting down... that's enough for today."); participant.DeleteContainedEntities(); dpf.DeleteParticipant(participant); ParticipantService.Instance.Shutdown(); Ace.Fini(); }
static void Main(string[] args) { Ace.Init(); DomainParticipantFactory dpf = ParticipantService.Instance.GetDomainParticipantFactory("-DCPSConfigFile", "rtps.ini"); DomainParticipant participant = dpf.CreateParticipant(42); if (participant == null) { throw new Exception("Could not create the participant"); } MessageTypeSupport support = new MessageTypeSupport(); ReturnCode result = support.RegisterType(participant, support.GetTypeName()); if (result != ReturnCode.Ok) { throw new Exception("Could not register type: " + result.ToString()); } Topic topic = participant.CreateTopic("MessageTopic", support.GetTypeName()); if (topic == null) { throw new Exception("Could not create the message topic"); } Subscriber subscriber = participant.CreateSubscriber(); if (subscriber == null) { throw new Exception("Could not create the subscriber"); } DataReader reader = subscriber.CreateDataReader(topic); if (reader == null) { throw new Exception("Could not create the message data reader"); } MessageDataReader messageReader = new MessageDataReader(reader); while (true) { StatusMask mask = messageReader.StatusChanges; if ((mask & StatusKind.DataAvailableStatus) != 0) { List <Message> receivedData = new List <Message>(); List <SampleInfo> receivedInfo = new List <SampleInfo>(); result = messageReader.Take(receivedData, receivedInfo); if (result == ReturnCode.Ok) { bool messageReceived = false; for (int i = 0; i < receivedData.Count; i++) { if (receivedInfo[i].ValidData) { Console.WriteLine(receivedData[i].Content); messageReceived = true; } } if (messageReceived) { break; } } } System.Threading.Thread.Sleep(100); } Console.WriteLine("Press a key to exit..."); Console.ReadKey(); participant.DeleteContainedEntities(); dpf.DeleteParticipant(participant); ParticipantService.Instance.Shutdown(); Ace.Fini(); }
static void Main(string[] args) { Ace.Init(); DomainParticipantFactory dpf = ParticipantService.Instance.GetDomainParticipantFactory("-DCPSConfigFile", "rtps.ini"); DomainParticipant participant = dpf.CreateParticipant(42); if (participant == null) { throw new Exception("Could not create the participant"); } MessageTypeSupport support = new MessageTypeSupport(); ReturnCode result = support.RegisterType(participant, support.GetTypeName()); if (result != ReturnCode.Ok) { throw new Exception("Could not register type: " + result.ToString()); } Topic topic = participant.CreateTopic("MessageTopic", support.GetTypeName()); if (topic == null) { throw new Exception("Could not create the message topic"); } Publisher publisher = participant.CreatePublisher(); if (publisher == null) { throw new Exception("Could not create the publisher"); } DataWriter writer = publisher.CreateDataWriter(topic); if (writer == null) { throw new Exception("Could not create the data writer"); } MessageDataWriter messageWriter = new MessageDataWriter(writer); Console.WriteLine("Waiting for a subscriber..."); PublicationMatchedStatus status = new PublicationMatchedStatus(); do { result = messageWriter.GetPublicationMatchedStatus(ref status); System.Threading.Thread.Sleep(500); }while (status.CurrentCount < 1); Console.WriteLine("Subscriber found, writting data...."); messageWriter.Write(new Message { Content = "Hello, I love you, won't you tell me your name?" }); Console.WriteLine("Press a key to exit..."); Console.ReadKey(); participant.DeleteContainedEntities(); dpf.DeleteParticipant(participant); ParticipantService.Instance.Shutdown(); Ace.Fini(); }