Пример #1
0
 /// <summary>
 /// 通过childname的限制信息验证value。
 /// 与public bool SetParentPath(string xpath)配合使用xpath到childname的父节点
 /// </summary>
 /// <param name="value"></param>
 /// <param name="childname"></param>
 /// <returns></returns>
 public bool Validate(string value, string childname)
 {
     foreach (var n in root.Children())
     {
         if (n.Name == childname)
         {
             return(ValidateValue(value, n.Children()));
         }
     }
     TraceMethod.Record(TraceMethod.TraceKind.WARNING,
                        $"Get no restriction info of {childname}, lack check of {value}");
     return(false);
 }
Пример #2
0
        //BMRG-0037
        private Dictionary <string, List <PathInfo> > GetConfigBeacon(string filename)
        {
            Dictionary <string, List <PathInfo> > allBeacons = new Dictionary <string, List <PathInfo> >();

            XmlFileHelper xmlfile = XmlFileHelper.CreateFromFile(filename);

            if (null != xmlfile)
            {
                XmlVisitor        root    = xmlfile.GetRoot();
                List <XmlVisitor> beacons = root.Children().ToList();
                foreach (XmlVisitor node in beacons)
                {
                    string            beaconName = node.GetAttribute("name");
                    List <PathInfo>   list       = new List <PathInfo>();
                    List <XmlVisitor> pathList   = node.Children().ToList();
                    foreach (XmlVisitor up in pathList)
                    {
                        string            pathName  = up.GetAttribute("name");
                        List <PointInfo>  pointList = new List <PointInfo>();
                        List <XmlVisitor> pnList    = up.Children().ToList();
                        foreach (XmlVisitor pn in pnList)
                        {
                            string ptName = pn.GetAttribute("name");
                            int    id     = DataOpr.Xmlvalue2Int(pn, "id");
                            Point  point  = (Point)Sys.GetNode(id, Sydb.pointInfoList.Cast <Basic>().ToList());
                            string pos    = pn.FirstChildByPath("position").Value;
                            string orit   = pn.FirstChildByPath("orientation_in_route").Value;
                            if (orit == Sys.Convergent || orit == Sys.Divergent)
                            {
                                PointInfo info = new PointInfo(point, pos, orit, true);
                                pointList.Add(info);
                            }
                            else
                            {
                                //log error
                            }
                        }
                        PathInfo path = new PathInfo(pathName, pointList);
                        list.Add(path);
                    }
                    allBeacons.Add(beaconName, list);
                }
            }
            return(allBeacons);
        }
Пример #3
0
        public bool Configure()
        {
            if (Option.BEACON == option)
            {
                //读取beacon layout文件
                List <XmlVisitor> beaconList = xmlBeaconInfo.Children().ToList();
                if (null != beaconList)
                {
                    foreach (XmlVisitor node in beaconList)
                    {
                        BeaconLayout beacon = new BeaconLayout();
                        if (!beacon.SetBeacon(node))
                        {
                            logMsg = string.Format("Read Beacon.ID = {0}  error, please check!", beacon.ID);
                            WriteLog(logMsg, LogManager.Level.Error);
                            continue;
                        }
                        BeaconInfoList.Add(beacon);
                    }
                }
            }
            else if (Option.BMV == option)
            {
                //读取beacon layout文件
                List <XmlVisitor> beaconList = xmlBeaconInfo.Children().ToList();
                if (null != beaconList)
                {
                    foreach (XmlVisitor node in beaconList)
                    {
                        BeaconLayout beacon = new BeaconLayout();
                        if (!beacon.SetBeacon(node))
                        {
                            logMsg = string.Format("Read Beacon.ID = {0} error in beacon layout file, please check!", beacon.ID);
                            WriteLog(logMsg, LogManager.Level.Error);
                            continue;
                        }
                        BeaconInfoList.Add(beacon);
                    }
                }

                try
                {
                    ReadSyDB readSydb = new ReadSyDB(xmlSyDBInfo);
                    //计算LINE.ID
                    sydb.LineID = readSydb.ReadLineId();
                    //读SYDB的IBBM表
                    sydb.ibbmInfoList = readSydb.ReadIBBM();
                    //读SYDB的route表
                    sydb.routeInfoList = readSydb.ReadRoute();
                    //读取SYDB的signal表
                    sydb.signalInfoList = readSydb.ReadSignal();
                    //读取SYDB的block表
                    sydb.blockInfoList = readSydb.ReadBlock();
                    //读取SYDB的point表
                    sydb.pointInfoList = readSydb.ReadPoint();
                    //读取SYDB的overlap表
                    sydb.overlapInfoList = readSydb.ReadOverlap();
                    //读取SYDB的TFC表
                    sydb.tfcInfoList = readSydb.ReadTFC();
                    //读取SYDB的TFC表
                    sydb.sddbInfoList = readSydb.ReadSDDB();
                }
                catch (System.Exception ex)
                {
                    logMsg = "Read sydb data error, please check!";
                    WriteLog(logMsg, LogManager.Level.Error);
                    return(false);
                }
            }
            else if (Option.LEURF == option)
            {
                //读取BMV文件
                this.lineID = DataOpr.Xmlattr2Int(xmlBMVInfo, "LINE_ID");
                List <XmlVisitor> bmvList = xmlBMVInfo.Children().ToList();
                if (null != bmvList)
                {
                    foreach (XmlVisitor node in bmvList)
                    {
                        BMVBeaconInfo bm = new BMVBeaconInfo(node);
                        BmvInfoList.Add(bm.GetBMBeaconInfo());
                    }
                }
            }
            else if (Option.LEUXML == option)
            {
                this.lineID = DataOpr.Xmlattr2Int(xmlLEURFInfo, "LINE_ID");
                List <XmlVisitor> leuList = xmlLEURFInfo.Children().ToList();
                if (null != leuList)
                {
                    foreach (XmlVisitor node in leuList)
                    {
                        LEURF leu = new LEURF();
                        if (!leu.Read(node))
                        {
                            logMsg = string.Format("Read LEU.ID = {0} error int LEU result filtered file, please check!", leu.leuId);
                            WriteLog(logMsg, LogManager.Level.Error);
                            continue;
                        }
                        LeuInfoList.Add(leu);
                    }
                }
                //根据Config文件夹下GID-Table文件的内容计算伪随机数列表
                string       filename = System.IO.Directory.GetCurrentDirectory() + "\\Config\\GID-Table.txt";
                StreamReader sr       = new StreamReader(filename);
                string       line     = null;
                while ((line = sr.ReadLine()) != null)
                {
                    string[] gids = line.Split(',');
                    if (gids.Length < 3)
                    {
                        continue;
                    }
                    GID gid = new GID();
                    gid.ibGid  = gids[0];
                    gid.ouGid  = gids[1];
                    gid.netGid = gids[2];
                    GidInfoList.Add(gid);
                }
            }
            return(true);
        }