private Device FindDevice(string nameId, StationElements allDevice) { if (nameId.Contains('(')) { int start = nameId.IndexOf('(') + 1; int length = nameId.IndexOf(')') - start; nameId = nameId.Substring(start, length); } string[] subs = nameId.Split('_'); if (subs.Length > 1) { return(allDevice.FindDevice(subs[subs.Length - 2], int.Parse(subs[subs.Length - 1]))); } return(null); }
private void LoadSwitch(XmlElement element, StationElements allDevices) { string strSwitch = element.GetAttribute("InSwitches").TrimEnd(); string strPosition = element.GetAttribute("Positions").TrimEnd(); if (!string.IsNullOrEmpty(strSwitch)) { string[] names = strSwitch.Split(' '); string[] positions = strPosition.Split(' '); for (int i = 0; i < names.Length; i++) { Switches.Add(new RouteSwitch( FindDevice(names[i], allDevices) as RailSwitch, (RailSwitch.SwitchPosition)Enum.Parse(typeof(RailSwitch.SwitchPosition), positions[i]))); } } }
public void LoadData(XmlElement element, StationElements allDevices) { Id = int.Parse(element.GetAttribute("ID")); Start = FindDevice(element.GetAttribute("Start"), allDevices) as Signal; End = FindDevice(element.GetAttribute("End"), allDevices) as Signal; Color = (Signal.SignalColor)Enum.Parse(typeof(Signal.SignalColor), element.GetAttribute("Color").Replace("Signal", "")); Direction = element.GetAttribute("Direction") == "DIRUP" ? Section.DefaultDirection.Upward : Section.DefaultDirection.Downward; LoadOccupyDevice("Incoming", Incoming, element, allDevices); LoadOccupyDevice("In", In, element, allDevices); LoadOccupyDevice("Leaving", Leaving, element, allDevices); LoadSwitch(element, allDevices); LoadPSDoor(element, "IncomingDoors", ApprochingPSDoors, allDevices); LoadPSDoor(element, "InDoors", InDoors, allDevices); LoadRelay(element, "Relays", Relays, allDevices); }
private void LoadOccupyDevice(string attributeName, List <IOccupy> devices, XmlElement element, StationElements allDevices) { string strTemp = element.GetAttribute(attributeName).TrimEnd(); if (!string.IsNullOrEmpty(strTemp)) { string[] strDevices = strTemp.Split(' '); foreach (var item in strDevices) { IOccupy device = FindDevice(item, allDevices) as IOccupy; devices.Add(FindDevice(item, allDevices) as IOccupy); } } }
private void LoadPSDoor(XmlElement element, string attributeName, List <PSDoor> devices, StationElements allDevices) { string strTemp = element.GetAttribute(attributeName).TrimEnd(); if (!string.IsNullOrEmpty(strTemp)) { string[] strDevices = strTemp.Split(' '); foreach (var item in strDevices) { devices.Add(FindDevice(item, allDevices) as PSDoor); } } }