Beispiel #1
0
        public override XmlVisitor GetVariantXmlNode()
        {
            XmlVisitor variant1 = XmlVisitor.Create("Variant", null);

            {//BMGR-0040 //BMGR-0030
                variant1.AppendChild("Index", m_Idx);
                variant1.AppendChild("Type", string.Format("POINT_{0}", PointVariantPos[0]));
                variant1.AppendChild("Object_name", string.Format("{0}_{1}", m_pt.Point.Name, PointVariantPos[0]));
            }

            //BMGR-0041 //BMGR-0031
            if (-1 != InputRank)
            {
                variant1.AppendChild("Input_rank", InputRank);
            }
            else if (-1 != value)
            {
                variant1.AppendChild("Value", value);
            }
            else
            {
                TraceMethod.RecordInfo($"Point[{m_pt.Info}] not in IBBM input and can't calculate value, log Error!");
            }
            return(variant1);
        }
Beispiel #2
0
        public static void CompareXmlFile(string xml, string xmlRight, bool ignoreNote = true)
        {
            XmlVisitor node1     = XmlFileHelper.CreateFromFile(xml).GetRoot();
            XmlVisitor rightnode = XmlFileHelper.CreateFromFile(xmlRight).GetRoot();

            Console.WriteLine($"now lack implement of CompareXmlFile {xml} {xmlRight}");
        }
        private bool GenLEUGlobalFile(LEURF leurf, LEUGlobal leugb, GID gid, string filename)
        {
            try
            {
                XmlFileHelper xmlFile = XmlFileHelper.CreateFromString(null);
                //根据LEU Result Filtered Values文件的内容修改可变部分的值
                leugb.leuName      = leurf.leuName;
                leugb.inBoard.gid  = gid.ibGid;
                leugb.outBoard.gid = gid.ouGid;
                //5.2.1生成Output_balise,TBD
                foreach (LEUBeacon beacon in leurf.beaconList)
                {
                    OutBalise ob = new OutBalise();
                    ob.id       = beacon.outNum;
                    ob.telegram = "LONG";

                    leugb.obList.Add(ob);
                }
                leugb.encoder.netGid = gid.netGid;

                //根据模板文件格式写入LEU文件
                XmlVisitor leuNode = leugb.Write();
                xmlFile.SetRoot(leuNode);
                xmlFile.Save2File(filename);
                return(true);
            }
            catch (System.Exception ex)
            {
                return(false);
            }
        }
Beispiel #4
0
 /// <summary>
 /// 设置到restrition file的某父级结点,以便调用 public bool Validate(string value, string childname) 检查各childname
 /// </summary>
 /// <param name="xpath">XPath格式为:名称1.子名称2.子名称3</param>
 /// <returns></returns>
 public bool SetParentPath(string xpath)
 {
     if (root.ChildrenByPath(xpath) == null)
     {
         return(false);
     }
     root = root.ChildrenByPath(xpath).First();
     return(root.HasChildren);
 }
Beispiel #5
0
        /// <summary>
        /// 将parent重设为restriction.xml根节点
        /// </summary>
        public void ResetParent()
        {
            IXmlVisitorBase fileroot = root.Parent;

            while (fileroot != null)
            {
                root     = (XmlVisitor)fileroot;
                fileroot = root.Parent;
            }
        }
Beispiel #6
0
        private void setTextBox(TextBox textBox, string name)
        {
            XmlVisitor root = XmlFileHelper.CreateFromFile(configFile).GetRoot();
            XmlVisitor node = root.FirstChildByPath(name);

            if (null != node)
            {
                textBox.Text = node.Value;
            }
        }
Beispiel #7
0
        //BMGR-0027
        private XmlVisitor CalBMVariantNode(BEACON beacon)
        {
            XmlVisitor bmNode = XmlVisitor.Create("BM_variants", null);

            foreach (Variant var in beacon.m_variantLst)
            {
                bmNode.AppendChild(var.GetVariantXmlNode());
            }
            return(bmNode);
        }
Beispiel #8
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);
        }
Beispiel #9
0
        public override XmlVisitor GetVariantXmlNode()
        {
            XmlVisitor variant1 = XmlVisitor.Create("Variant", null);

            variant1.AppendChild("Index", m_Idx);
            variant1.AppendChild("Type", "SIGNAL");
            variant1.AppendChild("Object_name", m_signal.SignalInfo.Name);
            variant1.AppendChild("Input_rank", InputRank);

            return(variant1);
        }
