示例#1
0
        private void GenTJFormatFileHead(string path)
        {
            string        logMsg      = "";
            XmlVisitor    allFileRoot = null;
            string        filename    = string.Format("{0}\\all_beacons.xml", path);
            XmlFileHelper allxmlFile  = XmlFileHelper.CreateFromString(null);

            AddLogHead(ref allxmlFile);

            allxmlFile.SetRoot("Beacons", null);
            allxmlFile.Save2File(filename);

            allFileRoot = allxmlFile.GetRoot();
            allFileRoot.UpdateAttribute("NUMBERS", sydb.GetBeacons().Count());

            foreach (IBeaconInfo beacon in sydb.GetBeacons())
            {
                string telValue = "";
                if (isITC)
                {//BMGR-0004
                    TraceMethod.RecordInfo("iTC not support now!");
                    telValue = "iTC not support";
                }
                else
                {
                    BeaconMessage bm = new BeaconMessage();
                    telValue = bm.GenerateMessage(beacon, sydb.LineID);
                }

                byte[] urstel = DataOpr.String2byte(telValue);

                XmlVisitor beaconNode = XmlVisitor.Create("Beacon", null);
                beaconNode.UpdateAttribute("ID", beacon.ID);
                beaconNode.UpdateAttribute("NAME", beacon.Name);
                byte[] content = new byte[128];
                bool   result  = DataOpr.PackCallScram_Tel(urstel, content);
                if (result)
                {
                    string tel1 = DataOpr.Byte2string(content);
                    beaconNode.AppendChild("Telegram0", telValue);
                    beaconNode.AppendChild("Telegram1", tel1);
                }
                else
                {
                    logMsg = string.Format("Encoding Error!");
                    TraceMethod.RecordInfo(logMsg);
                    continue;
                }
                allFileRoot.AppendChild(beaconNode);
            }

            allxmlFile.Save2File(filename);
            logMsg = "Generate basic_beacons.xml file successfully!";
            TraceMethod.RecordInfo(logMsg);
        }
示例#2
0
        private bool Save2Config(TextBox textBox, string nodeName)
        {
            XmlFileHelper configInfo = XmlFileHelper.CreateFromFile(configFile);
            XmlVisitor    root       = configInfo.GetRoot();
            XmlVisitor    compiler   = root.FirstChildByPath(nodeName);

            if (null == compiler)
            {
                root.AppendChild(nodeName, textBox.Text);
            }
            else
            {
                compiler.Value = textBox.Text;
            }
            configInfo.Save2File(configFile);
            return(true);
        }
        //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);
        }
