public EEPROMTool(EthCATDevice slave) { InitializeComponent(); if (slave == null) { memoryToolStripMenuItem.Enabled = false; Lbldevice.Text = "Offline mode"; } else { this.slave = (EthCATDevice)slave; Lbldevice.Text = slave.ToString(); writeToolStripMenuItem.Enabled = Properties.Settings.Default.EEPROMWriteEnable; } }
// Menu private void openInterfaceToolStripMenuItem_Click(object sender, EventArgs e) { List <Tuple <String, String, String> > interfaces = GetAvailableInterfaces(); var Input = new GenericInputBox <ComboBox>("Local Interface", "Interfaces", (o) => { foreach (Tuple <String, String, String> it in interfaces) { o.Items.Add(it.Item1); } o.Text = o.Items[0].ToString(); }, 1.7); DialogResult res = Input.ShowDialog(); if (res != DialogResult.OK) { return; } String userinput = Input.genericInput.Text; Cursor Memcurs = this.Cursor; this.Cursor = Cursors.WaitCursor; Trace.WriteLine("Openning interface " + userinput); Application.DoEvents(); foreach (Tuple <String, String, String> it in interfaces) { if (it.Item1 == userinput) { String PcapInterfaceName = "\\Device\\NPF_" + it.Item3; int NbSlaves = SoemInterrop.StartActivity(PcapInterfaceName, Properties.Settings.Default.DelayUpMs); if (NbSlaves > 0) { for (uint i = 0; i < NbSlaves; i++) { EthCATDevice slave = new EthCATDevice(i + 1); int img = SlaveStatetoIco(slave.State); TreeNode tn = new TreeNode(slave.ToString(), img, img); tn.Tag = slave; devicesTreeView.Nodes.Add(tn); } openInterfaceToolStripMenuItem.Enabled = false; if (tmrRefreshState.Interval >= 1000) { tmrRefreshState.Enabled = true; } SoemInterrop.Run(); tmrStart.Enabled = true; tmrInputFlow.Enabled = true; } else { Trace.WriteLine("No slave behind this Interface"); } } } this.Cursor = Memcurs; }
public ReadWritePDO(EthCATDevice slave) { this.slave = slave; InitializeComponent(); lbldevice.Text = slave.ToString(); // Get the dictionnary if exist List <PDODictionaryEntry> dico = PDODictionaryEntry.GetDictionary(Properties.Settings.Default.DatabaseFile, slave); // Fill the Treeview with it if (dico != null) { foreach (PDODictionaryEntry entry in dico) { string name = entry.ToString(); if (Properties.Settings.Default.ShowSDOIdx) { name = name + " (x" + entry.Index.ToString("X4") + ")"; } TreeNode tn = new TreeNode(name); tn.Tag = entry; tn.SelectedImageIndex = tn.ImageIndex = Type2ico(entry.type); dicoTree.Nodes.Add(tn); int ro = 0, rw = 0; if (entry.SubIdx != null) { foreach (PDODictionaryEntry entry2 in entry.SubIdx) { TreeNode tn2 = new TreeNode(entry2.ToString()); tn2.Tag = entry2; tn2.ToolTipText = entry2.type; tn2.SelectedImageIndex = tn2.ImageIndex = Type2ico(entry2.type); if (entry2.Access == PDOAccessLevel.ReadOnly) { tn2.ForeColor = Properties.Settings.Default.ReadOnlyAttributColor; ro++; } if (entry2.Access == PDOAccessLevel.ReadWrite) { tn2.ForeColor = Properties.Settings.Default.ReadWriteAttributColor; rw++; } tn.Nodes.Add(tn2); } } else { tn.ToolTipText = entry.type; } if ((ro != 0) && (rw == 0)) { tn.ForeColor = Properties.Settings.Default.ReadOnlyAttributColor; } if ((rw != 0) && (ro == 0)) { tn.ForeColor = Properties.Settings.Default.ReadOnlyAttributColor; } } } }