/// <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); }
/// <summary> /// search and load devices configure /// </summary> public void LoadAllDevices() { ArrayList devices = new ArrayList(); if (Directory.Exists(DataPath)) { var files = Directory.EnumerateFiles(DataPath, "*.xml"); foreach (var d in files) { Debug.Print(d.ToString()); DeviceConfig dev = new DeviceConfig(); dev.Load(d.ToString()); devices.Add(dev); } } Devices = (DeviceConfig[])devices.ToArray(typeof(DeviceConfig)); }