Ejemplo n.º 1
0
        //Connecter
        private void button2_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(IpBox.Text))
            {
                hostname = IpBox.Text.ToString();
            }
            if (!String.IsNullOrEmpty(PortBox.Text))
            {
                port = Convert.ToInt32(PortBox.Text);
            }
            if (!String.IsNullOrEmpty(PassBox.Text))
            {
                password = Convert.ToString(PassBox.ToString());
            }
            if (checkBox1.Checked && firspass)
            {
                param.UsePasswordAuthentication(password); firspass = false;
            }


            bool retry = true;

            while (retry)
            {
                try
                {
                    ConnectToIED.Connect(hostname, port);
                    Disconnect_button.Enabled = true;
                    Connect_button.Enabled    = false;
                    Exit_button.Enabled       = false;
                    CreateButton.Enabled      = true;
                    Get_reports.Enabled       = true;
                    IpBox.Clear();
                    PortBox.Clear();
                    PassBox.Clear();
                    retry           = false;
                    toolStatus.Text = "Connected";
                    IEDConnected    = true;
                    int i = 1;
                    for (i = 1; i < 65; i++)
                    {
                        refer.Add("GEDeviceF650/vinGGIO1.SPCSO" + i.ToString() + "");
                        control.Add(ConnectToIED.CreateControlObject(refer[i - 1]));
                    }
                }
                catch (IedConnectionException ex)
                {
                    IEDConnected    = false;
                    toolStatus.Text = "Failed to connect";
                    if (MessageBox.Show(ex.Message + "for the following reason" + ex.GetIedClientError(), "Erreur", MessageBoxButtons.RetryCancel) == DialogResult.Cancel)
                    {
                        retry = false;
                    }
                    else
                    {
                        retry = true;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public Client(string hostname, int port, string apTitleR, int aeQualifierR, uint pSelectorR, byte[] sSelectorR, byte[] tSelectorR,
                      string apTitleL, int aeQualifierL, uint pSelectorL, byte[] sSelectorL, byte[] tSelectorL, bool enabled, string password)
        {
            try
            {
                _hostname = hostname;
                _port     = port;

                _parameters = _connection.GetConnectionParameters();
                if (!string.IsNullOrEmpty(apTitleR) && !string.IsNullOrEmpty(aeQualifierR.ToString()))
                {
                    _parameters.SetRemoteApTitle(apTitleR, aeQualifierR);
                }
                if (!string.IsNullOrEmpty(pSelectorR.ToString()) && sSelectorR != null && tSelectorR != null)
                {
                    _parameters.SetRemoteAddresses(pSelectorR, sSelectorR, tSelectorR);
                }
                if (!string.IsNullOrEmpty(apTitleL) && !string.IsNullOrEmpty(aeQualifierL.ToString()))
                {
                    _parameters.SetLocalApTitle(apTitleL, aeQualifierL);
                }
                if (!string.IsNullOrEmpty(pSelectorL.ToString()) && sSelectorL != null && tSelectorL != null)
                {
                    _parameters.SetLocalAddresses(pSelectorL, sSelectorL, tSelectorL);
                }
                if (enabled && !string.IsNullOrEmpty(password))
                {
                    _parameters.UsePasswordAuthentication(password);
                }
            }
            catch (Exception e)
            {
                Log.Write(e, Log.Code.ERROR);
            }
        }
Ejemplo n.º 3
0
        public static void Main(string[] args)
        {
            IedConnection con = new IedConnection();

            string hostname;

            if (args.Length > 0)
            {
                hostname = args[0];
            }
            else
            {
                hostname = "localhost";
            }

            Console.WriteLine("Connect to " + hostname);


            try
            {
                IsoConnectionParameters parameters = con.GetConnectionParameters();

                parameters.UsePasswordAuthentication("top secret");

                con.Connect(hostname, 102);

                List <string> serverDirectory = con.GetServerDirectory(false);

                foreach (string entry in serverDirectory)
                {
                    Console.WriteLine("LD: " + entry);
                }

                con.Release();
            }
            catch (IedConnectionException e)
            {
                Console.WriteLine(e.Message);
            }


            // release all resources - do NOT use the object after this call!!
            con.Dispose();
        }