Esempio n. 1
0
        static void Main()
        {
            var vissim = new VissimLib200.VissimClass();

            vissim.LoadNet(_networkFile);
            vissim.LoadLayout(_layoutFile);

            // Use the expressive and powerful LINQ Query Expression on any  Vissim COM interface that  inherits
            // ICollectionBase, for example ILinkContainer. Actually, when  Vissim  COM types are imported  from
            // the type  library, Vissim  ICollectionBase interface is  automatically translated  as  inheriting
            // IEnumerable, because of the special flag [id(0xfffffffc)] specified to its _NewEnum  method. This
            // enables foreach loop and LINQ Query Expression on any Vissim COM interface object that implements
            // ICollectionBase.

            // Alternatively, IConnectionBase.FilteredB() method can also be used to query on conditions, though
            // FilteredBy() is obviously less expressive, powerful, and elegant than the full-fledged LINQ Query
            // Expression.

            var selectedLinks = from Link link in vissim.Net.Links
                                where  (int)link.AttValue["No"] > 10
                                select link;

            foreach (Link link in selectedLinks)
            {
                Console.WriteLine("LINQ selected link: {0}", link.AttValue["No"].ToString());
            }

            vissim.Graphics.AttValue["QuickMode"] = true;
            vissim.Simulation.RunContinuous();
            vissim.Exit();
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main()
        {
            var vissim = new VissimLib200.VissimClass();

            vissim.LoadNet(_networkFile);
            vissim.LoadLayout(_layoutFile);

            // We can use the expressive and powerful LINQ Query Expression on any Vissim COM interface that inherits Vissim
            // COM ICollectionBase interface, for example ILinkContainer. Actually, when Vissim COM types are imported from
            // the type library, the imported ICollectionBase interface is automatically translated as inheriting the IEnumerable
            // interface, because of the special flag [id(0xfffffffc)] specified to its _NewEnum method. This allows us to use
            // foreach loop and LINQ Query Expression on any Vissim COM interface object that in turn implements ICollectionBase
            // interface. Alternatively, we can also use IConnectionBase.FilteredBy method when appropriate, though FilteredBy is
            // less expressive and powerful than the full-fledged LINQ Query Expression, of course.
            var selectedLinks = from Link link in vissim.Net.Links
                                where  (int)link.AttValue["No"] > 10
                                select link;

            foreach (Link link in selectedLinks)
            {
                Console.WriteLine("LINQ selected link: {0}", link.AttValue["No"].ToString());
            }

            vissim.Graphics.AttValue["QuickMode"] = true;
            vissim.Simulation.RunContinuous();
            vissim.Exit();
            Console.ReadLine();
        }
Esempio n. 3
0
        static void Main()
        {
            var vissim = new VissimLib200.VissimClass();

            vissim.LoadNet(_networkFile);
            vissim.LoadLayout(_layoutFile);

            Console.WriteLine("Magic Happens Here! Vissim will disappear!");
            vissim.HideMainWindow();    // This will hide Vissim main window.

            vissim.Simulation.AttValue["SimBreakAt"] = 60;
            vissim.Simulation.RunContinuous();
            vissim.RestoreMainWindow(); // This will restore Vissim main window.

            Console.WriteLine("Magic Happens again! Vissim will show up!");

            vissim.Exit();
            Console.ReadLine();
        }