コード例 #1
0
ファイル: Program.cs プロジェクト: czogran/TSST
        /// <summary>
        /// Main
        /// </summary>
        /// <param name="args">Nieużywane</param>
        static void Main(string[] args)
        {
            Console.WriteLine(args[0]);

            string[] ips = ArgToIP(args[0]);
            Console.WriteLine(ips[0]);
            Console.WriteLine(ips[1]);

            Agent           agent           = new Agent(ips[0], 10000);
            Port            port            = new Port(ips[1], 10000);
            SwitchingMatrix switchingMatrix = new SwitchingMatrix();

            agent.Listen();
            Console.WriteLine(agent.receivedData);
            switchingMatrix.SetPortTable(agent.receivedData);
            switchingMatrix.PrintPortTable();
            agent.SendData("127.0.0.30", CLI.confirmation);

            //testy
            Thread thread1 = new Thread(new ThreadStart(port.Execute));
            Thread thread2 = new Thread(new ThreadStart(agent.Execute));

            thread1.Start();
            thread2.Start();
            thread1.Join();
            thread2.Join();
        }
コード例 #2
0
ファイル: Agent.cs プロジェクト: kirkosyn/MPLS-EON
        /// <summary>
        /// sluzy do przelaczania akcji w zaleznosci od otrzymanej wiadomosci
        ///docelowo powinna zostac wywalona do innej klasy, by to ladnie zrobic
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void SwitchAction(object sender, NotifyCollectionChangedEventArgs e)//(string message)
        {
            lock (SwitchingMatrix.agentCollection)
            {
                if (SwitchingMatrix.agentCollection.Last().Contains("node"))
                {
                    Console.WriteLine("  Zadanie dodania nowego polaczenia ");

                    XMLParser.AddConnection("myNode" + Program.number + ".xml", SwitchingMatrix.agentCollection.Last());

                    SwitchingMatrix.FillEonDictionary();
                }
                else if (SwitchingMatrix.agentCollection.Last().Contains("get_config"))
                {
                    Console.WriteLine("  Zadanie pobrania konfiguracji wezla ");
                    //jezeli w wiadomosci jest polecenie by dac konfiguracje wezla, wysyla do wiadomosci zawartosc swojego xml-a
                    Send(XMLParser.StringNode());
                }
                //gdy agent chce informacje co siedzi w danym porcie
                else if (SwitchingMatrix.agentCollection.Last().Contains("get_matrix"))
                {
                    int start  = SwitchingMatrix.agentCollection.Last().IndexOf("<get_matrix>");
                    int end    = SwitchingMatrix.agentCollection.Last().IndexOf("</get_matrix>");
                    int matrix = Int32.Parse(SwitchingMatrix.agentCollection.Last().Substring(start + 12, end - start - 12));

                    Console.WriteLine("  Zadanie pobrania portu: " + matrix);

                    Send(XMLParser.StringMatrix(matrix));
                }
                else if (SwitchingMatrix.agentCollection.Last().Contains("ping"))
                {
                }
                else if (SwitchingMatrix.agentCollection.Last().Contains("remove:"))
                {
                    int numer = Int32.Parse(SwitchingMatrix.agentCollection.Last().Substring(7));
                    Console.WriteLine("Zadanie usuniecia polaczenia: " + numer);

                    SwitchingMatrix.RemoveEonDictionary(numer);

                    XMLParser.RemoveConnection("myNode" + Program.number + ".xml", numer);
                }
                else
                {
                    Send(SwitchingMatrix.agentCollection.Last());
                }
            }
        }