Beispiel #10
0
        //BMGR-0025  BMGR-0069
        public XmlVisitor GetXmlNode()
        {//if point is in upstream, not support now, need modify
            XmlVisitor pointNode = XmlVisitor.Create("Point", null);

            pointNode.UpdateAttribute("NAME", this.Point.Name);
            pointNode.AppendChild("Id", this.Point.ID);

            pointNode.AppendChild("Position", this.Position);//BMGR-0024 //BMGR-0069
            pointNode.AppendChild("Orientation_in_route", orient);
            return(pointNode);
        }
Beispiel #11
0
        //BMGR-0046
        private bool GenerateBeaconInfoNode(BEACON beacon, ref XmlVisitor node, int outnum)
        {
            if (false == beacon.SetBeaconInfoNode_LEURF(ref node, outnum))
            {
                TraceMethod.RecordInfo($"Write SetBeaconInfoNode_LEURF for {beacon.Info} error!");
                return(false);
            }
            //BMGR-0047
            node.AppendChild("Variants_inputs", beacon.GetVariantsInputs());

            return(true);
        }
Beispiel #12
0
        public void when_visiting_xml_then_adds_members()
        {
            var member = DocReader.Read(Path.ChangeExtension(typeof(ProviderType).Assembly.Location, ".xml"));
            var visitor = new XmlVisitor();

            member.Accept(visitor);

            Assert.Equal("doc", visitor.Xml.Root.Name);
            Assert.Equal("members", visitor.Xml.Root.Elements().First().Name);

            //WriteXml(visitor.Xml);
        }
Beispiel #13
0
        public void test_GenerateBMBSDDBDisInfoNode()
        {
            List <LEU>    leulist = new List <LEU>();
            List <BEACON> blist   = new List <BEACON>();
            BMVFGen       bmvf    = new BMVFGen(false, ref blist, ref leulist);

            XmlVisitor beaconNodenull = XmlVisitor.Create("Beacon", null);

            Debug.Assert(false == bmvf.GenerateBMBSDDBDisInfoNode(null, ref beaconNodenull));

            Prepare.ReloadGlobalSydb(".//input//BMBDisSydb.xml");
            BFGen bf = new BFGen(".//input//BMBDisBeacons.csv", ".//input//BMBDisBeacons.xml", "", false, false);

            MethodHelper.InvokePrivateMethod <BFGen>(bf, "Init");
            bmvf.GenrateDeviceByIBBM();

            //the corresponding beacons are:
            //VB0102 VB0106 vb0101 vb0110 vb0111 vb0203 VB0609 vb1402 VB1303 ib1303 vb2002 fb1914 vb1705 VB0614 VB0601 VB0604
            string[] validdis = { "8.630", "5.910", "6.410", "5.340", "6.020", "6.060", "5.710", "5.550", "5.650", "5.650", "130.580", "44.740", "73.580", "3.230", "3.100", "6.000" };

            #region test the beacons of valid bmbdis
            {
                int beaconi = 0;
                foreach (var curdis in validdis)
                {
                    XmlVisitor beaconNode = XmlVisitor.Create("Beacon", null);
                    haschecked = false;
                    Debug.Assert(true == bmvf.GenerateBMBSDDBDisInfoNode(blist[beaconi], ref beaconNode));

                    //check BMBSDDB calculate and node generate
                    Debug.Assert(curdis == Prepare.getXmlNodeStr(beaconNode, "BMB_SDDB_distance"));

                    //check BeaconMessage use the right BMB_Dis
                    BeaconMessage bm = new BeaconMessage();
                    bm.GenerateMessage(blist[beaconi], 1, null);
                    Debug.Assert(bm.BMB_Distance_Unitcm() == blist[beaconi].BMB_Distance_cm);

                    ++beaconi;
                }
            }
            #endregion

            #region test the beacons of invalid bmbdis
            {//IB0302 FB1916
                int errBeaconi = validdis.Length;
                for (; errBeaconi < blist.Count; errBeaconi++)
                {
                    Debug.Assert(false == bmvf.GenerateBMBSDDBDisInfoNode(blist[errBeaconi], ref beaconNodenull));
                }
            }
            #endregion
        }
Beispiel #14
0
        public void when_writing_xml_then_can_roundtrip()
        {
            var originalXml = XDocument.Load(Path.ChangeExtension(typeof(ProviderType).Assembly.Location, ".xml"));
            var member = DocReader.Read(typeof(ProviderType).Assembly);
            var visitor = new XmlVisitor();

            member.Accept(visitor);

            //WriteXml(originalXml.Normalize(), "C:\\Temp\\source.xml");
            //WriteXml(visitor.Xml.Normalize(), "C:\\Temp\\target.xml");

            //Assert.True(originalXml.NormalizedEquals(visitor.Xml));
        }
