public static void Main(string[] args) { DefaultParticipant.DomainId = 0; if (args.Length >= 1) { int domainId = 0; if (!Int32.TryParse(args[0], out domainId)) { Console.WriteLine("Invalid domainId. Quitting..."); return; } DefaultParticipant.DomainId = domainId; } DDS.DomainParticipant participant = DefaultParticipant.Instance; try { DefaultParticipant.RegisterType<ShapeTypeExtended, ShapeTypeExtendedTypeSupport>(); Processor proc = new Processor(); proc.triangle_writer = DefaultParticipant.CreateDataWriter<ShapeTypeExtended>("Triangle"); IDisposable disposable = null; //int workerThreads, completionPortThreads; //System.Threading.ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads); //Console.WriteLine("# of workerThreads = {0}, # of completionPortThreads = {1} ", // workerThreads, completionPortThreads); IScheduler scheduler; if (args.Length >= 3) { if (args[2] == "Default") scheduler = Scheduler.Default; else if (args[2] == "ThreadPool") scheduler = Scheduler.Default; else if (args[2] == "Immediate") scheduler = Scheduler.Immediate; else if (args[2] == "CurrentThread") scheduler = Scheduler.CurrentThread; else if (args[2] == "TaskPool") scheduler = TaskPoolScheduler.Default; else if (args[2] == "EventLoop") scheduler = new EventLoopScheduler(); else throw new ApplicationException("Unknown Scheduler!"); } else scheduler = Scheduler.Immediate; if (args.Length >= 2) { if (args[1] == "demo1") disposable = proc.demo1(participant, scheduler); if (args[1] == "demo2") disposable = proc.demo2(participant, scheduler); if (args[1] == "demo3") disposable = proc.demo3(participant); if (args[1] == "demo4") disposable = proc.demo4(participant); if (args[1] == "demo5") disposable = proc.demo5(participant, scheduler); if (args[1] == "forward") disposable = proc.forward(participant); else if (args[1] == "forward_short") disposable = proc.forward_short(participant); else if (args[1] == "forward_shortest") disposable = proc.forward_shortest(participant); else if (args[1] == "swap") disposable = proc.swap(participant); else if (args[1] == "swap_shortest") disposable = proc.swap(participant); else if (args[1] == "flower") disposable = proc.flower(participant); else if (args[1] == "instance_forward") disposable = proc.instance_forward(participant); else if (args[1] == "aggregator") disposable = proc.aggregator(participant); else if (args[1] == "collisions_combinelatest") disposable = proc.collisions_combinelatest(participant, scheduler); else if (args[1] == "collisions") disposable = proc.collisions(participant, scheduler); else if (args[1] == "single_circle_correlator") disposable = proc.single_circle_correlator(participant); else if (args[1] == "selectmany_correlator") disposable = proc.selectmany_correlator(participant, false); else if (args[1] == "selectmany_correlator_linq") disposable = proc.selectmany_correlator(participant, true); else if (args[1] == "selectmany_groupby_correlator") disposable = proc.selectmany_groupby_correlator(participant); else if (args[1] == "many_circle_correlator") disposable = proc.many_circle_correlator(participant, scheduler); else if (args[1] == "circle_zip_correlator") disposable = proc.circle_zip_correlator(participant); else if (args[1] == "splitterDelayNAverageWindow") disposable = proc.splitterDelayNAverageWindow(participant); else if (args[1] == "splitterDelayNAverage") disposable = proc.splitterDelayNAverage(participant); else if (args[1] == "timeWindowAggregator") disposable = proc.timeWindowAggregator(participant, scheduler); else if (args[1] == "key_correlator_flat") disposable = proc.key_correlator_flat(participant); else if (args[1] == "key_correlator_grouped") disposable = proc.key_correlator_grouped(participant); else if (args[1] == "key_correlator_replay") disposable = proc.key_correlator_replay(participant, false); else if (args[1] == "key_correlator_replay_linq") disposable = proc.key_correlator_replay(participant, true); else if (args[1] == "key_correlator_zip4") disposable = proc.key_correlator_zip4(participant); else if (args[1] == "key_correlator_zipN") { int n = 8; if (args.Length == 2) n = Int32.Parse(args[1]); disposable = proc.key_correlator_zipN(participant, n); } else if (args[1] == "key_correlator_dynamic") disposable = proc.key_correlator_dynamic(participant, scheduler); else if (args[1] == "once") disposable = proc.once(participant); else if (args[1] == "groupJoinInfiniteInner") disposable = proc.groupJoinInfiniteInner(); } for (; disposable != null; ) { ConsoleKeyInfo info = Console.ReadKey(true); if (info.Key == ConsoleKey.Enter) { disposable.Dispose(); break; } } } catch (DDS.Exception e) { Console.WriteLine("DDS Exception {0}", e); } catch (Exception ex) { Console.WriteLine("Generic Exception {0}", ex); } Console.WriteLine("Quitting..."); System.Threading.Thread.Sleep(1000); DefaultParticipant.Shutdown(); }