Esempio n. 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);
        }
Esempio n. 2
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);
        }