/// <summary> /// load all devices in data folder /// </summary> /// <returns></returns> public bool Load() { try { DeviceConfig config = new DeviceConfig(); config.Load("Temp.xml"); config.Commands = new DeviceCommandsGroup(); config.Commands.Name = "Init"; config.Commands.Description = "Initial device"; config.Commands.Commands = new DeviceCommand[1]; DeviceCommand cmd = new DeviceCommand(); config.Commands.Commands[0] = cmd; config.Commands.Commands[0].Name = "test"; config.Commands.Commands[0].Description = "test des"; cmd.Data = new byte[] { 22, 33 }; cmd.ReadDataLength = 2; config.Save("test.xml"); //DeviceConfig.SaveAsTemp(); } catch (Exception e) { Debug.Print("Fail to load configure file."); } return false; }
/// <summary> /// load all devices in data folder /// </summary> /// <returns></returns> public bool Load() { try { DeviceConfig config = new DeviceConfig(); config.Load("Temp.xml"); config.Commands = new DeviceCommandsGroup(); config.Commands.Name = "Init"; config.Commands.Description = "Initial device"; config.Commands.Commands = new DeviceCommand[1]; DeviceCommand cmd = new DeviceCommand(); config.Commands.Commands[0] = cmd; config.Commands.Commands[0].Name = "test"; config.Commands.Commands[0].Description = "test des"; cmd.Data = new byte[] { 22, 33 }; cmd.ReadDataLength = 2; config.Save("test.xml"); //DeviceConfig.SaveAsTemp(); } catch (Exception e) { Debug.Print("Fail to load configure file."); } return(false); }
private void tvCommands_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode nd = tvCommands.SelectedNode; if (nd != null) { if (nd.Tag is DeviceCommand) { DeviceCommand cmd = (DeviceCommand)nd.Tag; lbCommandDes.Text = cmd.Description; } else if (nd.Tag is DeviceGUICommand) { DeviceGUICommand cmd = (DeviceGUICommand)nd.Tag; lbCommandDes.Text = cmd.Description + "\r\n" + cmd.GUIPath; } } }
private void tvCommands_DoubleClick(object sender, EventArgs e) { TreeNode nd = tvCommands.SelectedNode; if (nd != null) { if (nd.Tag is DeviceCommand) { DeviceCommand cmd = (DeviceCommand)nd.Tag; txtQuickSend.Text = cmd.GetSendDataString(GetFormat() == emViewFormat.Hex); chkWrite.Checked = cmd.Write; chkRead.Checked = cmd.ReadDataLength > 0; numReadLength.Value = cmd.ReadDataLength; Send(); } else if (nd.Tag is DeviceGUICommand) { string path = ""; try { DeviceGUICommand cmd = (DeviceGUICommand)nd.Tag; path = System.IO.Directory.GetParent(Application.ExecutablePath) + "\\" + cmd.GUIPath; Assembly guiLib = Assembly.LoadFile(path); //Type t = guiLib.GetType("I2CDIO8.MyGUI"); Type t = guiLib.GetType(cmd.TypeName); GuiInterface gui = (GuiInterface)Activator.CreateInstance(t); CommObj obj = new CommObj(this); gui.Show(obj); } catch { MessageBox.Show("Fail to load GUI " + path); } } } }