Пример #1
0
        public void testDeleteEONRow()
        {
            short frequency = 2;
            short band      = 3;

            //stworzenie nowej tabeli
            EONTable table = new EONTable();

            //stworzenie nowych rzedow
            EONTableRowIN  rowIn  = new EONTableRowIN(frequency, band);
            EONTableRowOut rowOut = new EONTableRowOut(frequency, band);

            //Dodanie rzedow
            table.addRow(rowIn);
            table.addRow(rowOut);

            //usuniecie rzedow
            table.deleteRow(rowIn);
            table.deleteRow(rowOut);

            Assert.IsTrue(table.CheckAvailability(rowIn));
            Assert.IsTrue(table.CheckAvailability(rowOut));

            //Kazdy wpis w tabeli po wyczyszczeniu powinien byc rowny -1
            foreach (short f in table.InFrequencies)
            {
                Assert.AreEqual(-1, f);
            }

            //Nie powinno byc rzedu w tablicy
            Assert.IsFalse(table.TableIN.Contains(rowIn));

            //Kazdy wpis w tabeli po wyczyszczeniu powinien byc rowny -1
            foreach (short f in table.OutFrequencies)
            {
                Assert.AreEqual(-1, f);
            }

            //Nie powinno byc rzedu w tablicy
            Assert.IsFalse(table.TableOut.Contains(rowOut));
        }