Beispiel #15
0
        public void when_visiting_xml_then_adds_source_assembly()
        {
            var member = DocReader.Read(typeof(ProviderType).Assembly);
            var visitor = new XmlVisitor();

            member.Accept(visitor);

            Assert.Equal("doc", visitor.Xml.Root.Name);
            Assert.Equal("assembly", visitor.Xml.Root.Elements().First().Name);
            Assert.Equal(typeof(ProviderType).Assembly.GetName().Name, visitor.Xml.Root.Elements().First().Elements().First().Value);

            //WriteXml(visitor.Xml);
        }
Beispiel #16
0
        public static string getXmlNodeStr(XmlVisitor node, string xpath)
        {
            string buff = "";

            if (node == null || xpath == "")
            {
                return("");
            }
            foreach (var n in node.ChildrenByPath2(xpath))
            {
                buff += n.Value + " ";
            }
            return(buff.TrimEnd());
        }
Beispiel #17
0
        //BMGR-0016 output LEU info
        private bool GenerateLEUInfoNode(GENERIC_SYSTEM_PARAMETERS.IMPLEMENTATION_BEACON_BLOCK_MODE.BM_BEACON ibbm, ref XmlVisitor node)
        {
            if (false == LEUList.Exists(x => x.Name == ibbm.LEU.LEU_Name))
            {
                TraceMethod.RecordInfo($"input LEU[{ibbm.LEU.LEU_Name}] error, not exist in LEU list");
                return(false);
            }
            int idx = LEUList.FindIndex(x => x.Name == ibbm.LEU.LEU_Name);
            //LEU
            XmlVisitor leu = XmlVisitor.Create("LEU", null);

            leu.UpdateAttribute("NAME", LEUList[idx].Name);
            leu.AppendChild("Id", LEUList[idx].ID);
            leu.AppendChild("BM_beacon_output_number", ibbm.LEU.Beacon_Output_number);
            node.AppendChild(leu);
            return(true);
        }
Beispiel #18
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);
        }
Beispiel #19
0
        public XmlVisitor GetXmlNode()
        {
            XmlVisitor node = XmlVisitor.Create("Path",null);

            if (PATH_TYPE.OVERLAP == m_type)
            {
                //BMGR-0068
                node.UpdateAttribute("NAME",GetOverlapPathName());
                //BMGR-0069
                foreach (PointInfo pt in pointList)
                {
                    node.AppendChild(pt.GetXmlNode());
                }
            }

            return(node);
        }
Beispiel #20
0
        //BMGR-0046
        public bool SetBeaconInfoNode_LEURF(ref XmlVisitor node, int outnum)
        {
            node.UpdateAttribute("ID", m_layoutInfo.ID);
            node.UpdateAttribute("NAME", Name);
            node.UpdateAttribute("TYPE", m_ibbmInfo.GetBeaconType());

            node.UpdateAttribute("NUM", outnum);
            node.UpdateAttribute("VERSION", m_layoutInfo.getVersion());

            node.UpdateAttribute("LINKED_SIGNAL", GetLindedSignalName());

            if ("" == GetLindedSignalName())
            {
                return(false);
            }
            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);
        }
Beispiel #22
0
        public XmlVisitor GetDstSigXmlNode(bool bOverLap)
        {
            XmlVisitor dstSig = XmlVisitor.Create("Destination_signal",null);

            { //BMGR-0036
                dstSig.UpdateAttribute("NAME",GetDstSignalName());
                dstSig.AppendChild("Id",NodeApi.getIDNullSafe(DstSig));
            }

            //BMGR-0026
            if (bOverLap && null != m_overlap)
            {
                XmlVisitor overlop = XmlVisitor.Create("Overlap",null);
                overlop = m_overlap.GetXmlNode();
                dstSig.AppendChild(overlop);
            }

            return(dstSig);
        }
Beispiel #23
0
        public override void Run()
        {
            var bank = new Bank();

            var person1  = new Person("Person_1", 20);
            var company1 = new Company("Company_1", "123456", 1990);
            var person2  = new Person("Person_2", 30);

            var xmlVisitor  = new XmlVisitor();
            var htmlVisitor = new HtmlVisitor();

            bank.AddAccount(person1);
            bank.AddAccount(company1);

            bank.Accept(xmlVisitor);
            bank.Accept(htmlVisitor);

            person2.Accept(xmlVisitor);
            person2.Accept(htmlVisitor);
        }
