コード例 #1
0
 /// <summary>
 /// 加载xml文件的方法
 /// </summary>
 /// <param name="xmlNode">xml文档中的单个节点</param>
 public override void LoadXml(XmlNode xmlNode)
 {
     m_productID    = xmlNode.Attributes[CShareLib.XML_PRODUCTID].InnerText;
     m_productName  = xmlNode.Attributes[CShareLib.XML_PRODUCTNAME].InnerText;
     m_productState = xmlNode.Attributes[CShareLib.XML_PRODUCT_STATE].InnerText;
     m_ip           = xmlNode.Attributes[CShareLib.XML_PRODUCT_IP].InnerText;
     m_port         = xmlNode.Attributes[CShareLib.XML_PRODUCT_PORT].InnerText;
     m_cProductLine = CDeviceDataFactory.Instance.ProjectConsole.ProductLine;
     ///遍历所有子节点,加载所属子子系统的数据
     foreach (XmlNode node in xmlNode.ChildNodes)
     {
         string   type   = node.Attributes[CShareLib.XML_DEVICE_TYPE].InnerText;
         ZCDevice device = CreateZCDevice(type);
         if (device != null)
         {
             device.LoadXml(node);
             m_cBelongsDevice.Add(device);
             LogManager.InfoLog.LogConfigurationInfo("线路数据", "ZC产品设备数据", "完成加载ZC设备" + this.ProductID + "的子子系统:" + device.DeviceName + "数据");
         }
         else
         {
             throw new MyException("非法设备类型:" + type);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// ZC设备工厂
        /// </summary>
        /// <param name="type"></param>
        /// <returns>返回设备实例</returns>
        private ZCDevice CreateZCDevice(string type)
        {
            ZCDevice device;

            switch (type)
            {
            case "PU13":
                device = new ZCPU13Device(this);
                break;

            case "PU24":
                device = new ZCPU24Device(this);
                break;

            case "CC":
                device = new CcDevice(this);
                break;

            case "COM":
                device = new CommDevice(this);
                break;

            default:
                device = new ZCDevice(this);
                break;
            }
            return(device);
        }