示例#4
0
 public bool Init(string bmvFile)
 {
     if (Option.LEURF == this.option)
     {
         try
         {
             XmlFileHelper xmlfile = XmlFileHelper.CreateFromFile(bmvFile);
             xmlBMVInfo = xmlfile.GetRoot();
         }
         catch (System.Exception ex)
         {
             logMsg = "Read block mode variant file error, please check!";
             WriteLog(logMsg, LogManager.Level.Error);
             return(false);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#5
0
        private bool GenerateBMVFile(string filename)
        {
            XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null);

            AddLogHead(ref xmlFile);
            xmlFile.SetRoot("Block_mode_beacons", null);

            XmlVisitor root = xmlFile.GetRoot();

            root.UpdateAttribute("LINE_ID", sydb.LineID);//BMGR-0014 log lineID

            foreach (BEACON beacon in GetValidBeaconList())
            {
                XmlVisitor beaconNode = XmlVisitor.Create("Beacon", null);

                if (false == beacon.SetBeaconInfoNode_BMVF(ref beaconNode) ||
                    false == GenerateLEUInfoNode(beacon.m_ibbmInfo, ref beaconNode) ||
                    false == GenerateBMBSDDBDisInfoNode(beacon, ref beaconNode))
                {
                    //log error
                    TraceMethod.RecordInfo($"Warning:GenerateBMVFile base info[Beacon][LEU][BMBSDDB_Distance] faild for {beacon.Info}.");
                }

                //then all reopen sig and the approach sig
                foreach (OriginSignal orgSig in beacon.GetOrgSignalList())
                {
                    beaconNode.AppendChild(orgSig.GetXmlNode(beacon.Name));
                }

                beaconNode.AppendChild(CalBMVariantNode(beacon));
                root.AppendChild(beaconNode);
            }

            xmlFile.Save2File(filename);
            return(true);
        }
示例#6
0
 public bool Init(string file1, string file2)
 {
     if (Option.BEACON == this.option)
     {
         try
         {
             XmlFileHelper xmlfile = XmlFileHelper.CreateFromFile(file1);
             XmlVisitor    root    = xmlfile.GetRoot();
             xmlBeaconInfo = root.FirstChildByPath("Beacons");
         }
         catch (System.Exception ex)
         {
             logMsg = "Read beacon layout file error, please check!";
             WriteLog(logMsg, LogManager.Level.Error);
             return(false);
         }
         this.balComPath = file2;
         return(true);
     }
     else if (Option.BMV == this.option)
     {
         XmlFileHelper xmlfile = null;
         try
         {
             xmlfile = XmlFileHelper.CreateFromFile(file1);
             XmlVisitor root = xmlfile.GetRoot();
             xmlBeaconInfo = root.FirstChildByPath("Beacons");
         }
         catch (System.Exception ex)
         {
             logMsg = "Read beacon layout file error, please check!";
             WriteLog(logMsg, LogManager.Level.Error);
             return(false);
         }
         try
         {
             xmlfile     = XmlFileHelper.CreateFromFile(file2);
             xmlSyDBInfo = xmlfile.GetRoot();
         }
         catch (System.Exception ex)
         {
             logMsg = "Read system database file error, please check!";
             WriteLog(logMsg, LogManager.Level.Error);
             return(false);
         }
         return(true);
     }
     else if (Option.LEUXML == this.option)
     {
         XmlFileHelper xmlfile = null;
         try
         {
             xmlfile      = XmlFileHelper.CreateFromFile(file1);
             xmlLEURFInfo = xmlfile.GetRoot();
         }
         catch (System.Exception ex)
         {
             logMsg = "Read LEU Result Filtered Value file error, please check!";
             WriteLog(logMsg, LogManager.Level.Error);
             return(false);
         }
         try
         {
             xmlfile      = XmlFileHelper.CreateFromFile(file2);
             xmlLEUTFInfo = xmlfile.GetRoot();
         }
         catch (System.Exception ex)
         {
             logMsg = "Read LEU XML Template file error, please check!";
             WriteLog(logMsg, LogManager.Level.Error);
             return(false);
         }
         return(true);
     }
     else if (Option.LEUBIN == this.option)
     {
         this.leuFilesDir = file1;
         this.leuComPath  = file2;
         return(true);
     }
     else
     {
         logMsg = "The option does not match the input files, please check!";
         WriteLog(logMsg, LogManager.Level.Error);
         return(false);
     }
 }
示例#7
0
        public Restriction(string xmlfullname)
        {
            XmlFileHelper f = XmlFileHelper.CreateFromFile(xmlfullname);

            root = f.GetRoot();
        }
示例#8
0
        //for tj format
        private bool GenBasciXml(string leuFile, string outputPath)
        {
            LEU_filtered_values leurfxml = FileLoader.Load <LEU_filtered_values>(leuFile);

            List <BasicBeacon> BeaconInfoList = new List <BasicBeacon>();

            foreach (LEU_filtered_values.leu leurf in leurfxml.LEU)
            {
                foreach (LEU_filtered_values.leu.BEACON leuBeacon in leurf.Beacon)
                {
                    BasicBeacon baBeacon = new BasicBeacon(leuBeacon);
                    var         signal   = (GENERIC_SYSTEM_PARAMETERS.SIGNALS.SIGNAL)Sys.GetNode((string)leuBeacon.LINKED_SIGNAL,sydb.signalInfoList.Cast <Node>().ToList());
                    if (null == signal)
                    {
                        continue;
                    }
                    baBeacon.SignalId   = signal.ID;
                    baBeacon.SignalName = signal.Name;
                    baBeacon.MsgList    = new List <MsgRank>();
                    foreach (LEU_filtered_values.leu.BEACON.MESSAGE msg in leuBeacon.msgList)
                    {
                        MsgRank msgRk = new MsgRank();
                        msgRk.routeInfo = new List <string>();
                        //按照Upstream_section,Reopening_section,Approach_section,Overlap_section的顺序将进路上的道岔和信号机依次取出
                        //先算道岔,再算信号机
                        List <string> ptList  = new List <string>();
                        List <string> sigList = new List <string>();
                        if (null != msg.Combined_sections)
                        {
                            JudgeSection(msg.Combined_sections.Upstream_section,ptList,sigList);
                            JudgeSection(msg.Combined_sections.Reopening_section,ptList,sigList);
                            JudgeSection(msg.Combined_sections.Approach_section,ptList,sigList);
                            JudgeSection(msg.Combined_sections.Overlap_section,ptList,sigList);
                        }

                        msgRk.routeInfo.AddRange(ptList);
                        msgRk.routeInfo.AddRange(sigList);

                        //计算tel0和tel1
                        msgRk.Tel0 = msg.Interoperable;
                        byte[] content  = new byte[128];
                        byte[] telValue = DataOpr.String2byte(msgRk.Tel0);
                        bool   result   = ScrambleTel(telValue,content);
                        if (result)
                        {
                            msgRk.Tel1 = DataOpr.Byte2string(content);
                        }
                        else
                        {
                            TraceMethod.RecordInfo("Encoding Error!");
                            continue;
                        }
                        baBeacon.MsgList.Add(msgRk);
                    }
                    BeaconInfoList.Add(baBeacon);
                }
            }

            //写入可变报文配置文件
            string        allFileName = string.Format("{0}\\basic_beacons.xml",outputPath);
            XmlFileHelper allxmlFile  = XmlFileHelper.CreateFromString(null);

            AddLogHead(ref allxmlFile);
            allxmlFile.SetRoot("Beacons",null);
            allxmlFile.Save2File(allFileName);

            XmlVisitor allFileRoot = allxmlFile.GetRoot();

            allFileRoot.UpdateAttribute("NUMBERS",BeaconInfoList.Count);

            foreach (BasicBeacon basBeacon in BeaconInfoList)
            {
                XmlVisitor beaconNode = XmlVisitor.Create("Beacon",null);
                beaconNode.UpdateAttribute("ID",basBeacon.ID);
                beaconNode.UpdateAttribute("NAME",basBeacon.Name);
                beaconNode.UpdateAttribute("RANKS",basBeacon.MsgList.Count());
                beaconNode.UpdateAttribute("TYPE",basBeacon.Type);
                beaconNode.UpdateAttribute("LINKED_SIGNALID",basBeacon.SignalId);
                beaconNode.UpdateAttribute("LINKED_SIGNALName",basBeacon.SignalName);
                for (int i = 0; i < basBeacon.MsgList.Count(); i++)
                {
                    XmlVisitor rankNode = XmlVisitor.Create("Message",null);
                    rankNode.UpdateAttribute("Rank",i);
                    string route = "";
                    foreach (string info in basBeacon.MsgList[i].routeInfo)
                    {
                        route += info + "|";
                    }
                    if (route.EndsWith('|'.ToString()))
                    {
                        route = route.Remove(route.LastIndexOf('|'));
                    }
                    if ("" != route)
                    {
                        rankNode.AppendChild("Route", route);
                    }
                    rankNode.AppendChild("Telegram0", basBeacon.MsgList[i].Tel0);
                    rankNode.AppendChild("Telegram1", basBeacon.MsgList[i].Tel1);
                    beaconNode.AppendChild(rankNode);
                }
                allFileRoot.AppendChild(beaconNode);
            }
            allxmlFile.Save2File(allFileName);
            return(true);
        }
示例#9
0
        private bool GenerateLEUResultFilterFile(string filename)
        {
            XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null);

            AddLogHead(ref xmlFile);

            //BMGR-0044
            xmlFile.SetRoot("LEU_filtered_values", null);
            xmlFile.Save2File(filename);

            XmlVisitor root = xmlFile.GetRoot();

            //BMGR-0044
            root.UpdateAttribute("LINE_ID", sydb.LineID);

            //BMGR-0045
            List <LEU> orderLEULst = m_LEULst.OrderBy(o => o.ID).ToList();

            foreach (LEU leu in orderLEULst)
            {
                XmlVisitor LEUnode = XmlVisitor.Create("LEU", null);

                //set LEU info
                if (false == GenerateLEUInfoNode(leu, ref LEUnode))
                {
                    return(false);
                }

                string[] bNames = leu.GetBeaconNames();
                //BMGR-0046
                for (int i = 0; i < bNames.Count(); ++i)
                {
                    string bName = bNames[i];
                    if ("" == bName)
                    {
                        continue;
                    }
                    int Bidx = m_BeaconLst.FindIndex(x => (x.Name == bName));
                    if (-1 == Bidx)
                    {
                        TraceMethod.RecordInfo($"Warning:LEU[{leu.Name}] contain beacon[{bName}] which not in valid beacon List, this beacon will be ignore!");
                        continue;
                    }

                    XmlVisitor beaconnode = XmlVisitor.Create("Beacon", null);
                    if (false == GenerateBeaconInfoNode(m_BeaconLst[Bidx], ref beaconnode, i + 1))
                    {
                        //
                    }

                    m_BeaconLst[Bidx].m_MsgLst = GenerateMessage(m_BeaconLst[Bidx]);

                    if (m_BeaconLst[Bidx].m_MsgLst.Count() > 128)
                    {//BMGR-0050
                        TraceMethod.RecordInfo($"LEU[{leu.Info} {m_BeaconLst[Bidx].Info}] generate messages {m_BeaconLst[Bidx].m_MsgLst.Count()} > 128");
                    }

                    foreach (Message msg in m_BeaconLst[Bidx].m_MsgLst)
                    {
                        //mes and combine_sections
                        XmlVisitor msgNode = msg.GetXmlNode();

                        //BMGR-0051 Variant_state
                        string varstate = GetMsgVar(msg, m_BeaconLst[Bidx]);
                        if (BEACON.MAXVARNUM != varstate.Length)
                        {
                            TraceMethod.RecordInfo($"Beacon[{m_BeaconLst[Bidx].Name}] Variant_state[{varstate}] length != {BEACON.MAXVARNUM}");
                        }
                        msgNode.AppendChild("Variant_state", varstate);

                        string msgBuff = "";
                        //Urbalis_iTC
                        if (0 == msg.GetRank())
                        {//BMGR-0004 leu default msg for input beacon
                            varstate = "";
                        }

                        //don't output Urbalis_iTC for BMGen tool this time
#if itcsupport
                        msgBuff = m_BeaconLst[Bidx].GenMsgItc(varstate);
                        if (86 != msgBuff.Length)
                        {
                            TraceMethod.RecordInfo(string.Format("Beacon[{0}] Urbalis_iTC message length != 16",
                                                                 m_BeaconLst[Bidx].Name));
                            return(false);
                        }

                        msgNode.AppendChild("Urbalis_iTC", msgBuff);
#endif
                        //Interoperable
                        BeaconMessage bm = new BeaconMessage();
                        msgBuff = bm.GenerateMessage(m_BeaconLst[Bidx], sydb.LineID, msg);

                        if (311 != msgBuff.Length)
                        {
                            TraceMethod.RecordInfo($"{m_BeaconLst[Bidx].Info} Interoperable message length != 311");
                        }
                        msgNode.AppendChild("Interoperable", msgBuff);

                        beaconnode.AppendChild(msgNode);
                    }

                    LEUnode.AppendChild(beaconnode);
                }

                root.AppendChild(LEUnode);
            }
            xmlFile.Save2File(filename);
            return(true);
        }