Esempio n. 1
0
 // Menu Item
 private void sendListIdentityDiscoverToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (client == null)
     {
         return;
     }
     client.DiscoverServers();
 }
Esempio n. 2
0
        public static void TestDiscover()
        {
            // Attach the default network interface
            EnIPClient client = new EnIPClient("");

            // Device arrival listener
            client.DeviceArrival += new DeviceArrivalHandler(client_DeviceArrival);
            // Send a broadcast discovery message
            client.DiscoverServers();
        }
Esempio n. 3
0
        // Menu Item
        private void openInterfaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (client == null)
            {
                var Input =
                    new GenericInputBoxExtended <ComboBox>("Local Interface", "IP address",
                                                           (o) =>
                {
                    string[] local_endpoints = GetAvailableIps();
                    o.Items.AddRange(local_endpoints);
                    o.Text = Properties.Settings.Default.DefaultIPInterface;
                });

                DialogResult res = Input.ShowDialog();

                if (res != DialogResult.OK)
                {
                    return;
                }
                String userinput = Input.genericInput.Text;
                Properties.Settings.Default.DefaultIPInterface = userinput;

                try
                {
                    client = new EnIPClient(userinput, Properties.Settings.Default.TCP_LAN_Timeout);
                    client.DeviceArrival += new DeviceArrivalHandler(On_DeviceArrival);

                    client.DiscoverServers();

                    openInterfaceToolStripMenuItem.Enabled = false;
                }
                catch
                {
                    MessageBox.Show("Local address unavailable", "Error in Open Interface", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                devicesTreeView.SelectedNode = null;
                devicesTreeView.CollapseAll();
            }
        }