Exemplo n.º 1
0
        public static UnitTypeHelperV2 CreateInstance()
        {
            //if (helper == null)
            //{
            _unitType = new List <UnitMainType>();
            helper    = new UnitTypeHelperV2();

            UnitMainType unitType = null;

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(_xmlPath);
            XmlNodeList unitNodeList = xmlDoc.SelectNodes("units/unit");

            if (unitNodeList != null)
            {
                foreach (XmlNode unitItem in unitNodeList)
                {
                    unitType       = new UnitMainType();
                    unitType.Name  = unitItem.Attributes["name"].Value;
                    unitType.Title = unitItem.Attributes["title"].Value;
                    unitType.Id    = byte.Parse(unitItem.Attributes["id"].Value);

                    UnitSubType subType     = null;
                    XmlNodeList subNodeList = unitItem.SelectNodes("subType/item");
                    foreach (XmlNode subTypeItem in subNodeList)
                    {
                        subType       = new UnitSubType();
                        subType.Name  = subTypeItem.Attributes["name"].Value;
                        subType.Title = subTypeItem.Attributes["title"].Value;
                        subType.Id    = byte.Parse(subTypeItem.Attributes["id"].Value);

                        subType.UnitSizeH = int.Parse(subTypeItem.Attributes["modalXCount"].Value);
                        subType.UnitSizeV = int.Parse(subTypeItem.Attributes["modalYCount"].Value);

                        subType.BoardPixelH = int.Parse(subTypeItem.Attributes["modalXPixelCount"].Value);
                        subType.BoardPixelV = int.Parse(subTypeItem.Attributes["modalYPixelCount"].Value);

                        if (subTypeItem.Attributes["mCount"] != null)
                        {
                            subType.ConnectModuleCount = int.Parse(subTypeItem.Attributes["mCount"].Value);
                        }

                        unitType.SubType.Add(subType);
                    }
                    if (unitType.SubType.Count > 0)
                    {
                        _unitType.Add(unitType);
                    }
                    //}
                }
            }

            return(helper);
        }
Exemplo n.º 2
0
        public UnitMainType GetMainType(string serial, string mainName)
        {
            UnitMainType resultType = null;

            if (_unitType != null)
            {
                foreach (UnitMainType item in _unitType)
                {
                    if (item.Name == mainName && item.Serial == serial)
                    {
                        resultType = item;
                        break;
                    }
                }
            }
            return(resultType);
        }