Пример #2
0
        public void fillingTable(string line, Socket socketsending, string key)
        {
            //Znaki oddzielające poszczególne części żądania klienta.
            char[] delimiterChars = { '#' };
            //Podzielenie żądania na tablicę stringów.
            string[] words;


            words = line.Split(delimiterChars);
            switch (words[0])
            {
            case "ADD":
                switch (Int32.Parse(words[1]))
                {
                //Dodawanie wpisu do BorderComutationTable
                case 1:
                    BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow(
                        words[2], Convert.ToInt16(words[3]), Convert.ToInt16(words[4]), Convert.ToInt16(words[5]), Convert.ToInt16(words[6]),
                        Convert.ToInt16(words[7]), words[8], Convert.ToInt16(words[9]), Convert.ToInt16(words[10]));
                    borderNodeCommutationTable.Table.Add(newRow);
                    stateReceivedMessageFromNMS("BorderNodeCommutationTable", "ADD");
                    break;

                //Dodanie wpisu do EONTable
                case 2:
                    EONTableRowIN  eonIN      = new EONTableRowIN(Convert.ToInt16(words[2]), Convert.ToInt16(words[3]));
                    EONTableRowOut eonOut     = new EONTableRowOut(Convert.ToInt16(words[4]), Convert.ToInt16(words[5]));
                    bool           eoninbool  = eonTable.addRow(eonIN);
                    bool           eonoutbool = eonTable.addRow(eonOut);
                    if (eoninbool == false || eonoutbool == false)
                    {
                        sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), "ERROR", socketsending);
                    }
                    else
                    {
                        stateReceivedMessageFromNMS("EONTable", "ADD");
                    }

                    break;

                //Dodanie wpisu do CommutationTable
                case 3:
                    CommutationTableRow commuteRow = new CommutationTableRow(Convert.ToInt16(words[2]),
                                                                             Convert.ToInt16(words[3]), Convert.ToInt16(words[4]), Convert.ToInt16(words[5]));
                    commutationTable.Table.Add(commuteRow);

                    stateReceivedMessageFromNMS("CommutationTable", "ADD");
                    break;

                default:
                    break;
                }
                break;

            case "DELETE":
                switch (Int32.Parse(words[1]))
                {
                //Dodawanie wpisu do BorderComutationTable
                case 1:
                    BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow();
                    newRow = borderNodeCommutationTable.FindRow(words[2], Convert.ToInt16(words[3]), words[4]);
                    borderNodeCommutationTable.Table.Remove(newRow);
                    stateReceivedMessageFromNMS("BorderNodeCommutationTable", "DELETE");
                    break;

                //Dodanie wpisu do EONTable
                case 2:
                    EONTableRowIN  eonIN      = new EONTableRowIN(Convert.ToInt16(words[2]), Convert.ToInt16(words[3]));
                    EONTableRowOut eonOut     = new EONTableRowOut(Convert.ToInt16(words[4]), Convert.ToInt16(words[5]));
                    bool           eoninbool  = eonTable.deleteRow(eonIN);
                    bool           eonoutbool = eonTable.deleteRow(eonOut);

                    if (eoninbool == false || eonoutbool == false)
                    {
                        sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), "ERROR", socketsending);
                    }
                    else
                    {
                        stateReceivedMessageFromNMS("EONTable", "DELETE");
                    }

                    break;

                //Dodanie wpisu do CommutationTable
                case 3:
                    CommutationTableRow rowToDelete = new CommutationTableRow();
                    rowToDelete = commutationTable.FindRow(Convert.ToInt16(words[2]), Convert.ToInt16(words[3]));
                    commutationTable.Table.Remove(rowToDelete);
                    stateReceivedMessageFromNMS("CommutationTable", "DELETE");
                    break;

                default:
                    break;
                }
                break;

            case "TOPOLOGY":
                switch (Int32.Parse(words[1]))
                {
                case 1:
                    //Dodawanie wpisu do BorderComutationTable
                    for (int i = 0; i < borderNodeCommutationTable.Table.Count; i++)
                    {
                        byte[] table_in_bytes = null;
                        string builder        = string.Empty;
                        string port_in        = string.Empty;
                        string port_out       = string.Empty;
                        string Hops           = string.Empty;
                        string command        = string.Empty;
                        string band_out       = string.Empty;
                        string destination_IP = string.Empty;
                        string Modulation     = string.Empty;
                        string BitRate        = string.Empty;
                        string IP_IN          = string.Empty;
                        string Frequency_out  = string.Empty;
                        command        = "TOPOLOGY";
                        IP_IN          = borderNodeCommutationTable.Table[i].IP_IN.ToString();
                        port_in        = borderNodeCommutationTable.Table[i].port_in.ToString();
                        band_out       = borderNodeCommutationTable.Table[i].band.ToString();
                        Frequency_out  = borderNodeCommutationTable.Table[i].frequency.ToString();
                        Modulation     = borderNodeCommutationTable.Table[i].modulationPerformance.ToString();
                        BitRate        = borderNodeCommutationTable.Table[i].bitRate.ToString();
                        destination_IP = borderNodeCommutationTable.Table[i].IP_Destination.ToString();
                        port_out       = borderNodeCommutationTable.Table[i].Port.ToString();
                        Hops           = borderNodeCommutationTable.Table[i].hopsNumber.ToString();

                        builder = command + "#" + "1" + "#" + IP_IN + "#" + port_in + "#" + band_out + "#" + Frequency_out + "#" +
                                  Modulation + "#" + BitRate + "#" + destination_IP + "#" + port_out + "#" + Hops;

                        sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), builder, socketsending);
                    }
                    break;

                //Dodanie wpisu do EONTable
                case 2:
                    for (int i = 0; i < eonTable.TableIN.Count; i++)
                    {
                        byte[] table_in_bytes = null;
                        string builder        = string.Empty;
                        ;
                        string command       = string.Empty;
                        string band_in       = string.Empty;
                        string frequency_out = string.Empty;
                        string band_out      = string.Empty;
                        string frequency_in  = string.Empty;
                        command = "TOPOLOGY";

                        frequency_in  = eonTable.TableIN[i].busyFrequency.ToString();
                        band_in       = eonTable.TableIN[i].busyBandIN.ToString();
                        frequency_out = eonTable.TableOut[i].busyFrequency.ToString();
                        band_out      = eonTable.TableOut[i].busyBandOUT.ToString();


                        builder = command + "#" + "2" + "#" + frequency_in + "#" + band_in + "#" + frequency_out + "#" + band_out;
                        sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), builder, socketsending);
                    }

                    break;

                //Dodanie wpisu do CommutationTable
                case 3:
                    for (int i = 0; i < commutationTable.Table.Count; i++)
                    {
                        byte[] table_in_bytes = null;
                        string command        = string.Empty;
                        string builder        = string.Empty;
                        string port_in        = string.Empty;
                        string port_out       = string.Empty;
                        string Frequency_in   = string.Empty;
                        string frequency_out  = string.Empty;
                        command = "TOPOLOGY";
                        port_in = commutationTable.Table[i].port_in.ToString();

                        frequency_out = commutationTable.Table[i].frequency_out.ToString();
                        Frequency_in  = commutationTable.Table[i].frequency_in.ToString();
                        port_out      = commutationTable.Table[i].port_out.ToString();


                        builder = command + "#" + "3" + "#" + Frequency_in + "#" + port_in + "#" + frequency_out + "#" + port_out;

                        sendingMessageCommunication(OperationConfiguration.getSetting(key, mySettings), builder, socketsending);
                    }



                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }



            // Console.ReadKey();
        }
