Exemplo n.º 1
0
        private Boolean CreateControl(String[] tab)
        {
            String       id = "";
            String       linkA = "";
            String       linkB = "";
            String       f1I = "";
            String       f2I = "";
            String       f1O = "";
            String       f2O = "";
            ModelControl control = null;
            String       snnpA = "", snnpB = "";

            linkA = tab[1];
            linkB = tab[2];
            f1I   = tab[3];
            f2I   = tab[4];
            f1O   = tab[5];
            f2O   = tab[6];
            id    = tab[7];

            snnpA   = zasoby.GetSnnpId(linkA);
            snnpB   = zasoby.GetSnnpId(linkB);
            control = new ModelControl(id, snnpA, snnpB, f1I, f2I, f1O, f2O);

            if (CheckParameters(control))
            {
                communicationT.Send_Text(ProtokolControl.CONN_R + " " + id, Network.outputControl);

                Connect(control);
                ControlList.Add(control);

                return(true);
            }
            else
            {
                communicationT.Send_Text(ProtokolControl.CONN_F + " " + id, Network.outputControl);
                return(false);
            }
        }
Exemplo n.º 2
0
        private Boolean Loguj() //petla ponownie oczekuje na confirmation, nie wysyla
        {                       // jeszcze raz logina
            String  message = "";
            Boolean x, y;

            x = false;
            y = false;
            int i = 0;

            message = Protokol.LOGIN + " " + Convert.ToString(Network.idW);
            communicationT.Send_Text(message, Network.outputControl);

            while (!x)
            {
                Thread.Sleep(1000);

                if (command[0] == Protokol.CONF)
                {
                    Console.WriteLine("Logowanie, sukces.");
                    x          = true; //przerywa petle
                    command[0] = null;
                    y          = true;
                    return(y);  //konczy obsluge
                }
                else if ((x == false) && (i < 5))
                {
                    Console.WriteLine("Błąd logowania, ponawiam próbę: " + Convert.ToString(i + 1));
                    i++;
                }
                else
                {
                    Console.WriteLine("Błąd logowania. Kończę nasłuchiwać.");
                    y = false;
                    return(y);
                }
            }
            return(y);
        }
Exemplo n.º 3
0
        private Boolean Loguj(Boolean service) //petla ponownie oczekuje na confirmation, nie wysyla
        {                                      // jeszcze raz logina
            String  message = "";
            Boolean x, y;

            x = false;
            y = false;
            int i = 0;


            if (!service)
            {
                message = Protokol.LOGIN + " " + Convert.ToString(Network.idW);
                communicationT.Send_Text(message, Network.outputControl);
            }
            else if (service)
            {
                message = (Protokol.LOGIN + " " + Convert.ToString(Network.idW) + " n");
                communicationT.Send_Text(message, Network.outputCloud);
            }

            //System.Timers.Timer timer_Log = new System.Timers.Timer();
            //timer_Log.Elapsed =
            //timer_Log.Interval = 2000;
            //timer_Log.Enabled = true;

            while (!x)
            {
                Thread.Sleep(1000);

                if (command[0] == Protokol.CONF)
                {
                    Console.WriteLine("Logowanie, sukces.");
                    x          = true;
                    command[0] = null;
                    y          = true;
                    return(y);
                }
                else if ((x == false) && (i < 5))
                {
                    Console.WriteLine("Błąd logowania, ponawiam próbę: " + Convert.ToString(i + 1));
                    i++;
                }
                else
                {
                    Console.WriteLine("Błąd logowania. Kończę nasłuchiwać.");
                    y = false;
                    return(y);
                }
            }
            return(y);
        }