Exemplo n.º 1
0
        override public void RunConcurrentMas(ConcurrentEnvironment env)
        {
            string home = env.ContainerName;

            if (home == "")
            {
                Console.WriteLine("Container not activated.");
                return;
            }

            Console.WriteLine("This is " + home);

            switch (home)
            {
            case "Container1":
                var m = new MobileAgent();
                env.Add(m, "Container1.mobile");

                for (int i = 1; i <= 1; i++)
                {
                    var a = new StaticAgent();
                    env.Add(a, "Container1.a" + i);
                    a.Start();
                }

                m.Start();
                break;

            case "Container2":
                for (int i = 1; i <= 2; i++)
                {
                    var a = new StaticAgent();
                    env.Add(a, "Container2.b" + i);
                    a.Start();
                }
                break;

            case "Container3":
                for (int i = 1; i <= 3; i++)
                {
                    var a = new StaticAgent();
                    env.Add(a, "Container3.c" + i);
                    a.Start();
                }
                break;

            default:
                break;
            }

            env.WaitAll();
        }
Exemplo n.º 2
0
        public override void RunMas(EnvironmentMas env)
        {
            string home = env.ContainerName;

            if (home == "")
            {
                Console.WriteLine("Container not activated.");
                return;
            }

            Console.WriteLine($"This is {home}");

            switch (home)
            {
            case "Container1":
                var m = new MobileAgent();
                env.Add(m, "mobile-k1");

                for (int i = 1; i <= 1; i++)
                {
                    var a = new StaticAgent();
                    env.Add(a, $"a{i}-k1");
                }
                break;

            case "Container2":
                for (int i = 1; i <= 2; i++)
                {
                    var a = new StaticAgent();
                    env.Add(a, $"b{i}-k1");
                }
                break;

            case "Container3":
                for (int i = 1; i <= 3; i++)
                {
                    var a = new StaticAgent();
                    env.Add(a, $"c{i}-k3");
                }
                break;

            default:
                break;
            }

            env.Start();
        }