예제 #1
0
        public Device FindDevice(string name, int id)
        {
            return(Devices.Find((Device device) =>
            {
                if (device.Name == name && device.Id == id)
                {
                    return true;
                }
                else if (device is RailSwitch)
                {
                    RailSwitch rs = device as RailSwitch;
                    return rs.section.Name == name && rs.section.Id == id;
                }

                return false;
            }));
        }
예제 #2
0
        /// <summary>
        /// 按类型读取设备配置
        /// </summary>
        /// <param name="doc">xml doc</param>
        /// <param name="deviceType">设备类型</param>
        private void LoadDevices(XmlDocument doc, Type deviceType)
        {
            var devieNodes = doc.SelectNodes("StationElements/" + deviceType.Name);

            foreach (XmlElement item in devieNodes)
            {
                Device device = (Device)Activator.CreateInstance(deviceType);
                device.LoadData(item);
                Devices.Add(device);

                if (device is RailSwitch)
                {
                    RailSwitch rs = device as RailSwitch;
                    if (!Devices.Contains(rs.section))
                    {
                        Devices.Add(rs.section);
                    }
                }
            }
        }
예제 #3
0
 public RouteSwitch(RailSwitch rSwitch, RailSwitch.SwitchPosition position)
 {
     RSwitch  = rSwitch;
     Position = position;
 }