Пример #3
0
        public void fillingTable(string line)
        {
            //Znaki oddzielające poszczególne części żądania klienta.
            char[] delimiterChars = { '#' };
            //Podzielenie żądania na tablicę stringów.
            string[] words;


            words = line.Split(delimiterChars);
            switch (words[0])
            {
            case "ADD":
                switch (Int32.Parse(words[1]))
                {
                //Dodawanie wpisu do BorderComutationTable
                case 1:
                    BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow(
                        words[2], Convert.ToInt16(words[3]), Convert.ToInt16(words[4]), Convert.ToInt16(words[5]), Convert.ToInt16(words[6]),
                        Convert.ToInt16(words[7]), words[8], Convert.ToInt16(words[9]), Convert.ToInt16(words[10]));
                    borderNodeCommutationTable.Table.Add(newRow);
                    stateReceivedMessageFromNMS("BorderNodeCommutationTable", "ADD");
                    break;

                //Dodanie wpisu do EONTable
                case 2:
                    EONTableRowIN  eonIN  = new EONTableRowIN(Convert.ToInt16(words[2]), Convert.ToInt16(words[3]));
                    EONTableRowOut eonOut = new EONTableRowOut(Convert.ToInt16(words[4]), Convert.ToInt16(words[5]));
                    eonTable.addRow(eonIN);
                    eonTable.addRow(eonOut);
                    stateReceivedMessageFromNMS("EONTable", "ADD");
                    break;

                //Dodanie wpisu do CommutationTable
                case 3:
                    CommutationTableRow commuteRow = new CommutationTableRow(Convert.ToInt16(words[2]),
                                                                             Convert.ToInt16(words[3]), Convert.ToInt16(words[4]), Convert.ToInt16(words[5]));
                    commutationTable.Table.Add(commuteRow);
                    stateReceivedMessageFromNMS("CommutationTable", "ADD");
                    break;

                default:
                    break;
                }
                break;

            case "DELETE":
                switch (Int32.Parse(words[1]))
                {
                //Dodawanie wpisu do BorderComutationTable
                case 1:
                    BorderNodeCommutationTableRow newRow = new BorderNodeCommutationTableRow();
                    newRow = borderNodeCommutationTable.FindRow(words[2], Convert.ToInt16(words[3]), words[4]);
                    borderNodeCommutationTable.Table.Remove(newRow);
                    stateReceivedMessageFromNMS("BorderNodeCommutationTable", "DELETE");
                    break;

                //Dodanie wpisu do EONTable
                case 2:
                    EONTableRowIN  eonIN  = new EONTableRowIN(Convert.ToInt16(words[2]), Convert.ToInt16(words[3]));
                    EONTableRowOut eonOut = new EONTableRowOut(Convert.ToInt16(words[4]), Convert.ToInt16(words[5]));
                    eonTable.deleteRow(eonIN);
                    eonTable.deleteRow(eonOut);
                    stateReceivedMessageFromNMS("EONTable", "DELETE");
                    break;

                //Dodanie wpisu do CommutationTable
                case 3:
                    CommutationTableRow rowToDelete = new CommutationTableRow();
                    rowToDelete = commutationTable.FindRow(Convert.ToInt16(words[2]), Convert.ToInt16(words[3]));
                    commutationTable.Table.Remove(rowToDelete);
                    stateReceivedMessageFromNMS("CommutationTable", "DELETE");
                    break;

                default:
                    break;
                }
                break;

            default:
                break;
            }



            // Console.ReadKey();
        }