Beispiel #24
0
        public XmlVisitor GetXmlNode()
        {
            XmlVisitor Node = XmlVisitor.Create("Message", null);

            Node.UpdateAttribute("RANK", Rank);
            //BMGR-0048 rank=0 has no Combined_sections
            if (0 != Rank)
            {
                Node.AppendChild(GetCombinedSectionsNode());
            }

            //Variant_state

            //Urbalise_iTC

            //Interoperable
            //they are generate after call this function

            return(Node);
        }
Beispiel #25
0
 public XmlEditor()
 {
     InitializeComponent();
     _redoStack          = new Stack <UndoRedoInfo>();
     _undoList           = new List <UndoRedoInfo>();
     _parser             = new XmlParser();
     _visitor            = new XmlVisitor();
     _visitor.VisitNode += VisitorOnVisitNode;
     _autoCompleteForm   = new ListBox
     {
         Visible             = false,
         MaximumSize         = new Size(0, 200),
         AutoSize            = true,
         MinimumSize         = new Size(350, 0),
         Anchor              = AnchorStyles.Left | AnchorStyles.Right,
         HorizontalScrollbar = true,
     };
     _highlightDelegate = Highlight;
     _highlightTimer    = new Timer(HighlightTimerCallback);
     Controls.Add(_autoCompleteForm);
 }
Beispiel #26
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);
     }
 }
Beispiel #27
0
        public XmlVisitor GetXmlNode()
        {
            XmlVisitor node = XmlVisitor.Create("Overlap",null);

            {//BMGR-0065
                node.UpdateAttribute("ID",m_Ol.ID);
                node.AppendChild("Distance",Sys.Cm2Meter(m_Ol.D_Overlap,3).ToString(Sys.StrFormat));
            }

            //BMGR-0066 BMGR-0067
            if ("" != m_switchPos)
            {
                node.AppendChild("Switch_position",m_switchPos);

                foreach (PathInfo path in m_pathLst)
                {
                    node.AppendChild(path.GetXmlNode());
                }
            }

            return(node);
        }
Beispiel #28
0
        public XmlVisitor GetCombinedSectionsNode()
        {
            XmlVisitor Node = XmlVisitor.Create("Combined_sections", null);

//BMGR-0048 red signal has <Combined_sections />

            if (null != upPath)
            {//BMGR-0070
                AddCombinSectionNode(ref Node, "Upstream_section", upPath.GetUpstreamPathName());
                UpSection = upPath.GetUpstreamPathName();
            }

            if (null != rpRs)
            {//BMGR-0077
                AddCombinSectionNode(ref Node, "Reopening_section", rpRs.GetName());
                RpSection = rpRs.GetName();
            }

            if (null != apRs)
            {//BMGR-0078
                AddCombinSectionNode(ref Node, "Approach_section", apRs.GetName());
                ApSection = apRs.GetName();
            }

            //BMGR-0079
            if (null != olPath)
            {
                AddCombinSectionNode(ref Node, "Overlap_section", olPath.GetOverlapPathName());
                OlSection = olPath.GetOverlapPathName();
            }
            else if (null != overlap)
            {
                AddCombinSectionNode(ref Node, "Overlap_section", overlap.GetSigname());
                OlSection = overlap.GetSigname();
            }

            return(Node);
        }
Beispiel #29
0
        //BMGR-0015 Block_mode_beacons.Beacon tag
        public bool SetBeaconInfoNode_BMVF(ref XmlVisitor beaconNode)
        {
            beaconNode.UpdateAttribute("NAME", Name);
            beaconNode.UpdateAttribute("TYPE", m_ibbmInfo.GetBeaconType());

            beaconNode.UpdateAttribute("VERSION", m_layoutInfo.getVersion());
            beaconNode.AppendChild("Id", m_layoutInfo.ID);

            //if m_ibbmInfo not valid return false
            if (null == m_ibbmInfo)
            {
                TraceMethod.RecordInfo($"Error:Beacon[{Info}] has on ibbm input struct");
                //log error
                return(false);
            }

            beaconNode.AppendChild("Direction", m_ibbmInfo.Direction);
            if (true == m_ibbmInfo.Is_Guaranted_Beacon)
            {
                beaconNode.AppendChild("Is_guaranted_BM_beacon", null);
            }
            return(true);
        }
Beispiel #30
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);
        }
Beispiel #31
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);
     }
 }
Beispiel #32
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);
        }
Beispiel #33
0
 //BMGR-0045
 private bool GenerateLEUInfoNode(LEU leuInfo, ref XmlVisitor leu)
 {
     leu.UpdateAttribute("ID", leuInfo.ID);
     leu.UpdateAttribute("NAME", leuInfo.Name);
     return(true);
 }