XmlConfig.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. using Aitex.Common.Util;
  2. using Aitex.Core.RT.SCCore;
  3. using MECF.Framework.Common.Equipment;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Xml.Linq;
  11. namespace EFEM.RT.Systems
  12. {
  13. public static class XmlConfig
  14. {
  15. public static Dictionary<ModuleName, string> LoadRobotTeachStation()
  16. {
  17. var path = PathManager.GetCfgDir() + $"{SC.GetStringValue("System.DeviceType")}\\" + "RobotTeachStation.xml";
  18. if (!File.Exists(path))
  19. return null;
  20. var teachStation = new Dictionary<ModuleName, string>();
  21. var doc = XDocument.Load(path);
  22. if (doc == null)
  23. return null;
  24. var items = doc.Root.Elements();
  25. if (items == null)
  26. return null;
  27. items.ToList().ForEach(x => teachStation.Add(ModuleHelper.Converter(x.Attribute("Module").Value), x.Attribute("Station").Value));
  28. return teachStation;
  29. }
  30. public static Dictionary<ModuleName, string> LoadRobotSlotToSlot()
  31. {
  32. var path = PathManager.GetCfgDir() + $"{SC.GetStringValue("System.DeviceType")}\\" + "RobotTeachStation.xml";
  33. if (!File.Exists(path))
  34. return null;
  35. var slot2Slot = new Dictionary<ModuleName, string>();
  36. var doc = XDocument.Load(path);
  37. if (doc == null)
  38. return null;
  39. var items = doc.Root.Elements();
  40. if (items == null)
  41. return null;
  42. items.ToList().ForEach(x => slot2Slot.Add(ModuleHelper.Converter(x.Attribute("Module").Value), x.Attribute("Slot2Slot").Value));
  43. return slot2Slot;
  44. }
  45. public static Dictionary<ModuleName, string> LoadMotionAxisTeachStation()
  46. {
  47. var path = PathManager.GetCfgDir() + $"{SC.GetStringValue("System.DeviceType")}\\" + "RobotTeachStation.xml";
  48. if (!File.Exists(path))
  49. return null;
  50. var teachStation = new Dictionary<ModuleName, string>();
  51. var doc = XDocument.Load(path);
  52. if (doc == null)
  53. return null;
  54. var items = doc.Root.Elements();
  55. if (items == null)
  56. return null;
  57. items.ToList().ForEach(x => teachStation.Add(ModuleHelper.Converter(x.Attribute("Module").Value), x.Attribute("MotionAxisStation").Value));
  58. return teachStation;
  59. }
  60. }
  61. }